@projectcaluma/ember-distribution 11.0.0-beta.30 → 11.0.0-beta.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/addon/abilities/inquiry.js +18 -2
  2. package/addon/components/cd-document-header.hbs +3 -12
  3. package/addon/components/cd-inquiry-answer-form.hbs +136 -76
  4. package/addon/components/cd-inquiry-answer-form.js +20 -2
  5. package/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs +5 -10
  6. package/addon/components/cd-inquiry-dialog/inquiry-deadline.js +14 -0
  7. package/addon/components/cd-inquiry-dialog/inquiry-part.hbs +118 -89
  8. package/addon/components/cd-inquiry-dialog.js +11 -15
  9. package/addon/components/cd-inquiry-edit-form.hbs +0 -3
  10. package/addon/components/cd-inquiry-edit-form.js +2 -2
  11. package/addon/components/cd-inquiry-new-form/bulk-edit.js +9 -6
  12. package/addon/components/cd-navigation/section.hbs +1 -1
  13. package/addon/components/cd-navigation/section.js +5 -13
  14. package/addon/components/cd-navigation.hbs +3 -10
  15. package/addon/config.js +17 -0
  16. package/addon/gql/fragments/inquiry-answer.graphql +57 -0
  17. package/addon/gql/fragments/inquiry-request.graphql +26 -0
  18. package/addon/gql/mutations/complete-inquiry-work-item.graphql +24 -13
  19. package/addon/gql/mutations/reopen-inquiry.graphql +3 -13
  20. package/addon/gql/queries/{control-work-items.graphql → controls.graphql} +1 -1
  21. package/addon/gql/queries/incomplete-inquiries.graphql +1 -1
  22. package/addon/gql/queries/inquiry-answer.graphql +5 -1
  23. package/addon/gql/queries/inquiry-dialog.graphql +31 -2
  24. package/addon/gql/queries/inquiry-form.graphql +1 -1
  25. package/addon/gql/queries/{inquiry-navigation.graphql → navigation.graphql} +24 -6
  26. package/addon/routes/application.js +7 -0
  27. package/addon/routes/index.js +15 -28
  28. package/addon/routes/inquiry/index.js +1 -4
  29. package/addon/routes/new.js +1 -5
  30. package/addon/services/distribution.js +71 -9
  31. package/addon/templates/application.hbs +1 -1
  32. package/addon/templates/inquiry/index.hbs +1 -5
  33. package/addon/templates/new.hbs +0 -1
  34. package/addon/utils/inquiry-deadline.js +3 -1
  35. package/app/styles/_answer-form.scss +4 -0
  36. package/package.json +10 -10
  37. package/translations/de.yaml +10 -1
  38. package/translations/en.yaml +11 -2
  39. package/translations/fr.yaml +10 -1
  40. package/addon/components/cd-navigation.js +0 -53
  41. package/addon/gql/fragments/inquiry.graphql +0 -117
  42. package/addon/modifiers/pikaday.js +0 -2
@@ -1,14 +1,17 @@
1
- import { getOwner } from "@ember/application";
2
1
  import Service, { inject as service } from "@ember/service";
2
+ import { tracked } from "@glimmer/tracking";
3
3
  import { queryManager, getObservable } from "ember-apollo-client";
4
4
  import { dropTask } from "ember-concurrency";
5
5
  import { trackedTask } from "ember-resources/util/ember-concurrency";
6
+ import { cached } from "tracked-toolbox";
6
7
 
7
8
  import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
8
9
  import config from "@projectcaluma/ember-distribution/config";
9
10
  import createInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/create-inquiry.graphql";
10
- import controlWorkItemsQuery from "@projectcaluma/ember-distribution/gql/queries/control-work-items.graphql";
11
- import inquiryNavigationQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-navigation.graphql";
11
+ import controlsQuery from "@projectcaluma/ember-distribution/gql/queries/controls.graphql";
12
+ import inquiryDialogQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-dialog.graphql";
13
+ import navigationQuery from "@projectcaluma/ember-distribution/gql/queries/navigation.graphql";
14
+ import uniqueByGroups from "@projectcaluma/ember-distribution/utils/unique-by-groups";
12
15
 
