@projectcaluma/ember-distribution 1.0.0-beta.1 → 1.0.0-beta.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/addon/abilities/distribution.js +41 -0
  3. package/addon/abilities/inquiry.js +20 -0
  4. package/addon/components/cd-document-header.hbs +17 -0
  5. package/addon/components/cd-inquiry-answer-form.hbs +78 -0
  6. package/addon/components/{inquiry-answer-form.js → cd-inquiry-answer-form.js} +32 -14
  7. package/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs +27 -0
  8. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +5 -1
  9. package/addon/components/cd-inquiry-dialog/inquiry-divider.hbs +8 -0
  10. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.js +1 -1
  11. package/addon/components/cd-inquiry-dialog/inquiry-part.hbs +109 -0
  12. package/addon/components/cd-inquiry-dialog/inquiry-part.js +69 -0
  13. package/addon/components/cd-inquiry-dialog/inquiry.hbs +16 -0
  14. package/addon/components/cd-inquiry-dialog/inquiry.js +11 -0
  15. package/addon/components/cd-inquiry-dialog.hbs +30 -0
  16. package/addon/components/cd-inquiry-dialog.js +94 -0
  17. package/addon/components/cd-inquiry-edit-form.hbs +44 -0
  18. package/addon/components/{inquiry-edit-form.js → cd-inquiry-edit-form.js} +5 -4
  19. package/addon/components/cd-inquiry-new-form.hbs +125 -0
  20. package/addon/components/cd-inquiry-new-form.js +114 -0
  21. package/addon/components/cd-navigation/controls.hbs +41 -0
  22. package/addon/components/cd-navigation/controls.js +95 -0
  23. package/addon/components/cd-navigation/item.hbs +18 -0
  24. package/addon/components/{distribution-navigation → cd-navigation}/item.js +2 -2
  25. package/addon/components/cd-navigation/section.hbs +26 -0
  26. package/addon/components/{distribution-navigation → cd-navigation}/section.js +1 -1
  27. package/addon/components/cd-navigation/status-indicator.hbs +13 -0
  28. package/addon/components/{distribution-navigation → cd-navigation}/status-indicator.js +1 -1
  29. package/addon/components/cd-navigation.hbs +11 -0
  30. package/addon/components/cd-navigation.js +53 -0
  31. package/addon/components/cd-notfound.hbs +12 -0
  32. package/addon/components/cd-truncated.hbs +8 -0
  33. package/addon/components/cd-truncated.js +32 -0
  34. package/addon/config.js +12 -7
  35. package/addon/controllers/application.js +10 -0
  36. package/addon/controllers/{distribution/new.js → new.js} +2 -2
  37. package/addon/engine.js +7 -1
  38. package/addon/gql/fragments/inquiry.graphql +37 -12
  39. package/addon/gql/mutations/complete-work-item.graphql +8 -0
  40. package/addon/gql/mutations/withdraw-inquiry.graphql +8 -0
  41. package/addon/gql/queries/control-work-items.graphql +18 -2
  42. package/addon/gql/queries/incomplete-inquiries.graphql +13 -0
  43. package/addon/gql/queries/inquiry-answer.graphql +17 -12
  44. package/addon/gql/queries/inquiry-dialog.graphql +3 -2
  45. package/addon/gql/queries/inquiry-edit.graphql +2 -0
  46. package/addon/gql/queries/inquiry-navigation.graphql +4 -1
  47. package/addon/modifiers/pikaday.js +2 -0
  48. package/addon/routes/{distribution.js → application.js} +1 -1
  49. package/addon/routes/{distribution/index.js → index.js} +2 -2
  50. package/addon/routes/inquiry/detail/answer.js +7 -0
  51. package/addon/routes/inquiry/detail/index.js +7 -0
  52. package/addon/routes/{distribution/inquiry → inquiry}/detail.js +1 -1
  53. package/addon/routes/inquiry/index.js +10 -0
  54. package/addon/routes/{distribution/inquiry.js → inquiry.js} +1 -1
  55. package/addon/routes/new.js +7 -0
  56. package/addon/routes/notfound.js +3 -0
  57. package/addon/routes.js +5 -6
  58. package/addon/services/distribution.js +112 -0
  59. package/addon/templates/application.hbs +18 -0
  60. package/addon/templates/index.hbs +11 -0
  61. package/addon/templates/inquiry/detail/answer.hbs +1 -0
  62. package/addon/templates/inquiry/detail/index.hbs +1 -0
  63. package/addon/templates/{distribution/inquiry → inquiry}/detail.hbs +0 -0
  64. package/addon/templates/{distribution/inquiry → inquiry}/index.hbs +1 -1
  65. package/addon/templates/{distribution/inquiry.hbs → inquiry.hbs} +0 -0
  66. package/addon/templates/{distribution/new.hbs → new.hbs} +1 -1
  67. package/addon/templates/notfound.hbs +1 -0
  68. package/addon/utils/inquiry-answer-status.js +34 -0
  69. package/addon/utils/inquiry-deadline.js +6 -9
  70. package/addon/utils/inquiry-status.js +12 -7
  71. package/addon/utils/unique-by-groups.js +1 -0
  72. package/app/abilities/distribution.js +1 -0
  73. package/app/components/cd-document-header.js +1 -0
  74. package/app/components/{inquiry-dialog/inquiry.js → cd-inquiry-answer-form.js} +1 -1
  75. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +1 -1
  76. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.js +1 -1
  77. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-part.js +1 -1
  78. package/app/components/{distribution-navigation.js → cd-inquiry-dialog/inquiry.js} +1 -1
  79. package/app/components/{inquiry-edit-form.js → cd-inquiry-dialog.js} +1 -1
  80. package/app/components/cd-inquiry-edit-form.js +1 -0
  81. package/app/components/{inquiry-answer-form.js → cd-inquiry-new-form.js} +1 -1
  82. package/app/components/cd-navigation/controls.js +1 -0
  83. package/app/components/cd-navigation/item.js +1 -0
  84. package/app/components/cd-navigation/section.js +1 -0
  85. package/app/components/{distribution-navigation/item.js → cd-navigation/status-indicator.js} +1 -1
  86. package/app/components/{inquiry-dialog.js → cd-navigation.js} +1 -1
  87. package/app/components/{icon-button.js → cd-notfound.js} +1 -1
  88. package/app/components/{inquiry-new-form.js → cd-truncated.js} +1 -1
  89. package/app/services/distribution.js +1 -0
  90. package/app/styles/@projectcaluma/ember-distribution.scss +3 -2
  91. package/app/styles/_answer-form.scss +4 -0
  92. package/app/styles/_group-list.scss +7 -0
  93. package/app/styles/_inquiry-divider.scss +22 -0
  94. package/app/styles/_truncated.scss +3 -0
  95. package/app/utils/inquiry-answer-status.js +1 -0
  96. package/index.js +10 -14
  97. package/package.json +31 -27
  98. package/public/assets/distribution.svg +1 -0
  99. package/translations/de.yaml +49 -8
  100. package/translations/en.yaml +50 -8
  101. package/translations/fr.yaml +49 -8
  102. package/addon/components/distribution-navigation/controls.hbs +0 -21
  103. package/addon/components/distribution-navigation/controls.js +0 -45
  104. package/addon/components/distribution-navigation/item.hbs +0 -18
  105. package/addon/components/distribution-navigation/section.hbs +0 -24
  106. package/addon/components/distribution-navigation/status-indicator.hbs +0 -17
  107. package/addon/components/distribution-navigation.hbs +0 -17
  108. package/addon/components/distribution-navigation.js +0 -81
  109. package/addon/components/icon-button.hbs +0 -20
  110. package/addon/components/icon-button.js +0 -22
  111. package/addon/components/inquiry-answer-form.hbs +0 -46
  112. package/addon/components/inquiry-dialog/inquiry-deadline.hbs +0 -6
  113. package/addon/components/inquiry-dialog/inquiry-divider.hbs +0 -7
  114. package/addon/components/inquiry-dialog/inquiry-part.hbs +0 -40
  115. package/addon/components/inquiry-dialog/inquiry-part.js +0 -20
  116. package/addon/components/inquiry-dialog/inquiry.hbs +0 -13
  117. package/addon/components/inquiry-dialog/inquiry.js +0 -7
  118. package/addon/components/inquiry-dialog.hbs +0 -9
  119. package/addon/components/inquiry-dialog.js +0 -42
  120. package/addon/components/inquiry-edit-form.hbs +0 -27
  121. package/addon/components/inquiry-new-form.hbs +0 -110
  122. package/addon/components/inquiry-new-form.js +0 -154
  123. package/addon/routes/distribution/inquiry/detail/answer.js +0 -7
  124. package/addon/routes/distribution/inquiry/detail/index.js +0 -7
  125. package/addon/routes/distribution/inquiry/index.js +0 -10
  126. package/addon/routes/distribution/new.js +0 -7
  127. package/addon/templates/distribution/inquiry/detail/answer.hbs +0 -1
  128. package/addon/templates/distribution/inquiry/detail/index.hbs +0 -1
  129. package/addon/templates/distribution.hbs +0 -8
  130. package/app/components/distribution-navigation/controls.js +0 -1
  131. package/app/components/distribution-navigation/section.js +0 -1
  132. package/app/components/distribution-navigation/status-indicator.js +0 -1
  133. package/app/styles/_icon-button.scss +0 -13
  134. package/app/styles/_status-indicator.scss +0 -31
