Add param to hide financial preview on print
This commit is contained in:
parent
52ffbde6ff
commit
9dd9167267
|
@ -15,6 +15,7 @@ export interface Params {
|
||||||
timeUnit: TimeUnit
|
timeUnit: TimeUnit
|
||||||
currency: string
|
currency: string
|
||||||
roundUpEstimations: boolean
|
roundUpEstimations: boolean
|
||||||
|
hideFinancialPreviewOnPrint: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaults = {
|
export const defaults = {
|
||||||
|
@ -42,6 +43,7 @@ export const defaults = {
|
||||||
roundUpEstimations: true,
|
roundUpEstimations: true,
|
||||||
currency: "€ H.T.",
|
currency: "€ H.T.",
|
||||||
costPerTimeUnit: 500,
|
costPerTimeUnit: 500,
|
||||||
|
hideFinancialPreviewOnPrint: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTimeUnit(project: Project): TimeUnit {
|
export function getTimeUnit(project: Project): TimeUnit {
|
||||||
|
@ -63,3 +65,7 @@ export function getTaskCategories(project: Project): TaskCategoriesIndex {
|
||||||
export function getTaskCategoryCost(taskCategory: TaskCategory): number {
|
export function getTaskCategoryCost(taskCategory: TaskCategory): number {
|
||||||
return taskCategory.hasOwnProperty("costPerTimeUnit") ? taskCategory.costPerTimeUnit : defaults.costPerTimeUnit;
|
return taskCategory.hasOwnProperty("costPerTimeUnit") ? taskCategory.costPerTimeUnit : defaults.costPerTimeUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getHideFinancialPreviewOnPrint(project: Project): boolean {
|
||||||
|
return project.params.hasOwnProperty("hideFinancialPreviewOnPrint") ? project.params.hideFinancialPreviewOnPrint : defaults.hideFinancialPreviewOnPrint;
|
||||||
|
}
|
|
@ -23,10 +23,7 @@ export function newProject(id?: string): Project {
|
||||||
description: "",
|
description: "",
|
||||||
tasks: {},
|
tasks: {},
|
||||||
params: {
|
params: {
|
||||||
taskCategories: defaults.taskCategories,
|
...defaults
|
||||||
currency: defaults.currency,
|
|
||||||
roundUpEstimations: defaults.roundUpEstimations,
|
|
||||||
timeUnit: defaults.timeUnit,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ import FinancialPreview from "./financial-preview";
|
||||||
import { addTask, updateTaskEstimation, removeTask, updateProjectLabel, updateTaskLabel, ProjectReducerActions } from "../../hooks/use-project-reducer";
|
import { addTask, updateTaskEstimation, removeTask, updateProjectLabel, updateTaskLabel, ProjectReducerActions } from "../../hooks/use-project-reducer";
|
||||||
import { Task, TaskID, EstimationConfidence } from "../../models/task";
|
import { Task, TaskID, EstimationConfidence } from "../../models/task";
|
||||||
import RepartitionPreview from "./repartition-preview";
|
import RepartitionPreview from "./repartition-preview";
|
||||||
|
import { getHideFinancialPreviewOnPrint } from "../../models/params";
|
||||||
|
|
||||||
export interface EstimationTabProps {
|
export interface EstimationTabProps {
|
||||||
project: Project
|
project: Project
|
||||||
|
@ -46,7 +47,7 @@ const EstimationTab: FunctionalComponent<EstimationTabProps> = ({ project, dispa
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class={`column ${getHideFinancialPreviewOnPrint(project) ? 'noPrint': ''}`}>
|
||||||
<FinancialPreview project={project} />
|
<FinancialPreview project={project} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { FunctionalComponent, h, Fragment } from "preact";
|
import { FunctionalComponent, h, Fragment } from "preact";
|
||||||
import { Project } from "../../models/project";
|
import { Project } from "../../models/project";
|
||||||
import { ProjectReducerActions, updateParam } from "../../hooks/use-project-reducer";
|
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 TaskCategoriesTable from "./task-categories-table";
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
import { route } from "preact-router";
|
import { route } from "preact-router";
|
||||||
|
@ -25,6 +25,11 @@ const ParamsTab: FunctionalComponent<ParamsTabProps> = ({ project, dispatch }) =
|
||||||
dispatch(updateParam("roundUpEstimations", checked));
|
dispatch(updateParam("roundUpEstimations", checked));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onHideFinancialPreview = (evt: Event) => {
|
||||||
|
const checked = (evt.currentTarget as HTMLInputElement).checked;
|
||||||
|
dispatch(updateParam("hideFinancialPreviewOnPrint", checked));
|
||||||
|
};
|
||||||
|
|
||||||
const onCurrencyChange = (evt: Event) => {
|
const onCurrencyChange = (evt: Event) => {
|
||||||
const value = (evt.currentTarget as HTMLInputElement).value;
|
const value = (evt.currentTarget as HTMLInputElement).value;
|
||||||
dispatch(updateParam("currency", value));
|
dispatch(updateParam("currency", value));
|
||||||
|
@ -50,6 +55,17 @@ const ParamsTab: FunctionalComponent<ParamsTabProps> = ({ project, dispatch }) =
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
<label class="label is-size-5">Impression</label>
|
||||||
|
<div class="field">
|
||||||
|
<input type="checkbox"
|
||||||
|
id="hideFinancialPreview"
|
||||||
|
name="hideFinancialPreview"
|
||||||
|
class="switch"
|
||||||
|
onChange={onHideFinancialPreview}
|
||||||
|
checked={getHideFinancialPreviewOnPrint(project)} />
|
||||||
|
<label for="hideFinancialPreview">Cacher le prévisionnel financier lors de l'impression</label>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-size-5">Unité de temps</label>
|
<label class="label is-size-5">Unité de temps</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
|
|
Loading…
Reference in New Issue