@projectcaluma/ember-distribution 11.0.0-beta.31 → 11.0.0-beta.33

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,11 +21,27 @@ export default class InquiryAbility extends Ability {
21
21
  }
22
22
 
23
23
  get canSend() {
24
- return this.config.permissions.sendInquiry?.(this.model) ?? true;
24
+ return (
25
+ !this.config.ui.readonly &&
26
+ this.model?.task.slug === this.config.inquiry.task &&
27
+ this.model?.status === "SUSPENDED" &&
28
+ (this.config.permissions.sendInquiry?.(this.model) ?? true) &&
29
+ this.model?.controllingGroups
30
+ .map(String)
31
+ .includes(String(this.calumaOptions.currentGroupId))
32
+ );
25
33
  }
26
34
 
27
35
  get canWithdraw() {
28
- return this.config.permissions.withdrawInquiry?.(this.model) ?? true;
36
+ return (
37
+ !this.config.ui.readonly &&
38
+ this.model?.task.slug === this.config.inquiry.task &&
39
+ this.model?.status === "SUSPENDED" &&
40
+ (this.config.permissions.withdrawInquiry?.(this.model) ?? true) &&
41
+ this.model?.controllingGroups
42
+ .map(String)
43
+ .includes(String(this.calumaOptions.currentGroupId))
44
+ );
29
45
  }
30
46
 
31
47
  get canAnswer() {
@@ -92,6 +92,7 @@
92
92
  @onClick={{fn
93
93
  (perform this.completeWorkItem)
94
94
  buttonConfig.workItemId
95
+ buttonConfig.willCompleteInquiry
95
96
  validate
96
97
  }}
97
98
  >{{buttonConfig.label}}</UkButton>
@@ -115,6 +116,7 @@
115
116
  @onClick={{fn
116
117
  (perform this.completeWorkItem)
117
118
  buttonConfig.workItemId
119
+ buttonConfig.willCompleteInquiry
118
120
  null
119
121
  }}
120
122
  >{{buttonConfig.label}}</UkButton>
@@ -2,7 +2,7 @@ import { action } from "@ember/object";
2
2
  import { inject as service } from "@ember/service";
3
3
  import Component from "@glimmer/component";
4
4
  import { tracked } from "@glimmer/tracking";
5
- import { queryManager, getObservable } from "ember-apollo-client";
5
+ import { queryManager } from "ember-apollo-client";
6
6
  import { dropTask } from "ember-concurrency";
7
7
  import { trackedTask } from "ember-resources/util/ember-concurrency";
8
8
 
@@ -55,6 +55,7 @@ export default class CdInquiryAnswerFormComponent extends Component {
55
55
  isFormButton:
56
56
  edge.node.task.__typename === "CompleteWorkflowFormTask",
57
57
  label: this.intl.t(config.label),
58
+ willCompleteInquiry: config.willCompleteInquiry ?? false,
58
59
  }
59
60
  : null;
60
61
  })
@@ -84,7 +85,7 @@ export default class CdInquiryAnswerFormComponent extends Component {
84
85
  }
85
86
 
86
87
  @dropTask
