@projectcaluma/ember-distribution 1.0.0-beta.4 → 1.0.0-beta.7
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +34 -0
- package/addon/abilities/distribution.js +8 -6
- package/addon/components/cd-icon-button.hbs +27 -0
- package/addon/components/{icon-button.js → cd-icon-button.js} +1 -1
- package/addon/components/{inquiry-answer-form.hbs → cd-inquiry-answer-form.hbs} +1 -1
- package/addon/components/{inquiry-answer-form.js → cd-inquiry-answer-form.js} +1 -1
- package/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs +28 -0
- package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +5 -1
- package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.hbs +2 -1
- package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.js +1 -1
- package/addon/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-part.hbs +16 -2
- package/addon/components/cd-inquiry-dialog/inquiry-part.js +59 -0
- package/addon/components/cd-inquiry-dialog/inquiry.hbs +16 -0
- package/addon/components/cd-inquiry-dialog/inquiry.js +11 -0
- package/addon/components/{inquiry-dialog.hbs → cd-inquiry-dialog.hbs} +2 -2
- package/addon/components/cd-inquiry-dialog.js +65 -0
- package/addon/components/{inquiry-edit-form.hbs → cd-inquiry-edit-form.hbs} +1 -1
- package/addon/components/{inquiry-edit-form.js → cd-inquiry-edit-form.js} +2 -1
- package/addon/components/{inquiry-new-form.hbs → cd-inquiry-new-form.hbs} +3 -3
- package/addon/components/{inquiry-new-form.js → cd-inquiry-new-form.js} +20 -28
- package/addon/components/{distribution-navigation → cd-navigation}/controls.hbs +10 -5
- package/addon/components/cd-navigation/controls.js +95 -0
- package/addon/components/{distribution-navigation → cd-navigation}/item.hbs +3 -6
- package/addon/components/{distribution-navigation → cd-navigation}/item.js +1 -1
- package/addon/components/{distribution-navigation → cd-navigation}/section.hbs +2 -2
- package/addon/components/{distribution-navigation → cd-navigation}/section.js +1 -1
- package/addon/components/{distribution-navigation → cd-navigation}/status-indicator.hbs +2 -1
- package/addon/components/{distribution-navigation → cd-navigation}/status-indicator.js +1 -1
- package/addon/components/{distribution-navigation.hbs → cd-navigation.hbs} +3 -6
- package/addon/components/cd-navigation.js +53 -0
- package/addon/components/{notfound.hbs → cd-notfound.hbs} +0 -0
- package/addon/config.js +1 -1
- package/addon/gql/mutations/complete-work-item.graphql +8 -0
- package/addon/gql/mutations/withdraw-inquiry.graphql +8 -0
- package/addon/gql/queries/incomplete-inquiries.graphql +13 -0
- package/addon/gql/queries/inquiry-navigation.graphql +2 -0
- package/addon/services/distribution.js +82 -0
- package/addon/templates/application.hbs +1 -1
- package/addon/templates/index.hbs +7 -4
- package/addon/templates/inquiry/detail/answer.hbs +1 -1
- package/addon/templates/inquiry/detail/index.hbs +1 -1
- package/addon/templates/inquiry/index.hbs +1 -1
- package/addon/templates/new.hbs +1 -1
- package/addon/templates/notfound.hbs +1 -1
- package/addon/utils/unique-by-groups.js +1 -0
- package/app/components/{inquiry-dialog.js → cd-icon-button.js} +1 -1
- package/app/components/{inquiry-dialog/inquiry.js → cd-inquiry-answer-form.js} +1 -1
- package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-deadline.js +1 -1
- package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-divider.js +1 -1
- package/app/components/{inquiry-dialog → cd-inquiry-dialog}/inquiry-part.js +1 -1
- package/app/components/{distribution-navigation.js → cd-inquiry-dialog/inquiry.js} +1 -1
- package/app/components/{inquiry-edit-form.js → cd-inquiry-dialog.js} +1 -1
- package/app/components/cd-inquiry-edit-form.js +1 -0
- package/app/components/{inquiry-answer-form.js → cd-inquiry-new-form.js} +1 -1
- package/app/components/cd-navigation/controls.js +1 -0
- package/app/components/{inquiry-new-form.js → cd-navigation/item.js} +1 -1
- package/app/components/cd-navigation/section.js +1 -0
- package/app/components/{distribution-navigation/item.js → cd-navigation/status-indicator.js} +1 -1
- package/app/components/{icon-button.js → cd-navigation.js} +1 -1
- package/app/components/{notfound.js → cd-notfound.js} +1 -1
- package/app/services/{caluma-distribution-controls.js → distribution.js} +1 -1
- package/app/styles/_inquiry-divider.scss +22 -0
- package/index.js +14 -13
- package/package.json +23 -20
- package/public/assets/distribution.svg +1 -0
- package/translations/de.yaml +16 -2
- package/translations/en.yaml +17 -2
- package/translations/fr.yaml +16 -2
- package/addon/components/distribution-navigation/controls.js +0 -9
- package/addon/components/distribution-navigation.js +0 -81
- package/addon/components/icon-button.hbs +0 -20
- package/addon/components/inquiry-dialog/inquiry-deadline.hbs +0 -6
- package/addon/components/inquiry-dialog/inquiry-part.js +0 -20
- package/addon/components/inquiry-dialog/inquiry.hbs +0 -13
- package/addon/components/inquiry-dialog/inquiry.js +0 -7
- package/addon/components/inquiry-dialog.js +0 -42
- package/addon/services/caluma-distribution-controls.js +0 -37
- package/app/components/distribution-navigation/controls.js +0 -1
- package/app/components/distribution-navigation/section.js +0 -1
- package/app/components/distribution-navigation/status-indicator.js +0 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
# [@projectcaluma/ember-distribution-v1.0.0-beta.7](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.6...@projectcaluma/ember-distribution-v1.0.0-beta.7) (2022-04-07)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* **distribution:** fix status indicator and deadline styling for firefox ([358acb1](https://github.com/projectcaluma/ember-caluma/commit/358acb1f8e23b425bd6e223dc5873e516710ef12))
|
7
|
+
* **distribution:** make sure distribution components are prefixed ([d7d98ec](https://github.com/projectcaluma/ember-caluma/commit/d7d98ec291f937f384e2521d4d89c363d8e34f02))
|
8
|
+
|
9
|
+
|
10
|
+
### Features
|
11
|
+
|
12
|
+
* **distribution:** enable completing the distribution ([beabe61](https://github.com/projectcaluma/ember-caluma/commit/beabe61bd34025c4785c1e1ba60c59babb3eb6ab))
|
13
|
+
|
14
|
+
# [@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)
|
15
|
+
|
16
|
+
|
17
|
+
### Bug Fixes
|
18
|
+
|
19
|
+
* **embroider:** add missing dependency on @ember/string ([3a6e6bb](https://github.com/projectcaluma/ember-caluma/commit/3a6e6bb39a8c1a40a2ae00b3d4ea00606a755e25))
|
20
|
+
|
21
|
+
|
22
|
+
### Features
|
23
|
+
|
24
|
+
* **distribution:** add functionality to send all pending inquiries ([d769953](https://github.com/projectcaluma/ember-caluma/commit/d769953d5a0ea196943426c8499ba87b77a42e61))
|
25
|
+
* **distribution:** add functionality to withdraw an inquiry ([c278895](https://github.com/projectcaluma/ember-caluma/commit/c2788957c0fb228c167ca9236fda4850717f5817))
|
26
|
+
|
27
|
+
# [@projectcaluma/ember-distribution-v1.0.0-beta.5](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.4...@projectcaluma/ember-distribution-v1.0.0-beta.5) (2022-03-11)
|
28
|
+
|
29
|
+
|
30
|
+
### Bug Fixes
|
31
|
+
|
32
|
+
* **distribution:** fix sorting after group names in navigation ([2299d3b](https://github.com/projectcaluma/ember-caluma/commit/2299d3b0e265204ab6747dbdc6a8b64fc22f247f))
|
33
|
+
* **distribution:** redirect to edit form after inquiry creation ([0a2c404](https://github.com/projectcaluma/ember-caluma/commit/0a2c40404fdb1258fb8d51a2809a03b335c7c78a))
|
34
|
+
|
1
35
|
# [@projectcaluma/ember-distribution-v1.0.0-beta.4](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-distribution-v1.0.0-beta.3...@projectcaluma/ember-distribution-v1.0.0-beta.4) (2022-02-16)
|
2
36
|
|
3
37
|
|
@@ -4,26 +4,28 @@ import { Ability } from "ember-can";
|
|
4
4
|
const hasStatus = (status) => (edge) => edge.node.status === status;
|
5
5
|
|
6
6
|
export default class DistributionAbility extends Ability {
|
7
|
-
@service
|
7
|
+
@service distribution;
|
8
8
|
|
9
9
|
get canSendInquiries() {
|
10
10
|
return (
|
11
|
-
this.controls.
|
12
|
-
|
11
|
+
this.distribution.controls.value?.send.edges.filter(
|
12
|
+
hasStatus("SUSPENDED")
|
13
|
+
).length > 0
|
13
14
|
);
|
14
15
|
}
|
15
16
|
|
16
17
|
get canCreateInquiry() {
|
17
18
|
return (
|
18
|
-
this.controls.
|
19
|
+
this.distribution.controls.value?.create.edges.filter(hasStatus("READY"))
|
19
20
|
.length > 0
|
20
21
|
);
|
21
22
|
}
|
22
23
|
|
23
24
|
get canComplete() {
|
24
25
|
return (
|
25
|
-
this.controls.
|
26
|
-
|
26
|
+
this.distribution.controls.value?.complete.edges.filter(
|
27
|
+
hasStatus("READY")
|
28
|
+
).length > 0
|
27
29
|
);
|
28
30
|
}
|
29
31
|
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{{#if @route}}
|
2
|
+
<LinkTo @route={{@route}} class={{this.class}} title={{@title}} ...attributes>
|
3
|
+
{{#if @loading}}
|
4
|
+
<UkSpinner @ratio={{0.6}} />
|
5
|
+
{{else if @fromSvgJar}}
|
6
|
+
{{svg-jar @icon title=@title width="20" height="20"}}
|
7
|
+
{{else}}
|
8
|
+
<UkIcon @icon={{@icon}} />
|
9
|
+
{{/if}}
|
10
|
+
</LinkTo>
|
11
|
+
{{else}}
|
12
|
+
<button
|
13
|
+
type="button"
|
14
|
+
class={{this.class}}
|
15
|
+
title={{@title}}
|
16
|
+
...attributes
|
17
|
+
{{on "click" @onClick}}
|
18
|
+
>
|
19
|
+
{{#if @loading}}
|
20
|
+
<UkSpinner @ratio={{0.6}} />
|
21
|
+
{{else if @fromSvgJar}}
|
22
|
+
{{svg-jar @icon title=@title width="20" height="20"}}
|
23
|
+
{{else}}
|
24
|
+
<UkIcon @icon={{@icon}} />
|
25
|
+
{{/if}}
|
26
|
+
</button>
|
27
|
+
{{/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
|
4
|
+
export default class CdIconButtonComponent extends Component {
|
5
5
|
get class() {
|
6
6
|
const gutters = [
|
7
7
|
"gutter",
|
@@ -9,7 +9,7 @@ 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
|
12
|
+
export default class CdInquiryAnswerFormComponent extends Component {
|
13
13
|
@service intl;
|
14
14
|
@service router;
|
15
15
|
@service notification;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{{#if this.deadline.value}}
|
2
|
+
<div
|
3
|
+
class="uk-position-top-right
|
4
|
+
{{if
|
5
|
+
this.config.ui.small
|
6
|
+
'uk-margin-top uk-margin-right'
|
7
|
+
'uk-margin-medium-top uk-margin-medium-right'
|
8
|
+
}}
|
9
|
+
{{if
|
10
|
+
this.isWithdrawn
|
11
|
+
'uk-text-muted'
|
12
|
+
(concat 'uk-text-' this.deadline.color)
|
13
|
+
}}
|
14
|
+
uk-flex-inline uk-flex-middle"
|
15
|
+
>
|
16
|
+
{{svg-jar
|
17
|
+
(if this.isWithdrawn "ban-outline" "alarm-outline")
|
18
|
+
height=26
|
19
|
+
width=26
|
20
|
+
class="uk-margin-small-right"
|
21
|
+
}}
|
22
|
+
{{#if this.isWithdrawn}}
|
23
|
+
{{t "caluma.distribution.withdraw.status"}}
|
24
|
+
{{else}}
|
25
|
+
{{format-date this.deadline.value}}
|
26
|
+
{{/if}}
|
27
|
+
</div>
|
28
|
+
{{/if}}
|
@@ -3,8 +3,12 @@ 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
|
6
|
+
export default class CdInquiryDialogInquiryDeadlineComponent extends Component {
|
7
7
|
@config config;
|
8
8
|
|
9
9
|
@inquiryDeadline deadline;
|
10
|
+
|
11
|
+
get isWithdrawn() {
|
12
|
+
return this.args.inquiry.status === "CANCELED";
|
13
|
+
}
|
10
14
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<div
|
2
|
-
class="inquiry-divider uk-flex uk-flex-center uk-flex-middle uk-flex-between uk-
|
2
|
+
class="inquiry-divider uk-flex uk-flex-center uk-flex-middle uk-flex-between uk-text-{{this.status.color}}
|
3
|
+
{{if this.config.ui.small 'inquiry-divider--small' 'uk-margin'}}"
|
3
4
|
>
|
4
5
|
<div class="inquiry-divider__icon uk-flex uk-flex-center uk-flex-middle">
|
5
6
|
{{svg-jar this.status.icon title=this.status.label}}
|
@@ -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
|
7
|
+
export default class CdInquiryDialogInquiryDividerComponent extends Component {
|
8
8
|
@service intl;
|
9
9
|
|
10
10
|
@config config;
|
@@ -8,7 +8,14 @@
|
|
8
8
|
{{/if}}
|
9
9
|
</p>
|
10
10
|
|
11
|
-
<ul
|
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
|
+
>
|
12
19
|
<li>
|
13
20
|
<span>
|
14
21
|
{{format-date this.date}}
|
@@ -21,6 +28,11 @@
|
|
21
28
|
{{t "caluma.distribution.edit.link"}}
|
22
29
|
</LinkTo>
|
23
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>
|
24
36
|
{{/if}}
|
25
37
|
{{#if (can "answer inquiry" @inquiry)}}
|
26
38
|
<li>
|
@@ -31,4 +43,6 @@
|
|
31
43
|
{{/if}}
|
32
44
|
</ul>
|
33
45
|
|
34
|
-
|
46
|
+
{{#if this.info}}
|
47
|
+
<p class="uk-margin-remove">{{this.info}}</p>
|
48
|
+
{{/if}}
|
@@ -0,0 +1,59 @@
|
|
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 { confirm } from "ember-uikit";
|
6
|
+
|
7
|
+
import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
|
8
|
+
import config from "@projectcaluma/ember-distribution/config";
|
9
|
+
import withdrawInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/withdraw-inquiry.graphql";
|
10
|
+
|
11
|
+
export default class CdInquiryDialogInquiryPartComponent extends Component {
|
12
|
+
@service notification;
|
13
|
+
@service router;
|
14
|
+
@service intl;
|
15
|
+
|
16
|
+
@queryManager apollo;
|
17
|
+
|
18
|
+
@config config;
|
19
|
+
|
20
|
+
get date() {
|
21
|
+
const key = this.args.type === "request" ? "createdAt" : "closedAt";
|
22
|
+
|
23
|
+
return this.args.inquiry[key];
|
24
|
+
}
|
25
|
+
|
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;
|
33
|
+
|
34
|
+
return document.info.edges[0]?.node.value;
|
35
|
+
}
|
36
|
+
|
37
|
+
@dropTask
|
38
|
+
*withdraw(e) {
|
39
|
+
e.preventDefault();
|
40
|
+
|
41
|
+
/* istanbul ignore next */
|
42
|
+
if (!(yield confirm(this.intl.t("caluma.distribution.withdraw.confirm")))) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
|
46
|
+
try {
|
47
|
+
yield this.apollo.mutate({
|
48
|
+
mutation: withdrawInquiryMutation,
|
49
|
+
variables: {
|
50
|
+
workItem: decodeId(this.args.inquiry.id),
|
51
|
+
},
|
52
|
+
});
|
53
|
+
} catch (error) {
|
54
|
+
this.notification.danger(
|
55
|
+
this.intl.t("caluma.distribution.withdraw.error")
|
56
|
+
);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
@@ -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>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import Component from "@glimmer/component";
|
2
|
+
|
3
|
+
import config from "@projectcaluma/ember-distribution/config";
|
4
|
+
|
5
|
+
export default class CdInquiryDialogInquiryComponent extends Component {
|
6
|
+
@config config;
|
7
|
+
|
8
|
+
get hasAnswer() {
|
9
|
+
return this.args.inquiry.status === "COMPLETED";
|
10
|
+
}
|
11
|
+
}
|
@@ -3,9 +3,9 @@
|
|
3
3
|
{{else if this.inquiries.length}}
|
4
4
|
<section>
|
5
5
|
{{#each this.inquiries as |inquiry|}}
|
6
|
-
<
|
6
|
+
<CdInquiryDialog::Inquiry @inquiry={{inquiry}} />
|
7
7
|
{{/each}}
|
8
8
|
</section>
|
9
9
|
{{else}}
|
10
|
-
<
|
10
|
+
<CdNotfound />
|
11
11
|
{{/if}}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { inject as service } from "@ember/service";
|
2
|
+
import Component from "@glimmer/component";
|
3
|
+
import { queryManager, getObservable } from "ember-apollo-client";
|
4
|
+
import { dropTask } from "ember-concurrency";
|
5
|
+
import { useTask } from "ember-resources";
|
6
|
+
|
7
|
+
import config from "@projectcaluma/ember-distribution/config";
|
8
|
+
import inquiryDialogQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-dialog.graphql";
|
9
|
+
|
10
|
+
export default class CdInquiryDialogComponent extends Component {
|
11
|
+
@service router;
|
12
|
+
|
13
|
+
@config config;
|
14
|
+
|
15
|
+
@queryManager apollo;
|
16
|
+
|
17
|
+
get inquiries() {
|
18
|
+
return this._inquiries.value?.allWorkItems.edges.map((edge) => edge.node);
|
19
|
+
}
|
20
|
+
|
21
|
+
_inquiries = useTask(this, this.fetchDialog, () => [
|
22
|
+
this.args.from,
|
23
|
+
this.args.to,
|
24
|
+
this.args.caseId,
|
25
|
+
this.config,
|
26
|
+
]);
|
27
|
+
|
28
|
+
@dropTask
|
29
|
+
*fetchDialog() {
|
30
|
+
const response = yield this.apollo.watchQuery({
|
31
|
+
query: inquiryDialogQuery,
|
32
|
+
variables: {
|
33
|
+
from: this.args.from,
|
34
|
+
to: this.args.to,
|
35
|
+
caseId: this.args.caseId,
|
36
|
+
task: this.config.inquiry.task,
|
37
|
+
infoQuestion: this.config.inquiry.infoQuestion,
|
38
|
+
deadlineQuestion: this.config.inquiry.deadlineQuestion,
|
39
|
+
statusQuestion: this.config.inquiry.answer.statusQuestion,
|
40
|
+
answerInfoQuestion: this.config.inquiry.answer.infoQuestion,
|
41
|
+
includeNavigationData: true,
|
42
|
+
},
|
43
|
+
});
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Sadly this is necessary to handle what happens after the withdraw task in
|
47
|
+
* the inquiry part component because the mutation triggers a refresh of the
|
48
|
+
* query above in the same runloop instead of the next one. This causes
|
49
|
+
* `this.inquiries` to be recomputed which then triggers a rerender of the
|
50
|
+
* component and therefore cancels the withdraw task before we can do a
|
51
|
+
* transition.
|
52
|
+
*
|
53
|
+
* TODO: If https://github.com/ember-graphql/ember-apollo-client/pull/421 is
|
54
|
+
* merged and released, we can rewrite this into an action that is triggered
|
55
|
+
* in the withdraw task of the child component.
|
56
|
+
*/
|
57
|
+
getObservable(response).subscribe(({ data: { allWorkItems } }) => {
|
58
|
+
if (allWorkItems.edges.every((edge) => edge.node.status === "CANCELED")) {
|
59
|
+
this.router.transitionTo("index");
|
60
|
+
}
|
61
|
+
});
|
62
|
+
|
63
|
+
return response;
|
64
|
+
}
|
65
|
+
}
|
@@ -8,9 +8,10 @@ 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
|
11
|
+
export default class CdInquiryEditFormComponent extends Component {
|
12
12
|
@service notification;
|
13
13
|
@service router;
|
14
|
+
@service intl;
|
14
15
|
|
15
16
|
@config config;
|
16
17
|
|
@@ -6,12 +6,12 @@
|
|
6
6
|
{{#if this.selectedGroups.length}}
|
7
7
|
<div class="uk-flex uk-flex-middle">
|
8
8
|
<div class="uk-width-expand">
|
9
|
-
<
|
9
|
+
<a href="">
|
10
10
|
{{t
|
11
11
|
"caluma.distribution.new.groups"
|
12
12
|
count=this.selectedGroups.length
|
13
13
|
}}
|
14
|
-
</
|
14
|
+
</a>
|
15
15
|
<div uk-dropdown class="uk-width-auto">
|
16
16
|
<ul
|
17
17
|
class="uk-list uk-list-bullet uk-margin-remove uk-padding-remove"
|
@@ -117,5 +117,5 @@
|
|
117
117
|
</div>
|
118
118
|
{{/if}}
|
119
119
|
{{else}}
|
120
|
-
<
|
120
|
+
<CdNotfound />
|
121
121
|
{{/if}}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { getOwner } from "@ember/application";
|
2
1
|
import { action } from "@ember/object";
|
3
2
|
import { inject as service } from "@ember/service";
|
3
|
+
import { macroCondition, isTesting } from "@embroider/macros";
|
4
4
|
import Component from "@glimmer/component";
|
5
5
|
import { tracked } from "@glimmer/tracking";
|
6
6
|
import { queryManager } from "ember-apollo-client";
|
@@ -10,7 +10,6 @@ import { useTask } from "ember-resources";
|
|
10
10
|
import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
|
11
11
|
import config from "@projectcaluma/ember-distribution/config";
|
12
12
|
import createInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/create-inquiry.graphql";
|
13
|
-
import inquiryNavigationQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-navigation.graphql";
|
14
13
|
|
15
14
|
const toggle = (value, array) => {
|
16
15
|
const set = new Set(array);
|
@@ -20,12 +19,12 @@ const toggle = (value, array) => {
|
|
20
19
|
return [...set];
|
21
20
|
};
|
22
21
|
|
23
|
-
export default class
|
22
|
+
export default class CdInquiryNewFormComponent extends Component {
|
24
23
|
@service calumaOptions;
|
25
24
|
@service notification;
|
26
25
|
@service intl;
|
27
26
|
@service router;
|
28
|
-
@service
|
27
|
+
@service distribution;
|
29
28
|
|
30
29
|
@queryManager apollo;
|
31
30
|
|
@@ -63,10 +62,10 @@ export default class InquiryNewFormComponent extends Component {
|
|
63
62
|
*updateSearch(e) {
|
64
63
|
e.preventDefault();
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
/* istanbul ignore next */
|
66
|
+
if (macroCondition(isTesting())) {
|
67
|
+
// no timeout
|
68
|
+
} else {
|
70
69
|
yield timeout(500);
|
71
70
|
}
|
72
71
|
|
@@ -82,7 +81,7 @@ export default class InquiryNewFormComponent extends Component {
|
|
82
81
|
try {
|
83
82
|
// get create inquiry work item to complete
|
84
83
|
const createId = decodeId(
|
85
|
-
this.controls.
|
84
|
+
this.distribution.controls.value?.create.edges[0].node.id
|
86
85
|
);
|
87
86
|
|
88
87
|
// create new inquiries
|
@@ -96,28 +95,21 @@ export default class InquiryNewFormComponent extends Component {
|
|
96
95
|
},
|
97
96
|
});
|
98
97
|
|
99
|
-
// refetch navigation data
|
100
|
-
|
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",
|
101
107
|
{
|
102
|
-
|
103
|
-
|
104
|
-
variables: {
|
105
|
-
caseId: this.args.caseId,
|
106
|
-
task: this.config.inquiry.task,
|
107
|
-
currentGroup: String(this.calumaOptions.currentGroupId),
|
108
|
-
statusQuestion: this.config.inquiry.answer.statusQuestion,
|
109
|
-
deadlineQuestion: this.config.inquiry.deadlineQuestion,
|
110
|
-
includeNavigationData: true,
|
111
|
-
},
|
108
|
+
from: lastControlling.controllingGroups[0],
|
109
|
+
to: lastControlling.addressedGroups[0],
|
112
110
|
},
|
113
|
-
|
111
|
+
decodeId(lastControlling.id)
|
114
112
|
);
|
115
|
-
|
116
|
-
// transition to last added inquiry
|
117
|
-
this.router.transitionTo("inquiry", {
|
118
|
-
from: navigationData[0].node.controllingGroups[0],
|
119
|
-
to: navigationData[0].node.addressedGroups[0],
|
120
|
-
});
|
121
113
|
} catch (e) {
|
122
114
|
this.notification.danger(
|
123
115
|
this.intl.t("caluma.distribution.new.error", {
|
@@ -1,23 +1,28 @@
|
|
1
1
|
<div class="uk-text-center uk-margin-small-top">
|
2
2
|
{{#if (can "create inquiry of distribution")}}
|
3
|
-
<
|
3
|
+
<CdIconButton @route="new" @icon="plus" />
|
4
4
|
{{/if}}
|
5
5
|
{{#if (can "send inquiries of distribution")}}
|
6
|
-
<
|
6
|
+
<CdIconButton
|
7
|
+
@title={{t "caluma.distribution.send"}}
|
7
8
|
@icon="paper-plane-outline"
|
8
9
|
@fromSvgJar={{true}}
|
9
10
|
@gutterTop={{4}}
|
10
11
|
@gutterRight={{6}}
|
11
12
|
@gutterLeft={{4}}
|
12
13
|
@gutterBottom={{4}}
|
13
|
-
@onClick={{this.
|
14
|
+
@onClick={{perform this.sendInquiries}}
|
15
|
+
@loading={{this.sendInquiries.isRunning}}
|
16
|
+
data-test-send-pending-inquiries
|
14
17
|
/>
|
15
18
|
{{/if}}
|
16
19
|
{{#if (can "complete distribution")}}
|
17
|
-
<
|
20
|
+
<CdIconButton
|
18
21
|
@icon="lock-closed-outline"
|
19
22
|
@fromSvgJar={{true}}
|
20
|
-
@onClick={{this.
|
23
|
+
@onClick={{perform this.completeDistribution}}
|
24
|
+
@loading={{this.completeDistribution.isRunning}}
|
25
|
+
data-test-complete-distribution
|
21
26
|
/>
|
22
27
|
{{/if}}
|
23
28
|
</div>
|
@@ -0,0 +1,95 @@
|
|
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 { confirm } from "ember-uikit";
|
6
|
+
import { gql } from "graphql-tag";
|
7
|
+
|
8
|
+
import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
|
9
|
+
import config from "@projectcaluma/ember-distribution/config";
|
10
|
+
import completeWorkItemMutation from "@projectcaluma/ember-distribution/gql/mutations/complete-work-item.graphql";
|
11
|
+
import incompleteInquiriesQuery from "@projectcaluma/ember-distribution/gql/queries/incomplete-inquiries.graphql";
|
12
|
+
|
13
|
+
export default class CdNavigationControlsComponent extends Component {
|
14
|
+
@service distribution;
|
15
|
+
@service intl;
|
16
|
+
@service notification;
|
17
|
+
@service router;
|
18
|
+
|
19
|
+
@queryManager apollo;
|
20
|
+
@config config;
|
21
|
+
|
22
|
+
@dropTask
|
23
|
+
*completeDistribution() {
|
24
|
+
try {
|
25
|
+
const incompleteInquiries = yield this.apollo.query(
|
26
|
+
{
|
27
|
+
query: incompleteInquiriesQuery,
|
28
|
+
variables: {
|
29
|
+
caseId: this.args.caseId,
|
30
|
+
task: this.config.inquiry.task,
|
31
|
+
},
|
32
|
+
},
|
33
|
+
"allWorkItems.totalCount"
|
34
|
+
);
|
35
|
+
|
36
|
+
if (
|
37
|
+
incompleteInquiries > 0 &&
|
38
|
+
!(yield confirm(
|
39
|
+
this.intl.t("caluma.distribution.complete-confirm", {
|
40
|
+
count: incompleteInquiries,
|
41
|
+
})
|
42
|
+
))
|
43
|
+
) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
const completeDistributionWorkItem =
|
48
|
+
this.distribution.controls.value.complete.edges?.[0]?.node.id;
|
49
|
+
|
50
|
+
yield this.apollo.mutate({
|
51
|
+
mutation: completeWorkItemMutation,
|
52
|
+
variables: {
|
53
|
+
workItem: completeDistributionWorkItem,
|
54
|
+
},
|
55
|
+
});
|
56
|
+
|
57
|
+
yield this.distribution.refetch();
|
58
|
+
this.router.transitionTo("index");
|
59
|
+
} catch (e) {
|
60
|
+
this.notification.danger(
|
61
|
+
this.intl.t("caluma.distribution.complete-error")
|
62
|
+
);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
@dropTask
|
67
|
+
*sendInquiries() {
|
68
|
+
if (!(yield confirm(this.intl.t("caluma.distribution.send-confirm")))) {
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
|
72
|
+
try {
|
73
|
+
const ids = this.distribution.controls.value.send.edges.map((edge) =>
|
74
|
+
decodeId(edge.node.id)
|
75
|
+
);
|
76
|
+
|
77
|
+
const mutations = ids.map(
|
78
|
+
(id, index) => `
|
79
|
+
sendInquiry${index}: resumeWorkItem(input: { id: "${id}" }) {
|
80
|
+
workItem {
|
81
|
+
id
|
82
|
+
status
|
83
|
+
}
|
84
|
+
}
|
85
|
+
`
|
86
|
+
);
|
87
|
+
|
88
|
+
const mutation = gql`mutation SendInquiries {${mutations.join("\n")}}`;
|
89
|
+
|
90
|
+
yield this.apollo.mutate({ mutation });
|
91
|
+
} catch (e) {
|
92
|
+
this.notification.danger(this.intl.t("caluma.distribution.send-error"));
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|