@projectcaluma/ember-distribution 11.0.0-beta.27 → 11.0.0-beta.28

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.
@@ -1,5 +1,6 @@
1
1
  import { inject as service } from "@ember/service";
2
2
  import { Ability } from "ember-can";
3
+ import { DateTime } from "luxon";
3
4
 
4
5
  import config from "@projectcaluma/ember-distribution/config";
5
6
 
@@ -66,4 +67,22 @@ export default class InquiryAbility extends Ability {
66
67
  (this.config.permissions.reopenInquiry?.(this.model) ?? true)
67
68
  );
68
69
  }
70
+
71
+ get canSendReminder() {
72
+ const deadline = DateTime.fromISO(
73
+ this.model.document?.deadline.edges[0]?.node.value
74
+ );
75
+
76
+ return (
77
+ !this.config.ui.readonly &&
78
+ this.config.enableReminders &&
79
+ this.model?.task.slug === this.config.inquiry.task &&
80
+ this.model?.status === "READY" &&
81
+ this.model?.controllingGroups
82
+ .map(String)
83
+ .includes(String(this.calumaOptions.currentGroupId)) &&
84
+ deadline.diffNow("days").days <= 0 &&
85
+ (this.config.permissions.sendReminder?.(this.model) ?? true)
86
+ );
87
+ }
69
88
  }
@@ -85,6 +85,39 @@
85
85
  </li>
86
86
  {{/if}}
87
87
  {{/unless}}
