Skip to content

Commit c2fa4da

Browse files
committed
fix(ember): improve code, apply review changes
1 parent 49172be commit c2fa4da

File tree

16 files changed

+38
-110
lines changed

16 files changed

+38
-110
lines changed

ember/app/caluma-query/models/work-item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default class CustomWorkItemModel extends WorkItemModel {
1010
}
1111

1212
get case() {
13-
return this.raw.case.parentWorkItem?.case || this.raw.case;
13+
return this.raw.case;
1414
}
1515

1616
static fragment = `{

ember/app/cases/detail/work-items/edit/form/controller.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import Controller from "@ember/controller";
22
import { action } from "@ember/object";
33
import { inject as service } from "@ember/service";
4-
import completeWorkItem from "caluma-portal-demo/gql/mutations/complete-work-item";
54
import { queryManager } from "ember-apollo-client";
6-
import { dropTask } from "ember-concurrency-decorators";
75

86
export default class CasesDetailWorkItemsEditFormController extends Controller {
97
@queryManager apollo;
@@ -15,16 +13,6 @@ export default class CasesDetailWorkItemsEditFormController extends Controller {
1513
return this.model.value[0];
1614
}
1715

18-
@dropTask()
19-
*completeWorkItem() {
20-
yield this.apollo.mutate({
21-
mutation: completeWorkItem,
22-
variables: { id: this.workItem.id },
23-
});
24-
25-
this.actionButtonOnSuccess();
26-
}
27-
2816
@action
2917
actionButtonOnSuccess() {
3018
this.notification.success("workItem.finishSuccess");

ember/app/cases/detail/work-items/edit/form/template.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
{{else}}
88
<CfContent @documentId={{this.workItem.document.id}}
99
@context={{hash
10-
completeCallback=(perform this.completeWorkItem)
1110
actionButtonOnSuccess=this.actionButtonOnSuccess
1211
}}
1312
@disabled={{not this.workItem.isReady}}

ember/app/cases/detail/work-items/edit/index/controller.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Controller from "@ember/controller";
22
import { action } from "@ember/object";
33
import { inject as service } from "@ember/service";
44
import { tracked } from "@glimmer/tracking";
5-
import completeWorkItem from "caluma-portal-demo/gql/mutations/complete-work-item";
65
import saveWorkItem from "caluma-portal-demo/gql/mutations/save-work-item";
76
import { queryManager } from "ember-apollo-client";
87
import { dropTask } from "ember-concurrency-decorators";
@@ -21,32 +20,10 @@ export default class CasesDetailWorkItemsEditController extends Controller {
2120

2221
@tracked description = this.workItem.description;
2322

24-
@dropTask
25-
*finishWorkItem(event) {
26-
event.preventDefault();
27-
28-
try {
29-
yield this.apollo.mutate({
30-
mutation: saveWorkItem,
31-
variables: {
32-
input: {
33-
workItem: this.workItem.id,
34-
meta: JSON.stringify(this.workItem.meta),
35-
},
36-
},
37-
});
38-
39-
yield this.apollo.mutate({
40-
mutation: completeWorkItem,
41-
variables: { id: this.workItem.id },
42-
});
23+
finishWorkItem() {
24+
this.notification.success(this.intl.t("workItems.finishSuccess"));
4325

44-
this.notification.success(this.intl.t("workItems.finishSuccess"));
45-
46-
this.router.transitionTo("cases.detail.work-items.index");
47-
} catch (error) {
48-
this.notification.danger(this.intl.t("workItems.saveError"));
49-
}
26+
this.router.transitionTo("cases.detail.work-items.index");
5027
}
5128

5229
@dropTask

ember/app/cases/detail/work-items/edit/index/template.hbs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
{{this.workItem.task.name}}
1313
</h2>
1414

15-
<div class="work-item-attributes">
15+
<div>
1616
{{#if this.workItem.isCompleted}}
17-
<div class="work-item-attribute">
18-
<span class="work-item-attribute__title">
17+
<div>
18+
<span>
1919
{{t "workItems.closedBy"}}
2020
</span>
2121
{{this.workItem.closedByUser.fullName}}
2222
</div>
23-
<div class="work-item-attribute">
24-
<span class="work-item-attribute__title">
23+
<div>
24+
<span>
2525
{{t "workItems.closedAt"}}
2626
</span>
2727
{{
@@ -81,10 +81,7 @@
8181

8282
<div class="uk-margin">
8383
<label class="uk-form-label" for="deadline">
84-
{{t "workItems.deadline"}}
85-
<span class="mandatory">
86-
*
87-
</span>
84+
{{t "workItems.deadline"}}*
8885
</label>
8986
<div class="uk-form-controls">
9087
<PikadayInput
@@ -110,12 +107,13 @@
110107
@label={{t "global.save"}}
111108
/>
112109

113-
<UkButton
114-
@type="submit"
115-
@color="primary"
116-
@label={{t "workItems.actions.finish"}}
117-
@onClick={{perform this.finishWorkItem}}
118-
/>
110+
<WorkItemButton
111+
@mutation="complete"
112+
@workItemId={{this.workItem.id}}
113+
@onSuccess={{this.finishWorkItem}}
114+
>
115+
{{t "workItems.actions.finish"}}
116+
</WorkItemButton>
119117
</div>
120118
</form>
121119
{{/if}}

ember/app/components/context-menu/template.hbs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
<span hidden>{{t "global.openMenu"}}</span>
77
<UkIcon @icon="more-vertical" />
88
</UkButton>
9-
<div uk-drop>
10-
<div class="uk-card uk-card-body uk-card-small uk-card-default">
11-
<ul class="uk-list">
9+
<div uk-dropdown>
10+
<ul class="uk-list uk-margin-remove">
1211
{{#each @actions as |action|}}
1312
<li>
1413
<UkButton
@@ -21,5 +20,4 @@
2120
</li>
2221
{{/each}}
2322
</ul>
24-
</div>
2523
</div>

ember/app/components/filters/radio-buttons/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div>
1+
<div class="uk-margin-right">
22
<label class="uk-display-block">{{@label}}</label>
33
<div class="uk-button-group">
44
{{#each @options as |option|}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div class="filters" ...attributes>
1+
<div class="uk-flex" ...attributes>
22
{{yield (hash RadioButtons=(component "filters/radio-buttons"))}}
33
</div>

ember/app/components/nav-bar/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</LinkTo>
99

1010
<UkTab as |tab|>
11-
<tab.item @href="/">{{t "nav.cases"}}</tab.item>
11+
<tab.item @href="/" @linkToIndex={{true}}>{{t "nav.cases"}}</tab.item>
1212
<tab.item @href="/work-items">{{t "nav.workItems"}}</tab.item>
1313
<tab.item @href="/form-builder">{{t "nav.form-builder"}}</tab.item>
1414
<tab.item @href="/alexandria">{{t "nav.alexandria"}}</tab.item>

ember/app/components/work-item-list/template.hbs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
/>
88

99
<div class="uk-width-expand uk-flex uk-flex-middle uk-text-meta uk-margin">
10-
<span>
11-
{{
12-
t
13-
"global.paginationInfo"
14-
count=@query.value.length
15-
total=@query.totalCount
16-
htmlSafe=true
17-
}}
18-
</span>
10+
{{
11+
t
12+
"global.paginationInfo"
13+
count=@query.value.length
14+
total=@query.totalCount
15+
htmlSafe=true
16+
}}
1917
</div>

0 commit comments

Comments
 (0)