@projectcaluma/ember-distribution 1.0.0-beta.5 → 1.0.0-beta.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/addon/abilities/distribution.js +8 -6
  3. package/addon/components/cd-icon-button.hbs +27 -0
  4. package/addon/components/{icon-button.js → cd-icon-button.js} +1 -1
  5. package/addon/components/{inquiry-answer-form.hbs → cd-inquiry-answer-form.hbs} +1 -1
  6. package/addon/components/{inquiry-answer-form.js → cd-inquiry-answer-form.js} +1 -1
  7. package/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs +28 -0
  8. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +5 -1
  9. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.hbs +0 -0
  10. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.js +1 -1
  11. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-part.hbs +5 -0
  12. package/addon/components/cd-inquiry-dialog/inquiry-part.js +59 -0
  13. package/addon/components/cd-inquiry-dialog/inquiry.hbs +16 -0
  14. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry.js +1 -1
  15. package/addon/components/{inquiry-dialog.hbs → cd-inquiry-dialog.hbs} +2 -2
  16. package/addon/components/cd-inquiry-dialog.js +65 -0
  17. package/addon/components/{inquiry-edit-form.hbs → cd-inquiry-edit-form.hbs} +1 -1
  18. package/addon/components/{inquiry-edit-form.js → cd-inquiry-edit-form.js} +1 -1
  19. package/addon/components/{inquiry-new-form.hbs → cd-inquiry-new-form.hbs} +3 -3
  20. package/addon/components/{inquiry-new-form.js → cd-inquiry-new-form.js} +11 -23
  21. package/addon/components/{distribution-navigation → cd-navigation}/controls.hbs +10 -5
  22. package/addon/components/cd-navigation/controls.js +95 -0
  23. package/addon/components/{distribution-navigation → cd-navigation}/item.hbs +3 -6
  24. package/addon/components/{distribution-navigation → cd-navigation}/item.js +1 -1
  25. package/addon/components/{distribution-navigation → cd-navigation}/section.hbs +2 -2
  26. package/addon/components/{distribution-navigation → cd-navigation}/section.js +1 -1
  27. package/addon/components/{distribution-navigation → cd-navigation}/status-indicator.hbs +2 -1
  28. package/addon/components/{distribution-navigation → cd-navigation}/status-indicator.js +1 -1
  29. package/addon/components/{distribution-navigation.hbs → cd-navigation.hbs} +3 -6
  30. package/addon/components/cd-navigation.js +53 -0
  31. package/addon/components/{notfound.hbs → cd-notfound.hbs} +0 -0
  32. package/addon/engine.js +7 -1
  33. package/addon/gql/mutations/complete-work-item.graphql +8 -0
  34. package/addon/gql/mutations/withdraw-inquiry.graphql +8 -0
  35. package/addon/gql/queries/incomplete-inquiries.graphql +13 -0
  36. package/addon/gql/queries/inquiry-navigation.graphql +2 -0
  37. package/addon/services/distribution.js +82 -0
  38. package/addon/templates/application.hbs +1 -1
  39. package/addon/templates/index.hbs +7 -4
  40. package/addon/templates/inquiry/detail/answer.hbs +1 -1
  41. package/addon/templates/inquiry/detail/index.hbs +1 -1
  42. package/addon/templates/inquiry/index.hbs +1 -1
  43. package/addon/templates/new.hbs +1 -1
  44. package/addon/templates/notfound.hbs +1 -1
  45. package/addon/utils/unique-by-groups.js +1 -0
  46. package/app/components/{inquiry-dialog.js → cd-icon-button.js} +1 -1
  47. package/app/components/{inquiry-dialog/inquiry.js → cd-inquiry-answer-form.js} +1 -1
  48. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +1 -1
  49. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.js +1 -1
  50. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-part.js +1 -1
  51. package/app/components/{distribution-navigation.js → cd-inquiry-dialog/inquiry.js} +1 -1
  52. package/app/components/{inquiry-edit-form.js → cd-inquiry-dialog.js} +1 -1
  53. package/app/components/cd-inquiry-edit-form.js +1 -0
  54. package/app/components/{inquiry-answer-form.js → cd-inquiry-new-form.js} +1 -1
  55. package/app/components/cd-navigation/controls.js +1 -0
  56. package/app/components/{inquiry-new-form.js → cd-navigation/item.js} +1 -1
  57. package/app/components/cd-navigation/section.js +1 -0
  58. package/app/components/{distribution-navigation/item.js → cd-navigation/status-indicator.js} +1 -1
  59. package/app/components/{icon-button.js → cd-navigation.js} +1 -1
  60. package/app/components/{notfound.js → cd-notfound.js} +1 -1
  61. package/app/services/{caluma-distribution-controls.js → distribution.js} +1 -1
  62. package/index.js +14 -13
  63. package/package.json +20 -18
  64. package/public/assets/distribution.svg +1 -0
  65. package/translations/de.yaml +16 -2
  66. package/translations/en.yaml +17 -2
  67. package/translations/fr.yaml +16 -2
  68. package/addon/components/distribution-navigation/controls.js +0 -9
  69. package/addon/components/distribution-navigation.js +0 -86
  70. package/addon/components/icon-button.hbs +0 -20
  71. package/addon/components/inquiry-dialog/inquiry-deadline.hbs +0 -14
  72. package/addon/components/inquiry-dialog/inquiry-part.js +0 -24
  73. package/addon/components/inquiry-dialog/inquiry.hbs +0 -16
  74. package/addon/components/inquiry-dialog.js +0 -42
  75. package/addon/services/caluma-distribution-controls.js +0 -37
  76. package/app/components/distribution-navigation/controls.js +0 -1
  77. package/app/components/distribution-navigation/section.js +0 -1
  78. package/app/components/distribution-navigation/status-indicator.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.8](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.7...@projectcaluma/ember-distribution-v1.0.0-beta.8) (2022-04-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **distribution:** inject store into distribution engine ([2e00d7f](https://github.com/projectcaluma/ember-caluma/commit/2e00d7f0707b7a36e6955d91baa340ce2af7e413))
7
+
8
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.7](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.6...@projectcaluma/ember-distribution-v1.0.0-beta.7) (2022-04-07)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **distribution:** fix status indicator and deadline styling for firefox ([358acb1](https://github.com/projectcaluma/ember-caluma/commit/358acb1f8e23b425bd6e223dc5873e516710ef12))
14
+ * **distribution:** make sure distribution components are prefixed ([d7d98ec](https://github.com/projectcaluma/ember-caluma/commit/d7d98ec291f937f384e2521d4d89c363d8e34f02))
15
+
16
+
17
+ ### Features
18
+
19
+ * **distribution:** enable completing the distribution ([beabe61](https://github.com/projectcaluma/ember-caluma/commit/beabe61bd34025c4785c1e1ba60c59babb3eb6ab))
20
+
21
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.6](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.5...@projectcaluma/ember-distribution-v1.0.0-beta.6) (2022-03-24)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * **embroider:** add missing dependency on @ember/string ([3a6e6bb](https://github.com/projectcaluma/ember-caluma/commit/3a6e6bb39a8c1a40a2ae00b3d4ea00606a755e25))
27
+
28
+
29
+ ### Features
30
+
31
+ * **distribution:** add functionality to send all pending inquiries ([d769953](https://github.com/projectcaluma/ember-caluma/commit/d769953d5a0ea196943426c8499ba87b77a42e61))
32
+ * **distribution:** add functionality to withdraw an inquiry ([c278895](https://github.com/projectcaluma/ember-caluma/commit/c2788957c0fb228c167ca9236fda4850717f5817))
33
+
1
34
  # [@projectcaluma/ember-distribution-v1.0.0-beta.5](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.4...@projectcaluma/ember-distribution-v1.0.0-beta.5) (2022-03-11)
2
35
 
3
36
 
@@ -4,26 +4,28 @@ import { Ability } from "ember-can";
4
4
  const hasStatus = (status) => (edge) => edge.node.status === status;
5
5
 
6
6
  export default class DistributionAbility extends Ability {
7
- @service("caluma-distribution-controls") controls;
7
+ @service distribution;
8
8
 
9
9
  get canSendInquiries() {
10
10
  return (
11
- this.controls.workItems.value?.send.edges.filter(hasStatus("SUSPENDED"))
12
- .length > 0
11
+ this.distribution.controls.value?.send.edges.filter(
12
+ hasStatus("SUSPENDED")
13
+ ).length > 0
13
14
  );
14
15
  }
15
16
 
16
17
  get canCreateInquiry() {
17
18
  return (
18
- this.controls.workItems.value?.create.edges.filter(hasStatus("READY"))
19
+ this.distribution.controls.value?.create.edges.filter(hasStatus("READY"))
19
20
  .length > 0
20
21
  );
21
22
  }
22
23
 
23
24
  get canComplete() {
24
25
  return (
25
- this.controls.workItems.value?.complete.edges.filter(hasStatus("READY"))
26
- .length > 0
26
+ this.distribution.controls.value?.complete.edges.filter(
27
+ hasStatus("READY")
28
+ ).length > 0
27
29
  );
28
30
  }
29
31
  }
@@ -0,0 +1,27 @@
1
+ {{#if @route}}
2
+ <LinkTo @route={{@route}} class={{this.class}} title={{@title}} ...attributes>
3
+ {{#if @loading}}
4
+ <UkSpinner @ratio={{0.6}} />
5
+ {{else if @fromSvgJar}}
6
+ {{svg-jar @icon title=@title width="20" height="20"}}
7
+ {{else}}
8
+ <UkIcon @icon={{@icon}} />
9
+ {{/if}}
10
+ </LinkTo>
11
+ {{else}}
12
+ <button
13
+ type="button"
14
+ class={{this.class}}
15
+ title={{@title}}
16
+ ...attributes
17
+ {{on "click" @onClick}}
18
+ >
19
+ {{#if @loading}}
20
+ <UkSpinner @ratio={{0.6}} />
21
+ {{else if @fromSvgJar}}
22
+ {{svg-jar @icon title=@title width="20" height="20"}}
23
+ {{else}}
24
+ <UkIcon @icon={{@icon}} />
25
+ {{/if}}
26
+ </button>
27
+ {{/if}}
@@ -1,7 +1,7 @@
1
1
  import { dasherize } from "@ember/string";
2
2
  import Component from "@glimmer/component";
3
3
 
4
- export default class IconButtonComponent extends Component {
4
+ export default class CdIconButtonComponent extends Component {
5
5
  get class() {
6
6
  const gutters = [
7
7
  "gutter",
@@ -44,5 +44,5 @@
44
44
  {{/if}}
45
45
  {{/each}}
46
46
  </:default>
47
- <:notfound><Notfound /></:notfound>
47
+ <:notfound><CdNotfound /></:notfound>
48
48
  </CfContent>
@@ -9,7 +9,7 @@ import config from "@projectcaluma/ember-distribution/config";
9
9
  import completeInquiryWorkItemMutation from "@projectcaluma/ember-distribution/gql/mutations/complete-inquiry-work-item.graphql";
10
10
  import inquiryAnswerQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-answer.graphql";
11
11
 
12
- export default class InquiryAnswerFormComponent extends Component {
12
+ export default class CdInquiryAnswerFormComponent extends Component {
13
13
  @service intl;
14
14
  @service router;
15
15
  @service notification;
@@ -0,0 +1,28 @@
1
+ {{#if this.deadline.value}}
2
+ <div
3
+ class="uk-position-top-right
4
+ {{if
5
+ this.config.ui.small
6
+ 'uk-margin-top uk-margin-right'
7
+ 'uk-margin-medium-top uk-margin-medium-right'
8
+ }}
9
+ {{if
10
+ this.isWithdrawn
11
+ 'uk-text-muted'
12
+ (concat 'uk-text-' this.deadline.color)
13
+ }}
14
+ uk-flex-inline uk-flex-middle"
15
+ >
16
+ {{svg-jar
17
+ (if this.isWithdrawn "ban-outline" "alarm-outline")
18
+ height=26
19
+ width=26
20
+ class="uk-margin-small-right"
21
+ }}
22
+ {{#if this.isWithdrawn}}
23
+ {{t "caluma.distribution.withdraw.status"}}
24
+ {{else}}
25
+ {{format-date this.deadline.value}}
26
+ {{/if}}
27
+ </div>
28
+ {{/if}}
@@ -3,8 +3,12 @@ import Component from "@glimmer/component";
3
3
  import config from "@projectcaluma/ember-distribution/config";
4
4
  import inquiryDeadline from "@projectcaluma/ember-distribution/utils/inquiry-deadline";
5
5
 
6
- export default class InquiryDialogInquiryDeadlineComponent extends Component {
6
+ export default class CdInquiryDialogInquiryDeadlineComponent extends Component {
7
7
  @config config;
8
8
 
9
9
  @inquiryDeadline deadline;
10
+
11
+ get isWithdrawn() {
12
+ return this.args.inquiry.status === "CANCELED";
13
+ }
10
14
  }
@@ -4,7 +4,7 @@ import Component from "@glimmer/component";
4
4
  import config from "@projectcaluma/ember-distribution/config";
5
5
  import inquiryStatus from "@projectcaluma/ember-distribution/utils/inquiry-status";
6
6
 
7
- export default class InquiryDialogInquiryDividerComponent extends Component {
7
+ export default class CdInquiryDialogInquiryDividerComponent extends Component {
8
8
  @service intl;
9
9
 
10
10
  @config config;
@@ -28,6 +28,11 @@
28
28
  {{t "caluma.distribution.edit.link"}}
29
29
  </LinkTo>
30
30
  </li>
31
+ <li>
32
+ <a href="" {{on "click" (perform this.withdraw)}} data-test-withdraw>
33
+ {{t "caluma.distribution.withdraw.link"}}
34
+ </a>
35
+ </li>
31
36
  {{/if}}
32
37
  {{#if (can "answer inquiry" @inquiry)}}
33
38
  <li>
@@ -0,0 +1,59 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+ import { queryManager } from "ember-apollo-client";
4
+ import { dropTask } from "ember-concurrency";
5
+ import { confirm } from "ember-uikit";
6
+
7
+ import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
8
+ import config from "@projectcaluma/ember-distribution/config";
9
+ import withdrawInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/withdraw-inquiry.graphql";
10
+
11
+ export default class CdInquiryDialogInquiryPartComponent extends Component {
12
+ @service notification;
13
+ @service router;
14
+ @service intl;
15
+
16
+ @queryManager apollo;
17
+
18
+ @config config;
19
+
20
+ get date() {
21
+ const key = this.args.type === "request" ? "createdAt" : "closedAt";
22
+
23
+ return this.args.inquiry[key];
24
+ }
25
+
26
+ get info() {
27
+ const document =
28
+ this.args.type === "request"
29
+ ? this.args.inquiry.document
30
+ : this.args.type === "answer"
31
+ ? this.args.inquiry.childCase.document
32
+ : null;
33
+
34
+ return document.info.edges[0]?.node.value;
35
+ }
36
+
37
+ @dropTask
38
+ *withdraw(e) {
39
+ e.preventDefault();
40
+
41
+ /* istanbul ignore next */
42
+ if (!(yield confirm(this.intl.t("caluma.distribution.withdraw.confirm")))) {
43
+ return;
44
+ }
45
+
46
+ try {
47
+ yield this.apollo.mutate({
48
+ mutation: withdrawInquiryMutation,
49
+ variables: {
50
+ workItem: decodeId(this.args.inquiry.id),
51
+ },
52
+ });
53
+ } catch (error) {
54
+ this.notification.danger(
55
+ this.intl.t("caluma.distribution.withdraw.error")
56
+ );
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,16 @@
1
+ <article
2
+ class="uk-card uk-card-default uk-margin
3
+ {{if this.config.ui.small 'uk-card-small'}}"
4
+ >
5
+ <div class="uk-card-body">
6
+ <CdInquiryDialog::InquiryDeadline @inquiry={{@inquiry}} />
7
+
8
+ {{#if this.hasAnswer}}
9
+ <CdInquiryDialog::InquiryPart @inquiry={{@inquiry}} @type="answer" />
10
+
11
+ <CdInquiryDialog::InquiryDivider @inquiry={{@inquiry}} />
12
+ {{/if}}
13
+
14
+ <CdInquiryDialog::InquiryPart @inquiry={{@inquiry}} @type="request" />
15
+ </div>
16
+ </article>
@@ -2,7 +2,7 @@ import Component from "@glimmer/component";
2
2
 
3
3
  import config from "@projectcaluma/ember-distribution/config";
4
4
 
5
- export default class InquiryDialogInquiryComponent extends Component {
5
+ export default class CdInquiryDialogInquiryComponent extends Component {
6
6
  @config config;
7
7
 
8
8
  get hasAnswer() {
@@ -3,9 +3,9 @@
3
3
  {{else if this.inquiries.length}}
4
4
  <section>
5
5
  {{#each this.inquiries as |inquiry|}}
6
- <InquiryDialog::Inquiry @inquiry={{inquiry}} />
6
+ <CdInquiryDialog::Inquiry @inquiry={{inquiry}} />
7
7
  {{/each}}
8
8
  </section>
9
9
  {{else}}
10
- <Notfound />
10
+ <CdNotfound />
11
11
  {{/if}}
@@ -0,0 +1,65 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+ import { queryManager, getObservable } from "ember-apollo-client";
4
+ import { dropTask } from "ember-concurrency";
5
+ import { useTask } from "ember-resources";
6
+
7
+ import config from "@projectcaluma/ember-distribution/config";
8
+ import inquiryDialogQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-dialog.graphql";
9
+
10
+ export default class CdInquiryDialogComponent extends Component {
11
+ @service router;
12
+
13
+ @config config;
14
+
15
+ @queryManager apollo;
16
+
17
+ get inquiries() {
18
+ return this._inquiries.value?.allWorkItems.edges.map((edge) => edge.node);
19
+ }
20
+
21
+ _inquiries = useTask(this, this.fetchDialog, () => [
22
+ this.args.from,
23
+ this.args.to,
24
+ this.args.caseId,
25
+ this.config,
26
+ ]);
27
+
28
+ @dropTask
29
+ *fetchDialog() {
30
+ const response = yield this.apollo.watchQuery({
31
+ query: inquiryDialogQuery,
32
+ variables: {
33
+ from: this.args.from,
34
+ to: this.args.to,
35
+ caseId: this.args.caseId,
36
+ task: this.config.inquiry.task,
37
+ infoQuestion: this.config.inquiry.infoQuestion,
38
+ deadlineQuestion: this.config.inquiry.deadlineQuestion,
39
+ statusQuestion: this.config.inquiry.answer.statusQuestion,
40
+ answerInfoQuestion: this.config.inquiry.answer.infoQuestion,
41
+ includeNavigationData: true,
42
+ },
43
+ });
44
+
45
+ /**
46
+ * Sadly this is necessary to handle what happens after the withdraw task in
47
+ * the inquiry part component because the mutation triggers a refresh of the
48
+ * query above in the same runloop instead of the next one. This causes
49
+ * `this.inquiries` to be recomputed which then triggers a rerender of the
50
+ * component and therefore cancels the withdraw task before we can do a
51
+ * transition.
52
+ *
53
+ * TODO: If https://github.com/ember-graphql/ember-apollo-client/pull/421 is
54
+ * merged and released, we can rewrite this into an action that is triggered
55
+ * in the withdraw task of the child component.
56
+ */
57
+ getObservable(response).subscribe(({ data: { allWorkItems } }) => {
58
+ if (allWorkItems.edges.every((edge) => edge.node.status === "CANCELED")) {
59
+ this.router.transitionTo("index");
60
+ }
61
+ });
62
+
63
+ return response;
64
+ }
65
+ }
@@ -25,5 +25,5 @@
25
25
  >{{t "caluma.distribution.edit.send"}}</UkButton>
26
26
  </DocumentValidity>
27
27
  </:default>
28
- <:notfound><Notfound /></:notfound>
28
+ <:notfound><CdNotfound /></:notfound>
29
29
  </CfContent>
@@ -8,7 +8,7 @@ import config from "@projectcaluma/ember-distribution/config";
8
8
  import resumeWorkItemMutation from "@projectcaluma/ember-distribution/gql/mutations/resume-work-item.graphql";
9
9
  import inquiryEditQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-edit.graphql";
10
10
 
11
- export default class InquiryEditFormComponent extends Component {
11
+ export default class CdInquiryEditFormComponent extends Component {
12
12
  @service notification;
13
13
  @service router;
14
14
  @service intl;
@@ -6,12 +6,12 @@
6
6
  {{#if this.selectedGroups.length}}
7
7
  <div class="uk-flex uk-flex-middle">
8
8
  <div class="uk-width-expand">
9
- <button type="button" class="uk-link uk-text-light">
9
+ <a href="">
10
10
  {{t
11
11
  "caluma.distribution.new.groups"
12
12
  count=this.selectedGroups.length
13
13
  }}
14
- </button>
14
+ </a>
15
15
  <div uk-dropdown class="uk-width-auto">
16
16
  <ul
17
17
  class="uk-list uk-list-bullet uk-margin-remove uk-padding-remove"
@@ -117,5 +117,5 @@
117
117
  </div>
118
118
  {{/if}}
119
119
  {{else}}
120
- <Notfound />
120
+ <CdNotfound />
121
121
  {{/if}}
@@ -10,7 +10,6 @@ import { useTask } from "ember-resources";
10
10
  import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
11
11
  import config from "@projectcaluma/ember-distribution/config";
12
12
  import createInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/create-inquiry.graphql";
13
- import inquiryNavigationQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-navigation.graphql";
14
13
 
15
14
  const toggle = (value, array) => {
16
15
  const set = new Set(array);
@@ -20,12 +19,12 @@ const toggle = (value, array) => {
20
19
  return [...set];
21
20
  };
22
21
 
23
- export default class InquiryNewFormComponent extends Component {
22
+ export default class CdInquiryNewFormComponent extends Component {
24
23
  @service calumaOptions;
25
24
  @service notification;
26
25
  @service intl;
27
26
  @service router;
28
- @service("caluma-distribution-controls") controls;
27
+ @service distribution;
29
28
 
30
29
  @queryManager apollo;
31
30
 
@@ -82,7 +81,7 @@ export default class InquiryNewFormComponent extends Component {
82
81
  try {
83
82
  // get create inquiry work item to complete
84
83
  const createId = decodeId(
85
- this.controls.workItems.value?.create.edges[0].node.id
84
+ this.distribution.controls.value?.create.edges[0].node.id
86
85
  );
87
86
 
88
87
  // create new inquiries
@@ -96,31 +95,20 @@ export default class InquiryNewFormComponent extends Component {
96
95
  },
97
96
  });
98
97
 
99
- // refetch navigation data
100
- const navigationData = yield this.apollo.query(
101
- {
102
- query: inquiryNavigationQuery,
103
- fetchPolicy: "network-only",
104
- variables: {
105
- caseId: this.args.caseId,
106
- task: this.config.inquiry.task,
107
- currentGroup: String(this.calumaOptions.currentGroupId),
108
- statusQuestion: this.config.inquiry.answer.statusQuestion,
109
- deadlineQuestion: this.config.inquiry.deadlineQuestion,
110
- includeNavigationData: true,
111
- },
112
- },
113
- "controlling.edges"
114
- );
98
+ // refetch navigation and controls data
99
+ yield this.distribution.refetch();
100
+
101
+ const lastControlling =
102
+ this.distribution.navigation.value.controlling.edges[0].node;
115
103
 
116
104
  // transition to last added inquiry
117
105
  this.router.transitionTo(
118
106
  "inquiry.detail.index",
119
107
  {
120
- from: navigationData[0].node.controllingGroups[0],
121
- to: navigationData[0].node.addressedGroups[0],
108
+ from: lastControlling.controllingGroups[0],
109
+ to: lastControlling.addressedGroups[0],
122
110
  },
123
- decodeId(navigationData[0].node.id)
111
+ decodeId(lastControlling.id)
124
112
  );
125
113
  } catch (e) {
126
114
  this.notification.danger(
@@ -1,23 +1,28 @@
1
1
  <div class="uk-text-center uk-margin-small-top">
2
2
  {{#if (can "create inquiry of distribution")}}
3
- <IconButton @route="new" @icon="plus" />
3
+ <CdIconButton @route="new" @icon="plus" />
4
4
  {{/if}}
5
5
  {{#if (can "send inquiries of distribution")}}
6
- <IconButton
6
+ <CdIconButton
7
+ @title={{t "caluma.distribution.send"}}
7
8
  @icon="paper-plane-outline"
8
9
  @fromSvgJar={{true}}
9
10
  @gutterTop={{4}}
10
11
  @gutterRight={{6}}
11
12
  @gutterLeft={{4}}
12
13
  @gutterBottom={{4}}
13
- @onClick={{this.noop}}
14
+ @onClick={{perform this.sendInquiries}}
15
+ @loading={{this.sendInquiries.isRunning}}
16
+ data-test-send-pending-inquiries
14
17
  />
15
18
  {{/if}}
16
19
  {{#if (can "complete distribution")}}
17
- <IconButton
20
+ <CdIconButton
18
21
  @icon="lock-closed-outline"
19
22
  @fromSvgJar={{true}}
20
- @onClick={{this.noop}}
23
+ @onClick={{perform this.completeDistribution}}
24
+ @loading={{this.completeDistribution.isRunning}}
25
+ data-test-complete-distribution
21
26
  />
22
27
  {{/if}}
23
28
  </div>
@@ -0,0 +1,95 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+ import { queryManager } from "ember-apollo-client";
4
+ import { dropTask } from "ember-concurrency";
5
+ import { confirm } from "ember-uikit";
6
+ import { gql } from "graphql-tag";
7
+
8
+ import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
9
+ import config from "@projectcaluma/ember-distribution/config";
10
+ import completeWorkItemMutation from "@projectcaluma/ember-distribution/gql/mutations/complete-work-item.graphql";
11
+ import incompleteInquiriesQuery from "@projectcaluma/ember-distribution/gql/queries/incomplete-inquiries.graphql";
12
+
13
+ export default class CdNavigationControlsComponent extends Component {
14
+ @service distribution;
15
+ @service intl;
16
+ @service notification;
17
+ @service router;
18
+
19
+ @queryManager apollo;
20
+ @config config;
21
+
22
+ @dropTask
23
+ *completeDistribution() {
24
+ try {
25
+ const incompleteInquiries = yield this.apollo.query(
26
+ {
27
+ query: incompleteInquiriesQuery,
28
+ variables: {
29
+ caseId: this.args.caseId,
30
+ task: this.config.inquiry.task,
31
+ },
32
+ },
33
+ "allWorkItems.totalCount"
34
+ );
35
+
36
+ if (
37
+ incompleteInquiries > 0 &&
38
+ !(yield confirm(
39
+ this.intl.t("caluma.distribution.complete-confirm", {
40
+ count: incompleteInquiries,
41
+ })
42
+ ))
43
+ ) {
44
+ return;
45
+ }
46
+
47
+ const completeDistributionWorkItem =
48
+ this.distribution.controls.value.complete.edges?.[0]?.node.id;
49
+
50
+ yield this.apollo.mutate({
51
+ mutation: completeWorkItemMutation,
52
+ variables: {
53
+ workItem: completeDistributionWorkItem,
54
+ },
55
+ });
56
+
57
+ yield this.distribution.refetch();
58
+ this.router.transitionTo("index");
59
+ } catch (e) {
60
+ this.notification.danger(
61
+ this.intl.t("caluma.distribution.complete-error")
62
+ );
63
+ }
64
+ }
65
+
66
+ @dropTask
67
+ *sendInquiries() {
68
+ if (!(yield confirm(this.intl.t("caluma.distribution.send-confirm")))) {
69
+ return;
70
+ }
71
+
72
+ try {
73
+ const ids = this.distribution.controls.value.send.edges.map((edge) =>
74
+ decodeId(edge.node.id)
75
+ );
76
+
77
+ const mutations = ids.map(
78
+ (id, index) => `
79
+ sendInquiry${index}: resumeWorkItem(input: { id: "${id}" }) {
80
+ workItem {
81
+ id
82
+ status
83
+ }
84
+ }
85
+ `
86
+ );
87
+
88
+ const mutation = gql`mutation SendInquiries {${mutations.join("\n")}}`;
89
+
90
+ yield this.apollo.mutate({ mutation });
91
+ } catch (e) {
92
+ this.notification.danger(this.intl.t("caluma.distribution.send-error"));
93
+ }
94
+ }
95
+ }
@@ -3,16 +3,13 @@
3
3
  <div class="uk-flex uk-flex-middle uk-width-1-1">
4
4
  <div class="uk-width-expand uk-text-truncate">
5
5
  {{#if (eq @type "addressed")}}
6
- {{group-name @inquiry.controllingGroups}}
6
+ {{@inquiry.controllingGroupName}}
7
7
  {{else}}
8
- {{group-name @inquiry.addressedGroups}}
8
+ {{@inquiry.addressedGroupName}}
9
9
  {{/if}}
10
10
  </div>
11
11
 
12
- <DistributionNavigation::StatusIndicator
13
- @inquiry={{@inquiry}}
14
- @type={{@type}}
15
- />
12
+ <CdNavigation::StatusIndicator @inquiry={{@inquiry}} @type={{@type}} />
16
13
  </div>
17
14
  </LinkTo>
18
15
  </li>
@@ -1,7 +1,7 @@
1
1
  import { inject as service } from "@ember/service";
2
2
  import Component from "@glimmer/component";
3
3
 
4
- export default class DistributionNavigationItemComponent extends Component {
4
+ export default class CdNavigationItemComponent extends Component {
5
5
  @service router;
6
6
 
7
7
  get model() {
@@ -14,13 +14,13 @@
14
14
  {{#if @inquiries.length}}
15
15
  <ul class="uk-tab uk-tab-left uk-margin-left">
16
16
  {{#each this.inquiries as |inquiry|}}
17
- <DistributionNavigation::Item @inquiry={{inquiry}} @type={{@type}} />
17
+ <CdNavigation::Item @inquiry={{inquiry}} @type={{@type}} />
18
18
  {{/each}}
19
19
  </ul>
20
20
  {{/if}}
21
21
 
22
22
  {{#if (eq @type "controlling")}}
23
- <DistributionNavigation::Controls @caseId={{@caseId}} />
23
+ <CdNavigation::Controls @caseId={{@caseId}} />
24
24
  {{/if}}
25
25
  {{/if}}
26
26
  </li>
@@ -2,7 +2,7 @@ import { action } from "@ember/object";
2
2
  import Component from "@glimmer/component";
3
3
  import { tracked } from "@glimmer/tracking";
4
4
 
5
- export default class DistributionNavigationSectionComponent extends Component {
5
+ export default class CdNavigationSectionComponent extends Component {
6
6
  @tracked expanded = true;
7
7
 
8
8
  @action