@projectcaluma/ember-distribution 1.0.0-beta.1

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 (91) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/addon/-private/decorator.js +24 -0
  3. package/addon/abilities/inquiry.js +39 -0
  4. package/addon/components/distribution-navigation/controls.hbs +21 -0
  5. package/addon/components/distribution-navigation/controls.js +45 -0
  6. package/addon/components/distribution-navigation/item.hbs +18 -0
  7. package/addon/components/distribution-navigation/item.js +17 -0
  8. package/addon/components/distribution-navigation/section.hbs +24 -0
  9. package/addon/components/distribution-navigation/section.js +25 -0
  10. package/addon/components/distribution-navigation/status-indicator.hbs +17 -0
  11. package/addon/components/distribution-navigation/status-indicator.js +19 -0
  12. package/addon/components/distribution-navigation.hbs +17 -0
  13. package/addon/components/distribution-navigation.js +81 -0
  14. package/addon/components/icon-button.hbs +20 -0
  15. package/addon/components/icon-button.js +22 -0
  16. package/addon/components/inquiry-answer-form.hbs +46 -0
  17. package/addon/components/inquiry-answer-form.js +75 -0
  18. package/addon/components/inquiry-dialog/inquiry-deadline.hbs +6 -0
  19. package/addon/components/inquiry-dialog/inquiry-deadline.js +10 -0
  20. package/addon/components/inquiry-dialog/inquiry-divider.hbs +7 -0
  21. package/addon/components/inquiry-dialog/inquiry-divider.js +13 -0
  22. package/addon/components/inquiry-dialog/inquiry-part.hbs +40 -0
  23. package/addon/components/inquiry-dialog/inquiry-part.js +20 -0
  24. package/addon/components/inquiry-dialog/inquiry.hbs +13 -0
  25. package/addon/components/inquiry-dialog/inquiry.js +7 -0
  26. package/addon/components/inquiry-dialog.hbs +9 -0
  27. package/addon/components/inquiry-dialog.js +42 -0
  28. package/addon/components/inquiry-edit-form.hbs +27 -0
  29. package/addon/components/inquiry-edit-form.js +53 -0
  30. package/addon/components/inquiry-new-form.hbs +110 -0
  31. package/addon/components/inquiry-new-form.js +154 -0
  32. package/addon/config.js +72 -0
  33. package/addon/controllers/distribution/new.js +22 -0
  34. package/addon/engine.js +18 -0
  35. package/addon/gql/fragments/inquiry.graphql +89 -0
  36. package/addon/gql/mutations/complete-inquiry-work-item.graphql +36 -0
  37. package/addon/gql/mutations/create-inquiry.graphql +5 -0
  38. package/addon/gql/mutations/resume-work-item.graphql +8 -0
  39. package/addon/gql/queries/control-work-items.graphql +37 -0
  40. package/addon/gql/queries/inquiry-answer.graphql +33 -0
  41. package/addon/gql/queries/inquiry-dialog.graphql +28 -0
  42. package/addon/gql/queries/inquiry-edit.graphql +18 -0
  43. package/addon/gql/queries/inquiry-navigation.graphql +56 -0
  44. package/addon/routes/distribution/index.js +41 -0
  45. package/addon/routes/distribution/inquiry/detail/answer.js +7 -0
  46. package/addon/routes/distribution/inquiry/detail/index.js +7 -0
  47. package/addon/routes/distribution/inquiry/detail.js +7 -0
  48. package/addon/routes/distribution/inquiry/index.js +10 -0
  49. package/addon/routes/distribution/inquiry.js +7 -0
  50. package/addon/routes/distribution/new.js +7 -0
  51. package/addon/routes/distribution.js +7 -0
  52. package/addon/routes.js +12 -0
  53. package/addon/templates/distribution/inquiry/detail/answer.hbs +1 -0
  54. package/addon/templates/distribution/inquiry/detail/index.hbs +1 -0
  55. package/addon/templates/distribution/inquiry/detail.hbs +1 -0
  56. package/addon/templates/distribution/inquiry/index.hbs +5 -0
  57. package/addon/templates/distribution/inquiry.hbs +1 -0
  58. package/addon/templates/distribution/new.hbs +7 -0
  59. package/addon/templates/distribution.hbs +8 -0
  60. package/addon/utils/inquiry-deadline.js +48 -0
  61. package/addon/utils/inquiry-status.js +68 -0
  62. package/addon/utils/unique-by-groups.js +17 -0
  63. package/app/abilities/inquiry.js +1 -0
  64. package/app/components/distribution-navigation/controls.js +1 -0
  65. package/app/components/distribution-navigation/item.js +1 -0
  66. package/app/components/distribution-navigation/section.js +1 -0
  67. package/app/components/distribution-navigation/status-indicator.js +1 -0
  68. package/app/components/distribution-navigation.js +1 -0
  69. package/app/components/icon-button.js +1 -0
  70. package/app/components/inquiry-answer-form.js +1 -0
  71. package/app/components/inquiry-dialog/inquiry-deadline.js +1 -0
  72. package/app/components/inquiry-dialog/inquiry-divider.js +1 -0
  73. package/app/components/inquiry-dialog/inquiry-part.js +1 -0
  74. package/app/components/inquiry-dialog/inquiry.js +1 -0
  75. package/app/components/inquiry-dialog.js +1 -0
  76. package/app/components/inquiry-edit-form.js +1 -0
  77. package/app/components/inquiry-new-form.js +1 -0
  78. package/app/styles/@projectcaluma/ember-distribution.scss +3 -0
  79. package/app/styles/_icon-button.scss +13 -0
  80. package/app/styles/_inquiry-divider.scss +49 -0
  81. package/app/styles/_status-indicator.scss +31 -0
  82. package/app/styles/app.scss +1 -0
  83. package/app/utils/inquiry-deadline.js +1 -0
  84. package/app/utils/inquiry-status.js +1 -0
  85. package/app/utils/unique-by-groups.js +1 -0
  86. package/config/environment.js +10 -0
  87. package/index.js +22 -0
  88. package/package.json +86 -0
  89. package/translations/de.yaml +42 -0
  90. package/translations/en.yaml +42 -0
  91. package/translations/fr.yaml +42 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # @projectcaluma/ember-distribution-v1.0.0-beta.1 (2022-01-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **core:** override apollo service instead of serving a mixin ([e86796e](https://github.com/projectcaluma/ember-caluma/commit/e86796e801dc5a2a5b1331b87bc9261509443605)), closes [#529](https://github.com/projectcaluma/ember-caluma/issues/529)
