Skip to content

Commit

Permalink
Merge pull request #893 from Yelinz/add-circ-column
Browse files Browse the repository at this point in the history
feat(ember): add amount circulation column
  • Loading branch information
open-dynaMIX authored Jun 23, 2023
2 parents a3af5eb + 579ea6f commit 1c318cd
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 7 deletions.
6 changes: 5 additions & 1 deletion ember/app/caluma-query/models/work-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ 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
question {
slug
meta
... on ChoiceQuestion {
options {
edges {
Expand All @@ -153,6 +154,9 @@ export default class CustomWorkItemModel extends WorkItemModel {
... on StringAnswer {
StringAnswerValue: value
}
... on FloatAnswer {
FloatAnswerValue: value
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions ember/app/ui/cases/detail/circulation/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 2 additions & 6 deletions ember/app/ui/cases/detail/index/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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`];
}
}
8 changes: 8 additions & 0 deletions ember/app/utils/format-currency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function formatCurrency(value, currency) {
return new Intl.NumberFormat("de-CH", {
style: "currency",
currency,
})
.format(value)
.replace(".00", ".-");
}
1 change: 1 addition & 0 deletions ember/translations/work-items/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ work-items:
documentNumber: "Referenz"
circulationComment: "Bemerkung"
circulationDecision: "Entscheid"
circulationAmount: "Betrag (WiMa)"
distributionPlan: "Verteilplan"

saveSuccess: "Aufgabe gespeichert"
Expand Down
1 change: 1 addition & 0 deletions ember/translations/work-items/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ work-items:
documentNumber: "Number"
circulationComment: "Comment"
circulationDecision: "Decision"
circulationAmount: "Amount (WiMa)"
distributionPlan: "Distribution plan"

saveSuccess: "Task successfully saved"
Expand Down
1 change: 1 addition & 0 deletions ember/translations/work-items/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ work-items:
documentNumber: "Référence"
circulationComment: "Remarque"
circulationDecision: "Décision"
circulationAmount: "Somme (WiMa)"
distributionPlan: "Plan de distribution"

saveSuccess: "Tâche enregistrée"
Expand Down

0 comments on commit 1c318cd

Please sign in to comment.