From c8457bdd6c8dea26970731aab1128d1349a9bfc3 Mon Sep 17 00:00:00 2001 From: yelinz Date: Wed, 21 Jun 2023 10:45:24 +0200 Subject: [PATCH 1/2] feat(ember): add amount circulation column --- ember/app/caluma-query/models/work-item.js | 5 ++++- ember/app/ui/cases/detail/circulation/controller.js | 6 ++++++ ember/translations/work-items/de.yaml | 1 + ember/translations/work-items/en.yaml | 1 + ember/translations/work-items/fr.yaml | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ember/app/caluma-query/models/work-item.js b/ember/app/caluma-query/models/work-item.js index 861fe36e7..9ce8b371d 100644 --- a/ember/app/caluma-query/models/work-item.js +++ b/ember/app/caluma-query/models/work-item.js @@ -133,7 +133,7 @@ export default class CustomWorkItemModel extends WorkItemModel { form { slug } - answers(filter: [{questions: ["circulation-decision", "circulation-comment"]}]) { + answers(filter: [{questions: ["circulation-decision", "circulation-comment", "circulation-antrag-betrag"]}]) { edges { node { id @@ -153,6 +153,9 @@ export default class CustomWorkItemModel extends WorkItemModel { ... on StringAnswer { StringAnswerValue: value } + ... on FloatAnswer { + FloatAnswerValue: value + } } } } diff --git a/ember/app/ui/cases/detail/circulation/controller.js b/ember/app/ui/cases/detail/circulation/controller.js index cfa3cf955..5b9858e12 100644 --- a/ember/app/ui/cases/detail/circulation/controller.js +++ b/ember/app/ui/cases/detail/circulation/controller.js @@ -58,6 +58,12 @@ export default class CasesDetailCirculationController extends Controller { answerKey: "document.answers.edges", type: "answer-value", }, + { + heading: { label: "work-items.circulationAmount" }, + questionSlug: "circulation-antrag-betrag", + answerKey: "document.answers.edges", + type: "answer-value", + }, { heading: { label: "work-items.action" }, type: "work-item-actions", diff --git a/ember/translations/work-items/de.yaml b/ember/translations/work-items/de.yaml index 31051f8a6..f12fc1668 100755 --- a/ember/translations/work-items/de.yaml +++ b/ember/translations/work-items/de.yaml @@ -15,6 +15,7 @@ work-items: documentNumber: "Referenz" circulationComment: "Bemerkung" circulationDecision: "Entscheid" + circulationAmount: "Betrag" distributionPlan: "Verteilplan" saveSuccess: "Aufgabe gespeichert" diff --git a/ember/translations/work-items/en.yaml b/ember/translations/work-items/en.yaml index 3555f722d..3ae9d39f6 100644 --- a/ember/translations/work-items/en.yaml +++ b/ember/translations/work-items/en.yaml @@ -15,6 +15,7 @@ work-items: documentNumber: "Number" circulationComment: "Comment" circulationDecision: "Decision" + circulationAmount: "Amount" distributionPlan: "Distribution plan" saveSuccess: "Task successfully saved" diff --git a/ember/translations/work-items/fr.yaml b/ember/translations/work-items/fr.yaml index ed3b6b29d..34fe63efa 100755 --- a/ember/translations/work-items/fr.yaml +++ b/ember/translations/work-items/fr.yaml @@ -15,6 +15,7 @@ work-items: documentNumber: "Référence" circulationComment: "Remarque" circulationDecision: "Décision" + circulationAmount: "Somme" distributionPlan: "Plan de distribution" saveSuccess: "Tâche enregistrée" From 579ea6f3b8be673495ed081a7b6e08f323fd9694 Mon Sep 17 00:00:00 2001 From: yelinz Date: Thu, 22 Jun 2023 10:13:45 +0200 Subject: [PATCH 2/2] fix(ember): add formatting for circulation column --- ember/app/caluma-query/models/work-item.js | 1 + ember/app/ui/cases/detail/index/controller.js | 8 ++------ .../components/dynamic-table/answer-value/component.js | 9 +++++++++ ember/app/utils/format-currency.js | 8 ++++++++ ember/translations/work-items/de.yaml | 2 +- ember/translations/work-items/en.yaml | 2 +- ember/translations/work-items/fr.yaml | 2 +- 7 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 ember/app/utils/format-currency.js diff --git a/ember/app/caluma-query/models/work-item.js b/ember/app/caluma-query/models/work-item.js index 9ce8b371d..badf7e02b 100644 --- a/ember/app/caluma-query/models/work-item.js +++ b/ember/app/caluma-query/models/work-item.js @@ -139,6 +139,7 @@ export default class CustomWorkItemModel extends WorkItemModel { id question { slug + meta ... on ChoiceQuestion { options { edges { diff --git a/ember/app/ui/cases/detail/index/controller.js b/ember/app/ui/cases/detail/index/controller.js index 56c843b18..1438e46e4 100644 --- a/ember/app/ui/cases/detail/index/controller.js +++ b/ember/app/ui/cases/detail/index/controller.js @@ -15,6 +15,7 @@ import redoWorkItemMutation from "mysagw/gql/mutations/redo-work-item.graphql"; import reopenCaseMutation from "mysagw/gql/mutations/reopen-case.graphql"; import getCaseQuery from "mysagw/gql/queries/get-case.graphql"; import downloadFile from "mysagw/utils/download-file"; +import formatCurrency from "mysagw/utils/format-currency"; import CaseValidations from "mysagw/validations/case"; export default class CasesDetailIndexController extends Controller { @@ -128,12 +129,7 @@ export default class CasesDetailIndexController extends Controller { let value = answer.node[`${answer.node.__typename}Value`]; if (answer.node.question.meta.waehrung) { - value = new Intl.NumberFormat("de-CH", { - style: "currency", - currency: answer.node.question.meta.waehrung, - }) - .format(value) - .replace(".00", ".-"); + value = formatCurrency(value, answer.node.question.meta.waehrung); } return { diff --git a/ember/app/ui/components/dynamic-table/answer-value/component.js b/ember/app/ui/components/dynamic-table/answer-value/component.js index 9696268b7..ea69b39ba 100644 --- a/ember/app/ui/components/dynamic-table/answer-value/component.js +++ b/ember/app/ui/components/dynamic-table/answer-value/component.js @@ -1,6 +1,8 @@ import { get } from "@ember/object"; import Component from "@glimmer/component"; +import formatCurrency from "mysagw/utils/format-currency"; + export default class AnswerValue extends Component { get value() { const value = this.args.value.parentWorkItem ?? this.args.value; @@ -20,6 +22,13 @@ export default class AnswerValue extends Component { ).node.label; } + if (answer.question.meta?.waehrung) { + return formatCurrency( + answer[`${answer.__typename}Value`], + answer.question.meta.waehrung + ); + } + return answer[`${answer.__typename}Value`]; } } diff --git a/ember/app/utils/format-currency.js b/ember/app/utils/format-currency.js new file mode 100644 index 000000000..b172aab43 --- /dev/null +++ b/ember/app/utils/format-currency.js @@ -0,0 +1,8 @@ +export default function formatCurrency(value, currency) { + return new Intl.NumberFormat("de-CH", { + style: "currency", + currency, + }) + .format(value) + .replace(".00", ".-"); +} diff --git a/ember/translations/work-items/de.yaml b/ember/translations/work-items/de.yaml index f12fc1668..9f20ff277 100755 --- a/ember/translations/work-items/de.yaml +++ b/ember/translations/work-items/de.yaml @@ -15,7 +15,7 @@ work-items: documentNumber: "Referenz" circulationComment: "Bemerkung" circulationDecision: "Entscheid" - circulationAmount: "Betrag" + circulationAmount: "Betrag (WiMa)" distributionPlan: "Verteilplan" saveSuccess: "Aufgabe gespeichert" diff --git a/ember/translations/work-items/en.yaml b/ember/translations/work-items/en.yaml index 3ae9d39f6..e395d66e8 100644 --- a/ember/translations/work-items/en.yaml +++ b/ember/translations/work-items/en.yaml @@ -15,7 +15,7 @@ work-items: documentNumber: "Number" circulationComment: "Comment" circulationDecision: "Decision" - circulationAmount: "Amount" + circulationAmount: "Amount (WiMa)" distributionPlan: "Distribution plan" saveSuccess: "Task successfully saved" diff --git a/ember/translations/work-items/fr.yaml b/ember/translations/work-items/fr.yaml index 34fe63efa..1443a94f6 100755 --- a/ember/translations/work-items/fr.yaml +++ b/ember/translations/work-items/fr.yaml @@ -15,7 +15,7 @@ work-items: documentNumber: "Référence" circulationComment: "Remarque" circulationDecision: "Décision" - circulationAmount: "Somme" + circulationAmount: "Somme (WiMa)" distributionPlan: "Plan de distribution" saveSuccess: "Tâche enregistrée"