7
+ * **deps:** update @projectcaluma/ember-core [skip ci] ([1e6af2d](https://github.com/projectcaluma/ember-caluma/commit/1e6af2dc2f29347897e605cc7144721abc2b44d7))
8
+ * **deps:** update @projectcaluma/ember-core [skip ci] ([27fb674](https://github.com/projectcaluma/ember-caluma/commit/27fb674f465bb78f3aed48c896259879d54a4de5))
9
+ * **deps:** update @projectcaluma/ember-core [skip ci] ([d2accca](https://github.com/projectcaluma/ember-caluma/commit/d2accca7678fe49cba53b1aef3224ff7a055b631))
10
+ * **deps:** update @projectcaluma/ember-core [skip ci] ([397f5ba](https://github.com/projectcaluma/ember-caluma/commit/397f5bae7fe2795a1e5824f450f666dee4a030d5))
11
+ * **deps:** update @projectcaluma/ember-form [skip ci] ([2f80820](https://github.com/projectcaluma/ember-caluma/commit/2f80820e5930fef578c8294255fef21ab137b333))
12
+ * **deps:** update @projectcaluma/ember-testing [skip ci] ([371d144](https://github.com/projectcaluma/ember-caluma/commit/371d1440a69cad682c1274ddbaeb46deef62376d))
13
+ * **deps:** update @projectcaluma/ember-testing [skip ci] ([0c339df](https://github.com/projectcaluma/ember-caluma/commit/0c339df93880ffba0023552fa326b313df7bcec3))
14
+ * **deps:** update @projectcaluma/ember-workflow [skip ci] ([e1232c8](https://github.com/projectcaluma/ember-caluma/commit/e1232c8d6929360b30a5c2a6777203f24255da94))
15
+ * **deps:** update @projectcaluma/ember-workflow [skip ci] ([07686c1](https://github.com/projectcaluma/ember-caluma/commit/07686c1e061fc4fc13715a3638cfad7b0a1197fe))
16
+ * **distribution:** fix infinte loop when fetching groups with ember-data ([f18ec33](https://github.com/projectcaluma/ember-caluma/commit/f18ec333908e669b24db764d1aa2a3396d8f25a7))
17
+ * **form:** fix dependencies for ember-autoresize-modifier ([242007a](https://github.com/projectcaluma/ember-caluma/commit/242007a9b5010fc99824b7f03d8102095904403f))
18
+
19
+
20
+ ### chore
21
+
22
+ * **deps:** update dependencies and drop support for node 10 ([51d6dee](https://github.com/projectcaluma/ember-caluma/commit/51d6deeda9811518622ba0cefd8d3876651dab4f))
23
+
24
+
25
+ ### Features
26
+
27
+ * **distribution:** add mask for creating new inquiries ([c90c5e7](https://github.com/projectcaluma/ember-caluma/commit/c90c5e72dd300899f2d209216d0b893968ce6b20))
28
+ * **distribution:** add masks for editing and answering inquiries ([14a743b](https://github.com/projectcaluma/ember-caluma/commit/14a743bbfa7a349a58f72b44ed6eed0843bd6d13))
29
+ * **distribution:** add read only view of distribution engine ([ac2c46a](https://github.com/projectcaluma/ember-caluma/commit/ac2c46aeec9c3f6aec4e450a84f2469d38ba6c14))
30
+ * **form:** enable autoresize for textarea questions ([428820f](https://github.com/projectcaluma/ember-caluma/commit/428820f2bdf842ebeb0393a70c5556ceceab9e4e))
31
+
32
+
33
+ ### BREAKING CHANGES
34
+
35
+ * **core:** The apollo service mixin was removed in favor of
36
+ directly overriding the service. For more information on how to migrate,
37
+ please visit the v11 migration guide.
38
+ * **deps:** Remove support for node v10
@@ -0,0 +1,24 @@
1
+ export function isDescriptor(possibleDesc) {
2
+ const [target, key, desc] = possibleDesc;
3
+
4
+ return (
5
+ possibleDesc.length === 3 &&
6
+ typeof target === "object" &&
7
+ target !== null &&
8
+ typeof key === "string" &&
9
+ typeof desc === "object" &&
10
+ desc !== null &&
11
+ "enumerable" in desc &&
12
+ "configurable" in desc
13
+ );
14
+ }
15
+
16
+ export function createDecorator(fn) {
17
+ return function (...args) {
18
+ if (isDescriptor(args)) {
19
+ return fn(...args);
20
+ }
21
+
22
+ return (...desc) => fn(...desc, ...args);
23
+ };
24
+ }
@@ -0,0 +1,39 @@
1
+ import { inject as service } from "@ember/service";
2
+ import { Ability } from "ember-can";
3
+
4
+ import config from "@projectcaluma/ember-distribution/config";
5
+
6
+ export default class InquiryAbility extends Ability {
7
+ @service calumaOptions;
8
+
9
+ @config config;
10
+
11
+ get canEdit() {
12
+ return (
13
+ this.model?.task.slug === this.config.inquiry.task &&
14
+ this.model?.status === "SUSPENDED" &&
15
+ this.model?.controllingGroups
16
+ .map(String)
17
+ .includes(String(this.calumaOptions.currentGroupId))
18
+ );
19
+ }
20
+
21
+ get canAnswer() {
22
+ return (
23
+ this.model?.task.slug === this.config.inquiry.task &&
24
+ this.model?.status === "READY" &&
25
+ this.model?.addressedGroups
26
+ .map(String)
27
+ .includes(String(this.calumaOptions.currentGroupId))
28
+ );
29
+ }
30
+
31
+ get canEditAnswerForm() {
32
+ return (
33
+ this.canAnswer &&
34
+ this.model?.childCase.workItems.edges.some(
35
+ (edge) => edge.node.task.__typename === "CompleteWorkflowFormTask"
36
+ )
37
+ );
38
+ }
39
+ }
@@ -0,0 +1,21 @@
1
+ <div class="uk-text-center uk-margin-small-top">
2
+ {{#if this.canCreate}}
3
+ <IconButton @route="distribution.new" @icon="plus" />
4
+ {{/if}}
5
+ <IconButton
6
+ @icon="paper-plane-outline"
7
+ @fromSvgJar={{true}}
8
+ @gutterTop={{4}}
9
+ @gutterRight={{6}}
10
+ @gutterLeft={{4}}
11
+ @gutterBottom={{4}}
12
+ @onClick={{this.noop}}
13
+ />
14
+ {{#if this.canComplete}}
15
+ <IconButton
16
+ @icon="lock-closed-outline"
17
+ @fromSvgJar={{true}}
18
+ @onClick={{this.noop}}
19
+ />
20
+ {{/if}}
21
+ </div>
@@ -0,0 +1,45 @@
1
+ import { action } from "@ember/object";
2
+ import { inject as service } from "@ember/service";
3
+ import Component from "@glimmer/component";
4
+ import { queryManager } from "ember-apollo-client";
5
+ import { dropTask } from "ember-concurrency";
6
+ import { useTask } from "ember-resources";
7
+
8
+ import config from "@projectcaluma/ember-distribution/config";
9
+ import controlWorkItemsQuery from "@projectcaluma/ember-distribution/gql/queries/control-work-items.graphql";
10
+
11
+ export default class DistributionNavigationControlsComponent extends Component {
12
+ @service calumaOptions;
13
+
14
+ @queryManager apollo;
15
+
16
+ @config config;
17
+
18
+ workItems = useTask(this, this.fetchWorkItems, () => []);
19
+
20
+ get canCreate() {
21
+ return this.workItems.value?.create.edges.length > 0;
22
+ }
23
+
24
+ get canComplete() {
25
+ return this.workItems.value?.complete.edges.length > 0;
26
+ }
27
+
28
+ @action
29
+ noop(e) {
30
+ e.preventDefault();
31
+ }
32
+
33
+ @dropTask
34
+ *fetchWorkItems() {
35
+ return yield this.apollo.watchQuery({
36
+ query: controlWorkItemsQuery,
37
+ variables: {
38
+ caseId: this.args.caseId,
39
+ currentGroup: String(this.calumaOptions.currentGroupId),
40
+ createTask: this.config.controls.createTask,
41
+ completeTask: this.config.controls.completeTask,
42
+ },
43
+ });
44
+ }
45
+ }
@@ -0,0 +1,18 @@
1
+ <li class={{if this.isActive "uk-active"}}>
2
+ <LinkTo @route="distribution.inquiry" @model={{this.model}}>
3
+ <div class="uk-flex uk-flex-middle uk-width-1-1">
4
+ <div class="uk-width-expand uk-text-truncate">
5
+ {{#if (eq @type "addressed")}}
6
+ {{group-name @inquiry.controllingGroups}}
7
+ {{else}}
8
+ {{group-name @inquiry.addressedGroups}}
9
+ {{/if}}
10
+ </div>
11
+
12
+ <DistributionNavigation::StatusIndicator
13
+ @inquiry={{@inquiry}}
14
+ @type={{@type}}
15
+ />
16
+ </div>
17
+ </LinkTo>
18
+ </li>
@@ -0,0 +1,17 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+
4
+ export default class DistributionNavigationItemComponent extends Component {
5
+ @service router;
6
+
7
+ get model() {
8
+ return {
9
+ from: this.args.inquiry.controllingGroups[0],
10
+ to: this.args.inquiry.addressedGroups[0],
11
+ };
12
+ }
13
+
14
+ get isActive() {
15
+ return this.router.isActive("distribution.inquiry", this.model);
16
+ }
17
+ }
@@ -0,0 +1,24 @@
1
+ <li class="uk-margin-small-bottom">
2
+ <a href="" class="uk-margin-small-bottom" {{on "click" this.toggle}}>
3
+ <span class="uk-width-expand">
4
+ {{t (concat "caluma.distribution.types." @type)}}
5
+ </span>
6
+ {{#if this.expanded}}
7
+ <UkIcon @icon="chevron-down" />
8
+ {{else}}
9
+ <UkIcon @icon="chevron-right" />
10
+ {{/if}}
11
+ </a>
12
+
13
+ {{#if (and @inquiries.length this.expanded)}}
14
+ <ul class="uk-tab uk-tab-left uk-margin-left">
15
+ {{#each this.inquiries as |inquiry|}}
16
+ <DistributionNavigation::Item @inquiry={{inquiry}} @type={{@type}} />
17
+ {{/each}}
18
+ </ul>
19
+
20
+ {{#if (eq @type "controlling")}}
21
+ <DistributionNavigation::Controls @caseId={{@caseId}} />
22
+ {{/if}}
23
+ {{/if}}
24
+ </li>
@@ -0,0 +1,25 @@
1
+ import { action } from "@ember/object";
2
+ import Component from "@glimmer/component";
3
+ import { tracked } from "@glimmer/tracking";
4
+
5
+ export default class DistributionNavigationSectionComponent extends Component {
6
+ @tracked expanded = true;
7
+
8
+ @action
9
+ toggle(e) {
10
+ e.preventDefault();
11
+
12
+ this.expanded = !this.expanded;
13
+ }
14
+
15
+ get inquiries() {
16
+ const sortProperty =
17
+ this.args.type === "addressed"
18
+ ? "controllingGroupName"
19
+ : "addressedGroupName";
20
+
21
+ return this.args.inquiries.sort((a, b) =>
22
+ a[sortProperty].localeCompare(b[sortProperty])
23
+ );
24
+ }
25
+ }
@@ -0,0 +1,17 @@
1
+ {{#if this.showDeadlineIndicator}}
2
+ <div
3
+ class="deadline-indicator uk-flex-uk-flex-middle uk-flex-center uk-margin-small-left uk-text-{{this.deadline.color}}"
4
+ >
5
+ {{svg-jar
6
+ "notifications-outline"
7
+ height=16
8
+ title=(format-date this.deadline.value)
9
+ }}
10
+ </div>
11
+ {{/if}}
12
+
13
+ <div
14
+ class="status-indicator uk-flex uk-flex-middle uk-flex-center uk-margin-small-left uk-text-{{this.status.color}}"
15
+ >
16
+ {{svg-jar this.status.icon title=this.status.label}}
17
+ </div>
@@ -0,0 +1,19 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+
4
+ import config from "@projectcaluma/ember-distribution/config";
5
+ import inquiryDeadline from "@projectcaluma/ember-distribution/utils/inquiry-deadline";
6
+ import inquiryStatus from "@projectcaluma/ember-distribution/utils/inquiry-status";
7
+
8
+ export default class DistributionNavigationStatusIndicatorComponent extends Component {
9
+ @service intl;
10
+
11
+ @config config;
12
+
13
+ @inquiryStatus status;
14
+ @inquiryDeadline deadline;
15
+
16
+ get showDeadlineIndicator() {
17
+ return this.deadline.isOverdue || this.deadline.isWarning;
18
+ }
19
+ }
@@ -0,0 +1,17 @@
1
+ <aside>
2
+ <ul class="uk-tab uk-tab-left">
3
+ <DistributionNavigation::Section
4
+ @type="controlling"
5
+ @inquiries={{this.inquiries.controlling}}
6
+ @caseId={{@caseId}}
7
+ />
8
+ <DistributionNavigation::Section
9
+ @type="addressed"
10
+ @inquiries={{this.inquiries.addressed}}
11
+ />
12
+ <DistributionNavigation::Section
13
+ @type="more"
14
+ @inquiries={{this.inquiries.more}}
15
+ />
16
+ </ul>
17
+ </aside>
@@ -0,0 +1,81 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+ import { tracked } from "@glimmer/tracking";
4
+ import { queryManager } from "ember-apollo-client";
5
+ import { restartableTask } from "ember-concurrency";
6
+ import { useTask } from "ember-resources";
7
+
8
+ import config from "@projectcaluma/ember-distribution/config";
9
+ import inquiryNavigationQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-navigation.graphql";
10
+ import uniqueByGroups from "@projectcaluma/ember-distribution/utils/unique-by-groups";
11
+
12
+ export default class DistributionNavigationComponent extends Component {
13
+ @service calumaOptions;
14
+ @service("-scheduler") scheduler;
15
+
16
+ @config config;
17
+
18
+ @queryManager apollo;
19
+
20
+ @tracked groups = [];
21
+
22
+ get inquiries() {
23
+ const findGroupName = (ids) =>
24
+ this.groups.find((g) =>
25
+ ids.includes(g[this.calumaOptions.groupIdentifierProperty])
26
+ )?.[this.calumaOptions.groupNameProperty];
27
+
28
+ return Object.entries(this._inquiries.value || []).reduce(
29
+ (inquiries, [key, objects]) => {
30
+ return {
31
+ ...inquiries,
32
+ [key]: uniqueByGroups(
33
+ objects.edges.map((edge) => ({
34
+ ...edge.node,
35
+ addressedGroupName: findGroupName(edge.node.addressedGroups),
36
+ controllingGroupName: findGroupName(edge.node.controllingGroups),
37
+ }))
38
+ ),
39
+ };
40
+ },
41
+ {}
42
+ );
43
+ }
44
+
45
+ _inquiries = useTask(this, this.fetchInquiries, () => [
46
+ this.args.caseId,
47
+ this.config,
48
+ ]);
49
+
50
+ @restartableTask
51
+ *fetchInquiries() {
52
+ const response = yield this.apollo.watchQuery({
53
+ query: inquiryNavigationQuery,
54
+ variables: {
55
+ caseId: this.args.caseId,
56
+ task: this.config.inquiry.task,
57
+ currentGroup: String(this.calumaOptions.currentGroupId),
58
+ statusQuestion: this.config.inquiry.answer.statusQuestion,
59
+ deadlineQuestion: this.config.inquiry.deadlineQuestion,
60
+ includeNavigationData: true,
61
+ },
62
+ });
63
+
64
+ const groupIds = [
65
+ ...new Set(
66
+ Object.values(response)
67
+ .map((inquiries) => {
68
+ return inquiries.edges.map((edge) => [
69
+ ...edge.node.addressedGroups,
70
+ ...edge.node.controllingGroups,
71
+ ]);
72
+ })
73
+ .flat(2)
74
+ ),
75
+ ];
76
+
77
+ this.groups = yield this.scheduler.resolve(groupIds, "group");
78
+
79
+ return response;
80
+ }
81
+ }
@@ -0,0 +1,20 @@
1
+ {{#if @route}}
2
+ <LinkTo
3
+ @route={{@route}}
4
+ class={{this.class}}
5
+ uk-icon={{unless @fromSvgJar @icon}}
6
+ ...attributes
7
+ >
8
+ {{#if @fromSvgJar}}{{svg-jar @icon width="20" height="20"}}{{/if}}
9
+ </LinkTo>
10
+ {{else}}
11
+ <button
12
+ type="button"
13
+ class={{this.class}}
14
+ uk-icon={{unless @fromSvgJar @icon}}
15
+ ...attributes
16
+ {{on "click" @onClick}}
17
+ >
18
+ {{#if @fromSvgJar}}{{svg-jar @icon width="20" height="20"}}{{/if}}
19
+ </button>
20
+ {{/if}}
@@ -0,0 +1,22 @@
1
+ import { dasherize } from "@ember/string";
2
+ import Component from "@glimmer/component";
3
+
4
+ export default class IconButtonComponent extends Component {
5
+ get class() {
6
+ const gutters = [
7
+ "gutter",
8
+ "gutterTop",
9
+ "gutterRight",
10
+ "gutterBottom",
11
+ "gutterLeft",
12
+ ]
13
+ .map((arg) =>
14
+ this.args[arg]
15
+ ? `uk-icon-button--${dasherize(arg)}-${this.args[arg]}`
16
+ : null
17
+ )
18
+ .filter(Boolean);
19
+
20
+ return ["uk-icon-button", ...gutters].join(" ");
21
+ }
22
+ }
@@ -0,0 +1,46 @@
1
+ <CfContent
2
+ @documentId={{decode-id this.inquiry.childCase.document.id}}
3
+ @disabled={{cannot "edit answer form of inquiry" this.inquiry}}
4
+ @loading={{this._inquiry.isRunning}}
5
+ as |content|
6
+ >
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>
16
+
17
+ <content.form />
18
+
19
+ {{#each this.buttons as |buttonConfig|}}
20
+ {{#if buttonConfig.isFormButton}}
21
+ <DocumentValidity @document={{content.document}} as |isValid validate|>
22
+ <UkButton
23
+ @type="submit"
24
+ @color={{buttonConfig.color}}
25
+ @disabled={{or (not isValid) this.completeWorkItem.isRunning}}
26
+ @on-click={{fn
27
+ (perform this.completeWorkItem)
28
+ buttonConfig.workItemId
29
+ validate
30
+ }}
31
+ >{{buttonConfig.label}}</UkButton>
32
+ </DocumentValidity>
33
+ {{else}}
34
+ <UkButton
35
+ @type="button"
36
+ @color={{buttonConfig.color}}
37
+ @disabled={{this.completeWorkItem.isRunning}}
38
+ @on-click={{fn
39
+ (perform this.completeWorkItem)
40
+ buttonConfig.workItemId
41
+ null
42
+ }}
43
+ >{{buttonConfig.label}}</UkButton>
44
+ {{/if}}
45
+ {{/each}}
46
+ </CfContent>
@@ -0,0 +1,75 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+ import { queryManager } from "ember-apollo-client";
4
+ import { dropTask } from "ember-concurrency";
5
+ import { useTask } from "ember-resources";
6
+
7
+ import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
8
+ import config from "@projectcaluma/ember-distribution/config";
9
+ import completeInquiryWorkItemMutation from "@projectcaluma/ember-distribution/gql/mutations/complete-inquiry-work-item.graphql";
10
+ import inquiryAnswerQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-answer.graphql";
11
+
12
+ export default class InquiryAnswerFormComponent extends Component {
13
+ @service intl;
14
+ @service router;
15
+ @service notification;
16
+
17
+ @config config;
18
+
19
+ @queryManager apollo;
20
+
21
+ _inquiry = useTask(this, this.fetchInquiryAnswer, () => [this.args.inquiry]);
22
+
23
+ get inquiry() {
24
+ return this._inquiry.value?.[0]?.node;
25
+ }
26
+
27
+ get buttons() {
28
+ return this.inquiry?.childCase.workItems.edges.map((edge) => {
29
+ const config = this.config.inquiry.answer.buttons[edge.node.task.slug];
30
+
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
+ }
39
+
40
+ @dropTask
41
+ *fetchInquiryAnswer() {
42
+ return yield this.apollo.watchQuery(
43
+ {
44
+ query: inquiryAnswerQuery,
45
+ variables: {
46
+ inquiry: this.args.inquiry,
47
+ buttonTasks: Object.keys(this.config.inquiry.answer.buttons),
48
+ },
49
+ },
50
+ "allWorkItems.edges"
51
+ );
52
+ }
53
+
54
+ @dropTask
55
+ *completeWorkItem(workItem, validate = () => true) {
56
+ try {
57
+ if (typeof validate === "function" && !(yield validate())) return;
58
+
59
+ yield this.apollo.mutate({
60
+ mutation: completeInquiryWorkItemMutation,
61
+ variables: {
62
+ workItem,
63
+ statusQuestion: this.config.inquiry.answer.statusQuestion,
64
+ buttonTasks: Object.keys(this.config.inquiry.answer.buttons),
65
+ },
66
+ });
67
+
68
+ yield this.router.transitionTo("distribution.inquiry.index");
69
+ } catch (error) {
70
+ this.notification.danger(
71
+ this.intl.t("caluma.distribution.answer.complete-error")
72
+ );
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,6 @@
1
+ <div
2
+ class="uk-position-top-right uk-margin-medium-top uk-margin-medium-right uk-flex-inline uk-flex-middle uk-text-{{this.deadline.color}}"
3
+ >
4
+ {{svg-jar "alarm-outline" height=26 class="uk-margin-small-right"}}
5
+ {{format-date this.deadline.value}}
6
+ </div>
@@ -0,0 +1,10 @@
1
+ import Component from "@glimmer/component";
2
+
3
+ import config from "@projectcaluma/ember-distribution/config";
4
+ import inquiryDeadline from "@projectcaluma/ember-distribution/utils/inquiry-deadline";
5
+
6
+ export default class InquiryDialogInquiryDeadlineComponent extends Component {
7
+ @config config;
8
+
9
+ @inquiryDeadline deadline;
10
+ }
@@ -0,0 +1,7 @@
1
+ <div
2
+ class="inquiry-divider uk-flex uk-flex-center uk-flex-middle uk-flex-between uk-margin uk-text-{{this.status.color}}"
3
+ >
4
+ <div class="inquiry-divider__icon uk-flex uk-flex-center uk-flex-middle">
5
+ {{svg-jar this.status.icon title=this.status.label}}
6
+ </div>
7
+ </div>
@@ -0,0 +1,13 @@
1
+ import { inject as service } from "@ember/service";
2
+ import Component from "@glimmer/component";
3
+
4
+ import config from "@projectcaluma/ember-distribution/config";
5
+ import inquiryStatus from "@projectcaluma/ember-distribution/utils/inquiry-status";
6
+
7
+ export default class InquiryDialogInquiryDividerComponent extends Component {
8
+ @service intl;
9
+
10
+ @config config;
11
+
12
+ @inquiryStatus status;
13
+ }
@@ -0,0 +1,40 @@
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>
10
+
11
+ <ul class="uk-subnav uk-subnav-divider uk-margin-small-top">
12
+ <li>
13
+ <span>
14
+ {{format-date this.date}}
15
+ {{format-time this.date hour="2-digit" minute="2-digit"}}
16
+ </span>
17
+ </li>
18
+ {{#if (can "edit inquiry" @inquiry)}}
19
+ <li>
20
+ <LinkTo
21
+ @route="distribution.inquiry.detail.index"
22
+ @model={{decode-id @inquiry.id}}
23
+ >
24
+ {{t "caluma.distribution.edit.link"}}
25
+ </LinkTo>
26
+ </li>
27
+ {{/if}}
28
+ {{#if (can "answer inquiry" @inquiry)}}
29
+ <li>
30
+ <LinkTo
31
+ @route="distribution.inquiry.detail.answer"
32
+ @model={{decode-id @inquiry.id}}
33
+ >
34
+ {{t "caluma.distribution.answer.link"}}
35
+ </LinkTo>
36
+ </li>
37
+ {{/if}}
38
+ </ul>
39
+
40
+ <p class="uk-margin-remove-bottom">{{this.info}}</p>
@@ -0,0 +1,20 @@
1
+ import Component from "@glimmer/component";
2
+
3
+ export default class InquiryDialogInquiryPartComponent extends Component {
4
+ get date() {
5
+ const key = this.args.type === "request" ? "createdAt" : "closedAt";
6
+
7
+ return this.args.inquiry[key];
8
+ }
9
+
10
+ get info() {
11
+ const document =
12
+ this.args.type === "request"
13
+ ? this.args.inquiry.document
14
+ : this.args.type === "answer"
15
+ ? this.args.inquiry.childCase.document
16
+ : null;
17
+
18
+ return document.info.edges[0]?.node.value;
19
+ }
20
+ }