@projectcaluma/ember-distribution 1.0.0-beta.6 → 1.0.0-beta.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/addon/components/cd-document-header.hbs +20 -0
  3. package/addon/components/{icon-button.hbs → cd-icon-button.hbs} +0 -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} +27 -10
  6. package/addon/components/{inquiry-answer-form.js → cd-inquiry-answer-form.js} +7 -3
  7. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.hbs +2 -0
  8. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +1 -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/cd-inquiry-dialog/inquiry-part.hbs +95 -0
  12. package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-part.js +16 -9
  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/cd-inquiry-dialog.hbs +24 -0
  16. package/addon/components/{inquiry-dialog.js → cd-inquiry-dialog.js} +32 -4
  17. package/addon/components/cd-inquiry-edit-form.hbs +31 -0
  18. package/addon/components/{inquiry-edit-form.js → cd-inquiry-edit-form.js} +3 -3
  19. package/addon/components/{inquiry-new-form.hbs → cd-inquiry-new-form.hbs} +4 -2
  20. package/addon/components/{inquiry-new-form.js → cd-inquiry-new-form.js} +17 -43
  21. package/addon/components/{distribution-navigation → cd-navigation}/controls.hbs +10 -4
  22. package/addon/components/cd-navigation/controls.js +95 -0
  23. package/addon/components/{distribution-navigation → cd-navigation}/item.hbs +1 -4
  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/{distribution-navigation.js → cd-navigation.js} +1 -1
  31. package/addon/components/{notfound.hbs → cd-notfound.hbs} +0 -0
  32. package/addon/components/cd-truncated.hbs +8 -0
  33. package/addon/components/cd-truncated.js +32 -0
  34. package/addon/config.js +1 -1
  35. package/addon/controllers/application.js +3 -0
  36. package/addon/controllers/new.js +1 -1
  37. package/addon/engine.js +7 -1
  38. package/addon/gql/fragments/inquiry.graphql +21 -12
  39. package/addon/gql/mutations/complete-work-item.graphql +8 -0
  40. package/addon/gql/queries/incomplete-inquiries.graphql +13 -0
  41. package/addon/gql/queries/inquiry-answer.graphql +15 -1
  42. package/addon/gql/queries/inquiry-dialog.graphql +2 -2
  43. package/addon/gql/queries/inquiry-edit.graphql +2 -0
  44. package/addon/gql/queries/inquiry-navigation.graphql +2 -1
  45. package/addon/services/distribution.js +33 -3
  46. package/addon/templates/application.hbs +16 -6
  47. package/addon/templates/inquiry/detail/answer.hbs +1 -1
  48. package/addon/templates/inquiry/detail/index.hbs +1 -1
  49. package/addon/templates/inquiry/index.hbs +1 -1
  50. package/addon/templates/new.hbs +1 -1
  51. package/addon/templates/notfound.hbs +1 -1
  52. package/addon/utils/inquiry-deadline.js +3 -5
  53. package/app/components/cd-document-header.js +1 -0
  54. package/app/components/{inquiry-dialog.js → cd-icon-button.js} +1 -1
  55. package/app/components/{inquiry-dialog/inquiry.js → cd-inquiry-answer-form.js} +1 -1
  56. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +1 -1
  57. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.js +1 -1
  58. package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-part.js +1 -1
  59. package/app/components/{distribution-navigation.js → cd-inquiry-dialog/inquiry.js} +1 -1
  60. package/app/components/{inquiry-edit-form.js → cd-inquiry-dialog.js} +1 -1
  61. package/app/components/cd-inquiry-edit-form.js +1 -0
  62. package/app/components/{inquiry-answer-form.js → cd-inquiry-new-form.js} +1 -1
  63. package/app/components/cd-navigation/controls.js +1 -0
  64. package/app/components/cd-navigation/item.js +1 -0
  65. package/app/components/cd-navigation/section.js +1 -0
  66. package/app/components/{distribution-navigation/item.js → cd-navigation/status-indicator.js} +1 -1
  67. package/app/components/{inquiry-new-form.js → cd-navigation.js} +1 -1
  68. package/app/components/{notfound.js → cd-notfound.js} +1 -1
  69. package/app/components/{icon-button.js → cd-truncated.js} +1 -1
  70. package/app/styles/@projectcaluma/ember-distribution.scss +2 -0
  71. package/app/styles/_answer-form.scss +4 -0
  72. package/app/styles/_truncated.scss +3 -0
  73. package/package.json +24 -24
  74. package/translations/de.yaml +11 -4
  75. package/translations/en.yaml +12 -4
  76. package/translations/fr.yaml +11 -4
  77. package/addon/components/distribution-navigation/controls.js +0 -51
  78. package/addon/components/inquiry-dialog/inquiry-part.hbs +0 -48
  79. package/addon/components/inquiry-dialog/inquiry.hbs +0 -16
  80. package/addon/components/inquiry-dialog.hbs +0 -11
  81. package/addon/components/inquiry-edit-form.hbs +0 -29
  82. package/app/components/distribution-navigation/controls.js +0 -1
  83. package/app/components/distribution-navigation/section.js +0 -1
  84. package/app/components/distribution-navigation/status-indicator.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,41 @@