88
+ {{#if (can "send reminder inquiry" @inquiry)}}
89
+ <li>
90
+ <a
91
+ data-test-send-reminder
92
+ href=""
93
+ {{on "click" (perform this.sendReminder)}}
94
+ >
95
+ {{t "caluma.distribution.reminder.link"}}
96
+ </a>
97
+ <div
98
+ uk-dropdown="mode: hover; pos: bottom"
99
+ class="uk-padding-small uk-width-small"
100
+ >
101
+ <div class="uk-text-center uk-text-bold uk-margin-small-bottom">
102
+ {{t "caluma.distribution.reminder.title"}}
103
+ </div>
104
+ {{#if @inquiry.meta.reminders}}
105
+ <div class="uk-height-max-small uk-overflow-auto">
106
+ {{#each @inquiry.meta.reminders as |reminder|}}
107
+ <div class="uk-text-center uk-text-small uk-text-muted">
108
+ {{format-date reminder}}
109
+ {{format-time reminder hour="2-digit" minute="2-digit"}}
110
+ </div>
111
+ {{/each}}
112
+ </div>
113
+ {{else}}
114
+ <div class="uk-text-center">
115
+ {{t "caluma.distribution.reminder.no-reminders"}}
116
+ </div>
117
+ {{/if}}
118
+ </div>
119
+ </li>
120
+ {{/if}}
88
121
  </ul>
89
122
 
90
123
  {{#if this.requestInfo}}
@@ -4,10 +4,12 @@ import Component from "@glimmer/component";
4
4
  import { queryManager } from "ember-apollo-client";
5
5
  import { dropTask } from "ember-concurrency";
6
6
  import { confirm } from "ember-uikit";
7
+ import { DateTime } from "luxon";
7
8
 
8
9
  import { decodeId } from "@projectcaluma/ember-core/helpers/decode-id";
9
10
  import config from "@projectcaluma/ember-distribution/config";
10
11
  import reopenInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/reopen-inquiry.graphql";
12
+ import updateInquiryMetaMutation from "@projectcaluma/ember-distribution/gql/mutations/update-inquiry-meta.graphql";
11
13
  import withdrawInquiryMutation from "@projectcaluma/ember-distribution/gql/mutations/withdraw-inquiry.graphql";
12
14
  import inquiryAnswerStatus from "@projectcaluma/ember-distribution/utils/inquiry-answer-status";
13
15
 
@@ -15,6 +17,7 @@ export default class CdInquiryDialogInquiryPartComponent extends Component {
15
17
  @service notification;
16
18
  @service router;
17
19
  @service intl;
20
+ @service calumaOptions;
18
21
 
19
22
  @queryManager apollo;
20
23
 
@@ -103,4 +106,41 @@ export default class CdInquiryDialogInquiryPartComponent extends Component {
103
106
  );
104
107
  }
105
108
  }
109
+
110
+ @dropTask
111
+ *sendReminder(e) {
112
+ e.preventDefault();
113
+
114
+ if (!(yield confirm(this.intl.t("caluma.distribution.reminder.confirm")))) {
115
+ return;
116
+ }
117
+
118
+ try {
119
+ yield this.calumaOptions.sendReminderDistributionInquiry(
120
+ decodeId(this.args.inquiry.id)
121
+ );
122
+
123
+ this.notification.success(
124
+ this.intl.t("caluma.distribution.reminder.success")
125
+ );
126
+
127
+ yield this.apollo.mutate({
128
+ mutation: updateInquiryMetaMutation,
129
+ variables: {
130
+ inquiry: decodeId(this.args.inquiry.id),
131
+ meta: JSON.stringify({
132
+ ...this.args.inquiry.meta,
133
+ reminders: [
134
+ DateTime.now().toISO(),
135
+ ...(this.args.inquiry.meta.reminders ?? []),
136
+ ],
137
+ }),
138
+ },
139
+ });
140
+ } catch (error) {
141
+ this.notification.danger(
142
+ this.intl.t("caluma.distribution.reminder.error")
143
+ );
144
+ }
145
+ }
106
146
  }
@@ -55,6 +55,8 @@ export default class CdNavigationControlsComponent extends Component {
55
55
  },
56
56
  });
57
57
 
58
+ yield this.config.hooks.postCompleteDistribution?.();
59
+
58
60
  yield this.distribution.refetch();
59
61
  this.router.transitionTo("index");
60
62
  } catch (e) {
package/addon/config.js CHANGED
@@ -69,6 +69,8 @@ export default function config(target, property) {
69
69
  },
70
70
  },
71
71
  permissions: {},
72
+ hooks: {},
73
+ enableReminders: true,
72
74
  },
73
75
  getOwner(this).lookup("service:calumaOptions")?.distribution ?? {}
74
76
  );
@@ -72,6 +72,7 @@ fragment InquiryDialog on WorkItem {
72
72
  id
73
73
  slug
74
74
  }
75
+ meta
75
76
  document {
76
77
  ...InquiryRequest
77
78
  }
@@ -0,0 +1,8 @@
1
+ mutation UpdateInquiryMeta($inquiry: ID!, $meta: JSONString!) {
2
+ saveWorkItem(input: { workItem: $inquiry, meta: $meta }) {
3
+ workItem {
4
+ id
5
+ meta
6
+ }
7
+ }
8
+ }
@@ -21,7 +21,7 @@ function decorator(
21
21
  const value = inquiry.document?.deadline.edges[0]?.node.value;
22
22
  const isDone = ["COMPLETED", "SKIPPED"].includes(inquiry.status);
23
23
 
24
- const { days: diff } = DateTime.fromISO(value).diffNow("days").toObject();
24
+ const diff = DateTime.fromISO(value).diffNow("days").days;
25
25
 
26
26
  const isOverdue = !isDone && diff <= 0;
27
27
  const isWarning = !isDone && diff <= this.config.warningPeriod;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-distribution",
3
- "version": "11.0.0-beta.27",
3
+ "version": "11.0.0-beta.28",
4
4
  "description": "Ember engine for the Caluma distribution module.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -22,20 +22,20 @@
22
22
  "@embroider/macros": "^1.8.3",
23
23
  "@glimmer/component": "^1.1.2",
24
24
  "@glimmer/tracking": "^1.1.2",
25
- "@projectcaluma/ember-core": "^11.0.0-beta.27",
26
- "@projectcaluma/ember-form": "^11.0.0-beta.27",
27
- "@projectcaluma/ember-workflow": "^11.0.0-beta.27",
25
+ "@projectcaluma/ember-core": "^11.0.0-beta.28",
26
+ "@projectcaluma/ember-form": "^11.0.0-beta.28",
27
+ "@projectcaluma/ember-workflow": "^11.0.0-beta.28",
28
28
  "ember-apollo-client": "~4.0.2",
29
29
  "ember-auto-import": "^2.4.2",
30
30
  "ember-can": "^4.2.0",
31
31
  "ember-cli-babel": "^7.26.11",
32
- "ember-cli-htmlbars": "^6.1.0",
33
- "ember-concurrency": "^2.3.2",
32
+ "ember-cli-htmlbars": "^6.1.1",
33
+ "ember-concurrency": "^2.3.7",
34
34
  "ember-engines-router-service": "^0.3.0",
35
35
  "ember-fetch": "^8.1.2",
36
36
  "ember-intl": "^5.7.2",
37
37
  "ember-pikaday": "^4.0.0",
38
- "ember-resources": "^5.3.0",
38
+ "ember-resources": "^5.3.2",
39
39
  "ember-svg-jar": "^2.3.4",
40
40
  "ember-test-selectors": "^6.0.0",
41
41
  "ember-uikit": "^6.0.0",
@@ -50,7 +50,7 @@
50
50
  "@ember/test-helpers": "2.8.1",
51
51
  "@embroider/test-setup": "1.8.3",
52
52
  "@faker-js/faker": "7.5.0",
53
- "@projectcaluma/ember-testing": "11.0.0-beta.27",
53
+ "@projectcaluma/ember-testing": "11.0.0-beta.28",
54
54
  "broccoli-asset-rev": "3.0.0",
55
55
  "ember-cli": "3.28.5",
56
56
  "ember-cli-code-coverage": "1.0.3",
@@ -75,7 +75,7 @@
75
75
  "npm-run-all": "4.1.5",
76
76
  "qunit": "2.19.1",
77
77
  "qunit-dom": "2.0.0",
78
- "sass": "1.54.6",
78
+ "sass": "1.54.9",
79
79
  "webpack": "5.74.0"
80
80
  },
81
81
  "engines": {
@@ -61,6 +61,14 @@ caluma:
61
61
  create-draft: "Entwurf erstellen"
62
62
  error: "Fehler beim Erstellen der {count, plural, =1 {Anfragen} other {Anfrage}}"
63
63
 
64
+ reminder:
65
+ link: "Erinnerung versenden"
66
+ confirm: "Wollen Sie wirklich eine Erinnerung für diese Anfrage versenden?"
67
+ title: "Versendete Erinnerungen"
68
+ no-reminders: "Es wurden noch keine Erinnerungen für diese Anfrage versendet."
69
+ success: "Die Erinnerung wurde erfolgreich versendet"
70
+ error: "Fehler beim Versenden der Erinnerung"
71
+
64
72
  types:
65
73
  controlling: "Angefordert"
66
74
  addressed: "Zu beantworten"
@@ -62,6 +62,14 @@ caluma:
62
62
  create-draft: "Create draft"
63
63
  error: "Error while creating the {count, plural, =1 {inquiry} other {inquiries}}"
64
64
 
65
+ reminder:
66
+ link: "Send reminder"
67
+ confirm: "Do you really want to send a reminder for this inquiry?"
68
+ title: "Sent reminders"
69
+ no-reminders: "No reminders have been sent for this inquiry yet."
70
+ success: "The reminder has been sent successfully"
71
+ error: "Error while sending the reminder"
72
+
65
73
  types:
66
74
  controlling: "Requested"
67
75
  addressed: "To answer"
@@ -61,6 +61,14 @@ caluma:
61
61
  create-draft: "Créer un brouillon"
62
62
  error: "Error lors de la création {count, plural, =1 {de la demande} other {des demandes}}"
63
63
 
64
+ reminder:
65
+ link: "Envoyer un rappel"
66
+ confirm: "Voulez-vous vraiment envoyer un rappel pour cette demande ?"
67
+ title: "Rappels envoyés"
68
+ no-reminders: Aucun rappel n'a encore été envoyé pour cette demande.
69
+ success: "Le rappel a été envoyé avec succès"
70
+ error: "Erreur lors de l'envoi du rappel"
71
+
64
72
  types:
65
73
  controlling: "Demandé"
66
74
  addressed: "A répondre"