@@ -0,0 +1,11 @@
1
+ import Component from "@glimmer/component";
2
+
3
+ import config from "@projectcaluma/ember-distribution/config";
4
+
5
+ export default class CdInquiryDialogInquiryComponent extends Component {
6
+ @config config;
7
+
8
+ get hasAnswer() {
9
+ return this.args.inquiry.status === "COMPLETED";
10
+ }
11
+ }
@@ -0,0 +1,30 @@
1
+ {{#if this._inquiries.isRunning}}
2
+ <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
3
+ {{else if this.inquiries.length}}
4
+ {{#if
5
+ (and (can "create inquiry of distribution") this.currentGroupIsCreator)
6
+ }}
7
+ <div class="uk-text-center uk-margin">
8
+ <button
9
+ type="button"
10
+ class="uk-icon-button"
11
+ title={{t "caluma.distribution.new.title"}}
12
+ data-test-new-inquiry
13
+ {{on "click" (perform this.createInquiry)}}
14
+ >
15
+ {{#if this.createInquiry.isRunning}}
16
+ <UkSpinner @ratio={{0.6}} />
17
+ {{else}}
18
+ <UkIcon @icon="plus" />
19
+ {{/if}}
20
+ </button>
21
+ </div>
22
+ {{/if}}
23
+ <section>
24
+ {{#each this.inquiries as |inquiry|}}
25
+ <CdInquiryDialog::Inquiry @inquiry={{inquiry}} />
26
+ {{/each}}
27
+ </section>
28
+ {{else}}
29
+ <CdNotfound />
30
+ {{/if}}
@@ -0,0 +1,94 @@
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 { trackedTask } from "ember-resources/util/ember-concurrency";
6
+
7
+ import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
8
+ import config from "@projectcaluma/ember-distribution/config";
9
+ import inquiryDialogQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-dialog.graphql";
10
+
11
+ export default class CdInquiryDialogComponent extends Component {
12
+ @service intl;
13
+ @service router;
14
+ @service distribution;
15
+ @service notification;
16
+ @service calumaOptions;
17
+
18
+ @config config;
19
+
20
+ @queryManager apollo;
21
+
22
+ get currentGroupIsCreator() {
23
+ return String(this.calumaOptions.currentGroupId) === this.args.from;
24
+ }
25
+
26
+ get inquiries() {
27
+ return this._inquiries.value?.allWorkItems.edges.map((edge) => edge.node);
28
+ }
29
+
30
+ _inquiries = trackedTask(this, this.fetchDialog, () => [
31
+ this.args.from,
32
+ this.args.to,
33
+ this.args.caseId,
34
+ this.config,
35
+ ]);
36
+
37
+ @dropTask
38
+ *fetchDialog() {
39
+ const response = yield this.apollo.watchQuery({
40
+ query: inquiryDialogQuery,
41
+ variables: {
42
+ from: this.args.from,
43
+ to: this.args.to,
44
+ caseId: this.args.caseId,
45
+ task: this.config.inquiry.task,
46
+ infoQuestion: this.config.inquiry.infoQuestion,
47
+ deadlineQuestion: this.config.inquiry.deadlineQuestion,
48
+ statusQuestion: this.config.inquiry.answer.statusQuestion,
49
+ answerInfoQuestions: this.config.inquiry.answer.infoQuestions,
50
+ buttonTasks: Object.keys(this.config.inquiry.answer.buttons),
51
+ includeNavigationData: true,
52
+ },
53
+ });
54
+
55
+ /**
56
+ * Sadly this is necessary to handle what happens after the withdraw task in
57
+ * the inquiry part component because the mutation triggers a refresh of the
58
+ * query above in the same runloop instead of the next one. This causes
59
+ * `this.inquiries` to be recomputed which then triggers a rerender of the
60
+ * component and therefore cancels the withdraw task before we can do a
61
+ * transition.
62
+ *
63
+ * TODO: If https://github.com/ember-graphql/ember-apollo-client/pull/421 is
64
+ * merged and released, we can rewrite this into an action that is triggered
65
+ * in the withdraw task of the child component.
66
+ */
67
+ getObservable(response).subscribe(({ data: { allWorkItems } }) => {
68
+ if (allWorkItems.edges.every((edge) => edge.node.status === "CANCELED")) {
69
+ this.router.transitionTo("index");
70
+ }
71
+ });
72
+
73
+ return response;
74
+ }
75
+
76
+ @dropTask
77
+ *createInquiry(e) {
78
+ e.preventDefault();
79
+
80
+ yield this.distribution.createInquiry.perform([this.args.to]);
81
+
82
+ // refetch dialog data
83
+ yield getObservable(this._inquiries.value).refetch();
84
+
85
+ this.router.transitionTo(
86
+ "inquiry.detail.index",
87
+ {
88
+ from: this.args.from,
89
+ to: this.args.to,
90
+ },
91
+ decodeId(this.inquiries[0].id)
92
+ );
93
+ }
94
+ }
@@ -0,0 +1,44 @@
1
+ <CfContent
2
+ @documentId={{decode-id this.inquiry.document.id}}
3
+ @disabled={{cannot "edit inquiry" this.inquiry}}
4
+ @loading={{this._inquiry.isRunning}}
5
+ >
6
+ <:default as |content|>
7
+ <CdDocumentHeader
8
+ @name={{content.document.rootForm.raw.name}}
9
+ @status={{if
10
+ (eq this.inquiry.status "SUSPENDED")
11
+ (t "caluma.distribution.status.draft")
12
+ }}
13
+ @modifiedAt={{this.inquiry.document.modifiedContentAt}}
14
+ @modifiedBy={{this.inquiry.document.modifiedContentByUser}}
15
+ />
16
+
17
+ <hr />
18
+
19
+ {{#if (cannot "send inquiry" this.inquiry)}}
20
+ <div class="uk-alert uk-alert-warning uk-flex uk-flex-middle">
21
+ <UkIcon @icon="warning" class="uk-margin-small-right" />
22
+ {{t "caluma.distribution.edit.send-not-allowed"}}
23
+ {{t "caluma.distribution.not-allowed-hint"}}
24
+ </div>
25
+ {{/if}}
26
+
27
+ <content.form />
28
+
29
+ {{#if
30
+ (and (can "edit inquiry" this.inquiry) (can "send inquiry" this.inquiry))
31
+ }}
32
+ <DocumentValidity @document={{content.document}} as |isValid validate|>
33
+ <UkButton
34
+ @type="submit"
35
+ @color="primary"
36
+ @disabled={{or (not isValid) this.send.isRunning}}
37
+ @onClick={{perform this.send validate}}
38
+ @loading={{this.send.isRunning}}
39
+ >{{t "caluma.distribution.edit.send"}}</UkButton>
40
+ </DocumentValidity>
41
+ {{/if}}
42
+ </:default>
43
+ <:notfound><CdNotfound /></:notfound>
44
+ </CfContent>
@@ -2,21 +2,22 @@ import { inject as service } from "@ember/service";
2
2
  import Component from "@glimmer/component";
3
3
  import { queryManager } from "ember-apollo-client";
4
4
  import { dropTask } from "ember-concurrency";
5
- import { useTask } from "ember-resources";
5
+ import { trackedTask } from "ember-resources/util/ember-concurrency";
6
6
 
7
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
+ @service intl;
14
15
 
15
16
  @config config;
16
17
 
17
18
  @queryManager apollo;
18
19
 
19
- _inquiry = useTask(this, this.fetchInquiry, () => [this.args.inquiry]);
20
+ _inquiry = trackedTask(this, this.fetchInquiry, () => [this.args.inquiry]);
20
21
 
21
22
  get inquiry() {
22
23
  return this._inquiry.value?.[0]?.node;
@@ -43,7 +44,7 @@ export default class InquiryEditFormComponent extends Component {
43
44
  variables: { workItem: this.args.inquiry },
44
45
  });
45
46
 
46
- yield this.router.transitionTo("distribution.inquiry.index");
47
+ yield this.router.transitionTo("inquiry.index");
47
48
  } catch (error) {
48
49
  this.notification.danger(
49
50
  this.intl.t("caluma.distribution.edit.send-error")
@@ -0,0 +1,125 @@
1
+ {{#if this.controls.workItems.isRunning}}
2
+ <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
3
+ {{else if (can "create inquiry of distribution")}}
4
+ <p class="uk-text-large">{{t "caluma.distribution.new.title"}}</p>
5
+
6
+ <hr />
7
+
8
+ {{#if this.selectedGroups.length}}
9
+ <div class="uk-flex uk-flex-middle">
10
+ <div class="uk-width-expand">
11
+ <a href="">
12
+ {{t
13
+ "caluma.distribution.new.groups"
14
+ count=this.selectedGroups.length
15
+ }}
16
+ </a>
17
+ <div uk-dropdown class="uk-width-auto">
18
+ <ul
19
+ class="uk-list uk-list-bullet uk-margin-remove uk-padding-remove"
20
+ data-test-selected-groups
21
+ >
22
+ {{#each this.selectedGroups as |identifier|}}
23
+ <li class="uk-text-nowrap">{{group-name identifier}}</li>
24
+ {{/each}}
25
+ </ul>
26
+ </div>
27
+ {{t
28
+ "caluma.distribution.new.selected"
29
+ count=this.selectedGroups.length
30
+ }}
31
+ </div>
32
+ <div>
33
+ <UkButton
34
+ @label={{t "caluma.distribution.new.reset"}}
35
+ @onClick={{this.clearSelectedGroups}}
36
+ data-test-reset
37
+ />
38
+ <UkButton
39
+ @color="primary"
40
+ @label={{t "caluma.distribution.new.create-draft"}}
41
+ @type="submit"
42
+ @loading={{this.submit.isRunning}}
43
+ @disabled={{this.submit.isRunning}}
44
+ @onClick={{perform this.submit}}
45
+ data-test-submit
46
+ />
47
+ </div>
48
+ </div>
49
+ <hr />
50
+ {{/if}}
51
+
52
+ <div class="uk-margin-bottom uk-button-group">
53
+ {{#each-in this.config.new.types as |slug config|}}
54
+ {{#unless config.disabled}}
55
+ <UkButton
56
+ data-test-type={{slug}}
57
+ @label={{t config.label}}
58
+ @color={{if (includes slug @selectedTypes) "primary" "default"}}
59
+ @onClick={{fn this.updateSelectedTypes slug}}
60
+ />
61
+ {{/unless}}
62
+ {{/each-in}}
63
+ </div>
64
+
65
+ <div class="uk-search uk-search-default uk-width-1-1">
66
+ <span class="uk-search-icon-flip" uk-search-icon></span>
67
+ <input
68
+ placeholder={{t "caluma.distribution.new.search"}}
69
+ aria-label={{t "caluma.distribution.new.search"}}
70
+ class="uk-search-input"
71
+ type="search"
72
+ value={{@search}}
73
+ data-test-search
74
+ {{on "input" (perform this.updateSearch)}}
75
+ />
76
+ </div>
77
+
78
+ {{#if this.groups.isRunning}}
79
+ <div class="uk-text-center uk-margin">
80
+ <UkSpinner @ratio={{2}} />
81
+ </div>
82
+ {{else if this.groups.value.length}}
83
+ <table
84
+ class="uk-table uk-table-striped uk-table-hover uk-table-small uk-table-middle group-list"
85
+ >
86
+ <tbody>
87
+ {{#each this.groups.value as |group|}}
88
+ {{! template-lint-disable require-presentational-children }}
89
+ <tr
90
+ role="checkbox"
91
+ data-test-group={{group.identifier}}
92
+ {{on "click" (fn this.updateSelectedGroups group.identifier)}}
93
+ >
94
+ <td class="uk-padding-remove-right">
95
+ {{! template-lint-disable require-input-label no-nested-interactive }}
96
+ <input
97
+ type="checkbox"
98
+ class="uk-checkbox"
99
+ checked={{includes group.identifier this.selectedGroups}}
100
+ />
101
+ </td>
102
+ <td class="uk-width-expand">{{group-name group.identifier}}</td>
103
+ <td class="uk-text-right">
104
+ {{#if group.config.icon}}
105
+ <UkIcon
106
+ @icon={{group.config.icon}}
107
+ class="uk-display-block uk-text-{{group.config.iconColor}}"
108
+ />
109
+ {{/if}}
110
+ </td>
111
+ </tr>
112
+ {{/each}}
113
+ </tbody>
114
+ </table>
115
+ {{else}}
116
+ <div class="uk-text-center">
117
+ <UkIcon @icon="search" @ratio={{10}} class="uk-margin-top" />
118
+ <p class="uk-text-muted">
119
+ {{t "caluma.distribution.new.empty"}}
120
+ </p>
121
+ </div>
122
+ {{/if}}
123
+ {{else}}
124
+ <CdNotfound />
125
+ {{/if}}
@@ -0,0 +1,114 @@
1
+ import { action } from "@ember/object";
2
+ import { inject as service } from "@ember/service";
3
+ import { macroCondition, isTesting } from "@embroider/macros";
4
+ import Component from "@glimmer/component";
5
+ import { tracked } from "@glimmer/tracking";
6
+ import { queryManager } from "ember-apollo-client";
7
+ import { timeout, restartableTask, dropTask, task } from "ember-concurrency";
8
+ import { trackedTask } from "ember-resources/util/ember-concurrency";
9
+
10
+ import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
11
+ import config from "@projectcaluma/ember-distribution/config";
12
+
13
+ const toggle = (value, array) => {
14
+ const set = new Set(array);
15
+
16
+ set.delete(value) || set.add(value);
17
+
18
+ return [...set];
19
+ };
20
+
21
+ export default class CdInquiryNewFormComponent extends Component {
22
+ @service calumaOptions;
23
+ @service notification;
24
+ @service intl;
25
+ @service router;
26
+ @service distribution;
27
+
28
+ @queryManager apollo;
29
+
30
+ @config config;
31
+
32
+ @tracked selectedGroups = [];
33
+
34
+ groups = trackedTask(this, this.fetchGroups, () => [
35
+ this.args.selectedTypes,
36
+ this.args.search,
37
+ ]);
38
+
39
+ @action
40
+ updateSelectedTypes(type, e) {
41
+ e.preventDefault();
42
+
43
+ this.args.onChangeSelectedTypes(toggle(type, this.args.selectedTypes));
44
+ }
45
+
46
+ @action
47
+ updateSelectedGroups(identifier) {
48
+ this.selectedGroups = toggle(identifier, this.selectedGroups);
49
+ }
50
+
51
+ @action
52
+ clearSelectedGroups(e) {
53
+ e.preventDefault();
54
+
55
+ this.selectedGroups = [];
56
+ }
57
+
58
+ @restartableTask
59
+ *updateSearch(e) {
60
+ e.preventDefault();
61
+
62
+ /* istanbul ignore next */
63
+ if (macroCondition(isTesting())) {
64
+ // no timeout
65
+ } else {
66
+ yield timeout(500);
67
+ }
68
+
69
+ this.args.onChangeSearch(e.target.value);
70
+ }
71
+
72
+ @dropTask
73
+ *submit(e) {
74
+ e.preventDefault();
75
+
76
+ if (!this.selectedGroups.length) return;
77
+
78
+ yield this.distribution.createInquiry.perform(this.selectedGroups);
79
+
80
+ const lastControlling =
81
+ this.distribution.navigation.value.controlling.edges[0].node;
82
+
83
+ // transition to last added inquiry
84
+ this.router.transitionTo(
85
+ "inquiry.detail.index",
86
+ {
87
+ from: lastControlling.controllingGroups[0],
88
+ to: lastControlling.addressedGroups[0],
89
+ },
90
+ decodeId(lastControlling.id)
91
+ );
92
+ }
93
+
94
+ @task
95
+ *fetchGroups(types, search) {
96
+ // https://github.com/ember-cli/eslint-plugin-ember/issues/1413
97
+ yield Promise.resolve();
98
+
99
+ const typedGroups = yield this.calumaOptions.fetchTypedGroups(
100
+ types,
101
+ search
102
+ );
103
+
104
+ return Object.entries(typedGroups)
105
+ .flatMap(([type, groups]) => {
106
+ return groups.map((group) => ({
107
+ identifier: group[this.calumaOptions.groupIdentifierProperty],
108
+ name: group[this.calumaOptions.groupNameProperty],
109
+ config: this.config.new.types[type],
110
+ }));
111
+ })
112
+ .sort((a, b) => a.name.localeCompare(b.name));
113
+ }
114
+ }
@@ -0,0 +1,41 @@
1
+ <div class="uk-text-center uk-margin-small-top">
2
+ {{#if (can "create inquiry of distribution")}}
3
+ <LinkTo
4
+ @route="new"
5
+ class="uk-icon-button"
6
+ title={{t "caluma.distribution.new.title"}}
7
+ >
8
+ <UkIcon @icon="plus" />
9
+ </LinkTo>
10
+ {{/if}}
11
+ {{#if (can "send inquiries of distribution")}}
12
+ <button
13
+ type="button"
14
+ class="uk-icon-button"
15
+ title={{t "caluma.distribution.send"}}
16
+ data-test-send-pending-inquiries
17
+ {{on "click" (perform this.sendInquiries)}}
18
+ >
19
+ {{#if this.sendInquiries.isRunning}}
20
+ <UkSpinner @ratio={{0.6}} />
21
+ {{else}}
22
+ <UkIcon @icon="comment" />
23
+ {{/if}}
24
+ </button>
25
+ {{/if}}
26
+ {{#if (can "complete distribution")}}
27
+ <button
28
+ type="button"
29
+ class="uk-icon-button"
30
+ title={{t "caluma.distribution.complete"}}
31
+ data-test-complete-distribution
32
+ {{on "click" (perform this.completeDistribution)}}
33
+ >
34
+ {{#if this.completeDistribution.isRunning}}
35
+ <UkSpinner @ratio={{0.6}} />
36
+ {{else}}
37
+ <UkIcon @icon="lock" />
38
+ {{/if}}
39
+ </button>
40
+ {{/if}}
41
+ </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.distribution.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
+ }
@@ -0,0 +1,18 @@
1
+ <li class="uk-width-auto {{if this.isActive 'uk-active'}}">
2
+ <LinkTo @route="inquiry" @model={{this.model}}>
3
+ {{#let
4
+ (if
5
+ (eq @type "addressed")
6
+ @inquiry.controllingGroupName
7
+ @inquiry.addressedGroupName
8
+ )
9
+ as |name|
10
+ }}
11
+ <span class="uk-width-expand uk-text-truncate" title={{name}}>
12
+ {{name}}
13
+ </span>
14
+ {{/let}}
15
+
16
+ <CdNavigation::StatusIndicator @inquiry={{@inquiry}} @type={{@type}} />
17
+ </LinkTo>
18
+ </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() {
@@ -12,6 +12,6 @@ export default class DistributionNavigationItemComponent extends Component {
12
12
  }
13
13
 
14
14
  get isActive() {
15
- return this.router.isActive("distribution.inquiry", this.model);
15
+ return this.router.isActive("inquiry", this.model);
16
16
  }
17
17
  }
@@ -0,0 +1,26 @@
1
+ <li class="uk-margin-small-bottom uk-width-auto">
2
+ <a href="" {{on "click" this.toggle}}>
3
+ <span class="uk-width-expand">
4
+ {{t (concat "caluma.distribution.types." @type)}}
5
+ </span>
6
+ {{#if this.expanded}}
7
+ <UkIcon @icon="chevron-down" />
8
+ {{else}}
9
+ <UkIcon @icon="chevron-right" />
10
+ {{/if}}
11
+ </a>
12
+
13
+ {{#if this.expanded}}
14
+ {{#if @inquiries.length}}
15
+ <ul class="uk-tab uk-tab-left uk-margin-left uk-width-auto">
16
+ {{#each this.inquiries as |inquiry|}}
17
+ <CdNavigation::Item @inquiry={{inquiry}} @type={{@type}} />
18
+ {{/each}}
19
+ </ul>
20
+ {{/if}}
21
+
22
+ {{#if (eq @type "controlling")}}
23
+ <CdNavigation::Controls />
24
+ {{/if}}
25
+ {{/if}}
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
@@ -0,0 +1,13 @@
1
+ {{#if this.showDeadlineIndicator}}
2
+ <UkIcon
3
+ @icon="clock"
4
+ class="uk-margin-small-right uk-text-{{this.deadline.color}}"
5
+ title={{format-date this.deadline.value}}
6
+ />
7
+ {{/if}}
8
+
9
+ <UkIcon
10
+ @icon={{this.status.icon}}
11
+ class="uk-text-{{this.status.color}}"
12
+ title={{this.status.label}}
13
+ />