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

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
  }
@@ -3,6 +3,6 @@
3
3
  {{if this.config.ui.small 'inquiry-divider--small' 'uk-margin'}}"
4
4
  >
5
5
  <div class="inquiry-divider__icon uk-flex uk-flex-center uk-flex-middle">
6
- <UkIcon @icon={{this.status.icon}} uk-tooltip={{this.status.label}} />
6
+ <UkIcon @icon={{this.status.icon}} {{uk-tooltip this.status.label}} />
7
7
  </div>
8
8
  </div>
@@ -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
  }
@@ -8,7 +8,7 @@
8
8
  <button
9
9
  type="button"
10
10
  class="uk-icon-button"
11
- uk-tooltip={{t "caluma.distribution.new.title"}}
11
+ {{uk-tooltip (t "caluma.distribution.new.title")}}
12
12
  data-test-new-inquiry
13
13
  {{on "click" (perform this.createInquiry)}}
14
14
  >
@@ -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();
@@ -3,7 +3,7 @@
3
3
  <LinkTo
4
4
  @route="new"
5
5
  class="uk-icon-button"
6
- uk-tooltip={{t "caluma.distribution.new.title"}}
6
+ {{uk-tooltip (t "caluma.distribution.new.title")}}
7
7
  data-test-new-inquiry
8
8
  >
9
9
  <UkIcon @icon="plus" />
@@ -13,7 +13,7 @@
13
13
  <button
14
14
  type="button"
15
15
  class="uk-icon-button"
16
- uk-tooltip={{t "caluma.distribution.send"}}
16
+ {{uk-tooltip (t "caluma.distribution.send")}}
17
17
  data-test-send-pending-inquiries
18
18
  {{on "click" (perform this.sendInquiries)}}
19
19
  >
@@ -28,7 +28,7 @@
28
28
  <button
29
29
  type="button"
30
30
  class="uk-icon-button"
31
- uk-tooltip={{t "caluma.distribution.complete"}}
31
+ {{uk-tooltip (t "caluma.distribution.complete")}}
32
32
  data-test-complete-distribution
33
33
  {{on "click" (perform this.completeDistribution)}}
34
34
  >
@@ -43,7 +43,7 @@
43
43
  <button
44
44
  type="button"
45
45
  class="uk-icon-button"
46
- uk-tooltip={{t "caluma.distribution.reopen"}}
46
+ {{uk-tooltip (t "caluma.distribution.reopen")}}
47
47
  data-test-reopen-distribution
48
48
  {{on "click" (perform this.reopenDistribution)}}
49
49
  >
@@ -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
  },
@@ -2,12 +2,12 @@
2
2
  <UkIcon
3
3
  @icon="clock"
4
4
  class="uk-margin-small-right uk-text-{{this.deadline.color}}"
5
- uk-tooltip={{format-date this.deadline.value}}
5
+ {{uk-tooltip (format-date this.deadline.value)}}
6
6
  />
7
7
  {{/if}}
8
8
 
9
9
  <UkIcon
10
10
  @icon={{this.status.icon}}
11
11
  class="uk-text-{{this.status.color}}"
12
- uk-tooltip={{this.status.label}}
12
+ {{uk-tooltip this.status.label}}
13
13
  />
@@ -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.24",
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.24",
26
- "@projectcaluma/ember-form": "^11.0.0-beta.24",
27
- "@projectcaluma/ember-workflow": "^11.0.0-beta.24",
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",
@@ -35,22 +35,22 @@
35
35
  "ember-fetch": "^8.1.2",
36
36
  "ember-intl": "^5.7.2",
37
37
  "ember-pikaday": "^4.0.0",
38
- "ember-resources": "^5.2.1",
38
+ "ember-resources": "^5.3.0",
39
39
  "ember-svg-jar": "^2.3.4",
40
40
  "ember-test-selectors": "^6.0.0",
41
- "ember-uikit": "^5.1.3",
41
+ "ember-uikit": "^6.0.0",
42
42
  "graphql": "^15.8.0",
43
43
  "graphql-tag": "^2.12.6",
44
44
  "lodash.merge": "^4.6.2",
45
- "luxon": "^3.0.1",
45
+ "luxon": "^3.0.3",
46
46
  "tracked-toolbox": "^1.2.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@ember/optional-features": "2.0.0",
50
50
  "@ember/test-helpers": "2.8.1",
51
51
  "@embroider/test-setup": "1.8.3",
52
- "@faker-js/faker": "7.4.0",
53
- "@projectcaluma/ember-testing": "11.0.0-beta.24",
52
+ "@faker-js/faker": "7.5.0",
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",
@@ -75,7 +75,7 @@
75
75
  "npm-run-all": "4.1.5",
76
76
  "qunit": "2.19.1",
77
77
  "qunit-dom": "2.0.0",
78
- "sass": "1.54.5",
78
+ "sass": "1.54.6",
79
79
  "webpack": "5.74.0"
80
80
  },
81
81
  "engines": {
@@ -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"