From 9dd916726729312fc976f560a9ec4b697c27527a Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 23 Apr 2020 13:40:20 +0200 Subject: [PATCH] Add param to hide financial preview on print --- src/models/params.ts | 6 ++++++ src/models/project.ts | 5 +---- src/routes/project/estimation-tab.tsx | 3 ++- src/routes/project/params-tab.tsx | 18 +++++++++++++++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/models/params.ts b/src/models/params.ts index 6d58506..8f9160f 100644 --- a/src/models/params.ts +++ b/src/models/params.ts @@ -15,6 +15,7 @@ export interface Params { timeUnit: TimeUnit currency: string roundUpEstimations: boolean + hideFinancialPreviewOnPrint: boolean } export const defaults = { @@ -42,6 +43,7 @@ export const defaults = { roundUpEstimations: true, currency: "€ H.T.", costPerTimeUnit: 500, + hideFinancialPreviewOnPrint: false, } export function getTimeUnit(project: Project): TimeUnit { @@ -62,4 +64,8 @@ export function getTaskCategories(project: Project): TaskCategoriesIndex { export function getTaskCategoryCost(taskCategory: TaskCategory): number { return taskCategory.hasOwnProperty("costPerTimeUnit") ? taskCategory.costPerTimeUnit : defaults.costPerTimeUnit; +} + +export function getHideFinancialPreviewOnPrint(project: Project): boolean { + return project.params.hasOwnProperty("hideFinancialPreviewOnPrint") ? project.params.hideFinancialPreviewOnPrint : defaults.hideFinancialPreviewOnPrint; } \ No newline at end of file diff --git a/src/models/project.ts b/src/models/project.ts index dbaef7c..b2be846 100644 --- a/src/models/project.ts +++ b/src/models/project.ts @@ -23,10 +23,7 @@ export function newProject(id?: string): Project { description: "", tasks: {}, params: { - taskCategories: defaults.taskCategories, - currency: defaults.currency, - roundUpEstimations: defaults.roundUpEstimations, - timeUnit: defaults.timeUnit, + ...defaults }, }; } \ No newline at end of file diff --git a/src/routes/project/estimation-tab.tsx b/src/routes/project/estimation-tab.tsx index fd617c3..9b5312b 100644 --- a/src/routes/project/estimation-tab.tsx +++ b/src/routes/project/estimation-tab.tsx @@ -6,6 +6,7 @@ import FinancialPreview from "./financial-preview"; import { addTask, updateTaskEstimation, removeTask, updateProjectLabel, updateTaskLabel, ProjectReducerActions } from "../../hooks/use-project-reducer"; import { Task, TaskID, EstimationConfidence } from "../../models/task"; import RepartitionPreview from "./repartition-preview"; +import { getHideFinancialPreviewOnPrint } from "../../models/params"; export interface EstimationTabProps { project: Project @@ -46,7 +47,7 @@ const EstimationTab: FunctionalComponent = ({ project, dispa
-
+
diff --git a/src/routes/project/params-tab.tsx b/src/routes/project/params-tab.tsx index aefbef4..ed56feb 100644 --- a/src/routes/project/params-tab.tsx +++ b/src/routes/project/params-tab.tsx @@ -1,7 +1,7 @@ import { FunctionalComponent, h, Fragment } from "preact"; import { Project } from "../../models/project"; import { ProjectReducerActions, updateParam } from "../../hooks/use-project-reducer"; -import { getRoundUpEstimations, getCurrency, getTimeUnit } from "../../models/params"; +import { getRoundUpEstimations, getCurrency, getTimeUnit, getHideFinancialPreviewOnPrint } from "../../models/params"; import TaskCategoriesTable from "./task-categories-table"; import { useState } from "preact/hooks"; import { route } from "preact-router"; @@ -25,6 +25,11 @@ const ParamsTab: FunctionalComponent = ({ project, dispatch }) = dispatch(updateParam("roundUpEstimations", checked)); }; + const onHideFinancialPreview = (evt: Event) => { + const checked = (evt.currentTarget as HTMLInputElement).checked; + dispatch(updateParam("hideFinancialPreviewOnPrint", checked)); + }; + const onCurrencyChange = (evt: Event) => { const value = (evt.currentTarget as HTMLInputElement).value; dispatch(updateParam("currency", value)); @@ -50,6 +55,17 @@ const ParamsTab: FunctionalComponent = ({ project, dispatch }) = return ( + +
+ + +
+