Project deletion
This commit is contained in:
parent
b0bffe6fb8
commit
4412851d32
|
@ -27,11 +27,19 @@ const FinancialPreview: FunctionalComponent<FinancialPreviewProps> = ({ project
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="is-narrow">Maximum</td>
|
<td class="is-narrow">Maximum</td>
|
||||||
<td>{maxCost} {getCurrency(project)}</td>
|
<td>
|
||||||
|
<details>
|
||||||
|
<summary>~ {maxCost} {getCurrency(project)}</summary>
|
||||||
|
</details>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="is-narrow">Minimum</td>
|
<td class="is-narrow">Minimum</td>
|
||||||
<td>{minCost} {getCurrency(project)}</td>
|
<td>
|
||||||
|
<details>
|
||||||
|
<summary>~ {minCost} {getCurrency(project)}</summary>
|
||||||
|
</details>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -43,7 +43,7 @@ const Project: FunctionalComponent<ProjectProps> = ({ projectId }) => {
|
||||||
render: () => <EstimationTab project={project} dispatch={dispatch} />
|
render: () => <EstimationTab project={project} dispatch={dispatch} />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Paramètres',
|
label: 'Options avancées',
|
||||||
icon: '⚙️',
|
icon: '⚙️',
|
||||||
render: () => <ParamsTab project={project} dispatch={dispatch} />
|
render: () => <ParamsTab project={project} dispatch={dispatch} />
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,6 +3,9 @@ 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 } from "../../models/params";
|
||||||
import TaskCategoriesTable from "./task-categories-table";
|
import TaskCategoriesTable from "./task-categories-table";
|
||||||
|
import { useState } from "preact/hooks";
|
||||||
|
import { route } from "preact-router";
|
||||||
|
import { getProjectStorageKey } from "../../util/storage";
|
||||||
|
|
||||||
export interface ParamsTabProps {
|
export interface ParamsTabProps {
|
||||||
project: Project
|
project: Project
|
||||||
|
@ -10,57 +13,69 @@ export interface ParamsTabProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ParamsTab: FunctionalComponent<ParamsTabProps> = ({ project, dispatch }) => {
|
const ParamsTab: FunctionalComponent<ParamsTabProps> = ({ project, dispatch }) => {
|
||||||
|
const [ deleteButtonEnabled, setDeleteButtonEnabled ] = useState(false);
|
||||||
|
|
||||||
|
const onEnableDeleteButtonChange = (evt: Event) => {
|
||||||
|
const checked = (evt.currentTarget as HTMLInputElement).checked;
|
||||||
|
setDeleteButtonEnabled(checked);
|
||||||
|
}
|
||||||
|
|
||||||
const onRoundUpChange = (evt: Event) => {
|
const onRoundUpChange = (evt: Event) => {
|
||||||
const checked = (evt.currentTarget as HTMLInputElement).checked;
|
const checked = (evt.currentTarget as HTMLInputElement).checked;
|
||||||
dispatch(updateParam("roundUpEstimations", checked));
|
dispatch(updateParam("roundUpEstimations", 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));
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeUnit = getTimeUnit(project);
|
const timeUnit = getTimeUnit(project);
|
||||||
|
|
||||||
const onTimeUnitLabelChange = (evt: Event) => {
|
const onTimeUnitLabelChange = (evt: Event) => {
|
||||||
const value = (evt.currentTarget as HTMLInputElement).value;
|
const value = (evt.currentTarget as HTMLInputElement).value;
|
||||||
dispatch(updateParam("timeUnit", { ...timeUnit, label: value }));
|
dispatch(updateParam("timeUnit", { ...timeUnit, label: value }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const onTimeUnitAcronymChange = (evt: Event) => {
|
const onTimeUnitAcronymChange = (evt: Event) => {
|
||||||
const value = (evt.currentTarget as HTMLInputElement).value;
|
const value = (evt.currentTarget as HTMLInputElement).value;
|
||||||
dispatch(updateParam("timeUnit", { ...timeUnit, acronym: value }));
|
dispatch(updateParam("timeUnit", { ...timeUnit, acronym: value }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDeleteProjectClick = (evt: Event) => {
|
||||||
|
const projectStorageKey = getProjectStorageKey(project.id);
|
||||||
|
window.localStorage.removeItem(projectStorageKey);
|
||||||
|
route('/');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<input type="checkbox"
|
<label class="label is-size-5">Unité de temps</label>
|
||||||
id="roundUpEstimations"
|
|
||||||
name="roundUpEstimations"
|
|
||||||
class="switch"
|
|
||||||
onChange={onRoundUpChange}
|
|
||||||
checked={getRoundUpEstimations(project)} />
|
|
||||||
<label for="roundUpEstimations">Arrondir les estimations de temps à l'entier supérieur</label>
|
|
||||||
</div>
|
|
||||||
<hr />
|
|
||||||
<div class="field">
|
|
||||||
<label class="label">Unité de temps</label>
|
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="text"
|
<input class="input" type="text"
|
||||||
onChange={onTimeUnitLabelChange}
|
onChange={onTimeUnitLabelChange}
|
||||||
value={timeUnit.label} />
|
value={timeUnit.label} />
|
||||||
</div>
|
</div>
|
||||||
<label class="label">Acronyme</label>
|
<label class="label is-size-6">Acronyme</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="text"
|
<input class="input" type="text"
|
||||||
onChange={onTimeUnitAcronymChange}
|
onChange={onTimeUnitAcronymChange}
|
||||||
value={timeUnit.acronym} />
|
value={timeUnit.acronym} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<input type="checkbox"
|
||||||
|
id="roundUpEstimations"
|
||||||
|
name="roundUpEstimations"
|
||||||
|
class="switch"
|
||||||
|
onChange={onRoundUpChange}
|
||||||
|
checked={getRoundUpEstimations(project)} />
|
||||||
|
<label for="roundUpEstimations">Arrondir les estimations de temps à l'entier supérieur</label>
|
||||||
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Devise</label>
|
<label class="label is-size-5">Devise</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="text"
|
<input class="input" type="text"
|
||||||
onChange={onCurrencyChange}
|
onChange={onCurrencyChange}
|
||||||
|
@ -69,6 +84,25 @@ const ParamsTab: FunctionalComponent<ParamsTabProps> = ({ project, dispatch }) =
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<TaskCategoriesTable project={project} dispatch={dispatch} />
|
<TaskCategoriesTable project={project} dispatch={dispatch} />
|
||||||
|
<hr />
|
||||||
|
<div>
|
||||||
|
<label class="label is-size-5">Supprimer le projet</label>
|
||||||
|
<div class="field">
|
||||||
|
<input type="checkbox"
|
||||||
|
id="enableDeleteButton"
|
||||||
|
name="enableDeleteButton"
|
||||||
|
class="switch is-warning"
|
||||||
|
onChange={onEnableDeleteButtonChange}
|
||||||
|
checked={deleteButtonEnabled} />
|
||||||
|
<label for="enableDeleteButton">Supprimer ce projet ?</label>
|
||||||
|
</div>
|
||||||
|
<button class="button is-danger"
|
||||||
|
onClick={onDeleteProjectClick}
|
||||||
|
disabled={!deleteButtonEnabled}>
|
||||||
|
🗑️ Supprimer
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,7 @@ const TaskCategoriesTable: FunctionalComponent<TaskCategoriesTableProps> = ({ pr
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
<label class="label">Catégories de tâche</label>
|
<label class="label is-size-5">Catégories de tâche</label>
|
||||||
<table class={`table is-bordered is-striped" ${style.middleTable}`}>
|
<table class={`table is-bordered is-striped" ${style.middleTable}`}>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue