@things-factory/organization 7.0.0-alpha.0 → 7.0.0-alpha.18
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.
- package/client/component/approval-line-view.ts +12 -16
- package/client/pages/department/department-list-page.ts +308 -196
- package/client/pages/department/department-tree-page.ts +153 -404
- package/client/route.ts +4 -4
- package/client/types/department.ts +0 -8
- package/dist-client/component/approval-line-view.js +12 -14
- package/dist-client/component/approval-line-view.js.map +1 -1
- package/dist-client/pages/department/department-list-page.d.ts +12 -20
- package/dist-client/pages/department/department-list-page.js +308 -182
- package/dist-client/pages/department/department-list-page.js.map +1 -1
- package/dist-client/pages/department/department-tree-page.d.ts +10 -12
- package/dist-client/pages/department/department-tree-page.js +142 -383
- package/dist-client/pages/department/department-tree-page.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +3 -3
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/types/department.d.ts +0 -6
- package/dist-client/types/department.js +0 -5
- package/dist-client/types/department.js.map +1 -1
- package/dist-server/service/approval-line/approval-line.js +2 -7
- package/dist-server/service/approval-line/approval-line.js.map +1 -1
- package/dist-server/service/department/department-history.js +4 -15
- package/dist-server/service/department/department-history.js.map +1 -1
- package/dist-server/service/department/department-query.js +15 -10
- package/dist-server/service/department/department-query.js.map +1 -1
- package/dist-server/service/department/department-type.js +0 -8
- package/dist-server/service/department/department-type.js.map +1 -1
- package/dist-server/service/department/department.js +1 -15
- package/dist-server/service/department/department.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/service/approval-line/approval-line.ts +5 -25
- package/server/service/department/department-history.ts +7 -31
- package/server/service/department/department-query.ts +13 -10
- package/server/service/department/department-type.ts +1 -7
- package/server/service/department/department.ts +0 -15
- package/translations/en.json +3 -0
- package/translations/ja.json +3 -0
- package/translations/ko.json +3 -0
- package/translations/ms.json +3 -0
- package/translations/zh.json +3 -0
|
@@ -4,17 +4,20 @@ import '@operato/context/ox-context-page-toolbar.js';
|
|
|
4
4
|
import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles';
|
|
5
5
|
import { PageView, store } from '@operato/shell';
|
|
6
6
|
import { css, html } from 'lit';
|
|
7
|
-
import { customElement, query, state } from 'lit/decorators.js';
|
|
7
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
8
8
|
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
9
9
|
import { client } from '@operato/graphql';
|
|
10
10
|
import { i18next, localize } from '@operato/i18n';
|
|
11
|
+
import { isMobileDevice } from '@operato/utils';
|
|
12
|
+
import { DataGrist } from '@operato/data-grist';
|
|
13
|
+
import { notify } from '@operato/layout';
|
|
14
|
+
import { OxPrompt } from '@operato/popup/ox-prompt.js';
|
|
11
15
|
import { connect } from 'pwa-helpers/connect-mixin';
|
|
12
16
|
import gql from 'graphql-tag';
|
|
13
17
|
import { DepartmentImporter } from './department-importer';
|
|
14
18
|
import { Department } from '../../types/department';
|
|
15
|
-
import { DepartmentView } from '../../component/department-view';
|
|
16
19
|
const departmentFragment = gql `
|
|
17
|
-
fragment
|
|
20
|
+
fragment departmentFragment on Department {
|
|
18
21
|
id
|
|
19
22
|
controlNo
|
|
20
23
|
name
|
|
@@ -28,7 +31,6 @@ const departmentFragment = gql `
|
|
|
28
31
|
email
|
|
29
32
|
}
|
|
30
33
|
active
|
|
31
|
-
state
|
|
32
34
|
picture
|
|
33
35
|
|
|
34
36
|
updater {
|
|
@@ -49,22 +51,20 @@ let DepartmentListPage = class DepartmentListPage extends connect(store)(localiz
|
|
|
49
51
|
title: i18next.t('title.department list'),
|
|
50
52
|
help: 'organization/department',
|
|
51
53
|
actions: [
|
|
54
|
+
// {
|
|
55
|
+
// icon: 'add',
|
|
56
|
+
// title: i18next.t('button.add-child-dept'),
|
|
57
|
+
// action: () => this.grist.addChildNodes()
|
|
58
|
+
// },
|
|
59
|
+
// {
|
|
60
|
+
// icon: 'add',
|
|
61
|
+
// title: i18next.t('button.add-sibling-dept'),
|
|
62
|
+
// action: () => this.grist.addSiblingNodes()
|
|
63
|
+
// },
|
|
52
64
|
{
|
|
53
|
-
icon: '
|
|
54
|
-
title: i18next.t('button.
|
|
55
|
-
action: this.
|
|
56
|
-
},
|
|
57
|
-
this.selected
|
|
58
|
-
? {
|
|
59
|
-
icon: 'save',
|
|
60
|
-
title: i18next.t('button.save'),
|
|
61
|
-
action: this.save.bind(this)
|
|
62
|
-
}
|
|
63
|
-
: null,
|
|
64
|
-
{
|
|
65
|
-
icon: 'refresh',
|
|
66
|
-
title: i18next.t('button.reset'),
|
|
67
|
-
action: this.reset.bind(this)
|
|
65
|
+
icon: 'save',
|
|
66
|
+
title: i18next.t('button.save'),
|
|
67
|
+
action: this.save.bind(this)
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
icon: 'delete',
|
|
@@ -72,212 +72,334 @@ let DepartmentListPage = class DepartmentListPage extends connect(store)(localiz
|
|
|
72
72
|
action: this.delete.bind(this)
|
|
73
73
|
}
|
|
74
74
|
].filter(Boolean),
|
|
75
|
-
exportable: {
|
|
76
|
-
name: i18next.t('title.department list'),
|
|
77
|
-
data: this.exportHandler.bind(this)
|
|
78
|
-
},
|
|
79
|
-
importable: {
|
|
80
|
-
handler: this.importHandler.bind(this)
|
|
81
|
-
},
|
|
82
75
|
toolbar: false
|
|
83
76
|
};
|
|
84
77
|
}
|
|
85
78
|
render() {
|
|
79
|
+
const mode = isMobileDevice() ? 'CARD' : 'GRID';
|
|
86
80
|
return html `
|
|
87
|
-
<
|
|
88
|
-
<div class="
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
|
|
94
|
-
</div>
|
|
81
|
+
<ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
|
|
82
|
+
<div slot="headroom" class="header">
|
|
83
|
+
<div class="title">
|
|
84
|
+
<mwc-icon>summarize</mwc-icon>
|
|
85
|
+
${i18next.t('title.department list')}
|
|
86
|
+
</div>
|
|
95
87
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
@select=${this.onSelect.bind(this)}
|
|
100
|
-
label-property="name"
|
|
101
|
-
></ox-tree-vertical>
|
|
88
|
+
<div class="filters">
|
|
89
|
+
<ox-filters-form class="filter" autofocus without-search></ox-filters-form>
|
|
90
|
+
</div>
|
|
102
91
|
|
|
103
|
-
|
|
92
|
+
<ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
|
|
93
|
+
</div>
|
|
94
|
+
</ox-grist>
|
|
104
95
|
`;
|
|
105
96
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
97
|
+
async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
|
|
98
|
+
const response = await client.query({
|
|
99
|
+
query: gql `
|
|
100
|
+
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
101
|
+
responses: departmentRoots(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
102
|
+
total
|
|
103
|
+
items {
|
|
104
|
+
...departmentFragment
|
|
105
|
+
children(filters: $filters, sortings: $sortings) {
|
|
106
|
+
...departmentFragment
|
|
107
|
+
children(filters: $filters, sortings: $sortings) {
|
|
108
|
+
...departmentFragment
|
|
109
|
+
children(filters: $filters, sortings: $sortings) {
|
|
110
|
+
...departmentFragment
|
|
111
|
+
children(filters: $filters, sortings: $sortings) {
|
|
112
|
+
...departmentFragment
|
|
113
|
+
children(filters: $filters, sortings: $sortings) {
|
|
114
|
+
...departmentFragment
|
|
115
|
+
children(filters: $filters, sortings: $sortings) {
|
|
116
|
+
...departmentFragment
|
|
117
|
+
children(filters: $filters, sortings: $sortings) {
|
|
118
|
+
...departmentFragment
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
135
127
|
}
|
|
136
128
|
}
|
|
137
129
|
|
|
138
130
|
${departmentFragment}
|
|
139
131
|
`,
|
|
140
132
|
variables: {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
hasUpload: true
|
|
133
|
+
filters,
|
|
134
|
+
pagination: { page, limit },
|
|
135
|
+
sortings
|
|
145
136
|
}
|
|
146
137
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
async save() {
|
|
152
|
-
const { id, controlNo, name, description, state, picture, active, manager } = this.departmentView.department;
|
|
153
|
-
if (!id) {
|
|
154
|
-
alert('Please select department first.');
|
|
155
|
-
}
|
|
156
|
-
var patch = {
|
|
157
|
-
controlNo,
|
|
158
|
-
name,
|
|
159
|
-
description,
|
|
160
|
-
state,
|
|
161
|
-
active,
|
|
162
|
-
manager
|
|
138
|
+
const { items: records, total } = response.data.responses;
|
|
139
|
+
return {
|
|
140
|
+
total,
|
|
141
|
+
records
|
|
163
142
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
${departmentFragment}
|
|
176
|
-
`,
|
|
177
|
-
variables: {
|
|
178
|
-
id,
|
|
179
|
-
patch
|
|
143
|
+
}
|
|
144
|
+
async pageInitialized(lifecycle) {
|
|
145
|
+
this.gristConfig = {
|
|
146
|
+
pagination: { pages: [50, 100, 200] },
|
|
147
|
+
list: {
|
|
148
|
+
thumbnail: 'profile',
|
|
149
|
+
fields: ['controlNo', 'name'],
|
|
150
|
+
details: ['email', 'manager', 'updatedAt']
|
|
180
151
|
},
|
|
181
|
-
|
|
182
|
-
|
|
152
|
+
columns: [
|
|
153
|
+
{
|
|
154
|
+
type: 'gutter',
|
|
155
|
+
gutterName: 'dirty',
|
|
156
|
+
fixed: true
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
type: 'tree',
|
|
160
|
+
name: 'name',
|
|
161
|
+
label: true,
|
|
162
|
+
header: i18next.t('label.name'),
|
|
163
|
+
record: {
|
|
164
|
+
editable: true,
|
|
165
|
+
options: {
|
|
166
|
+
selectable: true
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
filter: 'search',
|
|
170
|
+
sortable: true,
|
|
171
|
+
width: 200,
|
|
172
|
+
fixed: true,
|
|
173
|
+
handlers: {
|
|
174
|
+
contextmenu: 'contextmenu-tree-mutation'
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{ name: 'id', hidden: true },
|
|
178
|
+
{
|
|
179
|
+
type: 'string',
|
|
180
|
+
name: 'controlNo',
|
|
181
|
+
header: i18next.t('label.control-no'),
|
|
182
|
+
record: {
|
|
183
|
+
editable: true
|
|
184
|
+
},
|
|
185
|
+
filter: 'search',
|
|
186
|
+
sortable: true,
|
|
187
|
+
width: 110
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
type: 'string',
|
|
191
|
+
name: 'description',
|
|
192
|
+
header: i18next.t('label.description'),
|
|
193
|
+
record: {
|
|
194
|
+
editable: true
|
|
195
|
+
},
|
|
196
|
+
filter: 'search',
|
|
197
|
+
sortable: true,
|
|
198
|
+
width: 110
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
type: 'resource-object',
|
|
202
|
+
name: 'manager',
|
|
203
|
+
header: i18next.t('label.manager'),
|
|
204
|
+
record: {
|
|
205
|
+
editable: true,
|
|
206
|
+
options: {
|
|
207
|
+
title: i18next.t('title.employee list'),
|
|
208
|
+
queryName: 'employees',
|
|
209
|
+
pagination: { pages: [50, 100, 200] },
|
|
210
|
+
basicArgs: {
|
|
211
|
+
filters: [
|
|
212
|
+
{
|
|
213
|
+
name: 'active',
|
|
214
|
+
operator: 'eq',
|
|
215
|
+
value: true
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
list: { fields: ['controlNo', 'name', 'email'] },
|
|
220
|
+
columns: [
|
|
221
|
+
{ name: 'id', hidden: true },
|
|
222
|
+
{
|
|
223
|
+
name: 'controlNo',
|
|
224
|
+
width: 120,
|
|
225
|
+
header: { renderer: () => i18next.t('field.control-no') },
|
|
226
|
+
filter: 'search',
|
|
227
|
+
sortable: true
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'name',
|
|
231
|
+
width: 120,
|
|
232
|
+
header: { renderer: () => i18next.t('field.name') },
|
|
233
|
+
filter: 'search',
|
|
234
|
+
sortable: true
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: 'email',
|
|
238
|
+
width: 150,
|
|
239
|
+
header: { renderer: () => i18next.t('label.email') },
|
|
240
|
+
filter: 'search',
|
|
241
|
+
sortable: true
|
|
242
|
+
}
|
|
243
|
+
],
|
|
244
|
+
valueField: 'id',
|
|
245
|
+
nameField: 'name',
|
|
246
|
+
descriptionField: 'controlNo'
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
sortable: true,
|
|
250
|
+
width: 120
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
type: 'checkbox',
|
|
254
|
+
name: 'active',
|
|
255
|
+
label: true,
|
|
256
|
+
header: i18next.t('field.active'),
|
|
257
|
+
width: 70,
|
|
258
|
+
record: {
|
|
259
|
+
align: 'center',
|
|
260
|
+
editable: true
|
|
261
|
+
},
|
|
262
|
+
filter: true,
|
|
263
|
+
sortable: true
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
type: 'resource-object',
|
|
267
|
+
name: 'updater',
|
|
268
|
+
header: i18next.t('field.updater'),
|
|
269
|
+
width: 90,
|
|
270
|
+
sortable: false
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
type: 'datetime',
|
|
274
|
+
name: 'updatedAt',
|
|
275
|
+
header: i18next.t('field.updated_at'),
|
|
276
|
+
width: 180,
|
|
277
|
+
sortable: true
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
type: 'image',
|
|
281
|
+
name: 'picture',
|
|
282
|
+
record: {
|
|
283
|
+
renderer: function (value, column, record, rowIndex, field) {
|
|
284
|
+
return html `<ox-pfp-view style="height:90%; width: unset; aspect-ratio: 1 / 1;" .profile=${record.picture} .name=${record.name}></ox-pfp-view>`;
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
hidden: true
|
|
288
|
+
}
|
|
289
|
+
],
|
|
290
|
+
rows: {
|
|
291
|
+
appendable: false,
|
|
292
|
+
selectable: {
|
|
293
|
+
multiple: true
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
sorters: [
|
|
297
|
+
{
|
|
298
|
+
name: 'controlNo'
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
tree: {
|
|
302
|
+
childrenProperty: 'children',
|
|
303
|
+
expanded: () => true
|
|
183
304
|
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
async pageUpdated(changes, lifecycle) {
|
|
308
|
+
if (this.active) {
|
|
309
|
+
// do something here when this page just became as active
|
|
310
|
+
}
|
|
187
311
|
}
|
|
188
312
|
async delete() {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
313
|
+
if (!this.grist.selected || this.grist.selected.length == 0) {
|
|
314
|
+
await OxPrompt.open({
|
|
315
|
+
title: 'select department first.',
|
|
316
|
+
confirmButton: { text: i18next.t('button.confirm') }
|
|
317
|
+
});
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (this.grist.selected.find(selected => selected.children && selected.children.length > 0)) {
|
|
321
|
+
await OxPrompt.open({
|
|
322
|
+
title: 'Department having children cannot be deleted.',
|
|
323
|
+
confirmButton: { text: i18next.t('button.confirm') }
|
|
324
|
+
});
|
|
325
|
+
return;
|
|
192
326
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
327
|
+
if (await OxPrompt.open({
|
|
328
|
+
title: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
|
|
329
|
+
confirmButton: { text: i18next.t('button.confirm') },
|
|
330
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
331
|
+
})) {
|
|
332
|
+
const ids = this.grist.selected.map(record => record.id);
|
|
333
|
+
if (ids && ids.length > 0) {
|
|
334
|
+
const response = await client.mutate({
|
|
335
|
+
mutation: gql `
|
|
336
|
+
mutation ($ids: [String!]!) {
|
|
337
|
+
deleteDepartments(ids: $ids)
|
|
338
|
+
}
|
|
339
|
+
`,
|
|
340
|
+
variables: {
|
|
341
|
+
ids
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
if (!response.errors) {
|
|
345
|
+
this.grist.fetch();
|
|
346
|
+
notify({
|
|
347
|
+
message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
196
351
|
}
|
|
197
|
-
|
|
198
|
-
|
|
352
|
+
}
|
|
353
|
+
async save() {
|
|
354
|
+
let patches = this.grist.dirtyRecords;
|
|
355
|
+
if (patches && patches.length) {
|
|
356
|
+
patches = patches.map(patch => {
|
|
357
|
+
let patchField = patch.id ? { id: patch.id } : {};
|
|
358
|
+
const dirtyFields = patch.__dirtyfields__;
|
|
359
|
+
for (let key in dirtyFields) {
|
|
360
|
+
patchField[key] = dirtyFields[key].after;
|
|
361
|
+
}
|
|
362
|
+
patchField.parent = patch.parent;
|
|
363
|
+
patchField.cuFlag = patch.__dirty__;
|
|
364
|
+
return patchField;
|
|
365
|
+
});
|
|
199
366
|
const response = await client.mutate({
|
|
200
367
|
mutation: gql `
|
|
201
|
-
mutation ($
|
|
202
|
-
|
|
368
|
+
mutation ($patches: [DepartmentPatch!]!) {
|
|
369
|
+
updateMultipleDepartment(patches: $patches) {
|
|
370
|
+
name
|
|
371
|
+
}
|
|
203
372
|
}
|
|
204
373
|
`,
|
|
205
374
|
variables: {
|
|
206
|
-
|
|
375
|
+
patches
|
|
376
|
+
},
|
|
377
|
+
context: {
|
|
378
|
+
hasUpload: true
|
|
207
379
|
}
|
|
208
380
|
});
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
await this.fetch();
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
async pageInitialized(lifecycle) {
|
|
215
|
-
this.fetch();
|
|
216
|
-
}
|
|
217
|
-
async pageUpdated(changes, lifecycle) {
|
|
218
|
-
if (this.active) {
|
|
219
|
-
// do something here when this page just became as active
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
async fetch() {
|
|
223
|
-
const response = await client.query({
|
|
224
|
-
query: gql `
|
|
225
|
-
query {
|
|
226
|
-
responses: departmentRoot {
|
|
227
|
-
...Department_department
|
|
228
|
-
children {
|
|
229
|
-
...Department_department
|
|
230
|
-
children {
|
|
231
|
-
...Department_department
|
|
232
|
-
children {
|
|
233
|
-
...Department_department
|
|
234
|
-
children {
|
|
235
|
-
...Department_department
|
|
236
|
-
children {
|
|
237
|
-
...Department_department
|
|
238
|
-
children {
|
|
239
|
-
...Department_department
|
|
240
|
-
children {
|
|
241
|
-
...Department_department
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
381
|
+
if (!response.errors) {
|
|
382
|
+
this.grist.fetch();
|
|
248
383
|
}
|
|
249
|
-
}
|
|
250
384
|
}
|
|
251
|
-
|
|
252
|
-
${departmentFragment}
|
|
253
|
-
`
|
|
254
|
-
});
|
|
255
|
-
this.root = response.data.responses;
|
|
256
385
|
}
|
|
257
|
-
async exportHandler() { }
|
|
258
|
-
async importHandler(records) { }
|
|
259
386
|
};
|
|
260
387
|
DepartmentListPage.styles = [
|
|
261
|
-
CommonHeaderStyles,
|
|
262
388
|
ScrollbarStyles,
|
|
389
|
+
CommonHeaderStyles,
|
|
263
390
|
css `
|
|
264
391
|
:host {
|
|
265
392
|
display: flex;
|
|
266
|
-
flex-direction: column;
|
|
267
393
|
|
|
268
394
|
width: 100%;
|
|
269
|
-
overflow: auto;
|
|
270
|
-
}
|
|
271
395
|
|
|
272
|
-
|
|
273
|
-
|
|
396
|
+
--grid-record-emphasized-background-color: #8b0000;
|
|
397
|
+
--grid-record-emphasized-color: #ff6b6b;
|
|
274
398
|
}
|
|
275
399
|
|
|
276
|
-
|
|
400
|
+
ox-grist {
|
|
401
|
+
overflow-y: auto;
|
|
277
402
|
flex: 1;
|
|
278
|
-
|
|
279
|
-
max-width: 500px;
|
|
280
|
-
align-self: center;
|
|
281
403
|
}
|
|
282
404
|
`
|
|
283
405
|
];
|
|
@@ -290,9 +412,13 @@ __decorate([
|
|
|
290
412
|
__metadata("design:type", Department)
|
|
291
413
|
], DepartmentListPage.prototype, "selected", void 0);
|
|
292
414
|
__decorate([
|
|
293
|
-
query('
|
|
294
|
-
__metadata("design:type",
|
|
295
|
-
], DepartmentListPage.prototype, "
|
|
415
|
+
query('ox-grist'),
|
|
416
|
+
__metadata("design:type", DataGrist)
|
|
417
|
+
], DepartmentListPage.prototype, "grist", void 0);
|
|
418
|
+
__decorate([
|
|
419
|
+
property({ type: Object }),
|
|
420
|
+
__metadata("design:type", Object)
|
|
421
|
+
], DepartmentListPage.prototype, "gristConfig", void 0);
|
|
296
422
|
DepartmentListPage = __decorate([
|
|
297
423
|
customElement('department-list-page')
|
|
298
424
|
], DepartmentListPage);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"department-list-page.js","sourceRoot":"","sources":["../../../client/pages/department/department-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,6CAA6C,CAAA;AAEpD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAY,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAEhE,MAAM,kBAAkB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;CAwB7B,CAAA;AAGM,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IA0BtG,MAAM,KAAK,cAAc;QACvB,OAAO;YACL,qBAAqB,EAAE,kBAAkB;SAC1C,CAAA;IACH,CAAC;IAOD,IAAI,OAAO;QACT,OAAO;YACL,KAAK,E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AAkB,CAqR9B;SArRY,kBAAkB","sourcesContent":["import '@operato/data-tree'\nimport '@operato/context/ox-context-page-toolbar.js'\n\nimport { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { DepartmentImporter } from './department-importer'\nimport { Department } from '../../types/department'\n\nimport { DepartmentView } from '../../component/department-view'\n\nconst departmentFragment = gql`\n fragment Department_department on Department {\n id\n controlNo\n name\n description\n\n manager {\n id\n name\n controlNo\n photo\n email\n }\n active\n state\n picture\n\n updater {\n id\n name\n }\n updatedAt\n }\n`\n\n@customElement('department-list-page')\nexport class DepartmentListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n static styles = [\n CommonHeaderStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n width: 100%;\n overflow: auto;\n }\n\n ox-tree-vertical {\n flex: 1;\n }\n\n department-view {\n flex: 1;\n\n max-width: 500px;\n align-self: center;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'department-importer': DepartmentImporter\n }\n }\n\n @state() root?: Department\n @state() selected?: Department\n\n @query('department-view') departmentView!: DepartmentView\n\n get context() {\n return {\n title: i18next.t('title.department list'),\n help: 'organization/department',\n actions: [\n {\n icon: 'add',\n title: i18next.t('button.add'),\n action: this.create.bind(this)\n },\n this.selected\n ? {\n icon: 'save',\n title: i18next.t('button.save'),\n action: this.save.bind(this)\n }\n : null,\n {\n icon: 'refresh',\n title: i18next.t('button.reset'),\n action: this.reset.bind(this)\n },\n {\n icon: 'delete',\n title: i18next.t('button.delete'),\n action: this.delete.bind(this)\n }\n ].filter(Boolean),\n exportable: {\n name: i18next.t('title.department list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\n },\n toolbar: false\n }\n }\n\n render() {\n return html`\n <div class=\"header\">\n <div class=\"title\">\n <mwc-icon>summarize</mwc-icon>\n ${i18next.t('title.department list')}\n </div>\n\n <ox-context-page-toolbar class=\"actions\" .context=${this.context}></ox-context-page-toolbar>\n </div>\n\n <ox-tree-vertical\n .data=${this.root}\n .selected=${this.selected}\n @select=${this.onSelect.bind(this)}\n label-property=\"name\"\n ></ox-tree-vertical>\n\n <department-view .department=${this.selected}></department-view>\n `\n }\n\n onSelect(e: CustomEvent) {\n this.selected = e.detail as Department\n this.updateContext()\n }\n\n reset() {\n this.departmentView.department = {}\n }\n\n async create() {\n const { id: parentId } = this.selected || {}\n const { controlNo, name, description, state, picture, active, manager } = this.departmentView.department\n\n var department = {\n controlNo,\n name,\n description,\n state,\n manager,\n active\n } as any\n\n if (picture instanceof File) {\n department.picture = picture\n }\n\n if (parentId) {\n department.parent = { id: parentId }\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($department: NewDepartment!) {\n createDepartment(department: $department) {\n ...Department_department\n }\n }\n\n ${departmentFragment}\n `,\n variables: {\n department\n },\n context: {\n hasUpload: true\n }\n })\n\n this.selected = response.data.createDepartment\n this.updateContext()\n\n await this.fetch()\n }\n\n async save() {\n const { id, controlNo, name, description, state, picture, active, manager } = this.departmentView.department\n\n if (!id) {\n alert('Please select department first.')\n }\n\n var patch = {\n controlNo,\n name,\n description,\n state,\n active,\n manager\n } as any\n\n if (picture instanceof File) {\n patch.picture = picture\n }\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!, $patch: DepartmentPatch!) {\n updateDepartment(id: $id, patch: $patch) {\n ...Department_department\n }\n }\n\n ${departmentFragment}\n `,\n variables: {\n id,\n patch\n },\n context: {\n hasUpload: true\n }\n })\n\n this.selected = response.data.updateDepartment\n\n this.fetch()\n }\n\n async delete() {\n if (!this.selected) {\n alert('select department first.')\n }\n\n const children = this.selected?.children\n if (children && children.length > 0) {\n alert('Department having children cannot be deleted.')\n }\n\n if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {\n const { id } = this.selected || {}\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!) {\n deleteDepartment(id: $id)\n }\n `,\n variables: {\n id\n }\n })\n\n this.selected = {}\n this.updateContext()\n\n await this.fetch()\n }\n }\n\n async pageInitialized(lifecycle: any) {\n this.fetch()\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetch() {\n const response = await client.query({\n query: gql`\n query {\n responses: departmentRoot {\n ...Department_department\n children {\n ...Department_department\n children {\n ...Department_department\n children {\n ...Department_department\n children {\n ...Department_department\n children {\n ...Department_department\n children {\n ...Department_department\n children {\n ...Department_department\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n ${departmentFragment}\n `\n })\n\n this.root = response.data.responses\n }\n\n async exportHandler() {}\n\n async importHandler(records) {}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"department-list-page.js","sourceRoot":"","sources":["../../../client/pages/department/department-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,6CAA6C,CAAA;AAEpD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OA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S,CAAA;gBAEnC,OAAO,UAAU,CAAA;YACnB,CAAC,CAAC,CAAA;YAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;gBACnC,QAAQ,EAAE,GAAG,CAAA;;;;;;SAMZ;gBACD,SAAS,EAAE;oBACT,OAAO;iBACR;gBACD,OAAO,EAAE;oBACP,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;aACnB;SACF;IACH,CAAC;;AAlYM,yBAAM,GAAG;IACd,eAAe;IACf,kBAAkB;IAClB,GAAG,CAAA;;;;;;;;;;;;;;KAcF;CACF,CAAA;AAQD;IAAC,KAAK,EAAE;8BAAQ,UAAU;gDAAA;AAC1B;IAAC,KAAK,EAAE;8BAAY,UAAU;oDAAA;AAE9B;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;iDAAA;AAgC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uDAAiB;AA9DjC,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAoY9B;SApYY,kBAAkB","sourcesContent":["import '@operato/data-tree'\nimport '@operato/context/ox-context-page-toolbar.js'\n\nimport { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { notify } from '@operato/layout'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { DepartmentImporter } from './department-importer'\nimport { Department } from '../../types/department'\n\nconst departmentFragment = gql`\n fragment departmentFragment on Department {\n id\n controlNo\n name\n description\n\n manager {\n id\n name\n controlNo\n photo\n email\n }\n active\n picture\n\n updater {\n id\n name\n }\n updatedAt\n }\n`\n\n@customElement('department-list-page')\nexport class DepartmentListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n static styles = [\n ScrollbarStyles,\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'department-importer': DepartmentImporter\n }\n }\n\n @state() root?: Department\n @state() selected?: Department\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.department list'),\n help: 'organization/department',\n actions: [\n // {\n // icon: 'add',\n // title: i18next.t('button.add-child-dept'),\n // action: () => this.grist.addChildNodes()\n // },\n // {\n // icon: 'add',\n // title: i18next.t('button.add-sibling-dept'),\n // action: () => this.grist.addSiblingNodes()\n // },\n {\n icon: 'save',\n title: i18next.t('button.save'),\n action: this.save.bind(this)\n },\n {\n icon: 'delete',\n title: i18next.t('button.delete'),\n action: this.delete.bind(this)\n }\n ].filter(Boolean),\n toolbar: false\n }\n }\n\n @property({ type: Object }) gristConfig: any\n\n render() {\n const mode = isMobileDevice() ? 'CARD' : 'GRID'\n\n return html`\n <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"title\">\n <mwc-icon>summarize</mwc-icon>\n ${i18next.t('title.department list')}\n </div>\n\n <div class=\"filters\">\n <ox-filters-form class=\"filter\" autofocus without-search></ox-filters-form>\n </div>\n\n <ox-context-page-toolbar class=\"actions\" .context=${this.context}></ox-context-page-toolbar>\n </div>\n </ox-grist>\n `\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: departmentRoots(filters: $filters, pagination: $pagination, sortings: $sortings) {\n total\n items {\n ...departmentFragment\n children(filters: $filters, sortings: $sortings) {\n ...departmentFragment\n children(filters: $filters, sortings: $sortings) {\n ...departmentFragment\n children(filters: $filters, sortings: $sortings) {\n ...departmentFragment\n children(filters: $filters, sortings: $sortings) {\n ...departmentFragment\n children(filters: $filters, sortings: $sortings) {\n ...departmentFragment\n children(filters: $filters, sortings: $sortings) {\n ...departmentFragment\n children(filters: $filters, sortings: $sortings) {\n ...departmentFragment\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n ${departmentFragment}\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n const { items: records, total } = response.data.responses\n\n return {\n total,\n records\n }\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n pagination: { pages: [50, 100, 200] },\n list: {\n thumbnail: 'profile',\n fields: ['controlNo', 'name'],\n details: ['email', 'manager', 'updatedAt']\n },\n columns: [\n {\n type: 'gutter',\n gutterName: 'dirty',\n fixed: true\n },\n {\n type: 'tree',\n name: 'name',\n label: true,\n header: i18next.t('label.name'),\n record: {\n editable: true,\n options: {\n selectable: true\n }\n },\n filter: 'search',\n sortable: true,\n width: 200,\n fixed: true,\n handlers: {\n contextmenu: 'contextmenu-tree-mutation'\n }\n },\n { name: 'id', hidden: true },\n {\n type: 'string',\n name: 'controlNo',\n header: i18next.t('label.control-no'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 110\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('label.description'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 110\n },\n {\n type: 'resource-object',\n name: 'manager',\n header: i18next.t('label.manager'),\n record: {\n editable: true,\n options: {\n title: i18next.t('title.employee list'),\n queryName: 'employees',\n pagination: { pages: [50, 100, 200] },\n basicArgs: {\n filters: [\n {\n name: 'active',\n operator: 'eq',\n value: true\n }\n ]\n },\n list: { fields: ['controlNo', 'name', 'email'] },\n columns: [\n { name: 'id', hidden: true },\n {\n name: 'controlNo',\n width: 120,\n header: { renderer: () => i18next.t('field.control-no') },\n filter: 'search',\n sortable: true\n },\n {\n name: 'name',\n width: 120,\n header: { renderer: () => i18next.t('field.name') },\n filter: 'search',\n sortable: true\n },\n {\n name: 'email',\n width: 150,\n header: { renderer: () => i18next.t('label.email') },\n filter: 'search',\n sortable: true\n }\n ],\n valueField: 'id',\n nameField: 'name',\n descriptionField: 'controlNo'\n }\n },\n sortable: true,\n width: 120\n },\n {\n type: 'checkbox',\n name: 'active',\n label: true,\n header: i18next.t('field.active'),\n width: 70,\n record: {\n align: 'center',\n editable: true\n },\n filter: true,\n sortable: true\n },\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n width: 90,\n sortable: false\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n width: 180,\n sortable: true\n },\n {\n type: 'image',\n name: 'picture',\n record: {\n renderer: function (value, column, record, rowIndex, field) {\n return html`<ox-pfp-view style=\"height:90%; width: unset; aspect-ratio: 1 / 1;\" .profile=${record.picture} .name=${record.name}></ox-pfp-view>`\n }\n },\n hidden: true\n }\n ],\n rows: {\n appendable: false,\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'controlNo'\n }\n ],\n tree: {\n childrenProperty: 'children',\n expanded: () => true\n }\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async delete() {\n if (!this.grist.selected || this.grist.selected.length == 0) {\n await OxPrompt.open({\n title: 'select department first.',\n confirmButton: { text: i18next.t('button.confirm') }\n })\n return\n }\n\n if (this.grist.selected.find(selected => selected.children && selected.children.length > 0)) {\n await OxPrompt.open({\n title: 'Department having children cannot be deleted.',\n confirmButton: { text: i18next.t('button.confirm') }\n })\n return\n }\n\n if (\n await OxPrompt.open({\n title: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($ids: [String!]!) {\n deleteDepartments(ids: $ids)\n }\n `,\n variables: {\n ids\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n notify({\n message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n async save() {\n let patches = this.grist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(patch => {\n let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n patchField.parent = patch.parent\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [DepartmentPatch!]!) {\n updateMultipleDepartment(patches: $patches) {\n name\n }\n }\n `,\n variables: {\n patches\n },\n context: {\n hasUpload: true\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n}\n"]}
|