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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/addon/components/cd-document-header.hbs +20 -0
  3. package/addon/components/cd-inquiry-answer-form.hbs +26 -9
  4. package/addon/components/cd-inquiry-answer-form.js +6 -2
  5. package/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs +1 -0
  6. package/addon/components/cd-inquiry-dialog/inquiry-part.hbs +91 -44
  7. package/addon/components/cd-inquiry-dialog/inquiry-part.js +15 -8
  8. package/addon/components/cd-inquiry-dialog.hbs +13 -0
  9. package/addon/components/cd-inquiry-dialog.js +31 -3
  10. package/addon/components/cd-inquiry-edit-form.hbs +19 -17
  11. package/addon/components/cd-inquiry-edit-form.js +2 -2
  12. package/addon/components/cd-inquiry-new-form.hbs +3 -1
  13. package/addon/components/cd-inquiry-new-form.js +16 -42
  14. package/addon/components/cd-navigation/controls.hbs +5 -1
  15. package/addon/components/cd-truncated.hbs +8 -0
  16. package/addon/components/cd-truncated.js +32 -0
  17. package/addon/config.js +1 -1
  18. package/addon/controllers/application.js +3 -0
  19. package/addon/controllers/new.js +1 -1
  20. package/addon/gql/fragments/inquiry.graphql +21 -12
  21. package/addon/gql/queries/inquiry-answer.graphql +15 -1
  22. package/addon/gql/queries/inquiry-dialog.graphql +2 -2
  23. package/addon/gql/queries/inquiry-edit.graphql +2 -0
  24. package/addon/gql/queries/inquiry-navigation.graphql +2 -1
  25. package/addon/services/distribution.js +33 -3
  26. package/addon/templates/application.hbs +16 -6
  27. package/addon/utils/inquiry-deadline.js +3 -5
  28. package/app/components/cd-document-header.js +1 -0
  29. package/app/components/cd-truncated.js +1 -0
  30. package/app/styles/@projectcaluma/ember-distribution.scss +2 -0
  31. package/app/styles/_answer-form.scss +4 -0
  32. package/app/styles/_truncated.scss +3 -0
  33. package/package.json +18 -18
  34. package/translations/de.yaml +6 -4
  35. package/translations/en.yaml +6 -4
  36. package/translations/fr.yaml +6 -4
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
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
+
1
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)
2
20
 
3
21
 
@@ -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}}
@@ -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
@@ -2,7 +2,7 @@ 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";
@@ -18,7 +18,9 @@ export default class CdInquiryAnswerFormComponent 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 CdInquiryAnswerFormComponent 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,6 +12,7 @@
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")
@@ -1,48 +1,95 @@
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
+ <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>
10
11
 
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)}}
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
+ >
38
20
  <li>
39
- <LinkTo @route="inquiry.detail.answer" @model={{decode-id @inquiry.id}}>
40
- {{t "caluma.distribution.answer.link"}}
41
- </LinkTo>
21
+ <span>
22
+ {{format-date this.date}}
23
+ {{format-time this.date hour="2-digit" minute="2-digit"}}
24
+ </span>
42
25
  </li>
43
- {{/if}}
44
- </ul>
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>
45
66
 
46
- {{#if this.info}}
47
- <p class="uk-margin-remove">{{this.info}}</p>
48
- {{/if}}
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";
@@ -23,15 +24,21 @@ export default class CdInquiryDialogInquiryPartComponent 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
@@ -1,6 +1,19 @@
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
+ <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}}
4
17
  <section>
5
18
  {{#each this.inquiries as |inquiry|}}
6
19
  <CdInquiryDialog::Inquiry @inquiry={{inquiry}} />
@@ -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
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 CdInquiryDialogComponent 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 CdInquiryDialogComponent 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
  }
@@ -4,26 +4,28 @@
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.edit.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
+ <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 />
16
15
 
17
16
  <content.form />
18
17
 
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
- >{{t "caluma.distribution.edit.send"}}</UkButton>
26
- </DocumentValidity>
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}}
27
29
  </:default>
