From 10619bf7abb1a4e7dd5485eeab7928ce9efe426c Mon Sep 17 00:00:00 2001
From: Alana Luyten
Date: Thu, 20 Oct 2022 17:51:29 +0200
Subject: [PATCH] feat(distribution): enable configurable inquiry answer
details
Display configurable inquiry details on the answer form in
a side-bar and include the assigned user on the inquiry
answer dialog.
---
.../addon/components/cd-document-header.hbs | 13 +-
.../components/cd-inquiry-answer-form.hbs | 217 ++++++++++++------
.../components/cd-inquiry-answer-form.js | 14 ++
.../cd-inquiry-dialog/inquiry-deadline.hbs | 1 +
.../cd-inquiry-dialog/inquiry-part.hbs | 205 ++++++++++-------
.../addon/components/cd-inquiry-edit-form.hbs | 2 -
packages/distribution/addon/config.js | 17 ++
.../gql/fragments/inquiry-answer.graphql | 9 +-
.../addon/gql/queries/inquiry-answer.graphql | 2 +
.../addon/gql/queries/inquiry-dialog.graphql | 1 +
.../distribution/app/styles/_answer-form.scss | 4 +
.../components/cd-document-header-test.js | 14 --
.../cd-inquiry-dialog/inquiry-part-test.js | 8 +-
.../cd-inquiry-dialog/inquiry-test.js | 2 +-
.../distribution/tests/unit/config-test.js | 2 +
packages/distribution/translations/de.yaml | 11 +-
packages/distribution/translations/en.yaml | 11 +-
packages/distribution/translations/fr.yaml | 11 +-
18 files changed, 342 insertions(+), 202 deletions(-)
diff --git a/packages/distribution/addon/components/cd-document-header.hbs b/packages/distribution/addon/components/cd-document-header.hbs
index 14ff27627..0f23ea04b 100644
--- a/packages/distribution/addon/components/cd-document-header.hbs
+++ b/packages/distribution/addon/components/cd-document-header.hbs
@@ -9,15 +9,4 @@
{{/if}}
{{yield}}
-
-
-{{#if (and @modifiedBy @modifiedAt)}}
-
- {{t
- "caluma.distribution.last-modified"
- user=(user-name @modifiedBy)
- date=(format-date @modifiedAt)
- time=(format-time @modifiedAt hour="2-digit" minute="2-digit")
- }}
-
-{{/if}}
\ No newline at end of file
+
\ No newline at end of file
diff --git a/packages/distribution/addon/components/cd-inquiry-answer-form.hbs b/packages/distribution/addon/components/cd-inquiry-answer-form.hbs
index 847cc5085..069291ad0 100644
--- a/packages/distribution/addon/components/cd-inquiry-answer-form.hbs
+++ b/packages/distribution/addon/components/cd-inquiry-answer-form.hbs
@@ -5,92 +5,157 @@
>
<:default as |content|>
-
-
-
+
+
+
+
+
-
+ {{#if this.inquiryDetails.length}}
+
+
+
+ {{/if}}
+
-
-
-
+
- {{#if
- (and
- (not this.buttons.length)
- (can "edit answer form of inquiry" this.inquiry)
- )
- }}
-
-
- {{t "caluma.distribution.answer.complete-not-allowed"}}
- {{t "caluma.distribution.not-allowed-hint"}}
-
- {{/if}}
+
+
+
+
+
-
+ {{#if
+ (and
+ (not this.buttons.length)
+ (can "edit answer form of inquiry" this.inquiry)
+ )
+ }}
+
+
+ {{t "caluma.distribution.answer.complete-not-allowed"}}
+ {{t "caluma.distribution.not-allowed-hint"}}
+
+ {{/if}}
- {{#each this.buttons as |buttonConfig|}}
- {{#if buttonConfig.isFormButton}}
-
-
+
+ {{#each this.buttons as |buttonConfig|}}
+ {{#if buttonConfig.isFormButton}}
+
+ {{buttonConfig.label}}
+
+ {{else}}
+ {{buttonConfig.label}}
-
- {{else}}
-
{{buttonConfig.label}}
+ }}
+ @onClick={{fn
+ (perform this.completeWorkItem)
+ buttonConfig.workItemId
+ null
+ }}
+ >{{buttonConfig.label}}
+ {{/if}}
+ {{/each}}
+
+
+ {{#if (and this.isExpanded this.inquiryDetails.length)}}
+
{{/if}}
- {{/each}}
+
+
<:notfound>
\ No newline at end of file
diff --git a/packages/distribution/addon/components/cd-inquiry-answer-form.js b/packages/distribution/addon/components/cd-inquiry-answer-form.js
index f62cd5b18..8a76beef7 100644
--- a/packages/distribution/addon/components/cd-inquiry-answer-form.js
+++ b/packages/distribution/addon/components/cd-inquiry-answer-form.js
@@ -1,5 +1,7 @@
+import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
import { queryManager, getObservable } from "ember-apollo-client";
import { dropTask } from "ember-concurrency";
import { trackedTask } from "ember-resources/util/ember-concurrency";
@@ -22,6 +24,7 @@ export default class CdInquiryAnswerFormComponent extends Component {
@queryManager apollo;
@inquiryAnswerStatus({ inquiryProperty: "inquiry" }) answerStatus;
+ @tracked isExpanded = !this.config.ui.small;
_inquiry = trackedTask(this, this.fetchInquiryAnswer, () => [
this.args.inquiry,
@@ -31,8 +34,13 @@ export default class CdInquiryAnswerFormComponent extends Component {
return this._inquiry.value?.[0]?.node;
}
+ get inquiryDetails() {
+ return this.config.inquiry.answer.details?.(this.inquiry);
+ }
+
get buttons() {
return this.inquiry?.childCase.workItems.edges
+ .filter((edge) => edge.node.status === "READY")
.map((edge) => {
const config = this.config.inquiry.answer.buttons[edge.node.task.slug];
@@ -53,6 +61,12 @@ export default class CdInquiryAnswerFormComponent extends Component {
.filter(Boolean);
}
+ @action
+ toggle(e) {
+ e.preventDefault();
+ this.isExpanded = !this.isExpanded;
+ }
+
@dropTask
*fetchInquiryAnswer(inquiry) {
return yield this.apollo.watchQuery(
diff --git a/packages/distribution/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs b/packages/distribution/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs
index ca379158b..495659469 100644
--- a/packages/distribution/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs
+++ b/packages/distribution/addon/components/cd-inquiry-dialog/inquiry-deadline.hbs
@@ -1,6 +1,7 @@
{{#if this.deadline.value}}
diff --git a/packages/distribution/addon/components/cd-inquiry-dialog/inquiry-part.hbs b/packages/distribution/addon/components/cd-inquiry-dialog/inquiry-part.hbs
index 518b54fb9..c0cc17aa6 100644
--- a/packages/distribution/addon/components/cd-inquiry-dialog/inquiry-part.hbs
+++ b/packages/distribution/addon/components/cd-inquiry-dialog/inquiry-part.hbs
@@ -19,106 +19,133 @@
{{yield}}
-
- -
-
- {{format-date this.date}}
- {{format-time this.date hour="2-digit" minute="2-digit"}}
-
-
+
{{#unless @disabled}}
- {{#if (or (eq @type "answer") (cannot "edit inquiry" @inquiry))}}
-
-
-
- {{t "caluma.distribution.details"}}
-
-
- {{/if}}
- {{#if (can "edit inquiry" @inquiry)}}
-
-
-
- {{t "caluma.distribution.edit.link"}}
-
-
- {{#if (can "withdraw inquiry" @inquiry)}}
+
+ {{#if (or (eq @type "answer") (cannot "edit inquiry" @inquiry))}}
+ -
+
+ {{t "caluma.distribution.details"}}
+
+
+ {{/if}}
+ {{#if (can "edit inquiry" @inquiry)}}
+ -
+
+ {{t "caluma.distribution.edit.link"}}
+
+
+ {{#if (can "withdraw inquiry" @inquiry)}}
+ -
+
+ {{t "caluma.distribution.withdraw.link"}}
+
+
+ {{/if}}
+ {{else if (can "answer inquiry" @inquiry)}}
+ -
+
+ {{t "caluma.distribution.answer.link"}}
+
+
+ {{/if}}
+ {{#if (and (eq @type "answer") (can "reopen inquiry" @inquiry))}}
+ -
+
+ {{t "caluma.distribution.reopen-inquiry.link"}}
+
+
+ {{/if}}
+ {{#if (can "send reminder inquiry" @inquiry)}}
-
- {{t "caluma.distribution.withdraw.link"}}
+ {{t "caluma.distribution.reminder.link"}}
+
+
+ {{t "caluma.distribution.reminder.title"}}
+
+ {{#if @inquiry.meta.reminders}}
+
+ {{#each @inquiry.meta.reminders as |reminder|}}
+
+ {{format-date reminder}}
+ {{format-time reminder hour="2-digit" minute="2-digit"}}
+
+ {{/each}}
+
+ {{else}}
+
+ {{t "caluma.distribution.reminder.no-reminders"}}
+
+ {{/if}}
+
{{/if}}
- {{else if (can "answer inquiry" @inquiry)}}
- -
-
- {{t "caluma.distribution.answer.link"}}
-
-
- {{/if}}
- {{#if (and (eq @type "answer") (can "reopen inquiry" @inquiry))}}
- -
-
- {{t "caluma.distribution.reopen-inquiry.link"}}
-
+
+ {{/unless}}
+
+ {{#if (and (eq @type "answer") @inquiry.assignedUsers.length)}}
+ -
+ {{user-name @inquiry.assignedUsers}}
{{/if}}
- {{/unless}}
- {{#if (can "send reminder inquiry" @inquiry)}}
- -
-
- {{t "caluma.distribution.reminder.link"}}
-
-
-
- {{t "caluma.distribution.reminder.title"}}
-
- {{#if @inquiry.meta.reminders}}
-
- {{#each @inquiry.meta.reminders as |reminder|}}
-
- {{format-date reminder}}
- {{format-time reminder hour="2-digit" minute="2-digit"}}
-
- {{/each}}
-
- {{else}}
-
- {{t "caluma.distribution.reminder.no-reminders"}}
-
- {{/if}}
-
+ -
+ {{format-date this.date}}
+ {{format-time this.date hour="2-digit" minute="2-digit"}}
- {{/if}}
-
+
+
+
{{#if this.requestInfo}}
diff --git a/packages/distribution/addon/config.js b/packages/distribution/addon/config.js
index a12ae445b..5718ef13c 100644
--- a/packages/distribution/addon/config.js
+++ b/packages/distribution/addon/config.js
@@ -57,6 +57,23 @@ export default function config(target, property) {
status: "caluma.distribution.answer.buttons.adjust.status",
},
},
+ details: (inquiry) => [
+ {
+ label: "caluma.distribution.inquiry.created-at",
+ value: inquiry.createdAt,
+ type: "date",
+ },
+ {
+ label: "caluma.distribution.inquiry.assigned-user",
+ value: inquiry.assignedUsers,
+ type: "user",
+ },
+ {
+ label: "caluma.distribution.inquiry.closed-at",
+ value: inquiry.closedAt,
+ type: "date",
+ },
+ ],
},
},
new: {
diff --git a/packages/distribution/addon/gql/fragments/inquiry-answer.graphql b/packages/distribution/addon/gql/fragments/inquiry-answer.graphql
index e3a711ee0..422ab5171 100644
--- a/packages/distribution/addon/gql/fragments/inquiry-answer.graphql
+++ b/packages/distribution/addon/gql/fragments/inquiry-answer.graphql
@@ -16,11 +16,18 @@ fragment InquiryAnswerStatus on Document {
}
fragment InquiryAnswerButtons on Case {
- workItems(filter: [{ tasks: $buttonTasks }, { status: READY }]) {
+ workItems(
+ filter: [
+ { tasks: $buttonTasks }
+ { status: CANCELED, invert: true }
+ { status: SKIPPED, invert: true }
+ ]
+ ) {
edges {
node {
id
status
+ closedAt
task {
id
slug
diff --git a/packages/distribution/addon/gql/queries/inquiry-answer.graphql b/packages/distribution/addon/gql/queries/inquiry-answer.graphql
index 7c792900d..2a73fd330 100644
--- a/packages/distribution/addon/gql/queries/inquiry-answer.graphql
+++ b/packages/distribution/addon/gql/queries/inquiry-answer.graphql
@@ -14,6 +14,8 @@ query InquiryAnswer(
status
addressedGroups
controllingGroups
+ assignedUsers
+ closedByUser
createdAt
closedAt
task {
diff --git a/packages/distribution/addon/gql/queries/inquiry-dialog.graphql b/packages/distribution/addon/gql/queries/inquiry-dialog.graphql
index b71e03703..85f0dc6ba 100644
--- a/packages/distribution/addon/gql/queries/inquiry-dialog.graphql
+++ b/packages/distribution/addon/gql/queries/inquiry-dialog.graphql
@@ -5,6 +5,7 @@ fragment DialogInquiry on WorkItem {
id
addressedGroups
controllingGroups
+ assignedUsers
createdAt
closedAt
status
diff --git a/packages/distribution/app/styles/_answer-form.scss b/packages/distribution/app/styles/_answer-form.scss
index fb6e9606d..8664a0b3b 100644
--- a/packages/distribution/app/styles/_answer-form.scss
+++ b/packages/distribution/app/styles/_answer-form.scss
@@ -2,3 +2,7 @@
border-left: 5px solid $global-border;
padding-left: $global-gutter - 5px;
}
+
+.inquiry-answer-form__side-bar {
+ max-width: 25%;
+}
\ No newline at end of file
diff --git a/packages/distribution/tests/integration/components/cd-document-header-test.js b/packages/distribution/tests/integration/components/cd-document-header-test.js
index ce3f16332..979130cce 100644
--- a/packages/distribution/tests/integration/components/cd-document-header-test.js
+++ b/packages/distribution/tests/integration/components/cd-document-header-test.js
@@ -11,33 +11,19 @@ module("Integration | Component | cd-document-header", function (hooks) {
test("it renders", async function (assert) {
this.status = "Test";
- this.modifiedAt = new Date(2022, 4, 3, 14, 43);
- this.modifiedBy = 1;
await render(hbs`
`);
assert.dom("p.uk-text-large").containsText("Test");
assert.dom("p.uk-text-large .uk-label").hasText("Test");
- assert
- .dom("p.uk-text-meta")
- .hasText(
- 't:caluma.distribution.last-modified:("date":"5/3/2022","time":"02:43 PM","user":1)'
- );
-
this.set("status", null);
assert.dom("p.uk-text-large .uk-label").doesNotExist();
-
- this.set("modifiedBy", null);
-
- assert.dom("p.uk-text-meta").doesNotExist();
});
});
diff --git a/packages/distribution/tests/integration/components/cd-inquiry-dialog/inquiry-part-test.js b/packages/distribution/tests/integration/components/cd-inquiry-dialog/inquiry-part-test.js
index 1186c0ab3..c12b676fe 100644
--- a/packages/distribution/tests/integration/components/cd-inquiry-dialog/inquiry-part-test.js
+++ b/packages/distribution/tests/integration/components/cd-inquiry-dialog/inquiry-part-test.js
@@ -58,10 +58,10 @@ module(
assert.dom("[data-test-title]").containsText("controlling");
assert
- .dom("ul.uk-subnav > li:nth-of-type(1)")
+ .dom("ul:nth-of-type(2).uk-subnav > li:nth-of-type(1)")
.containsText(date(this.createdAt));
assert
- .dom("ul.uk-subnav > li:nth-of-type(1)")
+ .dom("ul:nth-of-type(2).uk-subnav > li:nth-of-type(1)")
.containsText(time(this.createdAt));
assert.dom("[data-test-inquiry-request]").hasText("Question?");
@@ -69,10 +69,10 @@ module(
assert.dom("[data-test-title]").containsText("addressed");
assert
- .dom("ul.uk-subnav > li:nth-of-type(1)")
+ .dom("ul:nth-of-type(2).uk-subnav > li:nth-of-type(1)")
.containsText(date(this.closedAt));
assert
- .dom("ul.uk-subnav > li:nth-of-type(1)")
+ .dom("ul:nth-of-type(2).uk-subnav > li:nth-of-type(1)")
.containsText(time(this.closedAt));
assert.dom("[data-test-inquiry-answer]").hasText("Answer!");
});
diff --git a/packages/distribution/tests/integration/components/cd-inquiry-dialog/inquiry-test.js b/packages/distribution/tests/integration/components/cd-inquiry-dialog/inquiry-test.js
index f25ea8292..a1bd15186 100644
--- a/packages/distribution/tests/integration/components/cd-inquiry-dialog/inquiry-test.js
+++ b/packages/distribution/tests/integration/components/cd-inquiry-dialog/inquiry-test.js
@@ -17,7 +17,7 @@ module("Integration | Component | cd-inquiry-dialog/inquiry", function (hooks) {
assert.dom("[data-test-deadline]").exists();
assert.dom(".inquiry-divider").exists();
- assert.dom(".uk-subnav").exists({ count: 2 });
+ assert.dom(".uk-subnav").exists({ count: 4 });
assert.dom("[data-test-title]").exists({ count: 2 });
assert.dom("p").exists({ count: 3 });
});
diff --git a/packages/distribution/tests/unit/config-test.js b/packages/distribution/tests/unit/config-test.js
index 765a8545f..a695d0a60 100644
--- a/packages/distribution/tests/unit/config-test.js
+++ b/packages/distribution/tests/unit/config-test.js
@@ -24,6 +24,7 @@ module("Unit | config", function (hooks) {
"q1-a3": "positive",
},
statusQuestion: "q1",
+ details: null,
},
},
};
@@ -60,6 +61,7 @@ module("Unit | config", function (hooks) {
},
},
infoQuestions: ["inquiry-answer-reason"],
+ details: null,
statusMapping: {
"inquiry-answer-status-needs-interaction": "needs-interaction",
"inquiry-answer-status-negative": "negative",
diff --git a/packages/distribution/translations/de.yaml b/packages/distribution/translations/de.yaml
index 43533abea..beda23ee5 100644
--- a/packages/distribution/translations/de.yaml
+++ b/packages/distribution/translations/de.yaml
@@ -29,12 +29,17 @@ caluma:
more: "mehr"
less: "weniger"
- last-modified: "Zuletzt bearbeitet von {user} am {date} um {time}"
details: "Details"
not-allowed-hint:
"Sie können jedoch das Formular bearbeiten und die Eingabedaten werden
automatisch gespeichert."
+ inquiry:
+ created-at: "Erstellt am"
+ closed-at: "Beantwortet am"
+ deadline: "Frist"
+ assigned-user: "Verantwortliche Person"
+
edit:
link: "Bearbeiten"
send: "Aktuelle Anfrage versenden"
@@ -64,6 +69,10 @@ caluma:
revise:
label: "Überarbeiten"
+ details:
+ show: "Details anzeigen"
+ hide: "Details verstecken"
+
new:
title: "Neue Anfrage"
search: "Suchen..."
diff --git a/packages/distribution/translations/en.yaml b/packages/distribution/translations/en.yaml
index 88bdd8b4c..d40a9a4d5 100644
--- a/packages/distribution/translations/en.yaml
+++ b/packages/distribution/translations/en.yaml
@@ -29,12 +29,17 @@ caluma:
more: "more"
less: "less"
- last-modified: "Last modified by {user} on {date} at {time}"
details: "Details"
not-allowed-hint:
"However, you can edit the form and the input will be saved
automatically."
+ inquiry:
+ created-at: "Created at"
+ closed-at: "Answered at"
+ deadline: "Deadline"
+ assigned-user: "Assigned user"
+
edit:
link: "Edit"
send: "Send current inquiry"
@@ -64,6 +69,10 @@ caluma:
revise:
label: "Revise"
+ details:
+ show: "Show details"
+ hide: "Hide details"
+
new:
title: "New inquiry"
search: "Search..."
diff --git a/packages/distribution/translations/fr.yaml b/packages/distribution/translations/fr.yaml
index be2bf7bbc..e1e1b6aa1 100644
--- a/packages/distribution/translations/fr.yaml
+++ b/packages/distribution/translations/fr.yaml
@@ -29,12 +29,17 @@ caluma:
more: "plus"
less: "moins"
- last-modified: "Dernière modification par {user} le {date} à {time}"
details: "Détails"
not-allowed-hint:
"Vous pouvez toutefois modifier le formulaire et les données seront
automatiquement enregistrées."
+ inquiry:
+ created-at: "Créé le"
+ closed-at: "Répondu le"
+ deadline: "Délai"
+ assigned-user: "Personne responsable"
+
edit:
link: "Modifier"
send: "Envoyer la demande actuelle"
@@ -64,6 +69,10 @@ caluma:
revise:
label: "Réviser"
+ details:
+ show: "Afficher les détails"
+ hide: "Cacher les détails"
+
new:
title: "Nouvelle demande"
search: "Chercher..."