@projectcaluma/ember-distribution 11.0.0-beta.26 → 11.0.0-beta.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,4 +56,14 @@ export default class InquiryAbility extends Ability {
56
56
  ) ?? true
57
57
  );
58
58
  }
59
+
60
+ get canReopen() {
61
+ return (
62
+ this.model.isRedoable &&
63
+ this.model?.addressedGroups
64
+ .map(String)
65
+ .includes(String(this.calumaOptions.currentGroupId)) &&
66
+ (this.config.permissions.reopenInquiry?.(this.model) ?? true)
67
+ );
68
+ }
59
69
  }
@@ -77,6 +77,13 @@
77
77
  </LinkTo>
78
78
  </li>
79
79
  {{/if}}
80
+ {{#if (and (eq @type "answer") (can "reopen inquiry" @inquiry))}}
81
+ <li>
82
+ <a href="" {{on "click" (perform this.reopen)}} data-test-reopen>
83
+ {{t "caluma.distribution.reopen-inquiry.link"}}
84
+ </a>
85
+ </li>
86
+ {{/if}}
80
87
  {{/unless}}
81
88
  </ul>
82
89
 
@@ -7,6 +7,7 @@ import { confirm } from "ember-uikit";
7
7
 
8
8
  import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
9
9
  import config from "@projectcaluma/ember-distribution/config";
10
+ import reopenInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/reopen-inquiry.graphql";
10
11
  import withdrawInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/withdraw-inquiry.graphql";
11
12
  import inquiryAnswerStatus from "@projectcaluma/ember-distribution/utils/inquiry-answer-status";
12
13
 
@@ -73,4 +74,33 @@ export default class CdInquiryDialogInquiryPartComponent extends Component {
73
74
  );
74
75
  }
75
76
  }
77
+
78
+ @dropTask
79
+ *reopen(e) {
80
+ e.preventDefault();
81
+
82
+ /* istanbul ignore next */
83
+ if (
84
+ !(yield confirm(
85
+ this.intl.t("caluma.distribution.reopen-inquiry.confirm")
86
+ ))
87
+ ) {
88
+ return;
89
+ }
90
+
91
+ try {
92
+ yield this.apollo.mutate({
93
+ mutation: reopenInquiryMutation,
94
+ variables: {
95
+ workItem: decodeId(this.args.inquiry.id),
96
+ statusQuestion: this.config.inquiry.answer.statusQuestion,
97
+ buttonTasks: Object.keys(this.config.inquiry.answer.buttons),
98
+ },
99
+ });
100
+ } catch (error) {
101
+ this.notification.danger(
102
+ this.intl.t("caluma.distribution.reopen-inquiry.error")
103
+ );
104
+ }
105
+ }
76
106
  }
@@ -52,6 +52,8 @@ export default class CdInquiryDialogComponent extends Component {
52
52
  },
53
53
  });
54
54
 
55
+ this._setRedoableStates(response.allWorkItems);
56
+
55
57
  /**
56
58
  * Sadly this is necessary to handle what happens after the withdraw task in
57
59
  * the inquiry part component because the mutation triggers a refresh of the
@@ -68,11 +70,39 @@ export default class CdInquiryDialogComponent extends Component {
68
70
  if (allWorkItems.edges.every((edge) => edge.node.status === "CANCELED")) {
69
71
  this.router.transitionTo("index");
70
72
  }
73
+
74
+ /**
75
+ * Get work item that was redoable in the previous calulation and is now
76
+ * not anymore. This indicates that the work item was redone which should
77
+ * result in a transition to the answer view.
78
+ */
79
+ const redoneWorkItem = this._redoableStates.find((stateObj) => {
80
+ const updatedWorkItem = allWorkItems.edges.find(
81
+ (edge) => decodeId(edge.node.id) === stateObj.id
82
+ );
83
+
84
+ return (
85
+ stateObj.isRedoable && !(updatedWorkItem?.node.isRedoable ?? true)
86
+ );
87
+ });
88
+
89
+ if (redoneWorkItem) {
90
+ this.router.transitionTo("inquiry.detail.answer", redoneWorkItem.id);
91
+ }
92
+
93
+ this._setRedoableStates(allWorkItems);
71
94
  });
72
95
 
73
96
  return response;
74
97
  }
75
98
 
99
+ _setRedoableStates(allWorkItems) {
100
+ this._redoableStates = allWorkItems.edges.map((edge) => ({
101
+ id: decodeId(edge.node.id),
102
+ isRedoable: edge.node.isRedoable,
103
+ }));
104
+ }
105
+
76
106
  @dropTask
