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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. package/CHANGELOG.md +110 -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 +20 -0
  5. package/addon/components/cd-icon-button.hbs +27 -0
  6. package/addon/components/{icon-button.js → cd-icon-button.js} +1 -1
  7. package/addon/components/cd-inquiry-answer-form.hbs +78 -0
  8. package/addon/components/{inquiry-answer-form.js → cd-inquiry-answer-form.js} +27 -13
  9. package/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs +29 -0
  10. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +5 -1
  11. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.hbs +2 -1
  12. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.js +1 -1
  13. package/addon/components/cd-inquiry-dialog/inquiry-part.hbs +101 -0
  14. package/addon/components/cd-inquiry-dialog/inquiry-part.js +66 -0
  15. package/addon/components/cd-inquiry-dialog/inquiry.hbs +16 -0
  16. package/addon/components/cd-inquiry-dialog/inquiry.js +11 -0
  17. package/addon/components/cd-inquiry-dialog.hbs +24 -0
  18. package/addon/components/cd-inquiry-dialog.js +93 -0
  19. package/addon/components/cd-inquiry-edit-form.hbs +41 -0
  20. package/addon/components/{inquiry-edit-form.js → cd-inquiry-edit-form.js} +5 -4
  21. package/addon/components/cd-inquiry-new-form.hbs +123 -0
  22. package/addon/components/cd-inquiry-new-form.js +116 -0
  23. package/addon/components/cd-navigation/controls.hbs +32 -0
  24. package/addon/components/cd-navigation/controls.js +95 -0
  25. package/addon/components/cd-navigation/item.hbs +15 -0
  26. package/addon/components/{distribution-navigation → cd-navigation}/item.js +2 -2
  27. package/addon/components/{distribution-navigation → cd-navigation}/section.hbs +9 -7
  28. package/addon/components/{distribution-navigation → cd-navigation}/section.js +1 -1
  29. package/addon/components/{distribution-navigation → cd-navigation}/status-indicator.hbs +2 -1
  30. package/addon/components/{distribution-navigation → cd-navigation}/status-indicator.js +1 -1
  31. package/addon/components/cd-navigation.hbs +14 -0
  32. package/addon/components/cd-navigation.js +53 -0
  33. package/addon/components/cd-notfound.hbs +12 -0
  34. package/addon/components/cd-truncated.hbs +8 -0
  35. package/addon/components/cd-truncated.js +32 -0
  36. package/addon/config.js +3 -1
  37. package/addon/controllers/application.js +10 -0
  38. package/addon/controllers/{distribution/new.js → new.js} +2 -2
  39. package/addon/engine.js +7 -1
  40. package/addon/gql/fragments/inquiry.graphql +21 -12
  41. package/addon/gql/mutations/complete-work-item.graphql +8 -0
  42. package/addon/gql/mutations/withdraw-inquiry.graphql +8 -0
  43. package/addon/gql/queries/control-work-items.graphql +18 -2
  44. package/addon/gql/queries/incomplete-inquiries.graphql +13 -0
  45. package/addon/gql/queries/inquiry-answer.graphql +15 -1
  46. package/addon/gql/queries/inquiry-dialog.graphql +2 -2
  47. package/addon/gql/queries/inquiry-edit.graphql +2 -0
  48. package/addon/gql/queries/inquiry-navigation.graphql +4 -1
  49. package/addon/modifiers/pikaday.js +2 -0
  50. package/addon/routes/{distribution.js → application.js} +1 -1
  51. package/addon/routes/{distribution/index.js → index.js} +2 -2
  52. package/addon/routes/inquiry/detail/answer.js +7 -0
  53. package/addon/routes/inquiry/detail/index.js +7 -0
  54. package/addon/routes/{distribution/inquiry → inquiry}/detail.js +1 -1
  55. package/addon/routes/inquiry/index.js +10 -0
  56. package/addon/routes/{distribution/inquiry.js → inquiry.js} +1 -1
  57. package/addon/routes/new.js +7 -0
  58. package/addon/routes/notfound.js +3 -0
  59. package/addon/routes.js +5 -6
  60. package/addon/services/distribution.js +112 -0
  61. package/addon/templates/application.hbs +18 -0
  62. package/addon/templates/index.hbs +11 -0
  63. package/addon/templates/inquiry/detail/answer.hbs +1 -0
  64. package/addon/templates/inquiry/detail/index.hbs +1 -0
  65. package/addon/templates/{distribution/inquiry → inquiry}/detail.hbs +0 -0
  66. package/addon/templates/{distribution/inquiry → inquiry}/index.hbs +1 -1
  67. package/addon/templates/{distribution/inquiry.hbs → inquiry.hbs} +0 -0
  68. package/addon/templates/{distribution/new.hbs → new.hbs} +1 -1
  69. package/addon/templates/notfound.hbs +1 -0
  70. package/addon/utils/inquiry-deadline.js +4 -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.js → cd-icon-button.js} +1 -1
  75. package/app/components/{inquiry-dialog/inquiry.js → cd-inquiry-answer-form.js} +1 -1
  76. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +1 -1
  77. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.js +1 -1
  78. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-part.js +1 -1
  79. package/app/components/{distribution-navigation.js → cd-inquiry-dialog/inquiry.js} +1 -1
  80. package/app/components/{inquiry-edit-form.js → cd-inquiry-dialog.js} +1 -1
  81. package/app/components/cd-inquiry-edit-form.js +1 -0
  82. package/app/components/{inquiry-answer-form.js → cd-inquiry-new-form.js} +1 -1
  83. package/app/components/cd-navigation/controls.js +1 -0
  84. package/app/components/cd-navigation/item.js +1 -0
  85. package/app/components/cd-navigation/section.js +1 -0
  86. package/app/components/{distribution-navigation/item.js → cd-navigation/status-indicator.js} +1 -1
  87. package/app/components/{inquiry-new-form.js → cd-navigation.js} +1 -1
  88. package/app/components/{icon-button.js → cd-notfound.js} +1 -1
  89. package/app/components/cd-truncated.js +1 -0
  90. package/app/services/distribution.js +1 -0
  91. package/app/styles/@projectcaluma/ember-distribution.scss +2 -0
  92. package/app/styles/_answer-form.scss +4 -0
  93. package/app/styles/_inquiry-divider.scss +22 -0
  94. package/app/styles/_truncated.scss +3 -0
  95. package/index.js +14 -13
  96. package/package.json +31 -26
  97. package/public/assets/distribution.svg +1 -0
  98. package/translations/de.yaml +34 -4
  99. package/translations/en.yaml +35 -4
  100. package/translations/fr.yaml +34 -4
  101. package/addon/components/distribution-navigation/controls.hbs +0 -21
  102. package/addon/components/distribution-navigation/controls.js +0 -45
  103. package/addon/components/distribution-navigation/item.hbs +0 -18
  104. package/addon/components/distribution-navigation.hbs +0 -17
  105. package/addon/components/distribution-navigation.js +0 -81
  106. package/addon/components/icon-button.hbs +0 -20
  107. package/addon/components/inquiry-answer-form.hbs +0 -46
  108. package/addon/components/inquiry-dialog/inquiry-deadline.hbs +0 -6
  109. package/addon/components/inquiry-dialog/inquiry-part.hbs +0 -40
  110. package/addon/components/inquiry-dialog/inquiry-part.js +0 -20
  111. package/addon/components/inquiry-dialog/inquiry.hbs +0 -13
  112. package/addon/components/inquiry-dialog/inquiry.js +0 -7
  113. package/addon/components/inquiry-dialog.hbs +0 -9
  114. package/addon/components/inquiry-dialog.js +0 -42
  115. package/addon/components/inquiry-edit-form.hbs +0 -27
  116. package/addon/components/inquiry-new-form.hbs +0 -110
  117. package/addon/components/inquiry-new-form.js +0 -154
  118. package/addon/routes/distribution/inquiry/detail/answer.js +0 -7
  119. package/addon/routes/distribution/inquiry/detail/index.js +0 -7
  120. package/addon/routes/distribution/inquiry/index.js +0 -10
  121. package/addon/routes/distribution/new.js +0 -7
  122. package/addon/templates/distribution/inquiry/detail/answer.hbs +0 -1
  123. package/addon/templates/distribution/inquiry/detail/index.hbs +0 -1
  124. package/addon/templates/distribution.hbs +0 -8
  125. package/app/components/distribution-navigation/controls.js +0 -1
  126. package/app/components/distribution-navigation/section.js +0 -1
  127. package/app/components/distribution-navigation/status-indicator.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,113 @@