1
+ # [@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)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update ember-engines ([5aa5300](https://github.com/projectcaluma/ember-caluma/commit/5aa530074ea7dc08267d8ccc411eb1538537a1b5))
7
+ * **distribution:** filter out empty types in new inquiry controller ([ad7e072](https://github.com/projectcaluma/ember-caluma/commit/ad7e072bd8d339964d1f7f6437bde6b4ff5824b5))
8
+ * **distribution:** hide suspended and canceled inquiries in more section ([a377c0c](https://github.com/projectcaluma/ember-caluma/commit/a377c0c599ab479a61c0f2f7d6051ce79817d998))
9
+ * **distribution:** improve padding of request in answer form ([de06459](https://github.com/projectcaluma/ember-caluma/commit/de06459a75e3fad30a008c738781a29a03640c96))
10
+ * **resources:** fix deprecations of ember-resources ([7a84c5c](https://github.com/projectcaluma/ember-caluma/commit/7a84c5c78d5b28f7b5393c64722907728dd5f42b))
11
+
12
+
13
+ ### Features
14
+
15
+ * **distribution:** add button to create new inquiry in dialog ([a2ab800](https://github.com/projectcaluma/ember-caluma/commit/a2ab800d8d8a9b10be1d22c7a03f34299cb87a93))
16
+ * **distribution:** allow displaying more information in the answer ([9de7f01](https://github.com/projectcaluma/ember-caluma/commit/9de7f0149406a0a326ba59ca0abe27860a64f2a1))
17
+ * **distribution:** improve edit and answer inquiry UI and UX ([6cd2dee](https://github.com/projectcaluma/ember-caluma/commit/6cd2dee45dde245064a0ac013160093bc783789c))
18
+
19
+ # [@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)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **distribution:** inject store into distribution engine ([2e00d7f](https://github.com/projectcaluma/ember-caluma/commit/2e00d7f0707b7a36e6955d91baa340ce2af7e413))
25
+
26
+ # [@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)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * **distribution:** fix status indicator and deadline styling for firefox ([358acb1](https://github.com/projectcaluma/ember-caluma/commit/358acb1f8e23b425bd6e223dc5873e516710ef12))
32
+ * **distribution:** make sure distribution components are prefixed ([d7d98ec](https://github.com/projectcaluma/ember-caluma/commit/d7d98ec291f937f384e2521d4d89c363d8e34f02))
33
+
34
+
35
+ ### Features
36
+
37
+ * **distribution:** enable completing the distribution ([beabe61](https://github.com/projectcaluma/ember-caluma/commit/beabe61bd34025c4785c1e1ba60c59babb3eb6ab))
38
+
1
39
  # [@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)
2
40
 
3
41
 
@@ -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}}
@@ -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",
@@ -4,15 +4,30 @@
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
+ <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>
16
31
 
17
32
  <content.form />
18
33
 
@@ -23,6 +38,7 @@
23
38
  @type="submit"
24
39
  @color={{buttonConfig.color}}
25
40
  @disabled={{or (not isValid) this.completeWorkItem.isRunning}}
41
+ @loading={{this.completeWorkItem.isRunning}}
26
42
  @onClick={{fn
27
43
  (perform this.completeWorkItem)
28
44
  buttonConfig.workItemId
@@ -35,6 +51,7 @@
35
51
  @type="button"
36
52
  @color={{buttonConfig.color}}
37
53
  @disabled={{this.completeWorkItem.isRunning}}
54
+ @loading={{this.completeWorkItem.isRunning}}
38
55
  @onClick={{fn
39
56
  (perform this.completeWorkItem)
40
57
  buttonConfig.workItemId
@@ -44,5 +61,5 @@
44
61
  {{/if}}
45
62
  {{/each}}
46
63
  </:default>
47
- <:notfound><Notfound /></:notfound>
64
+ <:notfound><CdNotfound /></:notfound>
48
65
  </CfContent>
@@ -2,14 +2,14 @@ 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
15
  @service notification;
@@ -18,7 +18,9 @@ export default class InquiryAnswerFormComponent extends Component {
18
18
 
19
19
  @queryManager apollo;
20
20
 
21
- _inquiry = useTask(this, this.fetchInquiryAnswer, () => [this.args.inquiry]);
21
+ _inquiry = trackedTask(this, this.fetchInquiryAnswer, () => [
22
+ this.args.inquiry,
23
+ ]);
22
24
 
23
25
  get inquiry() {
24
26
  return this._inquiry.value?.[0]?.node;
@@ -45,6 +47,8 @@ export default class InquiryAnswerFormComponent extends Component {
45
47
  variables: {
46
48
  inquiry: this.args.inquiry,
47
49
  buttonTasks: Object.keys(this.config.inquiry.answer.buttons),
50
+ infoQuestion: this.config.inquiry.infoQuestion,
51
+ deadlineQuestion: this.config.inquiry.deadlineQuestion,
48
52
  },
49
53
  },
50
54
  "allWorkItems.edges"
@@ -12,10 +12,12 @@
12
12
  (concat 'uk-text-' this.deadline.color)
13
13
  }}
14
14
  uk-flex-inline uk-flex-middle"
15
+ ...attributes
15
16
  >
16
17
  {{svg-jar
17
18
  (if this.isWithdrawn "ban-outline" "alarm-outline")
18
19
  height=26
20
+ width=26
19
21
  class="uk-margin-small-right"
20
22
  }}
21
23
  {{#if this.isWithdrawn}}
@@ -3,7 +3,7 @@ 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;
@@ -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,95 @@
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
+ <li>
49
+ <a href="" {{on "click" (perform this.withdraw)}} data-test-withdraw>
50
+ {{t "caluma.distribution.withdraw.link"}}
51
+ </a>
52
+ </li>
53
+ {{else if (can "answer inquiry" @inquiry)}}
54
+ <li>
55
+ <LinkTo
56
+ data-test-answer
57
+ @route="inquiry.detail.answer"
58
+ @model={{decode-id @inquiry.id}}
59
+ >
60
+ {{t "caluma.distribution.answer.link"}}
61
+ </LinkTo>
62
+ </li>
63
+ {{/if}}
64
+ {{/unless}}
65
+ </ul>
66
+
67
+ {{#if this.requestInfo}}
68
+ <CdTruncated
69
+ data-test-inquiry-request
70
+ @text={{this.requestInfo}}
71
+ @length={{500}}
72
+ />
73
+ {{else if this.answerInfo}}
74
+ {{#each this.answerInfo as |info|}}
75
+ <div class="uk-margin">
76
+ <p
77
+ class="uk-text-bolder
78
+ {{if
79
+ this.config.ui.small
80
+ 'uk-margin-remove'
81
+ 'uk-margin-small-bottom'
82
+ }}"
83
+ >
84
+ {{info.question}}
85
+ </p>
86
+ <CdTruncated
87
+ data-test-inquiry-answer
88
+ class="uk-margin-remove"
89
+ @text={{info.value}}
90
+ @length={{200}}
91
+ />
92
+ </div>
93
+ {{/each}}
94
+ {{/if}}
95
+ </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";
@@ -8,7 +9,7 @@ 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";
10
11
 
11
- export default class InquiryDialogInquiryPartComponent extends Component {
12
+ export default class CdInquiryDialogInquiryPartComponent extends Component {
12
13
  @service notification;
13
14
  @service router;
14
15
  @service intl;
@@ -23,15 +24,21 @@ export default class InquiryDialogInquiryPartComponent extends Component {
23
24
  return this.args.inquiry[key];
24
25
  }
25
26
 
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;
27
+ get requestInfo() {
28
+ return this.args.type === "request"
29
+ ? this.args.inquiry.document.info.edges[0]?.node.value
30
+ : null;
31
+ }
33
32
 
34
- return document.info.edges[0]?.node.value;
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;
35
42
  }
36
43
 
37
44
  @dropTask
@@ -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() {
@@ -0,0 +1,24 @@
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
+ <CdIconButton
9
+ @title={{t "caluma.distribution.new.title"}}
10
+ @icon="plus"
11
+ @loading={{this.createInquiry.isRunning}}
12
+ @onClick={{perform this.createInquiry}}
13
+ data-test-new-inquiry
14
+ />
15
+ </div>
16
+ {{/if}}
17
+ <section>
18
+ {{#each this.inquiries as |inquiry|}}
19
+ <CdInquiryDialog::Inquiry @inquiry={{inquiry}} />
20
+ {{/each}}
21
+ </section>
22
+ {{else}}
23
+ <CdNotfound />
24
+ {{/if}}
@@ -2,23 +2,32 @@ import { inject as service } from "@ember/service";
2
2
  import Component from "@glimmer/component";
3
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
+ import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
7
8
  import config from "@projectcaluma/ember-distribution/config";
8
9
  import inquiryDialogQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-dialog.graphql";
9
10
 
10
- export default class InquiryDialogComponent extends Component {
11
+ export default class CdInquiryDialogComponent extends Component {
12
+ @service intl;
11
13
  @service router;
14
+ @service distribution;
15
+ @service notification;
16
+ @service calumaOptions;
12
17
 
13
18
  @config config;
14
19
 
15
20
  @queryManager apollo;
16
21
 
22
+ get currentGroupIsCreator() {
23
+ return String(this.calumaOptions.currentGroupId) === this.args.from;
24
+ }
25
+
17
26
  get inquiries() {
18
27
  return this._inquiries.value?.allWorkItems.edges.map((edge) => edge.node);
19
28
  }
20
29
 
21
- _inquiries = useTask(this, this.fetchDialog, () => [
30
+ _inquiries = trackedTask(this, this.fetchDialog, () => [
22
31
  this.args.from,
23
32
  this.args.to,
24
33
  this.args.caseId,
@@ -37,7 +46,7 @@ export default class InquiryDialogComponent extends Component {
37
46
  infoQuestion: this.config.inquiry.infoQuestion,
38
47
  deadlineQuestion: this.config.inquiry.deadlineQuestion,
39
48
  statusQuestion: this.config.inquiry.answer.statusQuestion,
40
- answerInfoQuestion: this.config.inquiry.answer.infoQuestion,
49
+ answerInfoQuestions: this.config.inquiry.answer.infoQuestions,
41
50
  includeNavigationData: true,
42
51
  },
43
52
  });
@@ -62,4 +71,23 @@ export default class InquiryDialogComponent extends Component {
62
71
 
63
72
  return response;
64
73
  }
74
+
75
+ @dropTask
76
+ *createInquiry(e) {
77
+ e.preventDefault();
78
+
79
+ yield this.distribution.createInquiry.perform([this.args.to]);
80
+
81
+ // refetch dialog data
82
+ yield getObservable(this._inquiries.value).refetch();
83
+
84
+ this.router.transitionTo(
85
+ "inquiry.detail.index",
86
+ {
87
+ from: this.args.from,
88
+ to: this.args.to,
89
+ },
90
+ decodeId(this.inquiries[0].id)
91
+ );
92
+ }
65
93
  }
@@ -0,0 +1,31 @@
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
+ @isDraft={{eq this.inquiry.status "SUSPENDED"}}
10
+ @modifiedAt={{this.inquiry.document.modifiedContentAt}}
11
+ @modifiedBy={{this.inquiry.document.modifiedContentByUser}}
12
+ />
13
+
14
+ <hr />
15
+
16
+ <content.form />
17
+
18
+ {{#if (can "edit inquiry" this.inquiry)}}
19
+ <DocumentValidity @document={{content.document}} as |isValid validate|>
20
+ <UkButton
21
+ @type="submit"
22
+ @color="primary"
23
+ @disabled={{or (not isValid) this.send.isRunning}}
24
+ @onClick={{perform this.send validate}}
25
+ @loading={{this.send.isRunning}}
26
+ >{{t "caluma.distribution.edit.send"}}</UkButton>
27
+ </DocumentValidity>
28
+ {{/if}}
29
+ </:default>
30
+ <:notfound><CdNotfound /></:notfound>
31
+ </CfContent>
@@ -2,13 +2,13 @@ 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
14
  @service intl;
@@ -17,7 +17,7 @@ export default class InquiryEditFormComponent extends Component {
17
17
 
18
18
  @queryManager apollo;
19
19
 
20
- _inquiry = useTask(this, this.fetchInquiry, () => [this.args.inquiry]);
20
+ _inquiry = trackedTask(this, this.fetchInquiry, () => [this.args.inquiry]);
21
21
 
22
22
  get inquiry() {
23
23
  return this._inquiry.value?.[0]?.node;
@@ -1,7 +1,9 @@
1
1
  {{#if this.controls.workItems.isRunning}}
2
2
  <div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
3
3
  {{else if (can "create inquiry of distribution")}}
4
- <h1>{{t "caluma.distribution.new.title"}}</h1>
4
+ <p class="uk-text-large">{{t "caluma.distribution.new.title"}}</p>
5
+
6
+ <hr />
5
7
 
6
8
  {{#if this.selectedGroups.length}}
7
9
  <div class="uk-flex uk-flex-middle">
@@ -117,5 +119,5 @@
117
119
  </div>
118
120
  {{/if}}
119
121
  {{else}}
120
- <Notfound />
122
+ <CdNotfound />
121
123
  {{/if}}
@@ -5,11 +5,10 @@ import Component from "@glimmer/component";
5
5
  import { tracked } from "@glimmer/tracking";
6
6
  import { queryManager } from "ember-apollo-client";
7
7
  import { timeout, restartableTask, dropTask, task } from "ember-concurrency";
8
- import { useTask } from "ember-resources";
8
+ import { trackedTask } from "ember-resources/util/ember-concurrency";
9
9
 
10
10
  import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
11
11
  import config from "@projectcaluma/ember-distribution/config";
12
- import createInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/create-inquiry.graphql";
13
12
 
14
13
  const toggle = (value, array) => {
15
14
  const set = new Set(array);
@@ -19,7 +18,7 @@ const toggle = (value, array) => {
19
18
  return [...set];
20
19
  };
21
20
 
22
- export default class InquiryNewFormComponent extends Component {
21
+ export default class CdInquiryNewFormComponent extends Component {
23
22
  @service calumaOptions;
24
23
  @service notification;
25
24
  @service intl;
@@ -32,7 +31,7 @@ export default class InquiryNewFormComponent extends Component {
32
31
 
33
32
  @tracked selectedGroups = [];
34
33
 
35
- groups = useTask(this, this.fetchGroups, () => [
34
+ groups = trackedTask(this, this.fetchGroups, () => [
36
35
  this.args.selectedTypes,
37
36
  this.args.search,
38
37
  ]);
@@ -78,45 +77,20 @@ export default class InquiryNewFormComponent extends Component {
78
77
 
79
78
  if (!this.selectedGroups.length) return;
80
79
 
81
- try {
82
- // get create inquiry work item to complete
83
- const createId = decodeId(
84
- this.distribution.controls.value?.create.edges[0].node.id
85
- );
86
-
87
- // create new inquiries
88
- yield this.apollo.mutate({
89
- mutation: createInquiryMutation,
90
- variables: {
91
- id: createId,
92
- context: JSON.stringify({
93
- addressed_groups: this.selectedGroups.map(String),
94
- }),
95
- },
96
- });
97
-
98
- // refetch navigation and controls data
99
- yield this.distribution.refetch();
100
-
101
- const lastControlling =
102
- this.distribution.navigation.value.controlling.edges[0].node;
103
-
104
- // transition to last added inquiry
105
- this.router.transitionTo(
106
- "inquiry.detail.index",
107
- {
108
- from: lastControlling.controllingGroups[0],
109
- to: lastControlling.addressedGroups[0],
110
- },
111
- decodeId(lastControlling.id)
112
- );
113
- } catch (e) {
114
- this.notification.danger(
115
- this.intl.t("caluma.distribution.new.error", {
116
- count: this.selectedGroups.length,
117
- })
118
- );
119
- }
80
+ yield this.distribution.createInquiry.perform(this.selectedGroups);
81
+
82
+ const lastControlling =
83
+ this.distribution.navigation.value.controlling.edges[0].node;
84
+
85
+ // transition to last added inquiry
86
+ this.router.transitionTo(
87
+ "inquiry.detail.index",
88
+ {
89
+ from: lastControlling.controllingGroups[0],
90
+ to: lastControlling.addressedGroups[0],
91
+ },
92
+ decodeId(lastControlling.id)
93
+ );
120
94
  }
121
95
 
122
96
  @task