77
107
  *createInquiry(e) {
78
108
  e.preventDefault();
@@ -8,7 +8,7 @@ import { gql } from "graphql-tag";
8
8
  import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
9
9
  import config from "@projectcaluma/ember-distribution/config";
10
10
  import completeWorkItemMutation from "@projectcaluma/ember-distribution/gql/mutations/complete-work-item.graphql";
11
- import redoWorkItemMutation from "@projectcaluma/ember-distribution/gql/mutations/redo-work-item.graphql";
11
+ import reopenDistributionMutation from "@projectcaluma/ember-distribution/gql/mutations/reopen-distribution.graphql";
12
12
  import incompleteInquiriesQuery from "@projectcaluma/ember-distribution/gql/queries/incomplete-inquiries.graphql";
13
13
 
14
14
  export default class CdNavigationControlsComponent extends Component {
@@ -76,7 +76,7 @@ export default class CdNavigationControlsComponent extends Component {
76
76
  );
77
77
 
78
78
  yield this.apollo.mutate({
79
- mutation: redoWorkItemMutation,
79
+ mutation: reopenDistributionMutation,
80
80
  variables: {
81
81
  workItem: distributionWorkItemId,
82
82
  },
@@ -67,6 +67,7 @@ fragment InquiryDialog on WorkItem {
67
67
  createdAt
68
68
  closedAt
69
69
  status
70
+ isRedoable
70
71
  task {
71
72
  id
72
73
  slug
@@ -29,6 +29,7 @@ mutation CompleteInquiryWorkItem(
29
29
  parentWorkItem {
30
30
  id
31
31
  status
32
+ isRedoable
32
33
  }
33
34
  }
34
35
  }
@@ -1,4 +1,4 @@
1
- mutation RedoWorkItem($workItem: ID!) {
1
+ mutation ReopenDistribution($workItem: ID!) {
2
2
  redoWorkItem(input: { id: $workItem }) {
3
3
  workItem {
4
4
  id
@@ -0,0 +1,33 @@
1
+ #import InquiryStatusDocument from '../fragments/inquiry.graphql'
2
+
3
+ mutation ReopenInquiry(
4
+ $workItem: ID!
5
+ $statusQuestion: ID!
6
+ $buttonTasks: [String]!
7
+ ) {
8
+ redoWorkItem(input: { id: $workItem }) {
9
+ workItem {
10
+ id
11
+ status
12
+ isRedoable
13
+ childCase {
14
+ id
15
+ document {
16
+ id
17
+ ...InquiryStatusDocument
18
+ }
19
+ workItems(filter: [{ tasks: $buttonTasks }, { status: READY }]) {
20
+ edges {
21
+ node {
22
+ id
23
+ task {
24
+ id
25
+ slug
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-distribution",
3
- "version": "11.0.0-beta.26",
3
+ "version": "11.0.0-beta.27",
4
4
  "description": "Ember engine for the Caluma distribution module.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -22,9 +22,9 @@
22
22
  "@embroider/macros": "^1.8.3",
23
23
  "@glimmer/component": "^1.1.2",
24
24
  "@glimmer/tracking": "^1.1.2",
25
- "@projectcaluma/ember-core": "^11.0.0-beta.26",
26
- "@projectcaluma/ember-form": "^11.0.0-beta.26",
27
- "@projectcaluma/ember-workflow": "^11.0.0-beta.26",
25
+ "@projectcaluma/ember-core": "^11.0.0-beta.27",
26
+ "@projectcaluma/ember-form": "^11.0.0-beta.27",
27
+ "@projectcaluma/ember-workflow": "^11.0.0-beta.27",
28
28
  "ember-apollo-client": "~4.0.2",
29
29
  "ember-auto-import": "^2.4.2",
30
30
  "ember-can": "^4.2.0",
@@ -50,7 +50,7 @@
50
50
  "@ember/test-helpers": "2.8.1",
51
51
  "@embroider/test-setup": "1.8.3",
52
52
  "@faker-js/faker": "7.5.0",
53
- "@projectcaluma/ember-testing": "11.0.0-beta.26",
53
+ "@projectcaluma/ember-testing": "11.0.0-beta.27",
54
54
  "broccoli-asset-rev": "3.0.0",
55
55
  "ember-cli": "3.28.5",
56
56
  "ember-cli-code-coverage": "1.0.3",
@@ -85,3 +85,8 @@ caluma:
85
85
  confirm: "Wollen Sie die Anfrage wirklich zurückziehen?"
86
86
  error: "Fehler beim Zurückziehen der Anfrage"
87
87
  status: "Zurückgezogen"
88
+
89
+ reopen-inquiry:
90
+ link: "Wiedereröffnen"
91
+ confirm: "Wollen Sie die Anfrage wirklich wiedereröffnen?"
92
+ error: "Fehler beim Wiedereröffnen der Anfrage"
@@ -86,3 +86,8 @@ caluma:
86
86
  confirm: "Do you really want to withdraw the inquiry?"
87
87
  error: "Error while withdrawing the inquiry"
88
88
  status: "Withdrawn"
89
+
90
+ reopen-inquiry:
91
+ link: "Reopen"
92
+ confirm: "Do you really want to reopen the inquiry?"
93
+ error: "Error while reopening the inquiry"
@@ -85,3 +85,8 @@ caluma:
85
85
  confirm: "Voulez-vous vraiment retirer la demande ?"
86
86
  error: "Erreur lors du retrait de la demande"
87
87
  status: "Retirée"
88
+
89
+ reopen-inquiry:
90
+ link: "Rouvrir"
91
+ confirm: "Voulez-vous vraiment rouvrir la demande ?"
92
+ error: "Erreur lors de la réouverture de la demande"