87
- *completeWorkItem(workItem, validate = () => true) {
88
+ *completeWorkItem(workItem, willCompleteInquiry, validate = () => true) {
88
89
  try {
89
90
  if (typeof validate === "function" && !(yield validate())) return;
90
91
 
@@ -95,12 +96,14 @@ export default class CdInquiryAnswerFormComponent extends Component {
95
96
  statusQuestion: this.config.inquiry.answer.statusQuestion,
96
97
  buttonTasks: Object.keys(this.config.inquiry.answer.buttons),
97
98
  checkTask: this.config.controls.checkTask,
99
+ createTask: this.config.controls.createTask,
100
+ inquiryTask: this.config.inquiry.task,
98
101
  currentGroup: String(this.calumaOptions.currentGroupId),
99
102
  answerInfoQuestions: this.config.inquiry.answer.infoQuestions,
103
+ willCompleteInquiry,
100
104
  },
101
105
  });
102
106
 
103
- yield getObservable(this._inquiry.value)?.refetch();
104
107
  yield this.router.transitionTo("inquiry.index");
105
108
  } catch (error) {
106
109
  this.notification.danger(
@@ -128,21 +128,28 @@
128
128
  >
129
129
  {{#if (and (eq @type "answer") @inquiry.assignedUsers.length)}}
130
130
  <li {{uk-tooltip (t "caluma.distribution.inquiry.assigned-user")}}>
131
- {{user-name @inquiry.assignedUsers}}
131
+ <span>{{user-name @inquiry.assignedUsers}}</span>
132
+ </li>
133
+ {{/if}}
134
+ {{#if (eq @type "answer")}}
135
+ <li {{uk-tooltip (t "caluma.distribution.inquiry.closed-at")}}>
136
+ <span>
137
+ {{format-date @inquiry.closedAt}}
138
+ {{format-time @inquiry.closedAt hour="2-digit" minute="2-digit"}}
139
+ </span>
140
+ </li>
141
+ {{else if (and (eq @type "request") @inquiry.childCase.createdAt)}}
142
+ <li {{uk-tooltip (t "caluma.distribution.inquiry.sent-at")}}>
143
+ <span>
144
+ {{format-date @inquiry.childCase.createdAt}}
145
+ {{format-time
146
+ @inquiry.childCase.createdAt
147
+ hour="2-digit"
148
+ minute="2-digit"
149
+ }}
150
+ </span>
132
151
  </li>
133
152
  {{/if}}
134
- <li
135
- {{uk-tooltip
136
- (if
137
- (eq @type "answer")
138
- (t "caluma.distribution.inquiry.closed-at")
139
- (t "caluma.distribution.inquiry.created-at")
140
- )
141
- }}
142
- >
143
- {{format-date this.date}}
144
- {{format-time this.date hour="2-digit" minute="2-digit"}}
145
- </li>
146
153
  </ul>
147
154
 
148
155
  </div>
package/addon/config.js CHANGED
@@ -46,6 +46,7 @@ export default function config(target, property) {
46
46
  color: "primary",
47
47
  label: "caluma.distribution.answer.buttons.confirm.label",
48
48
  status: "caluma.distribution.answer.buttons.confirm.status",
49
+ willCompleteInquiry: true,
49
50
  },
50
51
  "revise-inquiry-answer": {
51
52
  color: "default",
@@ -59,8 +60,8 @@ export default function config(target, property) {
59
60
  },
60
61
  details: (inquiry) => [
61
62
  {
62
- label: "caluma.distribution.inquiry.created-at",
63
- value: inquiry.createdAt,
63
+ label: "caluma.distribution.inquiry.sent-at",
64
+ value: inquiry.childCase?.createdAt,
64
65
  type: "date",
65
66
  },
66
67
  {
@@ -68,11 +69,15 @@ export default function config(target, property) {
68
69
  value: inquiry.assignedUsers,
69
70
  type: "user",
70
71
  },
71
- {
72
- label: "caluma.distribution.inquiry.closed-at",
73
- value: inquiry.closedAt,
74
- type: "date",
75
- },
72
+ ...(inquiry.closedAt
73
+ ? [
74
+ {
75
+ label: "caluma.distribution.inquiry.closed-at",
76
+ value: inquiry.closedAt,
77
+ type: "date",
78
+ },
79
+ ]
80
+ : []),
76
81
  ],
77
82
  },
78
83
  },
@@ -4,9 +4,12 @@ mutation CompleteInquiryWorkItem(
4
4
  $workItem: ID!
5
5
  $statusQuestion: ID!
6
6
  $buttonTasks: [String]!
7
- $checkTask: ID!
7
+ $checkTask: String!
8
+ $inquiryTask: ID!
9
+ $createTask: String!
8
10
  $currentGroup: String!
9
11
  $answerInfoQuestions: [ID]!
12
+ $willCompleteInquiry: Boolean = false
10
13
  ) {
11
14
  completeWorkItem(input: { id: $workItem }) {
12
15
  workItem {
@@ -14,22 +17,26 @@ mutation CompleteInquiryWorkItem(
14
17
  status
15
18
  case {
16
19
  id
20
+ status
17
21
  document {
18
22
  id
19
23
  ...InquiryAnswer
20
24
  }
21
25
  ...InquiryAnswerButtons
22
- parentWorkItem {
26
+ # If the work item that will be completed also completes the inquiry
27
+ # itself, we need to fetch certain work items that were completed /
28
+ # canceled in the side effect layer and the inquiry itself
29
+ parentWorkItem @include(if: $willCompleteInquiry) {
23
30
  id
24
31
  status
25
32
  isRedoable
26
- # This is needed to remove the check inquiries button if that work
27
- # item is closed automatically after completing an inquiry.
33
+ closedByUser
34
+ closedAt
28
35
  case {
29
36
  id
30
- workItems(
37
+ controls: workItems(
31
38
  filter: [
32
- { task: $checkTask }
39
+ { tasks: [$checkTask, $createTask] }
33
40
  { addressedGroups: [$currentGroup] }
34
41
  ]
35
42
  ) {
@@ -40,6 +47,19 @@ mutation CompleteInquiryWorkItem(
40
47
  }
41
48
  }
42
49
  }
50
+ inquiries: workItems(
51
+ filter: [
52
+ { task: $inquiryTask }
53
+ { controllingGroups: [$currentGroup] }
54
+ ]
55
+ ) {
56
+ edges {
57
+ node {
58
+ id
59
+ isRedoable
60
+ }
61
+ }
62
+ }
43
63
  }
44
64
  }
45
65
  }
@@ -16,7 +16,6 @@ query InquiryAnswer(
16
16
  controllingGroups
17
17
  assignedUsers
18
18
  closedByUser
19
- createdAt
20
19
  closedAt
21
20
  task {
22
21
  id
@@ -29,10 +28,9 @@ query InquiryAnswer(
29
28
  childCase {
30
29
  id
31
30
  status
31
+ createdAt
32
32
  document {
33
33
  id
34
- modifiedContentAt
35
- modifiedContentByUser
36
34
  }
37
35
  ...InquiryAnswerButtons
38
36
  }
@@ -6,7 +6,6 @@ fragment DialogInquiry on WorkItem {
6
6
  addressedGroups
7
7
  controllingGroups
8
8
  assignedUsers
9
- createdAt
10
9
  closedAt
11
10
  status
12
11
  isRedoable
@@ -21,6 +20,7 @@ fragment DialogInquiry on WorkItem {
21
20
  }
22
21
  childCase {
23
22
  id
23
+ createdAt
24
24
  ...InquiryAnswerButtons
25
25
  document {
26
26
  id
@@ -12,8 +12,6 @@ query InquiryEdit($inquiry: ID!) {
12
12
  }
13
13
  document {
14
14
  id
15
- modifiedContentAt
16
- modifiedContentByUser
17
15
  }
18
16
  }
19
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-distribution",
3
- "version": "11.0.0-beta.31",
3
+ "version": "11.0.0-beta.33",
4
4
  "description": "Ember engine for the Caluma distribution module.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -23,9 +23,9 @@
23
23
  "@embroider/macros": "^1.9.0",
24
24
  "@glimmer/component": "^1.1.2",
25
25
  "@glimmer/tracking": "^1.1.2",
26
- "@projectcaluma/ember-core": "^11.0.0-beta.31",
27
- "@projectcaluma/ember-form": "^11.0.0-beta.31",
28
- "@projectcaluma/ember-workflow": "^11.0.0-beta.31",
26
+ "@projectcaluma/ember-core": "^11.0.0-beta.33",
27
+ "@projectcaluma/ember-form": "^11.0.0-beta.33",
28
+ "@projectcaluma/ember-workflow": "^11.0.0-beta.33",
29
29
  "ember-apollo-client": "~4.0.2",
30
30
  "ember-auto-import": "^2.4.3",
31
31
  "ember-can": "^4.2.0",
@@ -51,7 +51,7 @@
51
51
  "@ember/test-helpers": "2.7.0",
52
52
  "@embroider/test-setup": "1.8.3",
53
53
  "@faker-js/faker": "7.6.0",
54
- "@projectcaluma/ember-testing": "11.0.0-beta.31",
54
+ "@projectcaluma/ember-testing": "11.0.0-beta.33",
55
55
  "broccoli-asset-rev": "3.0.0",
56
56
  "ember-cli": "4.8.0",
57
57
  "ember-cli-code-coverage": "1.0.3",
@@ -35,7 +35,7 @@ caluma:
35
35
  automatisch gespeichert."
36
36
 
37
37
  inquiry:
38
- created-at: "Erstellt am"
38
+ sent-at: "Versendet am"
39
39
  closed-at: "Beantwortet am"
40
40
  deadline: "Frist"
41
41
  assigned-user: "Verantwortliche Person"
@@ -35,7 +35,7 @@ caluma:
35
35
  automatically."
36
36
 
37
37
  inquiry:
38
- created-at: "Created at"
38
+ sent-at: "Sent at"
39
39
  closed-at: "Answered at"
40
40
  deadline: "Deadline"
41
41
  assigned-user: "Assigned user"
@@ -35,7 +35,7 @@ caluma:
35
35
  automatiquement enregistrées."
36
36
 
37
37
  inquiry:
38
- created-at: "Créé le"
38
+ sent-at: "Envoyé le"
39
39
  closed-at: "Répondu le"
40
40
  deadline: "Délai"
41
41
  assigned-user: "Personne responsable"