@projectcaluma/ember-distribution 1.0.0-beta.7 → 11.0.0-beta.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/addon/abilities/distribution.js +19 -0
  3. package/addon/abilities/inquiry.js +20 -0
  4. package/addon/components/cd-document-header.hbs +20 -0
  5. package/addon/components/cd-inquiry-answer-form.hbs +34 -9
  6. package/addon/components/cd-inquiry-answer-form.js +30 -12
  7. package/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs +7 -13
  8. package/addon/components/cd-inquiry-dialog/inquiry-divider.hbs +1 -1
  9. package/addon/components/cd-inquiry-dialog/inquiry-part.hbs +107 -44
  10. package/addon/components/cd-inquiry-dialog/inquiry-part.js +25 -8
  11. package/addon/components/cd-inquiry-dialog/inquiry.hbs +8 -4
  12. package/addon/components/cd-inquiry-dialog.hbs +19 -0
  13. package/addon/components/cd-inquiry-dialog.js +32 -3
  14. package/addon/components/cd-inquiry-edit-form.hbs +36 -17
  15. package/addon/components/cd-inquiry-edit-form.js +2 -2
  16. package/addon/components/cd-inquiry-new-form.hbs +35 -31
  17. package/addon/components/cd-inquiry-new-form.js +17 -45
  18. package/addon/components/cd-navigation/controls.hbs +47 -18
  19. package/addon/components/cd-navigation/controls.js +34 -9
  20. package/addon/components/cd-navigation/item.hbs +14 -11
  21. package/addon/components/cd-navigation/section.hbs +4 -4
  22. package/addon/components/cd-navigation/status-indicator.hbs +10 -15
  23. package/addon/components/cd-navigation.hbs +11 -14
  24. package/addon/components/cd-truncated.hbs +8 -0
  25. package/addon/components/cd-truncated.js +32 -0
  26. package/addon/config.js +12 -8
  27. package/addon/controllers/application.js +3 -0
  28. package/addon/controllers/new.js +1 -1
  29. package/addon/engine.js +9 -1
  30. package/addon/gql/fragments/inquiry.graphql +40 -14
  31. package/addon/gql/mutations/complete-inquiry-work-item.graphql +1 -1
  32. package/addon/gql/mutations/redo-work-item.graphql +8 -0
  33. package/addon/gql/queries/control-work-items.graphql +11 -0
  34. package/addon/gql/queries/inquiry-answer.graphql +17 -12
  35. package/addon/gql/queries/inquiry-dialog.graphql +3 -2
  36. package/addon/gql/queries/inquiry-edit.graphql +2 -0
  37. package/addon/gql/queries/inquiry-navigation.graphql +2 -1
  38. package/addon/services/distribution.js +42 -4
  39. package/addon/templates/application.hbs +17 -6
  40. package/addon/utils/inquiry-answer-status.js +34 -0
  41. package/addon/utils/inquiry-deadline.js +5 -7
  42. package/addon/utils/inquiry-status.js +12 -7
  43. package/app/components/cd-document-header.js +1 -0
  44. package/app/components/{cd-icon-button.js → cd-truncated.js} +1 -1
  45. package/app/styles/@projectcaluma/ember-distribution.scss +3 -2
  46. package/app/styles/_answer-form.scss +4 -0
  47. package/app/styles/_group-list.scss +7 -0
  48. package/app/styles/_inquiry-divider.scss +1 -1
  49. package/app/styles/_truncated.scss +3 -0
  50. package/app/utils/inquiry-answer-status.js +1 -0
  51. package/index.js +1 -6
  52. package/package.json +28 -29
  53. package/translations/de.yaml +30 -8
  54. package/translations/en.yaml +31 -9
  55. package/translations/fr.yaml +31 -9
  56. package/addon/components/cd-icon-button.hbs +0 -27
  57. package/addon/components/cd-icon-button.js +0 -22
  58. package/app/styles/_icon-button.scss +0 -13
  59. package/app/styles/_status-indicator.scss +0 -31