28
30
  <:notfound><CdNotfound /></:notfound>
29
31
  </CfContent>
@@ -2,7 +2,7 @@ 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";
@@ -17,7 +17,7 @@ export default class CdInquiryEditFormComponent 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">
@@ -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);
@@ -32,7 +31,7 @@ export default class CdInquiryNewFormComponent 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 CdInquiryNewFormComponent 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
@@ -1,6 +1,10 @@
1
1
  <div class="uk-text-center uk-margin-small-top">
2
2
  {{#if (can "create inquiry of distribution")}}
3
- <CdIconButton @route="new" @icon="plus" />
3
+ <CdIconButton
4
+ @title={{t "caluma.distribution.new.title"}}
5
+ @icon="plus"
6
+ @route="new"
7
+ />
4
8
  {{/if}}
5
9
  {{#if (can "send inquiries of distribution")}}
6
10
  <CdIconButton
@@ -0,0 +1,8 @@
1
+ <p class="cd-truncated" ...attributes>
2
+ {{~this.displayedText~}}
3
+ {{#if this.truncate}}
4
+ <a href="" {{on "click" this.toggleExpand}}>
5
+ {{~t (concat "caluma.distribution." (if this.expand "less" "more"))~}}
6
+ </a>
7
+ {{/if}}
8
+ </p>
@@ -0,0 +1,32 @@
1
+ import { action } from "@ember/object";
2
+ import Component from "@glimmer/component";
3
+ import { tracked } from "@glimmer/tracking";
4
+
5
+ export default class CdTruncatedComponent extends Component {
6
+ @tracked expand = false;
7
+
8
+ get length() {
9
+ return parseInt(this.args.length);
10
+ }
11
+
12
+ get displayedText() {
13
+ if (this.truncate && !this.expand) {
14
+ // strip input string to the passed length minus 3 to make sure the output
15
+ // including the 3 dots doesn't exceed the expected length
16
+ return `${this.args.text.substring(0, this.length - 3).trim()}...`;
17
+ }
18
+
19
+ return this.args.text;
20
+ }
21
+
22
+ get truncate() {
23
+ return this.args.text.length > this.length;
24
+ }
25
+
26
+ @action
27
+ toggleExpand(e) {
28
+ e.preventDefault();
29
+
30
+ this.expand = !this.expand;
31
+ }
32
+ }
package/addon/config.js CHANGED
@@ -27,7 +27,7 @@ export default function config(target, property) {
27
27
  infoQuestion: "inquiry-remark",
28
28
  answer: {
29
29
  statusQuestion: "inquiry-answer-status",
30
- infoQuestion: "inquiry-answer-reason",
30
+ infoQuestions: ["inquiry-answer-reason"],
31
31
  statusMapping: {
32
32
  "inquiry-answer-status-positive": INQUIRY_STATUS.POSITIVE,
33
33
  "inquiry-answer-status-negative": INQUIRY_STATUS.NEGATIVE,
@@ -1,7 +1,10 @@
1
1
  import Controller from "@ember/controller";
2
+ import { inject as service } from "@ember/service";
2
3
 
3
4
  import config from "@projectcaluma/ember-distribution/config";
4
5
 
5
6
  export default class ApplicationController extends Controller {
6
7
  @config config;
8
+
9
+ @service distribution;
7
10
  }
@@ -13,7 +13,7 @@ export default class NewController extends Controller {
13
13
 
14
14
  @cached
15
15
  get selectedTypes() {
16
- return this.types.split(",");
16
+ return this.types.split(",").filter(Boolean);
17
17
  }
18
18
 
19
19
  set selectedTypes(value) {
@@ -30,6 +30,21 @@ fragment InquiryStatusDocument on Document {
30
30
  }
31
31
  }
32
32
 
33
+ fragment InquiryRequest on Document {
34
+ id
35
+ ...InquiryDeadlineDocument
36
+ info: answers(question: $infoQuestion) {
37
+ edges {
38
+ node {
39
+ id
40
+ ... on StringAnswer {
41
+ value
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+
33
48
  fragment InquiryDialog on WorkItem {
34
49
  id
35
50
  addressedGroups
@@ -42,26 +57,20 @@ fragment InquiryDialog on WorkItem {
42
57
  slug
43
58
  }
44
59
  document {
45
- ...InquiryDeadlineDocument
46
- info: answers(question: $infoQuestion) {
47
- edges {
48
- node {
49
- id
50
- ... on StringAnswer {
51
- value
52
- }
53
- }
54
- }
55
- }
60
+ ...InquiryRequest
56
61
  }
57
62
  childCase {
58
63
  id
59
64
  document {
60
65
  ...InquiryStatusDocument
61
- info: answers(question: $answerInfoQuestion) {
66
+ info: answers(questions: $answerInfoQuestions) {
62
67
  edges {
63
68
  node {
64
69
  id
70
+ question {
71
+ id
72
+ label
73
+ }
65
74
  ... on StringAnswer {
66
75
  value
67
76
  }
@@ -1,19 +1,33 @@
1
- query InquiryAnswer($inquiry: ID!, $buttonTasks: [String]!) {
1
+ #import InquiryDeadlineDocument, InquiryRequest from '../fragments/inquiry.graphql'
2
+
3
+ query InquiryAnswer(
4
+ $inquiry: ID!
5
+ $buttonTasks: [String]!
6
+ $infoQuestion: ID!
7
+ $deadlineQuestion: ID!
8
+ ) {
2
9
  allWorkItems(filter: [{ id: $inquiry }]) {
3
10
  edges {
4
11
  node {
5
12
  id
6
13
  status
7
14
  addressedGroups
15
+ controllingGroups
16
+ createdAt
8
17
  task {
9
18
  id
10
19
  slug
11
20
  }
21
+ document {
22
+ ...InquiryRequest
23
+ }
12
24
  childCase {
13
25
  id
14
26
  status
15
27
  document {
16
28
  id
29
+ modifiedContentAt
30
+ modifiedContentByUser
17
31
  }
18
32
  workItems(tasks: $buttonTasks, status: READY) {
19
33
  edges {
@@ -1,11 +1,11 @@
1
- #import InquiryDialog, InquiryDeadlineDocument, InquiryStatusDocument from '../fragments/inquiry.graphql'
1
+ #import InquiryDialog, InquiryDeadlineDocument, InquiryStatusDocument, InquiryRequest from '../fragments/inquiry.graphql'
2
2
 
3
3
  query InquiryDialog(
4
4
  $task: ID!
5
5
  $statusQuestion: ID!
6
6
  $deadlineQuestion: ID!
7
7
  $infoQuestion: ID!
8
- $answerInfoQuestion: ID!
8
+ $answerInfoQuestions: [ID]!
9
9
  $from: [String]!
10
10
  $to: [String]!
11
11
  $caseId: ID!
@@ -11,6 +11,8 @@ query InquiryEdit($inquiry: ID!) {
11
11
  }
12
12
  document {
13
13
  id
14
+ modifiedContentAt
15
+ modifiedContentByUser
14
16
  }
15
17
  }
16
18
  }
@@ -45,7 +45,8 @@ query InquiryNavigation(
45
45
  { task: $task }
46
46
  { controllingGroups: [$currentGroup], invert: true }
47
47
  { addressedGroups: [$currentGroup], invert: true }
48
- { status: COMPLETED }
48
+ { status: SUSPENDED, invert: true }
49
+ { status: CANCELED, invert: true }
49
50
  ]
50
51
  order: [{ attribute: CREATED_AT, direction: DESC }]
51
52
  ) {
@@ -2,9 +2,11 @@ import { getOwner } from "@ember/application";
2
2
  import Service, { inject as service } from "@ember/service";
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";
9
+ import createInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/create-inquiry.graphql";
8
10
  import controlWorkItemsQuery from "@projectcaluma/ember-distribution/gql/queries/control-work-items.graphql";
9
11
  import inquiryNavigationQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-navigation.graphql";
10
12
 
@@ -12,6 +14,8 @@ export default class DistributionService extends Service {
12
14
  @service("-scheduler") scheduler;
13
15
  @service calumaOptions;
14
16
  @service router;
17
+ @service intl;
18
+ @service notification;
15
19
 
16
20
  @queryManager apollo;
17
21
 
@@ -21,8 +25,8 @@ export default class DistributionService extends Service {
21
25
  return getOwner(this).lookup("route:application").currentModel;
22
26
  }
23
27
 
24
- controls = useTask(this, this.fetchControls, () => [this.caseId]);
25
- navigation = useTask(this, this.fetchNavigation, () => [this.caseId]);
28
+ controls = trackedTask(this, this.fetchControls, () => [this.caseId]);
29
+ navigation = trackedTask(this, this.fetchNavigation, () => [this.caseId]);
26
30
 
27
31
  async refetch() {
28
32
  await getObservable(this.controls.value)?.refetch();
@@ -79,4 +83,30 @@ export default class DistributionService extends Service {
79
83
 
80
84
  return response;
81
85
  }
86
+
87
+ @dropTask
88
+ *createInquiry(groups) {
89
+ try {
90
+ // get create inquiry work item to complete
91
+ const createId = decodeId(this.controls.value?.create.edges[0].node.id);
92
+
93
+ // create new inquiries
94
+ yield this.apollo.mutate({
95
+ mutation: createInquiryMutation,
96
+ variables: {
97
+ id: createId,
98
+ context: JSON.stringify({
99
+ addressed_groups: groups.map(String),
100
+ }),
101
+ },
102
+ });
103
+
104
+ // refetch navigation and controls data
105
+ yield this.refetch();
106
+ } catch (e) {
107
+ this.notification.danger(
108
+ this.intl.t("caluma.distribution.new.error", { count: groups.length })
109
+ );
110
+ }
111
+ }
82
112
  }
@@ -1,8 +1,18 @@
1
- <div uk-grid class={{if this.config.ui.stack "uk-grid-small"}}>
2
- <div class={{if this.config.ui.stack "uk-width-1-1" "uk-width-1-3"}}>
3
- <CdNavigation @caseId={{@model}} />
1
+ {{#if
2
+ (or
3
+ this.distribution.navigation.isRunning this.distribution.controls.isRunning
4
+ )
5
+ }}
6
+ <div class="uk-text-center">
7
+ <UkSpinner @ratio={{2}} />
4
8
  </div>
5
- <div class={{if this.config.ui.stack "uk-width-1-1" "uk-width-2-3"}}>
6
- {{outlet}}
9
+ {{else}}
10
+ <div uk-grid class={{if this.config.ui.stack "uk-grid-small"}}>
11
+ <div class={{if this.config.ui.stack "uk-width-1-1" "uk-width-1-3"}}>
12
+ <CdNavigation @caseId={{@model}} />
13
+ </div>
14
+ <div class={{if this.config.ui.stack "uk-width-1-1" "uk-width-2-3"}}>
15
+ {{outlet}}
16
+ </div>
7
17
  </div>
8
- </div>
18
+ {{/if}}
@@ -21,12 +21,10 @@ function decorator(
21
21
  const value = inquiry.document?.deadline.edges[0]?.node.value;
22
22
  const isAnswered = inquiry.status === "COMPLETED";
23
23
 
24
- const deadline = DateTime.fromISO(value).startOf("day");
25
- const now = DateTime.now().startOf("day");
24
+ const { days: diff } = DateTime.fromISO(value).diffNow("days").toObject();
26
25
 
27
- const isOverdue = !isAnswered && now > deadline;
28
- const isWarning =
29
- !isAnswered && now.plus({ days: this.config.warningPeriod }) > deadline;
26
+ const isOverdue = !isAnswered && diff <= 0;
27
+ const isWarning = !isAnswered && diff <= this.config.warningPeriod;
30
28
 
31
29
  return {
32
30
  value,
@@ -0,0 +1 @@
1
+ export { default } from "@projectcaluma/ember-distribution/components/cd-document-header";
@@ -0,0 +1 @@
1
+ export { default } from "@projectcaluma/ember-distribution/components/cd-truncated";
@@ -1,3 +1,5 @@
1
+ @import "../answer-form";
1
2
  @import "../icon-button";
2
3
  @import "../inquiry-divider";
3
4
  @import "../status-indicator";
5
+ @import "../truncated";
@@ -0,0 +1,4 @@
1
+ .inquiry-answer-form__request {
2
+ border-left: 5px solid $global-border;
3
+ padding-left: $global-gutter - 5px;
4
+ }
@@ -0,0 +1,3 @@
1
+ .cd-truncated {
2
+ white-space: pre-line;
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-distribution",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.0-beta.9",
4
4
  "description": "Ember engine for the Caluma distribution module.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -20,11 +20,11 @@
20
20
  "dependencies": {
21
21
  "@ember/string": "^3.0.0",
22
22
  "@embroider/macros": "^1.6.0",
23
- "@glimmer/component": "^1.1.1",
24
- "@glimmer/tracking": "^1.1.1",
25
- "@projectcaluma/ember-core": "^11.0.0-beta.6",
26
- "@projectcaluma/ember-form": "^11.0.0-beta.17",
27
- "@projectcaluma/ember-workflow": "^11.0.0-beta.6",
23
+ "@glimmer/component": "^1.1.2",
24
+ "@glimmer/tracking": "^1.1.2",
25
+ "@projectcaluma/ember-core": "^11.0.0-beta.7",
26
+ "@projectcaluma/ember-form": "^11.0.0-beta.19",
27
+ "@projectcaluma/ember-workflow": "^11.0.0-beta.7",
28
28
  "ember-apollo-client": "^4.0.2",
29
29
  "ember-auto-import": "^2.4.1",
30
30
  "ember-can": "^4.2.0",
@@ -35,48 +35,48 @@
35
35
  "ember-fetch": "^8.1.1",
36
36
  "ember-intl": "^5.7.2",
37
37
  "ember-pikaday": "^4.0.0",
38
- "ember-resources": "^4.4.0",
38
+ "ember-resources": "^4.7.1",
39
39
  "ember-svg-jar": "^2.3.4",
40
40
  "ember-test-selectors": "^6.0.0",
41
- "ember-uikit": "^5.1.1",
41
+ "ember-uikit": "^5.1.3",
42
42
  "graphql": "^15.8.0",
43
43
  "graphql-tag": "^2.12.6",
44
44
  "ionicons": "^6.0.1",
45
45
  "lodash.merge": "^4.6.2",
46
- "luxon": "^2.3.1",
46
+ "luxon": "^2.4.0",
47
47
  "tracked-toolbox": "^1.2.3"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@ember/optional-features": "2.0.0",
51
51
  "@ember/test-helpers": "2.7.0",
52
52
  "@embroider/test-setup": "1.6.0",
53
- "@faker-js/faker": "6.1.2",
54
- "@projectcaluma/ember-testing": "11.0.0-beta.6",
53
+ "@faker-js/faker": "6.3.1",
54
+ "@projectcaluma/ember-testing": "11.0.0-beta.7",
55
55
  "broccoli-asset-rev": "3.0.0",
56
56
  "ember-cli": "3.28.5",
57
57
  "ember-cli-code-coverage": "1.0.3",
58
- "ember-cli-dependency-checker": "3.2.0",
58
+ "ember-cli-dependency-checker": "3.3.1",
59
59
  "ember-cli-inject-live-reload": "2.1.0",
60
- "ember-cli-mirage": "3.0.0-alpha.2",
61
- "ember-cli-sass": "10.0.1",
60
+ "ember-cli-mirage": "3.0.0-alpha.3",
61
+ "ember-cli-sass": "11.0.1",
62
62
  "ember-cli-sri": "2.1.1",
63
63
  "ember-cli-terser": "4.0.2",
64
64
  "ember-disable-prototype-extensions": "1.1.3",
65
- "ember-engines": "0.8.20",
65
+ "ember-engines": "0.8.22",
66
66
  "ember-export-application-global": "2.0.1",
67
67
  "ember-load-initializers": "2.1.2",
68
68
  "ember-maybe-import-regenerator": "1.0.0",
69
69
  "ember-qunit": "5.1.5",
70
70
  "ember-resolver": "8.0.3",
71
- "ember-source": "3.28.8",
71
+ "ember-source": "3.28.9",
72
72
  "ember-source-channel-url": "3.0.0",
73
73
  "ember-try": "2.0.0",
74
74
  "loader.js": "4.7.0",
75
75
  "miragejs": "0.1.43",
76
76
  "npm-run-all": "4.1.5",
77
- "qunit": "2.18.1",
77
+ "qunit": "2.19.1",
78
78
  "qunit-dom": "2.0.0",
79
- "sass": "1.50.0",
79
+ "sass": "1.51.0",
80
80
  "webpack": "5.72.0"
81
81
  },
82
82
  "engines": {
@@ -11,17 +11,19 @@ caluma:
11
11
  send-error: "Fehler beim Versenden der offenen Anfragen"
12
12
  complete-error: "Fehler beim Abschliessen der Zirkulation"
13
13
 
14
+ more: "mehr"
15
+ less: "weniger"
16
+
17
+ last-modified: "Zuletzt bearbeitet von {user} am {date} um {time}"
18
+ details: "Details"
19
+
14
20
  edit:
15
- title: "Anfrage bearbeiten"
16
21
  link: "Bearbeiten"
17
-
18
22
  send: "Senden"
19
23
  send-error: "Fehler beim Senden der Anfrage"
20
24
 
21
25
  answer:
22
- title: "Anfrage beantworten"
23
26
  link: "Beantworten"
24
-
25
27
  release-for-review: "Zur Kontrolle freigeben"
26
28
  release-adjustment-for-review: "Anpassung zur Kontrolle freigeben"
27
29
  confirm: "Bestätigen"
@@ -12,17 +12,19 @@ caluma:
12
12
  send-error: "Error while sending pending inquiries"
13
13
  complete-error: "Error while completing distribution"
14
14
 
15
+ more: "more"
16
+ less: "less"
17
+
18
+ last-modified: "Last modified by {user} on {date} at {time}"
19
+ details: "Details"
20
+
15
21
  edit:
16
- title: "Edit inquiry"
17
22
  link: "Edit"
18
-
19
23
  send: "Send"
20
24
  send-error: "Error while sending the inquiry"
21
25
 
22
26
  answer:
23
- title: "Answer inquiry"
24
27
  link: "Answer"
25
-
26
28
  release-for-review: "Release for review"
27
29
  release-adjustment-for-review: "Release adjustment for review"
28
30
  confirm: "Confirm"
@@ -11,17 +11,19 @@ caluma:
11
11
  send-error: "Erreur lors de l'envoi des demandes ouvertes"
12
12
  complete-error: "Erreur lors de la terminaison de la distribution"
13
13
 
14
+ more: "plus"
15
+ less: "moins"
16
+
17
+ last-modified: "Dernière modification par {user} le {date} à {time}"
18
+ details: "Détails"
19
+
14
20
  edit:
15
- title: "Modifier la demande"
16
21
  link: "Modifier"
17
-
18
22
  send: "Envoyer"
19
23
  send-error: "Erreur lors de l'envoi de la demande"
20
24
 
21
25
  answer:
22
- title: "Répondre à la demande"
23
26
  link: "Répondre"
24
-
25
27
  release-for-review: "Valider pour vérification"
26
28
  release-adjustment-for-review: "Valider la révision pour vérification"
27
29
  confirm: "Confirmer"