1
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.10](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.9...@projectcaluma/ember-distribution-v1.0.0-beta.10) (2022-05-11)
2
+
3
+
4
+ ### Features
5
+
6
+ * **distribution:** add readonly mode ([2f45c98](https://github.com/projectcaluma/ember-caluma/commit/2f45c985a2fa387c79ca39c49c1e50dc37926352))
7
+ * **distribution:** allow custom permissions from the host app ([8a997bf](https://github.com/projectcaluma/ember-caluma/commit/8a997bf4d921ff738a6cca956a4dd9cbabe8f7c5))
8
+
9
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.9](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.8...@projectcaluma/ember-distribution-v1.0.0-beta.9) (2022-05-09)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * **deps:** update ember-engines ([5aa5300](https://github.com/projectcaluma/ember-caluma/commit/5aa530074ea7dc08267d8ccc411eb1538537a1b5))
15
+ * **distribution:** filter out empty types in new inquiry controller ([ad7e072](https://github.com/projectcaluma/ember-caluma/commit/ad7e072bd8d339964d1f7f6437bde6b4ff5824b5))
16
+ * **distribution:** hide suspended and canceled inquiries in more section ([a377c0c](https://github.com/projectcaluma/ember-caluma/commit/a377c0c599ab479a61c0f2f7d6051ce79817d998))
17
+ * **distribution:** improve padding of request in answer form ([de06459](https://github.com/projectcaluma/ember-caluma/commit/de06459a75e3fad30a008c738781a29a03640c96))
18
+ * **resources:** fix deprecations of ember-resources ([7a84c5c](https://github.com/projectcaluma/ember-caluma/commit/7a84c5c78d5b28f7b5393c64722907728dd5f42b))
19
+
20
+
21
+ ### Features
22
+
23
+ * **distribution:** add button to create new inquiry in dialog ([a2ab800](https://github.com/projectcaluma/ember-caluma/commit/a2ab800d8d8a9b10be1d22c7a03f34299cb87a93))
24
+ * **distribution:** allow displaying more information in the answer ([9de7f01](https://github.com/projectcaluma/ember-caluma/commit/9de7f0149406a0a326ba59ca0abe27860a64f2a1))
25
+ * **distribution:** improve edit and answer inquiry UI and UX ([6cd2dee](https://github.com/projectcaluma/ember-caluma/commit/6cd2dee45dde245064a0ac013160093bc783789c))
26
+
27
+ # [@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)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **distribution:** inject store into distribution engine ([2e00d7f](https://github.com/projectcaluma/ember-caluma/commit/2e00d7f0707b7a36e6955d91baa340ce2af7e413))
33
+
34
+ # [@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)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * **distribution:** fix status indicator and deadline styling for firefox ([358acb1](https://github.com/projectcaluma/ember-caluma/commit/358acb1f8e23b425bd6e223dc5873e516710ef12))
40
+ * **distribution:** make sure distribution components are prefixed ([d7d98ec](https://github.com/projectcaluma/ember-caluma/commit/d7d98ec291f937f384e2521d4d89c363d8e34f02))
41
+
42
+
43
+ ### Features
44
+
45
+ * **distribution:** enable completing the distribution ([beabe61](https://github.com/projectcaluma/ember-caluma/commit/beabe61bd34025c4785c1e1ba60c59babb3eb6ab))
46
+
47
+ # [@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)
48
+
49
+
50
+ ### Bug Fixes
51
+
52
+ * **embroider:** add missing dependency on @ember/string ([3a6e6bb](https://github.com/projectcaluma/ember-caluma/commit/3a6e6bb39a8c1a40a2ae00b3d4ea00606a755e25))
53
+
54
+
55
+ ### Features
56
+
57
+ * **distribution:** add functionality to send all pending inquiries ([d769953](https://github.com/projectcaluma/ember-caluma/commit/d769953d5a0ea196943426c8499ba87b77a42e61))
58
+ * **distribution:** add functionality to withdraw an inquiry ([c278895](https://github.com/projectcaluma/ember-caluma/commit/c2788957c0fb228c167ca9236fda4850717f5817))
59
+
60
+ # [@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)
61
+
62
+
63
+ ### Bug Fixes
64
+
65
+ * **distribution:** fix sorting after group names in navigation ([2299d3b](https://github.com/projectcaluma/ember-caluma/commit/2299d3b0e265204ab6747dbdc6a8b64fc22f247f))
66
+ * **distribution:** redirect to edit form after inquiry creation ([0a2c404](https://github.com/projectcaluma/ember-caluma/commit/0a2c40404fdb1258fb8d51a2809a03b335c7c78a))
67
+
68
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.4](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.3...@projectcaluma/ember-distribution-v1.0.0-beta.4) (2022-02-16)
69
+
70
+
71
+ ### Bug Fixes
72
+
73
+ * **distribution:** show controls if no inquiries exist yet ([5c73b6d](https://github.com/projectcaluma/ember-caluma/commit/5c73b6d0a870fd0e34d96af3fa34095733fe9fd9))
74
+ * **pikaday:** add pikaday modifier reexport in engines ([c13d302](https://github.com/projectcaluma/ember-caluma/commit/c13d3021bb8fe82e1245a60182af01287c507697))
75
+
76
+
77
+ ### Features
78
+
79
+ * **distribution:** add config variable to stack the UI ([2ad285a](https://github.com/projectcaluma/ember-caluma/commit/2ad285a24bf5fb45d15fe237e3f420dd1f1d94f2))
80
+ * **distribution:** add index page when no inquiries exist ([689089c](https://github.com/projectcaluma/ember-caluma/commit/689089c8f28146a33346f382fe69e7ca1b588d97))
81
+ * **distribution:** add proper 404 handling ([73e62e6](https://github.com/projectcaluma/ember-caluma/commit/73e62e671a9425fc549d7057dd653d1dc59883aa))
82
+ * **distribution:** remove distribution top level route ([6f396da](https://github.com/projectcaluma/ember-caluma/commit/6f396daf2881f07cdddaac6c7ca784db2b8777d3))
83
+
84
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.3](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.2...@projectcaluma/ember-distribution-v1.0.0-beta.3) (2022-02-07)
85
+
86
+
87
+ ### Bug Fixes
88
+
89
+ * **deps:** remove moment altogether and update ember-pikday ([b2f7fa2](https://github.com/projectcaluma/ember-caluma/commit/b2f7fa28fa076897addd36e5964c926c671508ff))
90
+ * **distribution:** replace moment with luxon ([80f6b9a](https://github.com/projectcaluma/ember-caluma/commit/80f6b9a984113a5870a1a9ffbcc8e1700cb33190))
91
+
92
+
93
+ ### BREAKING CHANGES
94
+
95
+ * **deps:** The host app now needs to opt-in to use the default
96
+ pikaday styles: https://github.com/adopted-ember-addons/ember-pikaday#styles
97
+
98
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.2](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.1...@projectcaluma/ember-distribution-v1.0.0-beta.2) (2022-02-01)
99
+
100
+
101
+ ### chore
102
+
103
+ * **deps:** update ember-uikit to v5 beta ([6568d39](https://github.com/projectcaluma/ember-caluma/commit/6568d398216d33b44da5b659830ca3c200dd7012))
104
+
105
+
106
+ ### BREAKING CHANGES
107
+
108
+ * **deps:** All `@projectcaluma/ember-*` packages now require
109
+ `ember-uikit` v5+.
110
+
1
111
  # @projectcaluma/ember-distribution-v1.0.0-beta.1 (2022-01-18)
2
112
 
3
113
 
@@ -0,0 +1,41 @@
1
+ import { inject as service } from "@ember/service";
2
+ import { Ability } from "ember-can";
3
+
4
+ import config from "@projectcaluma/ember-distribution/config";
5
+
6
+ const hasStatus = (status) => (edge) => edge.node.status === status;
7
+
8
+ export default class DistributionAbility extends Ability {
9
+ @service distribution;
10
+
11
+ @config config;
12
+
13
+ get canSendInquiries() {
14
+ return (
15
+ !this.config.ui.readonly &&
16
+ (this.config.permissions.sendInquiry?.(null) ?? true) &&
17
+ this.distribution.controls.value?.send.edges.filter(
18
+ hasStatus("SUSPENDED")
19
+ ).length > 0
20
+ );
21
+ }
22
+
23
+ get canCreateInquiry() {
24
+ return (
25
+ !this.config.ui.readonly &&
26
+ (this.config.permissions.createInquiry?.() ?? true) &&
27
+ this.distribution.controls.value?.create.edges.filter(hasStatus("READY"))
28
+ .length > 0
29
+ );
30
+ }
31
+
32
+ get canComplete() {
33
+ return (
34
+ !this.config.ui.readonly &&
35
+ (this.config.permissions.completeDistribution?.() ?? true) &&
36
+ this.distribution.controls.value?.complete.edges.filter(
37
+ hasStatus("READY")
38
+ ).length > 0
39
+ );
40
+ }
41
+ }
@@ -10,6 +10,7 @@ export default class InquiryAbility extends Ability {
10
10
 
11
11
  get canEdit() {
12
12
  return (
13
+ !this.config.ui.readonly &&
13
14
  this.model?.task.slug === this.config.inquiry.task &&
14
15
  this.model?.status === "SUSPENDED" &&
15
16
  this.model?.controllingGroups
@@ -18,8 +19,17 @@ export default class InquiryAbility extends Ability {
18
19
  );
19
20
  }
20
21
 
22
+ get canSend() {
23
+ return this.config.permissions.sendInquiry?.(this.model) ?? true;
24
+ }
25
+
26
+ get canWithdraw() {
27
+ return this.config.permissions.withdrawInquiry?.(this.model) ?? true;
28
+ }
29
+
21
30
  get canAnswer() {
22
31
  return (
32
+ !this.config.ui.readonly &&
23
33
  this.model?.task.slug === this.config.inquiry.task &&
24
34
  this.model?.status === "READY" &&
25
35
  this.model?.addressedGroups
@@ -30,10 +40,20 @@ export default class InquiryAbility extends Ability {
30
40
 
31
41
  get canEditAnswerForm() {
32
42
  return (
43
+ !this.config.ui.readonly &&
33
44
  this.canAnswer &&
34
45
  this.model?.childCase.workItems.edges.some(
35
46
  (edge) => edge.node.task.__typename === "CompleteWorkflowFormTask"
36
47
  )
37
48
  );
38
49
  }
50
+
51
+ get canCompleteChildWorkItem() {
52
+ return (
53
+ this.config.permissions.completeInquiryChildWorkItem?.(
54
+ this.model,
55
+ this.task
56
+ ) ?? true
57
+ );
58
+ }
39
59
  }
@@ -0,0 +1,20 @@
1
+ <p class="uk-text-large uk-margin-remove">
2
+ {{@name}}
3
+ {{#if @isDraft}}
4
+ <UkLabel
5
+ @label={{t "caluma.distribution.status.draft"}}
6
+ class="uk-margin-left"
7
+ />
8
+ {{/if}}
9
+ </p>
10
+
11
+ {{#if (and @modifiedBy @modifiedAt)}}
12
+ <p class="uk-text-meta uk-margin-remove-bottom uk-margin-small-top">
13
+ {{t
14
+ "caluma.distribution.last-modified"
15
+ user=(user-name @modifiedBy)
16
+ date=(format-date @modifiedAt)
17
+ time=(format-time @modifiedAt hour="2-digit" minute="2-digit")
18
+ }}
19
+ </p>
20
+ {{/if}}
@@ -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",
@@ -0,0 +1,78 @@
1
+ <CfContent
2
+ @documentId={{decode-id this.inquiry.childCase.document.id}}
3
+ @disabled={{cannot "edit answer form of inquiry" this.inquiry}}
4
+ @loading={{this._inquiry.isRunning}}
5
+ >
6
+ <:default as |content|>
7
+
8
+ <div class="uk-position-relative">
9
+ <CdDocumentHeader
10
+ @name={{content.document.rootForm.raw.name}}
11
+ @isDraft={{eq this.inquiry.status "READY"}}
12
+ @modifiedAt={{this.inquiry.childCase.document.modifiedContentAt}}
13
+ @modifiedBy={{this.inquiry.childCase.document.modifiedContentByUser}}
14
+ />
15
+
16
+ <CdInquiryDialog::InquiryDeadline
17
+ @inquiry={{this.inquiry}}
18
+ class="uk-margin-remove uk-position-center-right"
19
+ />
20
+ </div>
21
+
22
+ <hr />
23
+
24
+ <div class="uk-margin uk-text-italic inquiry-answer-form__request">
25
+ <CdInquiryDialog::InquiryPart
26
+ @inquiry={{this.inquiry}}
27
+ @type="request"
28
+ @disabled={{true}}
29
+ />
30
+ </div>
31
+
32
+ {{#if
33
+ (and
34
+ (not this.buttons.length)
35
+ (can "edit answer form of inquiry" this.inquiry)
36
+ )
37
+ }}
38
+ <div class="uk-alert uk-alert-warning uk-flex uk-flex-middle">
39
+ <UkIcon @icon="warning" class="uk-margin-small-right" />
40
+ {{t "caluma.distribution.answer.complete-not-allowed"}}
41
+ {{t "caluma.distribution.not-allowed-hint"}}
42
+ </div>
43
+ {{/if}}
44
+
45
+ <content.form />
46
+
47
+ {{#each this.buttons as |buttonConfig|}}
48
+ {{#if buttonConfig.isFormButton}}
49
+ <DocumentValidity @document={{content.document}} as |isValid validate|>
50
+ <UkButton
51
+ @type="submit"
52
+ @color={{buttonConfig.color}}
53
+ @disabled={{or (not isValid) this.completeWorkItem.isRunning}}
54
+ @loading={{this.completeWorkItem.isRunning}}
55
+ @onClick={{fn
56
+ (perform this.completeWorkItem)
57
+ buttonConfig.workItemId
58
+ validate
59
+ }}
60
+ >{{buttonConfig.label}}</UkButton>
61
+ </DocumentValidity>
62
+ {{else}}
63
+ <UkButton
64
+ @type="button"
65
+ @color={{buttonConfig.color}}
66
+ @disabled={{this.completeWorkItem.isRunning}}
67
+ @loading={{this.completeWorkItem.isRunning}}
68
+ @onClick={{fn
69
+ (perform this.completeWorkItem)
70
+ buttonConfig.workItemId
71
+ null
72
+ }}
73
+ >{{buttonConfig.label}}</UkButton>
74
+ {{/if}}
75
+ {{/each}}
76
+ </:default>
77
+ <:notfound><CdNotfound /></:notfound>
78
+ </CfContent>
@@ -2,39 +2,51 @@ 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 { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
8
8
  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
+ @service abilities;
15
16
  @service notification;
16
17
 
17
18
  @config config;
18
19
 
19
20
  @queryManager apollo;
20
21
 
21
- _inquiry = useTask(this, this.fetchInquiryAnswer, () => [this.args.inquiry]);
22
+ _inquiry = trackedTask(this, this.fetchInquiryAnswer, () => [
23
+ this.args.inquiry,
24
+ ]);
22
25
 
23
26
  get inquiry() {
24
27
  return this._inquiry.value?.[0]?.node;
25
28
  }
26
29
 
27
30
  get buttons() {
28
- return this.inquiry?.childCase.workItems.edges.map((edge) => {
29
- const config = this.config.inquiry.answer.buttons[edge.node.task.slug];
31
+ return this.inquiry?.childCase.workItems.edges
32
+ .map((edge) => {
33
+ const config = this.config.inquiry.answer.buttons[edge.node.task.slug];
30
34
 
31
- return {
32
- workItemId: decodeId(edge.node.id),
33
- color: config.color,
34
- isFormButton: edge.node.task.__typename === "CompleteWorkflowFormTask",
35
- label: this.intl.t(config.label),
36
- };
37
- });
35
+ return this.abilities.can(
36
+ "complete child work item of inquiry",
37
+ this.inquiry,
38
+ { task: edge.node.task.slug }
39
+ )
40
+ ? {
41
+ workItemId: decodeId(edge.node.id),
42
+ color: config.color,
43
+ isFormButton:
44
+ edge.node.task.__typename === "CompleteWorkflowFormTask",
45
+ label: this.intl.t(config.label),
46
+ }
47
+ : null;
48
+ })
49
+ .filter(Boolean);
38
50
  }
39
51
 
40
52
  @dropTask
@@ -45,6 +57,8 @@ export default class InquiryAnswerFormComponent extends Component {
45
57
  variables: {
46
58
  inquiry: this.args.inquiry,
47
59
  buttonTasks: Object.keys(this.config.inquiry.answer.buttons),
60
+ infoQuestion: this.config.inquiry.infoQuestion,
61
+ deadlineQuestion: this.config.inquiry.deadlineQuestion,
48
62
  },
49
63
  },
50
64
  "allWorkItems.edges"
@@ -65,7 +79,7 @@ export default class InquiryAnswerFormComponent extends Component {
65
79
  },
66
80
  });
67
81
 
68
- yield this.router.transitionTo("distribution.inquiry.index");
82
+ yield this.router.transitionTo("inquiry.index");
69
83
  } catch (error) {
70
84
  this.notification.danger(
71
85
  this.intl.t("caluma.distribution.answer.complete-error")
@@ -0,0 +1,29 @@
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
+ ...attributes
16
+ >
17
+ {{svg-jar
18
+ (if this.isWithdrawn "ban-outline" "alarm-outline")
19
+ height=26
20
+ width=26
21
+ class="uk-margin-small-right"
22
+ }}
23
+ {{#if this.isWithdrawn}}
24
+ {{t "caluma.distribution.withdraw.status"}}
25
+ {{else}}
26
+ {{format-date this.deadline.value}}
27
+ {{/if}}
28
+ </div>
29
+ {{/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
  }
@@ -1,5 +1,6 @@
1
1
  <div
2
- class="inquiry-divider uk-flex uk-flex-center uk-flex-middle uk-flex-between uk-margin uk-text-{{this.status.color}}"
2
+ class="inquiry-divider uk-flex uk-flex-center uk-flex-middle uk-flex-between uk-text-{{this.status.color}}
3
+ {{if this.config.ui.small 'inquiry-divider--small' 'uk-margin'}}"
3
4
  >
4
5
  <div class="inquiry-divider__icon uk-flex uk-flex-center uk-flex-middle">
5
6
  {{svg-jar this.status.icon title=this.status.label}}
@@ -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;
@@ -0,0 +1,101 @@
1
+ <div class="uk-margin-remove-last-child">
2
+ <p class="uk-flex uk-flex-middle uk-text-large uk-margin-remove">
3
+ {{#if (eq @type "request")}}
4
+ {{svg-jar "arrow-redo-outline" height=24 class="uk-margin-small-right"}}
5
+ {{group-name @inquiry.controllingGroups}}
6
+ {{else if (eq @type "answer")}}
7
+ {{svg-jar "arrow-undo-outline" height=24 class="uk-margin-small-right"}}
8
+ {{group-name @inquiry.addressedGroups}}
9
+ {{/if}}
10
+ </p>
11
+
12
+ <ul
13
+ class="uk-subnav uk-subnav-divider
14
+ {{if
15
+ this.config.ui.small
16
+ 'uk-margin-remove-top uk-margin-small-bottom'
17
+ 'uk-margin-small-top'
18
+ }}"
19
+ >
20
+ <li>
21
+ <span>
22
+ {{format-date this.date}}
23
+ {{format-time this.date hour="2-digit" minute="2-digit"}}
24
+ </span>
25
+ </li>
26
+ {{#unless @disabled}}
27
+ {{#if (or (eq @type "answer") (cannot "edit inquiry" @inquiry))}}
28
+ <li>
29
+ <LinkTo
30
+ data-test-details
31
+ @route="inquiry.detail.{{if (eq @type 'answer') 'answer' 'index'}}"
32
+ @model={{decode-id @inquiry.id}}
33
+ >
34
+ {{t "caluma.distribution.details"}}
35
+ </LinkTo>
36
+ </li>
37
+ {{/if}}
38
+ {{#if (can "edit inquiry" @inquiry)}}
39
+ <li>
40
+ <LinkTo
41
+ data-test-edit
42
+ @route="inquiry.detail.index"
43
+ @model={{decode-id @inquiry.id}}
44
+ >
45
+ {{t "caluma.distribution.edit.link"}}
46
+ </LinkTo>
47
+ </li>
48
+ {{#if (can "withdraw inquiry" @inquiry)}}
49
+ <li>
50
+ <a
51
+ href=""
52
+ {{on "click" (perform this.withdraw)}}
53
+ data-test-withdraw
54
+ >
55
+ {{t "caluma.distribution.withdraw.link"}}
56
+ </a>
57
+ </li>
58
+ {{/if}}
59
+ {{else if (can "answer inquiry" @inquiry)}}
60
+ <li>
61
+ <LinkTo
62
+ data-test-answer
63
+ @route="inquiry.detail.answer"
64
+ @model={{decode-id @inquiry.id}}
65
+ >
66
+ {{t "caluma.distribution.answer.link"}}
67
+ </LinkTo>
68
+ </li>
69
+ {{/if}}
70
+ {{/unless}}
71
+ </ul>
72
+
73
+ {{#if this.requestInfo}}
74
+ <CdTruncated
75
+ data-test-inquiry-request
76
+ @text={{this.requestInfo}}
77
+ @length={{500}}
78
+ />
79
+ {{else if this.answerInfo}}
80
+ {{#each this.answerInfo as |info|}}
81
+ <div class="uk-margin">
82
+ <p
83
+ class="uk-text-bolder
84
+ {{if
85
+ this.config.ui.small
86
+ 'uk-margin-remove'
87
+ 'uk-margin-small-bottom'
88
+ }}"
89
+ >
90
+ {{info.question}}
91
+ </p>
92
+ <CdTruncated
93
+ data-test-inquiry-answer
94
+ class="uk-margin-remove"
95
+ @text={{info.value}}
96
+ @length={{200}}
97
+ />
98
+ </div>
99
+ {{/each}}
100
+ {{/if}}
101
+ </div>
@@ -0,0 +1,66 @@
1
+ import { inject as service } from "@ember/service";
2
+ import { isEmpty } from "@ember/utils";
3
+ import Component from "@glimmer/component";
4
+ import { queryManager } from "ember-apollo-client";
5
+ import { dropTask } from "ember-concurrency";
6
+ import { confirm } from "ember-uikit";
7
+
8
+ import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
9
+ import config from "@projectcaluma/ember-distribution/config";
10
+ import withdrawInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/withdraw-inquiry.graphql";
11
+
12
+ export default class CdInquiryDialogInquiryPartComponent extends Component {
13
+ @service notification;
14
+ @service router;
15
+ @service intl;
16
+
17
+ @queryManager apollo;
18
+
19
+ @config config;
20
+
21
+ get date() {
22
+ const key = this.args.type === "request" ? "createdAt" : "closedAt";
23
+
24
+ return this.args.inquiry[key];
25
+ }
26
+
27
+ get requestInfo() {
28
+ return this.args.type === "request"
29
+ ? this.args.inquiry.document.info.edges[0]?.node.value
30
+ : null;
31
+ }
32
+
33
+ get answerInfo() {
34
+ return this.args.type === "answer"
35
+ ? this.args.inquiry.childCase.document.info.edges
36
+ .filter((edge) => !isEmpty(edge.node.value))
37
+ .map((edge) => ({
38
+ question: edge.node.question.label,
39
+ value: edge.node.value,
40
+ }))
41
+ : null;
42
+ }
43
+
44
+ @dropTask
45
+ *withdraw(e) {
46
+ e.preventDefault();
47
+
48
+ /* istanbul ignore next */
49
+ if (!(yield confirm(this.intl.t("caluma.distribution.withdraw.confirm")))) {
50
+ return;
51
+ }
52
+
53
+ try {
54
+ yield this.apollo.mutate({
55
+ mutation: withdrawInquiryMutation,
56
+ variables: {
57
+ workItem: decodeId(this.args.inquiry.id),
58
+ },
59
+ });
60
+ } catch (error) {
61
+ this.notification.danger(
62
+ this.intl.t("caluma.distribution.withdraw.error")
63
+ );
64
+ }
65
+ }
66
+ }
@@ -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>