@projectcaluma/ember-distribution 1.0.0-beta.1 → 1.0.0-beta.10
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +110 -0
- package/addon/abilities/distribution.js +41 -0
- package/addon/abilities/inquiry.js +20 -0
- package/addon/components/cd-document-header.hbs +20 -0
- package/addon/components/cd-icon-button.hbs +27 -0
- package/addon/components/{icon-button.js → cd-icon-button.js} +1 -1
- package/addon/components/cd-inquiry-answer-form.hbs +78 -0
- package/addon/components/{inquiry-answer-form.js → cd-inquiry-answer-form.js} +27 -13
- package/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs +29 -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/cd-inquiry-dialog/inquiry-part.hbs +101 -0
- package/addon/components/cd-inquiry-dialog/inquiry-part.js +66 -0
- package/addon/components/cd-inquiry-dialog/inquiry.hbs +16 -0
- package/addon/components/cd-inquiry-dialog/inquiry.js +11 -0
- package/addon/components/cd-inquiry-dialog.hbs +24 -0
- package/addon/components/cd-inquiry-dialog.js +93 -0
- package/addon/components/cd-inquiry-edit-form.hbs +41 -0
- package/addon/components/{inquiry-edit-form.js → cd-inquiry-edit-form.js} +5 -4
- package/addon/components/cd-inquiry-new-form.hbs +123 -0
- package/addon/components/cd-inquiry-new-form.js +116 -0
- package/addon/components/cd-navigation/controls.hbs +32 -0
- package/addon/components/cd-navigation/controls.js +95 -0
- package/addon/components/cd-navigation/item.hbs +15 -0
- package/addon/components/{distribution-navigation → cd-navigation}/item.js +2 -2
- package/addon/components/{distribution-navigation → cd-navigation}/section.hbs +9 -7
- 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/cd-navigation.hbs +14 -0
- package/addon/components/cd-navigation.js +53 -0
- package/addon/components/cd-notfound.hbs +12 -0
- package/addon/components/cd-truncated.hbs +8 -0
- package/addon/components/cd-truncated.js +32 -0
- package/addon/config.js +3 -1
- package/addon/controllers/application.js +10 -0
- package/addon/controllers/{distribution/new.js → new.js} +2 -2
- package/addon/engine.js +7 -1
- package/addon/gql/fragments/inquiry.graphql +21 -12
- package/addon/gql/mutations/complete-work-item.graphql +8 -0
- package/addon/gql/mutations/withdraw-inquiry.graphql +8 -0
- package/addon/gql/queries/control-work-items.graphql +18 -2
- package/addon/gql/queries/incomplete-inquiries.graphql +13 -0
- package/addon/gql/queries/inquiry-answer.graphql +15 -1
- package/addon/gql/queries/inquiry-dialog.graphql +2 -2
- package/addon/gql/queries/inquiry-edit.graphql +2 -0
- package/addon/gql/queries/inquiry-navigation.graphql +4 -1
- package/addon/modifiers/pikaday.js +2 -0
- package/addon/routes/{distribution.js → application.js} +1 -1
- package/addon/routes/{distribution/index.js → index.js} +2 -2
- package/addon/routes/inquiry/detail/answer.js +7 -0
- package/addon/routes/inquiry/detail/index.js +7 -0
- package/addon/routes/{distribution/inquiry → inquiry}/detail.js +1 -1
- package/addon/routes/inquiry/index.js +10 -0
- package/addon/routes/{distribution/inquiry.js → inquiry.js} +1 -1
- package/addon/routes/new.js +7 -0
- package/addon/routes/notfound.js +3 -0
- package/addon/routes.js +5 -6
- package/addon/services/distribution.js +112 -0
- package/addon/templates/application.hbs +18 -0
- package/addon/templates/index.hbs +11 -0
- package/addon/templates/inquiry/detail/answer.hbs +1 -0
- package/addon/templates/inquiry/detail/index.hbs +1 -0
- package/addon/templates/{distribution/inquiry → inquiry}/detail.hbs +0 -0
- package/addon/templates/{distribution/inquiry → inquiry}/index.hbs +1 -1
- package/addon/templates/{distribution/inquiry.hbs → inquiry.hbs} +0 -0
- package/addon/templates/{distribution/new.hbs → new.hbs} +1 -1
- package/addon/templates/notfound.hbs +1 -0
- package/addon/utils/inquiry-deadline.js +4 -7
- package/addon/utils/unique-by-groups.js +1 -0
- package/app/abilities/distribution.js +1 -0
- package/app/components/cd-document-header.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/cd-navigation/item.js +1 -0
- 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/{inquiry-new-form.js → cd-navigation.js} +1 -1
- package/app/components/{icon-button.js → cd-notfound.js} +1 -1
- package/app/components/cd-truncated.js +1 -0
- package/app/services/distribution.js +1 -0
- package/app/styles/@projectcaluma/ember-distribution.scss +2 -0
- package/app/styles/_answer-form.scss +4 -0
- package/app/styles/_inquiry-divider.scss +22 -0
- package/app/styles/_truncated.scss +3 -0
- package/index.js +14 -13
- package/package.json +31 -26
- package/public/assets/distribution.svg +1 -0
- package/translations/de.yaml +34 -4
- package/translations/en.yaml +35 -4
- package/translations/fr.yaml +34 -4
- package/addon/components/distribution-navigation/controls.hbs +0 -21
- package/addon/components/distribution-navigation/controls.js +0 -45
- package/addon/components/distribution-navigation/item.hbs +0 -18
- package/addon/components/distribution-navigation.hbs +0 -17
- package/addon/components/distribution-navigation.js +0 -81
- package/addon/components/icon-button.hbs +0 -20
- package/addon/components/inquiry-answer-form.hbs +0 -46
- package/addon/components/inquiry-dialog/inquiry-deadline.hbs +0 -6
- package/addon/components/inquiry-dialog/inquiry-part.hbs +0 -40
- 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.hbs +0 -9
- package/addon/components/inquiry-dialog.js +0 -42
- package/addon/components/inquiry-edit-form.hbs +0 -27
- package/addon/components/inquiry-new-form.hbs +0 -110
- package/addon/components/inquiry-new-form.js +0 -154
- package/addon/routes/distribution/inquiry/detail/answer.js +0 -7
- package/addon/routes/distribution/inquiry/detail/index.js +0 -7
- package/addon/routes/distribution/inquiry/index.js +0 -10
- package/addon/routes/distribution/new.js +0 -7
- package/addon/templates/distribution/inquiry/detail/answer.hbs +0 -1
- package/addon/templates/distribution/inquiry/detail/index.hbs +0 -1
- package/addon/templates/distribution.hbs +0 -8
- 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
@@ -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
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{{#if this._inquiries.isRunning}}
|
2
|
+
<div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
|
3
|
+
{{else if this.inquiries.length}}
|
4
|
+
{{#if
|
5
|
+
(and (can "create inquiry of distribution") this.currentGroupIsCreator)
|
6
|
+
}}
|
7
|
+
<div class="uk-text-center uk-margin">
|
8
|
+
<CdIconButton
|
9
|
+
@title={{t "caluma.distribution.new.title"}}
|
10
|
+
@icon="plus"
|
11
|
+
@loading={{this.createInquiry.isRunning}}
|
12
|
+
@onClick={{perform this.createInquiry}}
|
13
|
+
data-test-new-inquiry
|
14
|
+
/>
|
15
|
+
</div>
|
16
|
+
{{/if}}
|
17
|
+
<section>
|
18
|
+
{{#each this.inquiries as |inquiry|}}
|
19
|
+
<CdInquiryDialog::Inquiry @inquiry={{inquiry}} />
|
20
|
+
{{/each}}
|
21
|
+
</section>
|
22
|
+
{{else}}
|
23
|
+
<CdNotfound />
|
24
|
+
{{/if}}
|
@@ -0,0 +1,93 @@
|
|
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 { trackedTask } from "ember-resources/util/ember-concurrency";
|
6
|
+
|
7
|
+
import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
|
8
|
+
import config from "@projectcaluma/ember-distribution/config";
|
9
|
+
import inquiryDialogQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-dialog.graphql";
|
10
|
+
|
11
|
+
export default class CdInquiryDialogComponent extends Component {
|
12
|
+
@service intl;
|
13
|
+
@service router;
|
14
|
+
@service distribution;
|
15
|
+
@service notification;
|
16
|
+
@service calumaOptions;
|
17
|
+
|
18
|
+
@config config;
|
19
|
+
|
20
|
+
@queryManager apollo;
|
21
|
+
|
22
|
+
get currentGroupIsCreator() {
|
23
|
+
return String(this.calumaOptions.currentGroupId) === this.args.from;
|
24
|
+
}
|
25
|
+
|
26
|
+
get inquiries() {
|
27
|
+
return this._inquiries.value?.allWorkItems.edges.map((edge) => edge.node);
|
28
|
+
}
|
29
|
+
|
30
|
+
_inquiries = trackedTask(this, this.fetchDialog, () => [
|
31
|
+
this.args.from,
|
32
|
+
this.args.to,
|
33
|
+
this.args.caseId,
|
34
|
+
this.config,
|
35
|
+
]);
|
36
|
+
|
37
|
+
@dropTask
|
38
|
+
*fetchDialog() {
|
39
|
+
const response = yield this.apollo.watchQuery({
|
40
|
+
query: inquiryDialogQuery,
|
41
|
+
variables: {
|
42
|
+
from: this.args.from,
|
43
|
+
to: this.args.to,
|
44
|
+
caseId: this.args.caseId,
|
45
|
+
task: this.config.inquiry.task,
|
46
|
+
infoQuestion: this.config.inquiry.infoQuestion,
|
47
|
+
deadlineQuestion: this.config.inquiry.deadlineQuestion,
|
48
|
+
statusQuestion: this.config.inquiry.answer.statusQuestion,
|
49
|
+
answerInfoQuestions: this.config.inquiry.answer.infoQuestions,
|
50
|
+
includeNavigationData: true,
|
51
|
+
},
|
52
|
+
});
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Sadly this is necessary to handle what happens after the withdraw task in
|
56
|
+
* the inquiry part component because the mutation triggers a refresh of the
|
57
|
+
* query above in the same runloop instead of the next one. This causes
|
58
|
+
* `this.inquiries` to be recomputed which then triggers a rerender of the
|
59
|
+
* component and therefore cancels the withdraw task before we can do a
|
60
|
+
* transition.
|
61
|
+
*
|
62
|
+
* TODO: If https://github.com/ember-graphql/ember-apollo-client/pull/421 is
|
63
|
+
* merged and released, we can rewrite this into an action that is triggered
|
64
|
+
* in the withdraw task of the child component.
|
65
|
+
*/
|
66
|
+
getObservable(response).subscribe(({ data: { allWorkItems } }) => {
|
67
|
+
if (allWorkItems.edges.every((edge) => edge.node.status === "CANCELED")) {
|
68
|
+
this.router.transitionTo("index");
|
69
|
+
}
|
70
|
+
});
|
71
|
+
|
72
|
+
return response;
|
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
|
+
}
|
93
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<CfContent
|
2
|
+
@documentId={{decode-id this.inquiry.document.id}}
|
3
|
+
@disabled={{cannot "edit inquiry" this.inquiry}}
|
4
|
+
@loading={{this._inquiry.isRunning}}
|
5
|
+
>
|
6
|
+
<:default as |content|>
|
7
|
+
<CdDocumentHeader
|
8
|
+
@name={{content.document.rootForm.raw.name}}
|
9
|
+
@isDraft={{eq this.inquiry.status "SUSPENDED"}}
|
10
|
+
@modifiedAt={{this.inquiry.document.modifiedContentAt}}
|
11
|
+
@modifiedBy={{this.inquiry.document.modifiedContentByUser}}
|
12
|
+
/>
|
13
|
+
|
14
|
+
<hr />
|
15
|
+
|
16
|
+
{{#if (cannot "send inquiry" this.inquiry)}}
|
17
|
+
<div class="uk-alert uk-alert-warning uk-flex uk-flex-middle">
|
18
|
+
<UkIcon @icon="warning" class="uk-margin-small-right" />
|
19
|
+
{{t "caluma.distribution.edit.send-not-allowed"}}
|
20
|
+
{{t "caluma.distribution.not-allowed-hint"}}
|
21
|
+
</div>
|
22
|
+
{{/if}}
|
23
|
+
|
24
|
+
<content.form />
|
25
|
+
|
26
|
+
{{#if
|
27
|
+
(and (can "edit inquiry" this.inquiry) (can "send inquiry" this.inquiry))
|
28
|
+
}}
|
29
|
+
<DocumentValidity @document={{content.document}} as |isValid validate|>
|
30
|
+
<UkButton
|
31
|
+
@type="submit"
|
32
|
+
@color="primary"
|
33
|
+
@disabled={{or (not isValid) this.send.isRunning}}
|
34
|
+
@onClick={{perform this.send validate}}
|
35
|
+
@loading={{this.send.isRunning}}
|
36
|
+
>{{t "caluma.distribution.edit.send"}}</UkButton>
|
37
|
+
</DocumentValidity>
|
38
|
+
{{/if}}
|
39
|
+
</:default>
|
40
|
+
<:notfound><CdNotfound /></:notfound>
|
41
|
+
</CfContent>
|
@@ -2,21 +2,22 @@ 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 {
|
5
|
+
import { trackedTask } from "ember-resources/util/ember-concurrency";
|
6
6
|
|
7
7
|
import config from "@projectcaluma/ember-distribution/config";
|
8
8
|
import resumeWorkItemMutation from "@projectcaluma/ember-distribution/gql/mutations/resume-work-item.graphql";
|
9
9
|
import inquiryEditQuery from "@projectcaluma/ember-distribution/gql/queries/inquiry-edit.graphql";
|
10
10
|
|
11
|
-
export default class
|
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
|
|
17
18
|
@queryManager apollo;
|
18
19
|
|
19
|
-
_inquiry =
|
20
|
+
_inquiry = trackedTask(this, this.fetchInquiry, () => [this.args.inquiry]);
|
20
21
|
|
21
22
|
get inquiry() {
|
22
23
|
return this._inquiry.value?.[0]?.node;
|
@@ -43,7 +44,7 @@ export default class InquiryEditFormComponent extends Component {
|
|
43
44
|
variables: { workItem: this.args.inquiry },
|
44
45
|
});
|
45
46
|
|
46
|
-
yield this.router.transitionTo("
|
47
|
+
yield this.router.transitionTo("inquiry.index");
|
47
48
|
} catch (error) {
|
48
49
|
this.notification.danger(
|
49
50
|
this.intl.t("caluma.distribution.edit.send-error")
|
@@ -0,0 +1,123 @@
|
|
1
|
+
{{#if this.controls.workItems.isRunning}}
|
2
|
+
<div class="uk-text-center"><UkSpinner @ratio={{2}} /></div>
|
3
|
+
{{else if (can "create inquiry of distribution")}}
|
4
|
+
<p class="uk-text-large">{{t "caluma.distribution.new.title"}}</p>
|
5
|
+
|
6
|
+
<hr />
|
7
|
+
|
8
|
+
{{#if this.selectedGroups.length}}
|
9
|
+
<div class="uk-flex uk-flex-middle">
|
10
|
+
<div class="uk-width-expand">
|
11
|
+
<a href="">
|
12
|
+
{{t
|
13
|
+
"caluma.distribution.new.groups"
|
14
|
+
count=this.selectedGroups.length
|
15
|
+
}}
|
16
|
+
</a>
|
17
|
+
<div uk-dropdown class="uk-width-auto">
|
18
|
+
<ul
|
19
|
+
class="uk-list uk-list-bullet uk-margin-remove uk-padding-remove"
|
20
|
+
data-test-selected-groups
|
21
|
+
>
|
22
|
+
{{#each this.selectedGroups as |identifier|}}
|
23
|
+
<li class="uk-text-nowrap">{{group-name identifier}}</li>
|
24
|
+
{{/each}}
|
25
|
+
</ul>
|
26
|
+
</div>
|
27
|
+
{{t
|
28
|
+
"caluma.distribution.new.selected"
|
29
|
+
count=this.selectedGroups.length
|
30
|
+
}}
|
31
|
+
</div>
|
32
|
+
<div>
|
33
|
+
<UkButton
|
34
|
+
@label={{t "caluma.distribution.new.reset"}}
|
35
|
+
@onClick={{this.clearSelectedGroups}}
|
36
|
+
data-test-reset
|
37
|
+
/>
|
38
|
+
<UkButton
|
39
|
+
@color="primary"
|
40
|
+
@label={{t "caluma.distribution.new.create-draft"}}
|
41
|
+
@type="submit"
|
42
|
+
@loading={{this.submit.isRunning}}
|
43
|
+
@disabled={{this.submit.isRunning}}
|
44
|
+
@onClick={{perform this.submit}}
|
45
|
+
data-test-submit
|
46
|
+
/>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
<hr />
|
50
|
+
{{/if}}
|
51
|
+
|
52
|
+
<div class="uk-margin-bottom uk-button-group">
|
53
|
+
{{#each-in this.config.new.types as |slug config|}}
|
54
|
+
{{#unless config.disabled}}
|
55
|
+
<UkButton
|
56
|
+
data-test-type={{slug}}
|
57
|
+
@label={{t config.label}}
|
58
|
+
@color={{if (includes slug @selectedTypes) "primary" "default"}}
|
59
|
+
@onClick={{fn this.updateSelectedTypes slug}}
|
60
|
+
/>
|
61
|
+
{{/unless}}
|
62
|
+
{{/each-in}}
|
63
|
+
</div>
|
64
|
+
|
65
|
+
<div class="uk-search uk-search-default uk-width-1-1">
|
66
|
+
<span class="uk-search-icon-flip" uk-search-icon></span>
|
67
|
+
<input
|
68
|
+
placeholder={{t "caluma.distribution.new.search"}}
|
69
|
+
aria-label={{t "caluma.distribution.new.search"}}
|
70
|
+
class="uk-search-input"
|
71
|
+
type="search"
|
72
|
+
value={{@search}}
|
73
|
+
data-test-search
|
74
|
+
{{on "input" (perform this.updateSearch)}}
|
75
|
+
/>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
{{#if this.groups.isRunning}}
|
79
|
+
<div class="uk-text-center uk-margin">
|
80
|
+
<UkSpinner @ratio={{2}} />
|
81
|
+
</div>
|
82
|
+
{{else if this.groups.value.length}}
|
83
|
+
<ul class="uk-list uk-list-striped">
|
84
|
+
{{#each this.groups.value as |group|}}
|
85
|
+
{{! template-lint-disable require-presentational-children }}
|
86
|
+
<li
|
87
|
+
role="checkbox"
|
88
|
+
class="uk-flex uk-flex-between uk-flex-middle"
|
89
|
+
data-test-group={{group.identifier}}
|
90
|
+
{{on "click" (fn this.updateSelectedGroups group.identifier)}}
|
91
|
+
>
|
92
|
+
{{! template-lint-disable no-nested-interactive }}
|
93
|
+
<label for="group-{{group.identifier}}">
|
94
|
+
<input
|
95
|
+
type="checkbox"
|
96
|
+
class="uk-checkbox uk-margin-small-right"
|
97
|
+
checked={{includes group.identifier this.selectedGroups}}
|
98
|
+
id="group-{{group.identifier}}"
|
99
|
+
/>
|
100
|
+
{{group-name group.identifier}}
|
101
|
+
</label>
|
102
|
+
{{#if group.config.icon}}
|
103
|
+
{{svg-jar
|
104
|
+
group.config.icon
|
105
|
+
width="20"
|
106
|
+
height="20"
|
107
|
+
class=(concat "uk-text-" group.config.iconColor)
|
108
|
+
}}
|
109
|
+
{{/if}}
|
110
|
+
</li>
|
111
|
+
{{/each}}
|
112
|
+
</ul>
|
113
|
+
{{else}}
|
114
|
+
<div class="uk-text-center">
|
115
|
+
<UkIcon @icon="search" @ratio={{10}} class="uk-margin-top" />
|
116
|
+
<p class="uk-text-muted">
|
117
|
+
{{t "caluma.distribution.new.empty"}}
|
118
|
+
</p>
|
119
|
+
</div>
|
120
|
+
{{/if}}
|
121
|
+
{{else}}
|
122
|
+
<CdNotfound />
|
123
|
+
{{/if}}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import { action } from "@ember/object";
|
2
|
+
import { inject as service } from "@ember/service";
|
3
|
+
import { macroCondition, isTesting } from "@embroider/macros";
|
4
|
+
import Component from "@glimmer/component";
|
5
|
+
import { tracked } from "@glimmer/tracking";
|
6
|
+
import { queryManager } from "ember-apollo-client";
|
7
|
+
import { timeout, restartableTask, dropTask, task } from "ember-concurrency";
|
8
|
+
import { trackedTask } from "ember-resources/util/ember-concurrency";
|
9
|
+
|
10
|
+
import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
|
11
|
+
import config from "@projectcaluma/ember-distribution/config";
|
12
|
+
|
13
|
+
const toggle = (value, array) => {
|
14
|
+
const set = new Set(array);
|
15
|
+
|
16
|
+
set.delete(value) || set.add(value);
|
17
|
+
|
18
|
+
return [...set];
|
19
|
+
};
|
20
|
+
|
21
|
+
export default class CdInquiryNewFormComponent extends Component {
|
22
|
+
@service calumaOptions;
|
23
|
+
@service notification;
|
24
|
+
@service intl;
|
25
|
+
@service router;
|
26
|
+
@service distribution;
|
27
|
+
|
28
|
+
@queryManager apollo;
|
29
|
+
|
30
|
+
@config config;
|
31
|
+
|
32
|
+
@tracked selectedGroups = [];
|
33
|
+
|
34
|
+
groups = trackedTask(this, this.fetchGroups, () => [
|
35
|
+
this.args.selectedTypes,
|
36
|
+
this.args.search,
|
37
|
+
]);
|
38
|
+
|
39
|
+
@action
|
40
|
+
updateSelectedTypes(type, e) {
|
41
|
+
e.preventDefault();
|
42
|
+
|
43
|
+
this.args.onChangeSelectedTypes(toggle(type, this.args.selectedTypes));
|
44
|
+
}
|
45
|
+
|
46
|
+
@action
|
47
|
+
updateSelectedGroups(identifier, e) {
|
48
|
+
e.preventDefault();
|
49
|
+
|
50
|
+
this.selectedGroups = toggle(identifier, this.selectedGroups);
|
51
|
+
}
|
52
|
+
|
53
|
+
@action
|
54
|
+
clearSelectedGroups(e) {
|
55
|
+
e.preventDefault();
|
56
|
+
|
57
|
+
this.selectedGroups = [];
|
58
|
+
}
|
59
|
+
|
60
|
+
@restartableTask
|
61
|
+
*updateSearch(e) {
|
62
|
+
e.preventDefault();
|
63
|
+
|
64
|
+
/* istanbul ignore next */
|
65
|
+
if (macroCondition(isTesting())) {
|
66
|
+
// no timeout
|
67
|
+
} else {
|
68
|
+
yield timeout(500);
|
69
|
+
}
|
70
|
+
|
71
|
+
this.args.onChangeSearch(e.target.value);
|
72
|
+
}
|
73
|
+
|
74
|
+
@dropTask
|
75
|
+
*submit(e) {
|
76
|
+
e.preventDefault();
|
77
|
+
|
78
|
+
if (!this.selectedGroups.length) return;
|
79
|
+
|
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
|
+
);
|
94
|
+
}
|
95
|
+
|
96
|
+
@task
|
97
|
+
*fetchGroups(types, search) {
|
98
|
+
// https://github.com/ember-cli/eslint-plugin-ember/issues/1413
|
99
|
+
yield Promise.resolve();
|
100
|
+
|
101
|
+
const typedGroups = yield this.calumaOptions.fetchTypedGroups(
|
102
|
+
types,
|
103
|
+
search
|
104
|
+
);
|
105
|
+
|
106
|
+
return Object.entries(typedGroups)
|
107
|
+
.flatMap(([type, groups]) => {
|
108
|
+
return groups.map((group) => ({
|
109
|
+
identifier: group[this.calumaOptions.groupIdentifierProperty],
|
110
|
+
name: group[this.calumaOptions.groupNameProperty],
|
111
|
+
config: this.config.new.types[type],
|
112
|
+
}));
|
113
|
+
})
|
114
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
115
|
+
}
|
116
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<div class="uk-text-center uk-margin-small-top">
|
2
|
+
{{#if (can "create inquiry of distribution")}}
|
3
|
+
<CdIconButton
|
4
|
+
@title={{t "caluma.distribution.new.title"}}
|
5
|
+
@icon="plus"
|
6
|
+
@route="new"
|
7
|
+
/>
|
8
|
+
{{/if}}
|
9
|
+
{{#if (can "send inquiries of distribution")}}
|
10
|
+
<CdIconButton
|
11
|
+
@title={{t "caluma.distribution.send"}}
|
12
|
+
@icon="paper-plane-outline"
|
13
|
+
@fromSvgJar={{true}}
|
14
|
+
@gutterTop={{4}}
|
15
|
+
@gutterRight={{6}}
|
16
|
+
@gutterLeft={{4}}
|
17
|
+
@gutterBottom={{4}}
|
18
|
+
@onClick={{perform this.sendInquiries}}
|
19
|
+
@loading={{this.sendInquiries.isRunning}}
|
20
|
+
data-test-send-pending-inquiries
|
21
|
+
/>
|
22
|
+
{{/if}}
|
23
|
+
{{#if (can "complete distribution")}}
|
24
|
+
<CdIconButton
|
25
|
+
@icon="lock-closed-outline"
|
26
|
+
@fromSvgJar={{true}}
|
27
|
+
@onClick={{perform this.completeDistribution}}
|
28
|
+
@loading={{this.completeDistribution.isRunning}}
|
29
|
+
data-test-complete-distribution
|
30
|
+
/>
|
31
|
+
{{/if}}
|
32
|
+
</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
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<li class={{if this.isActive "uk-active"}}>
|
2
|
+
<LinkTo @route="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
|
+
{{@inquiry.controllingGroupName}}
|
7
|
+
{{else}}
|
8
|
+
{{@inquiry.addressedGroupName}}
|
9
|
+
{{/if}}
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<CdNavigation::StatusIndicator @inquiry={{@inquiry}} @type={{@type}} />
|
13
|
+
</div>
|
14
|
+
</LinkTo>
|
15
|
+
</li>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { inject as service } from "@ember/service";
|
2
2
|
import Component from "@glimmer/component";
|
3
3
|
|
4
|
-
export default class
|
4
|
+
export default class CdNavigationItemComponent extends Component {
|
5
5
|
@service router;
|
6
6
|
|
7
7
|
get model() {
|
@@ -12,6 +12,6 @@ export default class DistributionNavigationItemComponent extends Component {
|
|
12
12
|
}
|
13
13
|
|
14
14
|
get isActive() {
|
15
|
-
return this.router.isActive("
|
15
|
+
return this.router.isActive("inquiry", this.model);
|
16
16
|
}
|
17
17
|
}
|
@@ -10,15 +10,17 @@
|
|
10
10
|
{{/if}}
|
11
11
|
</a>
|
12
12
|
|
13
|
-
{{#if
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
{{#if this.expanded}}
|
14
|
+
{{#if @inquiries.length}}
|
15
|
+
<ul class="uk-tab uk-tab-left uk-margin-left">
|
16
|
+
{{#each this.inquiries as |inquiry|}}
|
17
|
+
<CdNavigation::Item @inquiry={{inquiry}} @type={{@type}} />
|
18
|
+
{{/each}}
|
19
|
+
</ul>
|
20
|
+
{{/if}}
|
19
21
|
|
20
22
|
{{#if (eq @type "controlling")}}
|
21
|
-
<
|
23
|
+
<CdNavigation::Controls @caseId={{@caseId}} />
|
22
24
|
{{/if}}
|
23
25
|
{{/if}}
|
24
26
|
</li>
|
@@ -2,7 +2,7 @@ import { action } from "@ember/object";
|
|
2
2
|
import Component from "@glimmer/component";
|
3
3
|
import { tracked } from "@glimmer/tracking";
|
4
4
|
|
5
|
-
export default class
|
5
|
+
export default class CdNavigationSectionComponent extends Component {
|
6
6
|
@tracked expanded = true;
|
7
7
|
|
8
8
|
@action
|
@@ -1,10 +1,11 @@
|
|
1
1
|
{{#if this.showDeadlineIndicator}}
|
2
2
|
<div
|
3
|
-
class="deadline-indicator uk-flex
|
3
|
+
class="deadline-indicator uk-flex uk-flex-middle uk-flex-center uk-margin-small-left uk-text-{{this.deadline.color}}"
|
4
4
|
>
|
5
5
|
{{svg-jar
|
6
6
|
"notifications-outline"
|
7
7
|
height=16
|
8
|
+
width=16
|
8
9
|
title=(format-date this.deadline.value)
|
9
10
|
}}
|
10
11
|
</div>
|
@@ -5,7 +5,7 @@ import config from "@projectcaluma/ember-distribution/config";
|
|
5
5
|
import inquiryDeadline from "@projectcaluma/ember-distribution/utils/inquiry-deadline";
|
6
6
|
import inquiryStatus from "@projectcaluma/ember-distribution/utils/inquiry-status";
|
7
7
|
|
8
|
-
export default class
|
8
|
+
export default class CdNavigationStatusIndicatorComponent extends Component {
|
9
9
|
@service intl;
|
10
10
|
|
11
11
|
@config config;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<aside>
|
2
|
+
<ul class="uk-tab uk-tab-left uk-margin-remove-bottom">
|
3
|
+
<CdNavigation::Section
|
4
|
+
@type="controlling"
|
5
|
+
@inquiries={{this.inquiries.controlling}}
|
6
|
+
@caseId={{@caseId}}
|
7
|
+
/>
|
8
|
+
<CdNavigation::Section
|
9
|
+
@type="addressed"
|
10
|
+
@inquiries={{this.inquiries.addressed}}
|
11
|
+
/>
|
12
|
+
<CdNavigation::Section @type="more" @inquiries={{this.inquiries.more}} />
|
13
|
+
</ul>
|
14
|
+
</aside>
|