package/CHANGELOG.md CHANGED
@@ -1,3 +1,98 @@
1
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.16](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.15...@projectcaluma/ember-distribution-v1.0.0-beta.16) (2022-08-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * **distribution:** always show confirmation dialog when completing ([507e062](https://github.com/projectcaluma/ember-caluma/commit/507e062afa32e7d4b8d64a2016a4c795a6e632cf))
7
+
8
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.15](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.14...@projectcaluma/ember-distribution-v1.0.0-beta.15) (2022-07-18)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **distribution:** include fetch service dependency ([841c233](https://github.com/projectcaluma/ember-caluma/commit/841c23320f07968a8181bfc9273f592652049516))
14
+ * **distribution:** only show permission info for suspended inquiries ([bd594f8](https://github.com/projectcaluma/ember-caluma/commit/bd594f8ac026af8bf0579dc947862710363ac028))
15
+
16
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.14](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.13...@projectcaluma/ember-distribution-v1.0.0-beta.14) (2022-07-06)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **distribution:** fix title and deadline alignment and icon size ([eb6f495](https://github.com/projectcaluma/ember-caluma/commit/eb6f495408decdf7d735ad2dbc702ee7e4e0ede5))
22
+ * **distribution:** fix title layout with status ([dc49b82](https://github.com/projectcaluma/ember-caluma/commit/dc49b82b3d2f3b9962e9373506e286b4b7ca7225))
23
+ * **distribution:** order answers by configured question order ([668383f](https://github.com/projectcaluma/ember-caluma/commit/668383f5526403187ee66b4ac85cc8ace4ad061a))
24
+
25
+
26
+ ### Features
27
+
28
+ * **distribution:** change needs-interaction status icon to text file ([695c6db](https://github.com/projectcaluma/ember-caluma/commit/695c6db4b7d87af87e334da7aece7e0f4b17129e))
29
+
30
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.13](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.12...@projectcaluma/ember-distribution-v1.0.0-beta.13) (2022-06-09)
31
+
32
+
33
+ ### Features
34
+
35
+ * **caluma:** use new filter syntax of caluma ([7a00c03](https://github.com/projectcaluma/ember-caluma/commit/7a00c03a103933d9e48dd88adb7382441a298742))
36
+
37
+
38
+ ### BREAKING CHANGES
39
+
40
+ * **caluma:** `ember-caluma` now requires Caluma version >=
41
+ 8.0.0-beta.6
42
+
43
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.12](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.11...@projectcaluma/ember-distribution-v1.0.0-beta.12) (2022-06-09)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * **distribution:** fix selection of groups with the checkbox ([9f028dc](https://github.com/projectcaluma/ember-caluma/commit/9f028dc6ec16214249f43e519280397131006e7c))
49
+ * **distribution:** refetch inquiry answer after work-item completion ([60cfaca](https://github.com/projectcaluma/ember-caluma/commit/60cfaca04d94a44efc4950eeb1aecee767b4eeb5))
50
+
51
+
52
+ ### Features
53
+
54
+ * **distribution:** add configurable status for unanswered inquiries ([e08247f](https://github.com/projectcaluma/ember-caluma/commit/e08247f6e2b73f859011f4eac7ffff71f101f546))
55
+
56
+ # [@projectcaluma/ember-distribution-v1.0.0-beta.11](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.10...@projectcaluma/ember-distribution-v1.0.0-beta.11) (2022-05-13)
57
+
58
+
59
+ ### Features
60
+
61
+ * **distribution:** add status for skipped inquiries ([1f93c92](https://github.com/projectcaluma/ember-caluma/commit/1f93c92d76b697954ec54aefa12348c84cd0abf9))
62
+
63
+ # [@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)
64
+
65
+
66
+ ### Features
67
+
68
+ * **distribution:** add readonly mode ([2f45c98](https://github.com/projectcaluma/ember-caluma/commit/2f45c985a2fa387c79ca39c49c1e50dc37926352))
69
+ * **distribution:** allow custom permissions from the host app ([8a997bf](https://github.com/projectcaluma/ember-caluma/commit/8a997bf4d921ff738a6cca956a4dd9cbabe8f7c5))
70
+
71
+ # [@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)
72
+
73
+
74
+ ### Bug Fixes
75
+
76
+ * **deps:** update ember-engines ([5aa5300](https://github.com/projectcaluma/ember-caluma/commit/5aa530074ea7dc08267d8ccc411eb1538537a1b5))
77
+ * **distribution:** filter out empty types in new inquiry controller ([ad7e072](https://github.com/projectcaluma/ember-caluma/commit/ad7e072bd8d339964d1f7f6437bde6b4ff5824b5))
78
+ * **distribution:** hide suspended and canceled inquiries in more section ([a377c0c](https://github.com/projectcaluma/ember-caluma/commit/a377c0c599ab479a61c0f2f7d6051ce79817d998))
79
+ * **distribution:** improve padding of request in answer form ([de06459](https://github.com/projectcaluma/ember-caluma/commit/de06459a75e3fad30a008c738781a29a03640c96))
80
+ * **resources:** fix deprecations of ember-resources ([7a84c5c](https://github.com/projectcaluma/ember-caluma/commit/7a84c5c78d5b28f7b5393c64722907728dd5f42b))
81
+
82
+
83
+ ### Features
84
+
85
+ * **distribution:** add button to create new inquiry in dialog ([a2ab800](https://github.com/projectcaluma/ember-caluma/commit/a2ab800d8d8a9b10be1d22c7a03f34299cb87a93))
86
+ * **distribution:** allow displaying more information in the answer ([9de7f01](https://github.com/projectcaluma/ember-caluma/commit/9de7f0149406a0a326ba59ca0abe27860a64f2a1))
87
+ * **distribution:** improve edit and answer inquiry UI and UX ([6cd2dee](https://github.com/projectcaluma/ember-caluma/commit/6cd2dee45dde245064a0ac013160093bc783789c))
88
+
89
+ # [@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)
90
+
91
+
92
+ ### Bug Fixes
93
+
94
+ * **distribution:** inject store into distribution engine ([2e00d7f](https://github.com/projectcaluma/ember-caluma/commit/2e00d7f0707b7a36e6955d91baa340ce2af7e413))
95
+
1
96
  # [@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)
2
97
 
3
98
 
@@ -1,13 +1,19 @@
1
1
  import { inject as service } from "@ember/service";
2
2
  import { Ability } from "ember-can";
3
3
 
4
+ import config from "@projectcaluma/ember-distribution/config";
5
+
4
6
  const hasStatus = (status) => (edge) => edge.node.status === status;
5
7
 
6
8
  export default class DistributionAbility extends Ability {
7
9
  @service distribution;
8
10
 
11
+ @config config;
12
+
9
13
  get canSendInquiries() {
10
14
  return (
15
+ !this.config.ui.readonly &&
16
+ (this.config.permissions.sendInquiry?.(null) ?? true) &&
11
17
  this.distribution.controls.value?.send.edges.filter(
12
18
  hasStatus("SUSPENDED")
13
19
  ).length > 0
@@ -16,6 +22,8 @@ export default class DistributionAbility extends Ability {
16
22
 
17
23
  get canCreateInquiry() {
18
24
  return (
25
+ !this.config.ui.readonly &&
26
+ (this.config.permissions.createInquiry?.() ?? true) &&
19
27
  this.distribution.controls.value?.create.edges.filter(hasStatus("READY"))
20
28
  .length > 0
21
29
  );
@@ -23,9 +31,20 @@ export default class DistributionAbility extends Ability {
23
31
 
24
32
  get canComplete() {
25
33
  return (
34
+ !this.config.ui.readonly &&
35
+ (this.config.permissions.completeDistribution?.() ?? true) &&
26
36
  this.distribution.controls.value?.complete.edges.filter(
27
37
  hasStatus("READY")
28
38
  ).length > 0
29
39
  );
30
40
  }
41
+
42
+ get canReopen() {
43
+ return (
44
+ !this.config.ui.readonly &&
45
+ (this.config.permissions.reopenDistribution?.() ?? true) &&
46
+ this.distribution.controls.value?.case.edges[0]?.node.parentWorkItem
47
+ .isRedoable
48
+ );
49
+ }
31
50
  }
@@ -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 uk-flex uk-flex-middle">
2
+ <div class="uk-width-expand">
3
+ {{@name}}
4
+ {{#if @status}}
5
+ <UkLabel @label={{@status}} class="uk-margin-left" />
6
+ {{/if}}
7
+ </div>
8
+ {{yield}}
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}}
@@ -4,15 +4,38 @@
4
4
  @loading={{this._inquiry.isRunning}}
5
5
  >
6
6
  <:default as |content|>
7
- <h1 class="uk-flex uk-flex-middle">
8
- {{t "caluma.distribution.answer.title"}}
9
- {{#if (eq this.inquiry.status "RUNNING")}}
10
- <UkLabel
11
- class="uk-margin-left"
12
- @label={{t "caluma.distribution.status.draft"}}
13
- />
14
- {{/if}}
15
- </h1>
7
+
8
+ <CdDocumentHeader
9
+ @name={{content.document.rootForm.raw.name}}
10
+ @status={{if (eq this.inquiry.status "READY") this.answerStatus}}
11
+ @modifiedAt={{this.inquiry.childCase.document.modifiedContentAt}}
12
+ @modifiedBy={{this.inquiry.childCase.document.modifiedContentByUser}}
13
+ >
14
+ <CdInquiryDialog::InquiryDeadline @inquiry={{this.inquiry}} />
15
+ </CdDocumentHeader>
16
+
17
+ <hr />
18
+
19
+ <div class="uk-margin uk-text-italic inquiry-answer-form__request">
20
+ <CdInquiryDialog::InquiryPart
21
+ @inquiry={{this.inquiry}}
22
+ @type="request"
23
+ @disabled={{true}}
24
+ />
25
+ </div>
26
+
27
+ {{#if
28
+ (and
29
+ (not this.buttons.length)
30
+ (can "edit answer form of inquiry" this.inquiry)
31
+ )
32
+ }}
33
+ <div class="uk-alert uk-alert-warning uk-flex uk-flex-middle">
34
+ <UkIcon @icon="warning" class="uk-margin-small-right" />
35
+ {{t "caluma.distribution.answer.complete-not-allowed"}}
36
+ {{t "caluma.distribution.not-allowed-hint"}}
37
+ </div>
38
+ {{/if}}
16
39
 
17
40
  <content.form />
18
41
 
@@ -23,6 +46,7 @@
23
46
  @type="submit"
24
47
  @color={{buttonConfig.color}}
25
48
  @disabled={{or (not isValid) this.completeWorkItem.isRunning}}
49
+ @loading={{this.completeWorkItem.isRunning}}
26
50
  @onClick={{fn
27
51
  (perform this.completeWorkItem)
28
52
  buttonConfig.workItemId
@@ -35,6 +59,7 @@
35
59
  @type="button"
36
60
  @color={{buttonConfig.color}}
37
61
  @disabled={{this.completeWorkItem.isRunning}}
62
+ @loading={{this.completeWorkItem.isRunning}}
38
63
  @onClick={{fn
39
64
  (perform this.completeWorkItem)
40
65
  buttonConfig.workItemId
@@ -1,40 +1,55 @@
1
1
  import { inject as service } from "@ember/service";
2
2
  import Component from "@glimmer/component";
3
- import { queryManager } from "ember-apollo-client";
3
+ import { queryManager, getObservable } 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
+ import inquiryAnswerStatus from "@projectcaluma/ember-distribution/utils/inquiry-answer-status";
11
12
 
12
13
  export default class CdInquiryAnswerFormComponent extends Component {
13
14
  @service intl;
14
15
  @service router;
16
+ @service abilities;
15
17
  @service notification;
16
18
 
17
19
  @config config;
18
20
 
19
21
  @queryManager apollo;
20
22
 
21
- _inquiry = useTask(this, this.fetchInquiryAnswer, () => [this.args.inquiry]);
23
+ @inquiryAnswerStatus({ inquiryProperty: "inquiry" }) answerStatus;
24
+
25
+ _inquiry = trackedTask(this, this.fetchInquiryAnswer, () => [
26
+ this.args.inquiry,
27
+ ]);
22
28
 
23
29
  get inquiry() {
24
30
  return this._inquiry.value?.[0]?.node;
25
31
  }
26
32
 
27
33
  get buttons() {
28
- return this.inquiry?.childCase.workItems.edges.map((edge) => {
29
- const config = this.config.inquiry.answer.buttons[edge.node.task.slug];
34
+ return this.inquiry?.childCase.workItems.edges
35
+ .map((edge) => {
36
+ const config = this.config.inquiry.answer.buttons[edge.node.task.slug];
30
37
 
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
- });
38
+ return this.abilities.can(
39
+ "complete child work item of inquiry",
40
+ this.inquiry,
41
+ { task: edge.node.task.slug }
42
+ )
43
+ ? {
44
+ workItemId: decodeId(edge.node.id),
45
+ color: config.color,
46
+ isFormButton:
47
+ edge.node.task.__typename === "CompleteWorkflowFormTask",
48
+ label: this.intl.t(config.label),
49
+ }
50
+ : null;
51
+ })
52
+ .filter(Boolean);
38
53
  }
39
54
 
40
55
  @dropTask
@@ -45,6 +60,8 @@ export default class CdInquiryAnswerFormComponent extends Component {
45
60
  variables: {
46
61
  inquiry: this.args.inquiry,
47
62
  buttonTasks: Object.keys(this.config.inquiry.answer.buttons),
63
+ infoQuestion: this.config.inquiry.infoQuestion,
64
+ deadlineQuestion: this.config.inquiry.deadlineQuestion,
48
65
  },
49
66
  },
50
67
  "allWorkItems.edges"
@@ -65,6 +82,7 @@ export default class CdInquiryAnswerFormComponent extends Component {
65
82
  },
66
83
  });
67
84
 
85
+ yield getObservable(this._inquiry.value)?.refetch();
68
86
  yield this.router.transitionTo("inquiry.index");
69
87
  } catch (error) {
70
88
  this.notification.danger(
@@ -1,24 +1,18 @@
1
1
  {{#if this.deadline.value}}
2
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
- }}
3
+ class="uk-flex-inline uk-flex-middle
9
4
  {{if
10
5
  this.isWithdrawn
11
6
  'uk-text-muted'
12
7
  (concat 'uk-text-' this.deadline.color)
13
- }}
14
- uk-flex-inline uk-flex-middle"
8
+ }}"
9
+ data-test-deadline
10
+ ...attributes
15
11
  >
16
- {{svg-jar
17
- (if this.isWithdrawn "ban-outline" "alarm-outline")
18
- height=26
19
- width=26
12
+ <UkIcon
13
+ @icon={{if this.isWithdrawn "ban" "clock"}}
20
14
  class="uk-margin-small-right"
21
- }}
15
+ />
22
16
  {{#if this.isWithdrawn}}
23
17
  {{t "caluma.distribution.withdraw.status"}}
24
18
  {{else}}
@@ -3,6 +3,6 @@
3
3
  {{if this.config.ui.small 'inquiry-divider--small' 'uk-margin'}}"
4
4
  >
5
5
  <div class="inquiry-divider__icon uk-flex uk-flex-center uk-flex-middle">
6
- {{svg-jar this.status.icon title=this.status.label}}
6
+ <UkIcon @icon={{this.status.icon}} uk-tooltip={{this.status.label}} />
7
7
  </div>
8
8
  </div>
@@ -1,48 +1,111 @@
1
- <p class="uk-flex uk-flex-middle uk-text-bold uk-margin-remove">
2
- {{#if (eq @type "request")}}
3
- {{svg-jar "arrow-redo-outline" height=24 class="uk-margin-small-right"}}
4
- {{group-name @inquiry.controllingGroups}}
5
- {{else if (eq @type "answer")}}
6
- {{svg-jar "arrow-undo-outline" height=24 class="uk-margin-small-right"}}
7
- {{group-name @inquiry.addressedGroups}}
8
- {{/if}}
9
- </p>
1
+ <div class="uk-margin-remove-last-child">
2
+ <div class="uk-flex uk-flex-middle uk-text-large" data-test-title>
3
+ {{#if (eq @type "request")}}
4
+ <UkIcon @icon="forward" class="uk-margin-small-right" />
5
+ <div class="uk-width-expand uk-margin-small-right">
6
+ {{group-name @inquiry.controllingGroups}}
7
+ {{#if
8
+ (and
9
+ (can "answer inquiry" @inquiry) (not @disabled) this.answerStatus
10
+ )
11
+ }}
12
+ <UkLabel @label={{this.answerStatus}} class="uk-margin-left" />
13
+ {{/if}}
14
+ </div>
15
+ {{else if (eq @type "answer")}}
16
+ <UkIcon @icon="reply" class="uk-margin-small-right" />
17
+ <div class="uk-width-expand">{{group-name @inquiry.addressedGroups}}</div>
18
+ {{/if}}
19
+ {{yield}}
20
+ </div>
10
21
 
11
- <ul
12
- class="uk-subnav uk-subnav-divider
13
- {{if
14
- this.config.ui.small
15
- 'uk-margin-remove-top uk-margin-small-bottom'
16
- 'uk-margin-small-top'
17
- }}"
18
- >
19
- <li>
20
- <span>
21
- {{format-date this.date}}
22
- {{format-time this.date hour="2-digit" minute="2-digit"}}
23
- </span>
24
- </li>
25
- {{#if (can "edit inquiry" @inquiry)}}
26
- <li>
27
- <LinkTo @route="inquiry.detail.index" @model={{decode-id @inquiry.id}}>
28
- {{t "caluma.distribution.edit.link"}}
29
- </LinkTo>
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>
36
- {{/if}}
37
- {{#if (can "answer inquiry" @inquiry)}}
22
+ <ul
23
+ class="uk-subnav uk-subnav-divider
24
+ {{if
25
+ this.config.ui.small
26
+ 'uk-margin-remove-top uk-margin-small-bottom'
27
+ 'uk-margin-small-top'
28
+ }}"
29
+ >
38
30
  <li>
39
- <LinkTo @route="inquiry.detail.answer" @model={{decode-id @inquiry.id}}>
40
- {{t "caluma.distribution.answer.link"}}
41
- </LinkTo>
31
+ <span>
32
+ {{format-date this.date}}
33
+ {{format-time this.date hour="2-digit" minute="2-digit"}}
34
+ </span>
42
35
  </li>
43
- {{/if}}
44
- </ul>
36
+ {{#unless @disabled}}
37
+ {{#if (or (eq @type "answer") (cannot "edit inquiry" @inquiry))}}
38
+ <li>
39
+ <LinkTo
40
+ data-test-details
41
+ @route="inquiry.detail.{{if (eq @type 'answer') 'answer' 'index'}}"
42
+ @model={{decode-id @inquiry.id}}
43
+ >
44
+ {{t "caluma.distribution.details"}}
45
+ </LinkTo>
46
+ </li>
47
+ {{/if}}
48
+ {{#if (can "edit inquiry" @inquiry)}}
49
+ <li>
50
+ <LinkTo
51
+ data-test-edit
52
+ @route="inquiry.detail.index"
53
+ @model={{decode-id @inquiry.id}}
54
+ >
55
+ {{t "caluma.distribution.edit.link"}}
56
+ </LinkTo>
57
+ </li>
58
+ {{#if (can "withdraw inquiry" @inquiry)}}
59
+ <li>
60
+ <a
61
+ href=""
62
+ {{on "click" (perform this.withdraw)}}
63
+ data-test-withdraw
64
+ >
65
+ {{t "caluma.distribution.withdraw.link"}}
66
+ </a>
67
+ </li>
68
+ {{/if}}
69
+ {{else if (can "answer inquiry" @inquiry)}}
70
+ <li>
71
+ <LinkTo
72
+ data-test-answer
73
+ @route="inquiry.detail.answer"
74
+ @model={{decode-id @inquiry.id}}
75
+ >
76
+ {{t "caluma.distribution.answer.link"}}
77
+ </LinkTo>
78
+ </li>
79
+ {{/if}}
80
+ {{/unless}}
81
+ </ul>
45
82
 
46
- {{#if this.info}}
47
- <p class="uk-margin-remove">{{this.info}}</p>
48
- {{/if}}
83
+ {{#if this.requestInfo}}
84
+ <CdTruncated
85
+ data-test-inquiry-request
86
+ @text={{this.requestInfo}}
87
+ @length={{500}}
88
+ />
89
+ {{else if this.answerInfo}}
90
+ {{#each this.answerInfo as |info|}}
91
+ <div class="uk-margin">
92
+ <p
93
+ class="uk-text-bolder
94
+ {{if
95
+ this.config.ui.small
96
+ 'uk-margin-remove'
97
+ 'uk-margin-small-bottom'
98
+ }}"
99
+ >
100
+ {{info.question}}
101
+ </p>
102
+ <CdTruncated
103
+ data-test-inquiry-answer
104
+ class="uk-margin-remove"
105
+ @text={{info.value}}
106
+ @length={{200}}
107
+ />
108
+ </div>
109
+ {{/each}}
110
+ {{/if}}
111
+ </div>
@@ -1,4 +1,5 @@
1
1
  import { inject as service } from "@ember/service";
2
+ import { isEmpty } from "@ember/utils";
2
3
  import Component from "@glimmer/component";
3
4
  import { queryManager } from "ember-apollo-client";
4
5
  import { dropTask } from "ember-concurrency";
@@ -7,6 +8,7 @@ import { confirm } from "ember-uikit";
7
8
  import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
8
9
  import config from "@projectcaluma/ember-distribution/config";
9
10
  import withdrawInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/withdraw-inquiry.graphql";
11
+ import inquiryAnswerStatus from "@projectcaluma/ember-distribution/utils/inquiry-answer-status";
10
12
 
11
13
  export default class CdInquiryDialogInquiryPartComponent extends Component {
12
14
  @service notification;
@@ -17,21 +19,36 @@ export default class CdInquiryDialogInquiryPartComponent extends Component {
17
19
 
18
20
  @config config;
19
21
 
22
+ @inquiryAnswerStatus answerStatus;
23
+
20
24
  get date() {
21
25
  const key = this.args.type === "request" ? "createdAt" : "closedAt";
22
26
 
23
27
  return this.args.inquiry[key];
24
28
  }
25
29
 
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;
30
+ get requestInfo() {
31
+ return this.args.type === "request"
32
+ ? this.args.inquiry.document.info.edges[0]?.node.value
33
+ : null;
34
+ }
35
+
36
+ get answerInfo() {
37
+ const questions = this.config.inquiry.answer.infoQuestions ?? [];
33
38
 
34
- return document.info.edges[0]?.node.value;
39
+ return this.args.type === "answer"
40
+ ? this.args.inquiry.childCase.document.info.edges
41
+ .filter((edge) => !isEmpty(edge.node.value))
42
+ .sort(
43
+ (a, b) =>
44
+ questions.indexOf(a.node.question.slug) -
45
+ questions.indexOf(b.node.question.slug)
46
+ )
47
+ .map((edge) => ({
48
+ question: edge.node.question.label,
49
+ value: edge.node.value,
50
+ }))
51
+ : null;
35
52
  }
36
53
 
37
54
  @dropTask
@@ -3,14 +3,18 @@
3
3
  {{if this.config.ui.small 'uk-card-small'}}"
4
4
  >
5
5
  <div class="uk-card-body">
6
- <CdInquiryDialog::InquiryDeadline @inquiry={{@inquiry}} />
7
-
8
6
  {{#if this.hasAnswer}}
9
- <CdInquiryDialog::InquiryPart @inquiry={{@inquiry}} @type="answer" />
7
+ <CdInquiryDialog::InquiryPart @inquiry={{@inquiry}} @type="answer">
8
+ <CdInquiryDialog::InquiryDeadline @inquiry={{@inquiry}} />
9
+ </CdInquiryDialog::InquiryPart>
10
10
 
11
11
  <CdInquiryDialog::InquiryDivider @inquiry={{@inquiry}} />
12
12
  {{/if}}
13
13
 
14
- <CdInquiryDialog::InquiryPart @inquiry={{@inquiry}} @type="request" />
14
+ <CdInquiryDialog::InquiryPart @inquiry={{@inquiry}} @type="request">
15
+ {{#unless this.hasAnswer}}
16
+ <CdInquiryDialog::InquiryDeadline @inquiry={{@inquiry}} />
17
+ {{/unless}}
18
+ </CdInquiryDialog::InquiryPart>
15
19
  </div>
16
20
  </article>
@@ -1,6 +1,25 @@
1
1
  {{#if this._inquiries.isRunning}}
2
2
  <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
3
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
+ uk-tooltip={{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}}
4
23
  <section>
5
24
  {{#each this.inquiries as |inquiry|}}
6
25
  <CdInquiryDialog::Inquiry @inquiry={{inquiry}} />