13
16
  export default class DistributionService extends Service {
14
17
  @service("-scheduler") scheduler;
@@ -21,9 +24,7 @@ export default class DistributionService extends Service {
21
24
 
22
25
  @config config;
23
26
 
24
- get caseId() {
25
- return getOwner(this).lookup("route:application").currentModel;
26
- }
27
+ @tracked caseId;
27
28
 
28
29
  get hasInquiries() {
29
30
  return (
@@ -52,7 +53,7 @@ export default class DistributionService extends Service {
52
53
  @dropTask
53
54
  *fetchControls(caseId) {
54
55
  return yield this.apollo.watchQuery({
55
- query: controlWorkItemsQuery,
56
+ query: controlsQuery,
56
57
  variables: {
57
58
  caseId,
58
59
  currentGroup: String(this.calumaOptions.currentGroupId),
@@ -67,14 +68,13 @@ export default class DistributionService extends Service {
67
68
  @dropTask
68
69
  *fetchNavigation(caseId) {
69
70
  const response = yield this.apollo.watchQuery({
70
- query: inquiryNavigationQuery,
71
+ query: navigationQuery,
71
72
  variables: {
72
73
  caseId,
73
74
  task: this.config.inquiry.task,
74
75
  currentGroup: String(this.calumaOptions.currentGroupId),
75
76
  statusQuestion: this.config.inquiry.answer.statusQuestion,
76
77
  deadlineQuestion: this.config.inquiry.deadlineQuestion,
77
- includeNavigationData: true,
78
78
  },
79
79
  });
80
80
 
@@ -107,6 +107,22 @@ export default class DistributionService extends Service {
107
107
  // get create inquiry work item to complete
108
108
  const createId = decodeId(this.controls.value?.create.edges[0].node.id);
109
109
 
110
+ // refetch dialog queries of the groups that will have a new inquiry
111
+ const refetchQueries = groups.map((group) => ({
112
+ query: inquiryDialogQuery,
113
+ variables: {
114
+ from: String(this.calumaOptions.currentGroupId),
115
+ to: String(group),
116
+ caseId: this.caseId,
117
+ task: this.config.inquiry.task,
118
+ infoQuestion: this.config.inquiry.infoQuestion,
119
+ deadlineQuestion: this.config.inquiry.deadlineQuestion,
120
+ statusQuestion: this.config.inquiry.answer.statusQuestion,
121
+ answerInfoQuestions: this.config.inquiry.answer.infoQuestions,
122
+ buttonTasks: Object.keys(this.config.inquiry.answer.buttons),
123
+ },
124
+ }));
125
+
110
126
  // create new inquiries
111
127
  yield this.apollo.mutate({
112
128
  mutation: createInquiryMutation,
@@ -117,6 +133,7 @@ export default class DistributionService extends Service {
117
133
  addressed_groups: groups.map(String),
118
134
  }),
119
135
  },
136
+ refetchQueries,
120
137
  });
121
138
 
122
139
  // refetch navigation and controls data
@@ -127,4 +144,49 @@ export default class DistributionService extends Service {
127
144
  );
128
145
  }
129
146
  }
147
+
148
+ @cached
149
+ get inquiries() {
150
+ const findGroupName = (identifiers) => {
151
+ const group = this.scheduler.groupCache.find((group) =>
152
+ identifiers
153
+ .map(String)
154
+ .includes(String(group[this.calumaOptions.groupIdentifierProperty]))
155
+ );
156
+
157
+ return group?.[this.calumaOptions.groupNameProperty] ?? "";
158
+ };
159
+
160
+ return Object.entries(this.navigation.value ?? {}).reduce(
161
+ (inquiries, [key, objects]) => {
162
+ return {
163
+ ...inquiries,
164
+ // Don't return any data until the internal scheduler has cached
165
+ // groups since we don't want to render empty navigation items
166
+ [key]: this.scheduler.groupCache.length
167
+ ? uniqueByGroups(
168
+ objects.edges.map((edge) => ({
169
+ ...edge.node,
170
+ // Populate the work item with the names of the involved
171
+ // groups so the <DistributionNavigation::Section /> component
172
+ // can sort by them
173
+ addressedGroupName: findGroupName(edge.node.addressedGroups),
174
+ controllingGroupName: findGroupName(
175
+ edge.node.controllingGroups
176
+ ),
177
+ }))
178
+ ).sort((a, b) => {
179
+ const sortProperty =
180
+ key === "addressed"
181
+ ? "controllingGroupName"
182
+ : "addressedGroupName";
183
+
184
+ return a[sortProperty].localeCompare(b[sortProperty]);
185
+ })
186
+ : [],
187
+ };
188
+ },
189
+ {}
190
+ );
191
+ }
130
192
  }
@@ -10,7 +10,7 @@
10
10
  <div uk-grid class={{if this.config.ui.stack "uk-grid-small"}}>
11
11
  {{#if this.distribution.hasInquiries}}
12
12
  <div class={{if this.config.ui.stack "uk-width-1-1" "uk-width-1-3"}}>
13
- <CdNavigation @caseId={{@model}} />
13
+ <CdNavigation />
14
14
  </div>
15
15
  {{#if this.config.ui.stack}}<div class="uk-width-1-1"><hr /></div>{{/if}}
16
16
  {{/if}}
@@ -1,5 +1 @@
1
- <CdInquiryDialog
2
- @from={{@model.from}}
3
- @to={{@model.to}}
4
- @caseId={{@model.case}}
5
- />
1
+ <CdInquiryDialog @from={{@model.from}} @to={{@model.to}} />
@@ -1,7 +1,6 @@
1
1
  <CdInquiryNewForm
2
2
  @selectedTypes={{this.selectedTypes}}
3
3
  @search={{this.search}}
4
- @caseId={{@model}}
5
4
  @onChangeSelectedTypes={{fn (mut this.selectedTypes)}}
6
5
  @onChangeSearch={{fn (mut this.search)}}
7
6
  />
@@ -19,7 +19,9 @@ function decorator(
19
19
  get() {
20
20
  const inquiry = get(this, inquiryProperty);
21
21
  const value = inquiry.document?.deadline.edges[0]?.node.value;
22
- const isDone = ["COMPLETED", "SKIPPED"].includes(inquiry.status);
22
+ const isDone = ["COMPLETED", "SKIPPED", "CANCELED"].includes(
23
+ inquiry.status
24
+ );
23
25
 
24
26
  const diff = DateTime.fromISO(value).diffNow("days").days;
25
27
 
@@ -2,3 +2,7 @@
2
2
  border-left: 5px solid $global-border;
3
3
  padding-left: $global-gutter - 5px;
4
4
  }
5
+
6
+ .inquiry-answer-form__side-bar {
7
+ max-width: 25%;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-distribution",
3
- "version": "11.0.0-beta.30",
3
+ "version": "11.0.0-beta.32",
4
4
  "description": "Ember engine for the Caluma distribution module.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -10,7 +10,7 @@
10
10
  "homepage": "https://docs.caluma.io/ember-caluma",
11
11
  "repository": "github:projectcaluma/ember-caluma",
12
12
  "scripts": {
13
- "test": "npm-run-all test:*",
13
+ "test": "npm-run-all --print-name \"lint\" \"test:*\"",
14
14
  "test:ember": "ember test",
15
15
  "test:ember-compatibility": "ember try:each"
16
16
  },
@@ -23,9 +23,9 @@
23
23
  "@embroider/macros": "^1.9.0",
24
24
  "@glimmer/component": "^1.1.2",
25
25
  "@glimmer/tracking": "^1.1.2",
26
- "@projectcaluma/ember-core": "^11.0.0-beta.30",
27
- "@projectcaluma/ember-form": "^11.0.0-beta.30",
28
- "@projectcaluma/ember-workflow": "^11.0.0-beta.30",
26
+ "@projectcaluma/ember-core": "^11.0.0-beta.32",
27
+ "@projectcaluma/ember-form": "^11.0.0-beta.32",
28
+ "@projectcaluma/ember-workflow": "^11.0.0-beta.32",
29
29
  "ember-apollo-client": "~4.0.2",
30
30
  "ember-auto-import": "^2.4.3",
31
31
  "ember-can": "^4.2.0",
@@ -34,10 +34,10 @@
34
34
  "ember-concurrency": "^2.3.7",
35
35
  "ember-engines-router-service": "^0.3.0",
36
36
  "ember-fetch": "^8.1.2",
37
+ "ember-flatpickr": "^3.2.3",
37
38
  "ember-intl": "^5.7.2",
38
- "ember-pikaday": "^4.0.0",
39
39
  "ember-resources": "^5.4.0",
40
- "ember-svg-jar": "^2.4.0",
40
+ "ember-svg-jar": "^2.4.1",
41
41
  "ember-test-selectors": "^6.0.0",
42
42
  "ember-uikit": "^6.1.0",
43
43
  "graphql": "^15.8.0",
@@ -51,9 +51,9 @@
51
51
  "@ember/test-helpers": "2.7.0",
52
52
  "@embroider/test-setup": "1.8.3",
53
53
  "@faker-js/faker": "7.6.0",
54
- "@projectcaluma/ember-testing": "11.0.0-beta.30",
54
+ "@projectcaluma/ember-testing": "11.0.0-beta.32",
55
55
  "broccoli-asset-rev": "3.0.0",
56
- "ember-cli": "4.7.0",
56
+ "ember-cli": "4.8.0",
57
57
  "ember-cli-code-coverage": "1.0.3",
58
58
  "ember-cli-dependency-checker": "3.3.1",
59
59
  "ember-cli-inject-live-reload": "2.1.0",
@@ -78,7 +78,7 @@
78
78
  "webpack": "5.74.0"
79
79
  },
80
80
  "engines": {
81
- "node": "14.* || >= 16"
81
+ "node": "14.* || 16.* || >= 18"
82
82
  },
83
83
  "ember": {
84
84
  "edition": "octane"
@@ -29,12 +29,17 @@ caluma:
29
29
  more: "mehr"
30
30
  less: "weniger"
31
31
 
32
- last-modified: "Zuletzt bearbeitet von {user} am {date} um {time}"
33
32
  details: "Details"
34
33
  not-allowed-hint:
35
34
  "Sie können jedoch das Formular bearbeiten und die Eingabedaten werden
36
35
  automatisch gespeichert."
37
36
 
37
+ inquiry:
38
+ created-at: "Erstellt am"
39
+ closed-at: "Beantwortet am"
40
+ deadline: "Frist"
41
+ assigned-user: "Verantwortliche Person"
42
+
38
43
  edit:
39
44
  link: "Bearbeiten"
40
45
  send: "Aktuelle Anfrage versenden"
@@ -64,6 +69,10 @@ caluma:
64
69
  revise:
65
70
  label: "Überarbeiten"
66
71
 
72
+ details:
73
+ show: "Details anzeigen"
74
+ hide: "Details verstecken"
75
+
67
76
  new:
68
77
  title: "Neue Anfrage"
69
78
  search: "Suchen..."
@@ -8,7 +8,7 @@ caluma:
8
8
  reopen: "Reopen circulation"
9
9
  check-inquiries: "Mark inquiries as checked"
10
10
  send-confirm:
11
- "Do you really want to send <b>{other, plural, =1 {one pending inquiry}
11
+ "Do you really want to send <b>{count, plural, =1 {one pending inquiry}
12
12
  other {{count} pending inquiries}}</b>?"
13
13
  complete-confirm:
14
14
  "There {count, plural, =1 {is <b>one pending inquiry} other {are
@@ -29,12 +29,17 @@ caluma:
29
29
  more: "more"
30
30
  less: "less"
31
31
 
32
- last-modified: "Last modified by {user} on {date} at {time}"
33
32
  details: "Details"
34
33
  not-allowed-hint:
35
34
  "However, you can edit the form and the input will be saved
36
35
  automatically."
37
36
 
37
+ inquiry:
38
+ created-at: "Created at"
39
+ closed-at: "Answered at"
40
+ deadline: "Deadline"
41
+ assigned-user: "Assigned user"
42
+
38
43
  edit:
39
44
  link: "Edit"
40
45
  send: "Send current inquiry"
@@ -64,6 +69,10 @@ caluma:
64
69
  revise:
65
70
  label: "Revise"
66
71
 
72
+ details:
73
+ show: "Show details"
74
+ hide: "Hide details"
75
+
67
76
  new:
68
77
  title: "New inquiry"
69
78
  search: "Search..."
@@ -29,12 +29,17 @@ caluma:
29
29
  more: "plus"
30
30
  less: "moins"
31
31
 
32
- last-modified: "Dernière modification par {user} le {date} à {time}"
33
32
  details: "Détails"
34
33
  not-allowed-hint:
35
34
  "Vous pouvez toutefois modifier le formulaire et les données seront
36
35
  automatiquement enregistrées."
37
36
 
37
+ inquiry:
38
+ created-at: "Créé le"
39
+ closed-at: "Répondu le"
40
+ deadline: "Délai"
41
+ assigned-user: "Personne responsable"
42
+
38
43
  edit:
39
44
  link: "Modifier"
40
45
  send: "Envoyer la demande actuelle"
@@ -64,6 +69,10 @@ caluma:
64
69
  revise:
65
70
  label: "Réviser"
66
71
 
72
+ details:
73
+ show: "Afficher les détails"
74
+ hide: "Cacher les détails"
75
+
67
76
  new:
68
77
  title: "Nouvelle demande"
69
78
  search: "Chercher..."
@@ -1,53 +0,0 @@
1
- import { inject as service } from "@ember/service";
2
- import Component from "@glimmer/component";
3
- import { queryManager } from "ember-apollo-client";
4
-
5
- import config from "@projectcaluma/ember-distribution/config";
6
- import uniqueByGroups from "@projectcaluma/ember-distribution/utils/unique-by-groups";
7
-
8
- export default class CdNavigationComponent extends Component {
9
- @service("-scheduler") scheduler;
10
- @service calumaOptions;
11
- @service distribution;
12
-
13
- @config config;
14
-
15
- @queryManager apollo;
16
-
17
- get inquiries() {
18
- const findGroupName = (identifiers) => {
19
- const group = this.scheduler.groupCache.find((group) =>
20
- identifiers
21
- .map(String)
22
- .includes(String(group[this.calumaOptions.groupIdentifierProperty]))
23
- );
24
-
25
- return group?.[this.calumaOptions.groupNameProperty] ?? "";
26
- };
27
-
28
- return Object.entries(this.distribution.navigation.value ?? {}).reduce(
29
- (inquiries, [key, objects]) => {
30
- return {
31
- ...inquiries,
32
- // Don't return any data until the internal scheduler has cached
33
- // groups since we don't want to render empty navigation items
34
- [key]: this.scheduler.groupCache.length
35
- ? uniqueByGroups(
36
- objects.edges.map((edge) => ({
37
- ...edge.node,
38
- // Populate the work item with the names of the involved
39
- // groups so the <DistributionNavigation::Section /> component
40
- // can sort by them
41
- addressedGroupName: findGroupName(edge.node.addressedGroups),
42
- controllingGroupName: findGroupName(
43
- edge.node.controllingGroups
44
- ),
45
- }))
46
- )
47
- : [],
48
- };
49
- },
50
- {}
51
- );
52
- }
53
- }
@@ -1,117 +0,0 @@
1
- fragment InquiryAnswerButtons on Case {
2
- workItems(filter: [{ tasks: $buttonTasks }, { status: READY }]) {
3
- edges {
4
- node {
5
- id
6
- status
7
- task {
8
- id
9
- slug
10
- }
11
- }
12
- }
13
- }
14
- }
15
-
16
- fragment InquiryDeadlineDocument on Document {
17
- id
18
- deadline: answers(filter: [{ question: $deadlineQuestion }]) {
19
- edges {
20
- node {
21
- id
22
- ... on DateAnswer {
23
- value
24
- }
25
- }
26
- }
27
- }
28
- }
29
-
30
- fragment InquiryStatusDocument on Document {
31
- id
32
- status: answers(filter: [{ question: $statusQuestion }]) {
33
- edges {
34
- node {
35
- id
36
- ... on StringAnswer {
37
- value
38
- selectedOption {
39
- slug
40
- label
41
- }
42
- }
43
- }
44
- }
45
- }
46
- }
47
-
48
- fragment InquiryRequest on Document {
49
- id
50
- ...InquiryDeadlineDocument
51
- info: answers(filter: [{ question: $infoQuestion }]) {
52
- edges {
53
- node {
54
- id
55
- ... on StringAnswer {
56
- value
57
- }
58
- }
59
- }
60
- }
61
- }
62
-
63
- fragment InquiryDialog on WorkItem {
64
- id
65
- addressedGroups
66
- controllingGroups
67
- createdAt
68
- closedAt
69
- status
70
- isRedoable
71
- task {
72
- id
73
- slug
74
- }
75
- meta
76
- document {
77
- ...InquiryRequest
78
- }
79
- childCase {
80
- id
81
- ...InquiryAnswerButtons
82
- document {
83
- ...InquiryStatusDocument
84
- info: answers(filter: [{ questions: $answerInfoQuestions }]) {
85
- edges {
86
- node {
87
- id
88
- question {
89
- id
90
- label
91
- slug
92
- }
93
- ... on StringAnswer {
94
- value
95
- }
96
- }
97
- }
98
- }
99
- }
100
- }
101
- }
102
-
103
- fragment Inquiry on WorkItem {
104
- id
105
- status
106
- addressedGroups
107
- controllingGroups
108
- document @include(if: $includeNavigationData) {
109
- ...InquiryDeadlineDocument
110
- }
111
- childCase @include(if: $includeNavigationData) {
112
- id
113
- document {
114
- ...InquiryStatusDocument
115
- }
116
- }
117
- }
@@ -1,2 +0,0 @@
1
- import "ember-pikaday/pikaday.css";
2
- export { default } from "ember-pikaday/modifiers/pikaday";