diff --git a/ember/app/caluma-query/models/work-item.js b/ember/app/caluma-query/models/work-item.js
index f69003b6..079b4b9f 100644
--- a/ember/app/caluma-query/models/work-item.js
+++ b/ember/app/caluma-query/models/work-item.js
@@ -1,45 +1,6 @@
-import { inject as service } from "@ember/service";
-import { tracked } from "@glimmer/tracking";
import WorkItemModel from "@projectcaluma/ember-core/caluma-query/models/work-item";
-import saveWorkItemMutation from "caluma-portal-demo/gql/mutations/save-work-item";
-import { queryManager } from "ember-apollo-client";
export default class CustomWorkItemModel extends WorkItemModel {
- @queryManager apollo;
-
- @service store;
- @service router;
- @service intl;
- @service notifications;
-
- @tracked meta = this.raw.meta;
- @tracked notViewed = this.raw.meta["not-viewed"];
- @tracked assignedUsers = this.raw.assignedUsers;
- @tracked addressedGroups = this.raw.addressedGroups;
-
- get assignedUser() {
- return this.assignedUsers;
- }
- set assignedUser(user) {
- this.assignedUsers = [user];
- }
-
- get addressedGroup() {
- return this.addressedGroups;
- }
-
- get closedByUser() {
- return this.raw.closedByUser;
- }
-
- get createdByUser() {
- return this.raw.createdByUser;
- }
-
- get createdByGroup() {
- return this.raw.createdByGroup;
- }
-
get isReady() {
return this.raw.status === "READY";
}
@@ -48,77 +9,10 @@ export default class CustomWorkItemModel extends WorkItemModel {
return this.raw.status === "COMPLETED";
}
- get canEdit() {
- return this.isReady;
- }
-
- get canEditAsCreator() {
- return this.isReady;
- }
-
- get canComplete() {
- return this.isReady;
- }
-
- get responsible() {
- return this.assignedUser;
- }
-
get case() {
return this.raw.case.parentWorkItem?.case || this.raw.case;
}
- get calumaForm() {
- return null;
- }
-
- async toggleRead() {
- try {
- this.notViewed = !this.notViewed;
-
- await this.apollo.mutate({
- mutation: saveWorkItemMutation,
- variables: {
- input: {
- workItem: this.id,
- meta: JSON.stringify({
- ...this.raw.meta,
- "not-viewed": this.notViewed,
- }),
- },
- },
- });
-
- return true;
- } catch (error) {
- this.notifications.error(this.intl.t("workItems.saveError"));
- }
- }
-
- async assignToMe() {
- return await this.assignToUser(/* TODO current user*/);
- }
-
- async assignToUser(user) {
- try {
- this.assignedUser = user;
-
- await this.apollo.mutate({
- mutation: saveWorkItemMutation,
- variables: {
- input: {
- workItem: this.id,
- assignedUsers: this.assignedUsers,
- },
- },
- });
-
- return true;
- } catch (error) {
- this.notifications.error(this.intl.t("workItems.saveError"));
- }
- }
-
static fragment = `{
createdAt
createdByUser
diff --git a/ember/app/cases/detail/controller.js b/ember/app/cases/detail/controller.js
index 793ef422..e9a42db9 100644
--- a/ember/app/cases/detail/controller.js
+++ b/ember/app/cases/detail/controller.js
@@ -16,8 +16,9 @@ export default class CasesDetailController extends Controller.extend(
this.fetchCase.cancelAll();
}
- @lastValue("fetchCase") caseNode;
- @task *fetchCase() {
+ @lastValue("fetchCase") case;
+ @task
+ *fetchCase() {
if (typeof this.model === "object" && this.model) {
return this.model;
}
diff --git a/ember/app/cases/detail/template.hbs b/ember/app/cases/detail/template.hbs
index 966ee5eb..1ab6d387 100644
--- a/ember/app/cases/detail/template.hbs
+++ b/ember/app/cases/detail/template.hbs
@@ -9,19 +9,19 @@
class="uk-icon-button uk-margin-right"
uk-icon="icon: arrow-left; ratio: 2"
/>
- {{this.caseNode.document.form.name}}
+ {{this.case.document.form.name}}
-
+
{{t "documents.subnav.overview"}}
-
-
+
+
{{t "documents.subnav.workItems"}}
-
-
+
+
{{t "documents.subnav.document"}}
-
+
{{outlet}}
diff --git a/ember/app/cases/detail/work-items/edit/controller.js b/ember/app/cases/detail/work-items/edit/controller.js
deleted file mode 100644
index 4f653f7a..00000000
--- a/ember/app/cases/detail/work-items/edit/controller.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import Controller from "@ember/controller";
-
-export default class CasesDetailWorkItemsEditController extends Controller {}
diff --git a/ember/app/cases/detail/work-items/edit/form/controller.js b/ember/app/cases/detail/work-items/edit/form/controller.js
index 748c0ed0..c3737d9d 100644
--- a/ember/app/cases/detail/work-items/edit/form/controller.js
+++ b/ember/app/cases/detail/work-items/edit/form/controller.js
@@ -14,27 +14,26 @@ export default class CasesDetailWorkItemsEditFormController extends Controller {
@queryManager apollo;
@service store;
- @service notifications;
+ @service notification;
@service intl;
- @service moment;
-
- @lastValue("fetchWorkItems") workItem;
+ @service router;
@calumaQuery({ query: allWorkItems })
workItemsQuery;
+ @lastValue("fetchWorkItems") workItem;
@restartableTask()
- *fetchWorkItems(model) {
- if (typeof model === "object") {
- return model;
+ *fetchWorkItems(id) {
+ if (typeof id === "object") {
+ return id;
}
try {
- yield this.workItemsQuery.fetch({ filter: [{ id: model }] });
+ yield this.workItemsQuery.fetch({ filter: [{ id }] });
return this.workItemsQuery.value[0];
} catch (error) {
console.error(error);
- this.notifications.error(this.intl.t("workItems.fetchError"));
+ this.notification.danger(this.intl.t("workItems.fetchError"));
}
}
@@ -44,6 +43,6 @@ export default class CasesDetailWorkItemsEditFormController extends Controller {
mutation: completeWorkItem,
variables: { id: this.workItem.id },
});
- this.transitionToRoute("cases.detail.work-items");
+ this.router.transitionTo("cases.detail.work-items");
}
}
diff --git a/ember/app/cases/detail/work-items/edit/index/controller.js b/ember/app/cases/detail/work-items/edit/index/controller.js
index 4c82ac81..98fe7b57 100644
--- a/ember/app/cases/detail/work-items/edit/index/controller.js
+++ b/ember/app/cases/detail/work-items/edit/index/controller.js
@@ -1,12 +1,12 @@
import Controller from "@ember/controller";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
-import { tracked } from "@glimmer/tracking";
import calumaQuery from "@projectcaluma/ember-core/caluma-query";
import { allWorkItems } from "@projectcaluma/ember-core/caluma-query/queries";
import completeWorkItem from "caluma-portal-demo/gql/mutations/complete-work-item";
import saveWorkItem from "caluma-portal-demo/gql/mutations/save-work-item";
import { queryManager } from "ember-apollo-client";
+import { lastValue } from "ember-concurrency";
import { dropTask } from "ember-concurrency-decorators";
import moment from "moment";
@@ -14,11 +14,9 @@ export default class CasesDetailWorkItemsEditController extends Controller {
@queryManager apollo;
@service store;
- @service notifications;
+ @service notification;
@service intl;
- @service moment;
-
- @tracked workItem;
+ @service router;
@calumaQuery({ query: allWorkItems, options: "options" })
workItemsQuery;
@@ -29,14 +27,15 @@ export default class CasesDetailWorkItemsEditController extends Controller {
};
}
+ @lastValue("fetchWorkItem") workItem;
@dropTask()
- *fetchWorkItems() {
+ *fetchWorkItem(id) {
try {
- yield this.workItemsQuery.fetch({ filter: [{ id: this.model }] });
+ yield this.workItemsQuery.fetch({ filter: [{ id }] });
- this.workItem = this.workItemsQuery.value[0];
+ return this.workItemsQuery.value[0];
} catch (error) {
- this.notifications.error(this.intl.t("workItems.fetchError"));
+ this.notification.danger(this.intl.t("workItems.fetchError"));
}
}
@@ -60,11 +59,11 @@ export default class CasesDetailWorkItemsEditController extends Controller {
variables: { id: this.workItem.id },
});
- this.notifications.success(this.intl.t("workItems.finishSuccess"));
+ this.notification.success(this.intl.t("workItems.finishSuccess"));
- this.transitionToRoute("cases.detail.work-items.index");
+ this.router.transitionTo("cases.detail.work-items.index");
} catch (error) {
- this.notifications.error(this.intl.t("workItems.saveError"));
+ this.notification.danger(this.intl.t("workItems.saveError"));
}
}
@@ -85,11 +84,11 @@ export default class CasesDetailWorkItemsEditController extends Controller {
},
});
- this.notifications.success(this.intl.t("workItems.saveSuccess"));
+ this.notification.success(this.intl.t("workItems.saveSuccess"));
- this.transitionToRoute("cases.detail.work-items.index");
+ this.router.transitionTo("cases.detail.work-items.index");
} catch (error) {
- this.notifications.error(this.intl.t("workItems.saveError"));
+ this.notification.danger(this.intl.t("workItems.saveError"));
}
}
@@ -97,4 +96,9 @@ export default class CasesDetailWorkItemsEditController extends Controller {
setDeadline(value) {
this.workItem.deadline = moment(value);
}
+
+ @action
+ cancel() {
+ this.router.transitionTo("cases.detail.work-items.index");
+ }
}
diff --git a/ember/app/cases/detail/work-items/edit/index/route.js b/ember/app/cases/detail/work-items/edit/index/route.js
index 1cfcf4f9..46d9d991 100644
--- a/ember/app/cases/detail/work-items/edit/index/route.js
+++ b/ember/app/cases/detail/work-items/edit/index/route.js
@@ -4,4 +4,9 @@ export default class CasesDetailWorkItemsEditRoute extends Route {
model() {
return this.modelFor("cases.detail.work-items.edit");
}
+
+ setupController(controller, model) {
+ super.setupController(controller, model);
+ controller.fetchWorkItem.perform(model);
+ }
}
diff --git a/ember/app/cases/detail/work-items/edit/index/template.hbs b/ember/app/cases/detail/work-items/edit/index/template.hbs
index 7e989a5a..ae140bbf 100644
--- a/ember/app/cases/detail/work-items/edit/index/template.hbs
+++ b/ember/app/cases/detail/work-items/edit/index/template.hbs
@@ -1,6 +1,4 @@
-
-
-
+
{{t "workItems.edit"}}
@@ -33,12 +31,6 @@
hour12=false
}}
-
-
- {{t "workItems.comment"}}
-
- {{or this.workItem.meta.completion-comment "-"}}
-
{{/if}}
@@ -47,53 +39,29 @@
{{on "submit" (perform this.saveManualWorkItem)}}
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-{{#if this.workItem.canComplete}}
-
-{{/if}}
diff --git a/ember/app/cases/detail/work-items/edit/route.js b/ember/app/cases/detail/work-items/edit/route.js
index 6c8b6759..c12f8892 100644
--- a/ember/app/cases/detail/work-items/edit/route.js
+++ b/ember/app/cases/detail/work-items/edit/route.js
@@ -1,7 +1,7 @@
import Route from "@ember/routing/route";
export default class CasesDetailWorkItemsEditRoute extends Route {
- model(params) {
- return params.work_item_id;
+ model({ work_item_id }) {
+ return work_item_id;
}
}
diff --git a/ember/app/cases/detail/work-items/edit/template.hbs b/ember/app/cases/detail/work-items/edit/template.hbs
deleted file mode 100644
index e2147cab..00000000
--- a/ember/app/cases/detail/work-items/edit/template.hbs
+++ /dev/null
@@ -1 +0,0 @@
-{{outlet}}
\ No newline at end of file
diff --git a/ember/app/cases/detail/work-items/index/controller.js b/ember/app/cases/detail/work-items/index/controller.js
index 7dcfc1ad..d3403e7c 100644
--- a/ember/app/cases/detail/work-items/index/controller.js
+++ b/ember/app/cases/detail/work-items/index/controller.js
@@ -1,12 +1,9 @@
import Controller from "@ember/controller";
import calumaQuery from "@projectcaluma/ember-core/caluma-query";
import { allWorkItems } from "@projectcaluma/ember-core/caluma-query/queries";
-import { queryManager } from "ember-apollo-client";
import { restartableTask } from "ember-concurrency-decorators";
export default class CasesDetailWorkItemsController extends Controller {
- @queryManager apollo;
-
@calumaQuery({
query: allWorkItems,
options: "options",
@@ -25,20 +22,48 @@ export default class CasesDetailWorkItemsController extends Controller {
};
}
- get columns() {
- return [
- "task",
- "instance",
- "description",
- ...(this.status === "open"
- ? ["deadline", "responsible"]
- : ["closedAt", "closedBy"]),
- ];
+ get readyTableConfig() {
+ return {
+ columns: [
+ {
+ heading: { label: "workItems.task" },
+ type: "task-name",
+ },
+ {
+ heading: { label: "workItems.deadline" },
+ modelKey: "deadline",
+ type: "date",
+ },
+ {
+ heading: { label: "workItems.actions.title" },
+ type: "work-item-actions",
+ },
+ ],
+ };
+ }
+ get completedTableConfig() {
+ return {
+ columns: [
+ {
+ heading: { label: "workItems.task" },
+ type: "task-name",
+ },
+ {
+ heading: { label: "workItems.closedAt" },
+ modelKey: "closedAt",
+ type: "date",
+ },
+ {
+ heading: { label: "workItems.actions.title" },
+ type: "work-item-actions",
+ },
+ ],
+ };
}
@restartableTask
*fetchWorkItems() {
- const filter = [{ hasDeadline: true }, { case: this.model.id }];
+ const filter = [{ case: this.model.id }];
yield this.readyWorkItemsQuery.fetch({
filter: [...filter, { status: "READY" }],
diff --git a/ember/app/cases/detail/work-items/index/template.hbs b/ember/app/cases/detail/work-items/index/template.hbs
index 174d5ec6..2676e2e2 100644
--- a/ember/app/cases/detail/work-items/index/template.hbs
+++ b/ember/app/cases/detail/work-items/index/template.hbs
@@ -6,13 +6,13 @@
{{t "workItems.completedTitle"}}
\ No newline at end of file
diff --git a/ember/app/cases/template.hbs b/ember/app/cases/template.hbs
deleted file mode 100644
index c24cd689..00000000
--- a/ember/app/cases/template.hbs
+++ /dev/null
@@ -1 +0,0 @@
-{{outlet}}
diff --git a/ember/app/components/context-menu/component.js b/ember/app/components/context-menu/component.js
deleted file mode 100644
index b0b008d5..00000000
--- a/ember/app/components/context-menu/component.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { action } from "@ember/object";
-import { later, cancel } from "@ember/runloop";
-import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
-
-export default class ContextMenuComponent extends Component {
- @tracked menuOpen = false;
- closeMenuDelay;
-
- @action
- handleMouseLeave() {
- this.closeMenuDelay = later(
- this,
- function () {
- this.menuOpen = false;
- },
- 1000
- );
- }
-
- @action
- handleMouseEnter() {
- cancel(this.closeMenuDelay);
- }
-}
diff --git a/ember/app/components/context-menu/template.hbs b/ember/app/components/context-menu/template.hbs
index caa409fb..58f314d0 100644
--- a/ember/app/components/context-menu/template.hbs
+++ b/ember/app/components/context-menu/template.hbs
@@ -1,25 +1,25 @@
-{{!-- template-lint-disable no-invalid-interactive --}}
-