From 066709eddb40f524d052aa1e162e4f64465fd12c Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Tue, 24 Feb 2026 22:40:37 +0000 Subject: [PATCH] Added the cost editor --- public/locales/bg/budgetOption.json | 5 ++ public/locales/bg/priority.json | 5 ++ public/locales/cs/budgetOption.json | 5 ++ public/locales/cs/priority.json | 5 ++ public/locales/de/budgetOption.json | 5 ++ public/locales/de/priority.json | 4 + public/locales/en/budgetOption.json | 6 +- public/locales/en/priority.json | 6 +- public/locales/es/budgetOption.json | 5 ++ public/locales/es/priority.json | 4 + public/locales/fr/budgetOption.json | 5 ++ public/locales/fr/priority.json | 4 + public/locales/ko/budgetOption.json | 5 ++ public/locales/ko/priority.json | 4 + public/locales/nl/budgetOption.json | 5 ++ public/locales/nl/priority.json | 5 ++ public/locales/pl/budgetOption.json | 5 ++ public/locales/pl/priority.json | 4 + public/locales/pt/budgetOption.json | 5 ++ public/locales/pt/priority.json | 5 ++ public/locales/uk/budgetOption.json | 5 ++ public/locales/uk/priority.json | 5 ++ public/locales/ur/budgetOption.json | 5 ++ public/locales/ur/priority.json | 5 ++ src/components/common/CostEditor.tsx | 80 +++++++++++++++++++ src/components/common/Input.tsx | 16 +++- .../BudgetEditorRegistryEntry.tsx | 9 ++- 27 files changed, 214 insertions(+), 8 deletions(-) create mode 100644 public/locales/bg/budgetOption.json create mode 100644 public/locales/bg/priority.json create mode 100644 public/locales/cs/budgetOption.json create mode 100644 public/locales/cs/priority.json create mode 100644 public/locales/de/budgetOption.json create mode 100644 public/locales/de/priority.json create mode 100644 public/locales/es/budgetOption.json create mode 100644 public/locales/es/priority.json create mode 100644 public/locales/fr/budgetOption.json create mode 100644 public/locales/fr/priority.json create mode 100644 public/locales/ko/budgetOption.json create mode 100644 public/locales/ko/priority.json create mode 100644 public/locales/nl/budgetOption.json create mode 100644 public/locales/nl/priority.json create mode 100644 public/locales/pl/budgetOption.json create mode 100644 public/locales/pl/priority.json create mode 100644 public/locales/pt/budgetOption.json create mode 100644 public/locales/pt/priority.json create mode 100644 public/locales/uk/budgetOption.json create mode 100644 public/locales/uk/priority.json create mode 100644 public/locales/ur/budgetOption.json create mode 100644 public/locales/ur/priority.json create mode 100644 src/components/common/CostEditor.tsx diff --git a/public/locales/bg/budgetOption.json b/public/locales/bg/budgetOption.json new file mode 100644 index 0000000..ae0c555 --- /dev/null +++ b/public/locales/bg/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "Не прикажи", + "ShowAndEdit": "Прикажи и уреди", + "ShowOnly": "Прикажи само" +} \ No newline at end of file diff --git a/public/locales/bg/priority.json b/public/locales/bg/priority.json new file mode 100644 index 0000000..58d9bca --- /dev/null +++ b/public/locales/bg/priority.json @@ -0,0 +1,5 @@ +{ + "High": "Висок", + "Low": "Нисак", + "Normal": "Нормално" +} \ No newline at end of file diff --git a/public/locales/cs/budgetOption.json b/public/locales/cs/budgetOption.json new file mode 100644 index 0000000..d6dd752 --- /dev/null +++ b/public/locales/cs/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "Nepokážte.", + "ShowAndEdit": "Zobrazit a upravit", + "ShowOnly": "Zobrazit pouze" +} \ No newline at end of file diff --git a/public/locales/cs/priority.json b/public/locales/cs/priority.json new file mode 100644 index 0000000..75f8c9a --- /dev/null +++ b/public/locales/cs/priority.json @@ -0,0 +1,5 @@ +{ + "High": "Vysoký", + "Low": "Nízký", + "Normal": "Normální" +} \ No newline at end of file diff --git a/public/locales/de/budgetOption.json b/public/locales/de/budgetOption.json new file mode 100644 index 0000000..da96bb2 --- /dev/null +++ b/public/locales/de/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "Nicht anzeigen", + "ShowAndEdit": "Anzeigen und Bearbeiten", + "ShowOnly": "Nur anzeigen" +} \ No newline at end of file diff --git a/public/locales/de/priority.json b/public/locales/de/priority.json new file mode 100644 index 0000000..0b971bc --- /dev/null +++ b/public/locales/de/priority.json @@ -0,0 +1,4 @@ +{ + "High": "Hoch", + "Low": "Niedrig" +} \ No newline at end of file diff --git a/public/locales/en/budgetOption.json b/public/locales/en/budgetOption.json index 343e6e4..f09d0d0 100644 --- a/public/locales/en/budgetOption.json +++ b/public/locales/en/budgetOption.json @@ -1,5 +1,5 @@ { "DoNotShow": "Do Not Show", - "ShowOnly": "Show Only", - "ShowAndEdit": "Show And Edit" -} + "ShowAndEdit": "Show And Edit", + "ShowOnly": "Show Only" +} \ No newline at end of file diff --git a/public/locales/en/priority.json b/public/locales/en/priority.json index b73bf9b..7d56b76 100644 --- a/public/locales/en/priority.json +++ b/public/locales/en/priority.json @@ -1,5 +1,5 @@ { + "High": "High", "Low": "Low", - "Normal": "Normal", - "High": "High" -} + "Normal": "Normal" +} \ No newline at end of file diff --git a/public/locales/es/budgetOption.json b/public/locales/es/budgetOption.json new file mode 100644 index 0000000..6c153c2 --- /dev/null +++ b/public/locales/es/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "No mostrar", + "ShowAndEdit": "Mostrar y editar", + "ShowOnly": "Mostrar solo" +} \ No newline at end of file diff --git a/public/locales/es/priority.json b/public/locales/es/priority.json new file mode 100644 index 0000000..899c658 --- /dev/null +++ b/public/locales/es/priority.json @@ -0,0 +1,4 @@ +{ + "High": "Alto", + "Low": "Bajo" +} \ No newline at end of file diff --git a/public/locales/fr/budgetOption.json b/public/locales/fr/budgetOption.json new file mode 100644 index 0000000..cd66518 --- /dev/null +++ b/public/locales/fr/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "Ne pas afficher", + "ShowAndEdit": "Afficher et modifier", + "ShowOnly": "Afficher uniquement" +} \ No newline at end of file diff --git a/public/locales/fr/priority.json b/public/locales/fr/priority.json new file mode 100644 index 0000000..bb49528 --- /dev/null +++ b/public/locales/fr/priority.json @@ -0,0 +1,4 @@ +{ + "High": "Élevé", + "Low": "Faible" +} \ No newline at end of file diff --git a/public/locales/ko/budgetOption.json b/public/locales/ko/budgetOption.json new file mode 100644 index 0000000..32b830d --- /dev/null +++ b/public/locales/ko/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "표시하지 마세요", + "ShowAndEdit": "보기 및 편집", + "ShowOnly": "쇼 온리" +} \ No newline at end of file diff --git a/public/locales/ko/priority.json b/public/locales/ko/priority.json new file mode 100644 index 0000000..b64f7d6 --- /dev/null +++ b/public/locales/ko/priority.json @@ -0,0 +1,4 @@ +{ + "Low": "로우", + "Normal": "정상" +} \ No newline at end of file diff --git a/public/locales/nl/budgetOption.json b/public/locales/nl/budgetOption.json new file mode 100644 index 0000000..a7e75f1 --- /dev/null +++ b/public/locales/nl/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "Niet weergeven", + "ShowAndEdit": "Weergeven en bewerken", + "ShowOnly": "Alleen weergeven" +} \ No newline at end of file diff --git a/public/locales/nl/priority.json b/public/locales/nl/priority.json new file mode 100644 index 0000000..5ecec06 --- /dev/null +++ b/public/locales/nl/priority.json @@ -0,0 +1,5 @@ +{ + "High": "Hoog", + "Low": "Laag", + "Normal": "Normaal" +} \ No newline at end of file diff --git a/public/locales/pl/budgetOption.json b/public/locales/pl/budgetOption.json new file mode 100644 index 0000000..027840c --- /dev/null +++ b/public/locales/pl/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "Nie wyświetlać", + "ShowAndEdit": "Pokaż i edytuj", + "ShowOnly": "Pokaż tylko" +} \ No newline at end of file diff --git a/public/locales/pl/priority.json b/public/locales/pl/priority.json new file mode 100644 index 0000000..32a9121 --- /dev/null +++ b/public/locales/pl/priority.json @@ -0,0 +1,4 @@ +{ + "High": "Wysoki", + "Low": "Niski" +} \ No newline at end of file diff --git a/public/locales/pt/budgetOption.json b/public/locales/pt/budgetOption.json new file mode 100644 index 0000000..7e8acbd --- /dev/null +++ b/public/locales/pt/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "Não exibir", + "ShowAndEdit": "Mostrar e Editar", + "ShowOnly": "Mostrar apenas" +} \ No newline at end of file diff --git a/public/locales/pt/priority.json b/public/locales/pt/priority.json new file mode 100644 index 0000000..93dd9c7 --- /dev/null +++ b/public/locales/pt/priority.json @@ -0,0 +1,5 @@ +{ + "High": "Alto", + "Low": "Baixo", + "Normal": "Normal." +} \ No newline at end of file diff --git a/public/locales/uk/budgetOption.json b/public/locales/uk/budgetOption.json new file mode 100644 index 0000000..6fbd01e --- /dev/null +++ b/public/locales/uk/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "Не відображати", + "ShowAndEdit": "Показати та редагувати", + "ShowOnly": "Показати тільки" +} \ No newline at end of file diff --git a/public/locales/uk/priority.json b/public/locales/uk/priority.json new file mode 100644 index 0000000..d56cebc --- /dev/null +++ b/public/locales/uk/priority.json @@ -0,0 +1,5 @@ +{ + "High": "Високий", + "Low": "Низький", + "Normal": "Звичайний" +} \ No newline at end of file diff --git a/public/locales/ur/budgetOption.json b/public/locales/ur/budgetOption.json new file mode 100644 index 0000000..fb7fc22 --- /dev/null +++ b/public/locales/ur/budgetOption.json @@ -0,0 +1,5 @@ +{ + "DoNotShow": "न दिखाएं।", + "ShowAndEdit": "دکھائیں اور ترمیم کریں", + "ShowOnly": "صرف ذلك هو المطلوب." +} \ No newline at end of file diff --git a/public/locales/ur/priority.json b/public/locales/ur/priority.json new file mode 100644 index 0000000..961e613 --- /dev/null +++ b/public/locales/ur/priority.json @@ -0,0 +1,5 @@ +{ + "High": "بहुत ऊँचा", + "Low": "کम", + "Normal": "سामान्य" +} \ No newline at end of file diff --git a/src/components/common/CostEditor.tsx b/src/components/common/CostEditor.tsx new file mode 100644 index 0000000..69ced7c --- /dev/null +++ b/src/components/common/CostEditor.tsx @@ -0,0 +1,80 @@ +import Input, { InputType } from "./Input"; + +export type CostValue = { + amount: number; + isoCurrencySymbol: string; +}; + +export interface CostEditorProps { + name: string; + value: CostValue; + amountLabel?: string; + currencyLabel?: string; + amountError?: string; + currencyError?: string; + onChange: (value: CostValue) => void; +} + +function normalizeAmount(rawValue: string) { + if (rawValue.trim() === "") { + return 0; + } + + const parsed = Number(rawValue); + return Number.isFinite(parsed) ? parsed : 0; +} + +export default function CostEditor(props: CostEditorProps) { + const { + name, + value, + amountLabel, + currencyLabel, + amountError, + currencyError, + onChange, + } = props; + + const currentValue: CostValue = { + amount: value?.amount ?? 0, + isoCurrencySymbol: value?.isoCurrencySymbol ?? "", + }; + + return ( +
+ { + const nextAmount = normalizeAmount(String(event.target.value)); + onChange({ + ...currentValue, + amount: nextAmount, + }); + }} + /> + { + onChange({ + ...currentValue, + isoCurrencySymbol: String(event.target.value).toUpperCase(), + }); + }} + /> +
+ ); +} diff --git a/src/components/common/Input.tsx b/src/components/common/Input.tsx index ed56eff..6e5a3a9 100644 --- a/src/components/common/Input.tsx +++ b/src/components/common/Input.tsx @@ -4,6 +4,7 @@ import ErrorBlock from "./ErrorBlock"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons"; import { Checklist } from "./Checklist"; +import CostEditor, { CostValue } from "./CostEditor"; import { TagsInput } from "./inputTags"; export enum InputType { @@ -11,6 +12,7 @@ export enum InputType { checkbox = "checkbox", checklist = "checklist", color = "color", + cost = "cost", date = "date", datetimelocal = "datetime-local", email = "email", @@ -42,7 +44,7 @@ export interface InputProps { placeHolder?: string; readOnly?: boolean; type: InputType; - value?: string | number | readonly string[] | boolean | undefined; + value?: string | number | readonly string[] | boolean | CostValue | undefined; defaultValue?: string | number | readonly string[] | undefined; min?: number; max?: number; @@ -147,6 +149,18 @@ function Input(props: InputProps) { error={props.error} /> ), + [InputType.cost]: (props) => ( + { + onChange?.({ + target: { value: nextValue }, + } as any); + }} + /> + ), // future controls go here }; diff --git a/src/modules/manager/workflowTemplates/components/CapabilityEditors/BudgetEditorRegistryEntry.tsx b/src/modules/manager/workflowTemplates/components/CapabilityEditors/BudgetEditorRegistryEntry.tsx index 9be9920..c794614 100644 --- a/src/modules/manager/workflowTemplates/components/CapabilityEditors/BudgetEditorRegistryEntry.tsx +++ b/src/modules/manager/workflowTemplates/components/CapabilityEditors/BudgetEditorRegistryEntry.tsx @@ -28,7 +28,14 @@ export const BudgetEditor: React.FC = (props) => { InputType.number, fieldErrors, )} -
Cost goes here
+ {renderTaskField( + task, + onChange, + "cost", + "Cost", + InputType.cost, + fieldErrors, + )}