@things-factory/i18n-base 7.0.1-alpha.77 → 7.0.1-alpha.82
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/page/terminology-page.ts +131 -83
- package/client/route.ts +1 -1
- package/dist-client/page/terminology-page.d.ts +14 -5
- package/dist-client/page/terminology-page.js +126 -78
- package/dist-client/page/terminology-page.js.map +1 -1
- package/dist-client/route.js +1 -1
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/terminology/index.js +1 -2
- package/dist-server/service/terminology/index.js.map +1 -1
- package/dist-server/service/terminology/terminology-mutation.js +26 -3
- package/dist-server/service/terminology/terminology-mutation.js.map +1 -1
- package/dist-server/service/terminology/terminology-query.js +21 -0
- package/dist-server/service/terminology/terminology-query.js.map +1 -1
- package/dist-server/service/terminology/terminology-type.js +3 -3
- package/dist-server/service/terminology/terminology-type.js.map +1 -1
- package/dist-server/service/terminology/terminology.js +20 -3
- package/dist-server/service/terminology/terminology.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/server/service/index.ts +5 -1
- package/server/service/terminology/index.ts +1 -2
- package/server/service/terminology/terminology-mutation.ts +48 -6
- package/server/service/terminology/terminology-query.ts +11 -0
- package/server/service/terminology/terminology-type.ts +6 -6
- package/server/service/terminology/terminology.ts +30 -8
- package/things-factory.config.js +9 -1
- package/translations/en.json +7 -0
- package/translations/ja.json +7 -0
- package/translations/ko.json +7 -0
- package/translations/ms.json +7 -0
- package/translations/zh.json +7 -0
- package/dist-server/service/terminology/event-subscriber.js +0 -40
- package/dist-server/service/terminology/event-subscriber.js.map +0 -1
- package/server/service/terminology/event-subscriber.ts +0 -41
|
@@ -4,18 +4,16 @@ import '@operato/data-grist'
|
|
|
4
4
|
import '@operato/context/ox-context-page-toolbar.js'
|
|
5
5
|
import '@operato/input/ox-input-select-buttons.js'
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { customElement,
|
|
7
|
+
import { css, html } from 'lit'
|
|
8
|
+
import { customElement, query, state } from 'lit/decorators.js'
|
|
9
9
|
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
10
10
|
import gql from 'graphql-tag'
|
|
11
11
|
|
|
12
|
-
import { store, PageView } from '@operato/shell'
|
|
12
|
+
import { store, CustomAlert, PageView } from '@operato/shell'
|
|
13
13
|
import { client } from '@operato/graphql'
|
|
14
14
|
import { DataGrist, FetchOption, GristRecord } from '@operato/data-grist'
|
|
15
15
|
import { i18next, localize } from '@operato/i18n'
|
|
16
|
-
import { openPopup } from '@operato/layout'
|
|
17
16
|
import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
|
|
18
|
-
import { OxPrompt } from '@operato/popup/ox-prompt.js'
|
|
19
17
|
import { isMobileDevice } from '@operato/utils'
|
|
20
18
|
|
|
21
19
|
@customElement('terminology-page')
|
|
@@ -48,7 +46,7 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
48
46
|
|
|
49
47
|
get context() {
|
|
50
48
|
return {
|
|
51
|
-
title: i18next.t('
|
|
49
|
+
title: i18next.t('title.terminology'),
|
|
52
50
|
search: {
|
|
53
51
|
handler: (search: string) => {
|
|
54
52
|
this.grist.searchText = search
|
|
@@ -63,9 +61,9 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
63
61
|
help: 'mfg-warehouse/term-page',
|
|
64
62
|
actions: [
|
|
65
63
|
{
|
|
66
|
-
title: i18next.t('button.
|
|
67
|
-
action: this.
|
|
68
|
-
icon: '
|
|
64
|
+
title: i18next.t('button.clear-cache'),
|
|
65
|
+
action: this.clearCache.bind(this),
|
|
66
|
+
icon: 'ink_eraser'
|
|
69
67
|
},
|
|
70
68
|
{
|
|
71
69
|
title: i18next.t('button.save'),
|
|
@@ -73,9 +71,12 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
73
71
|
icon: 'save'
|
|
74
72
|
},
|
|
75
73
|
{
|
|
76
|
-
title: i18next.t('button.
|
|
77
|
-
action: this.
|
|
78
|
-
icon: '
|
|
74
|
+
title: i18next.t('button.delete'),
|
|
75
|
+
action: this.delete.bind(this),
|
|
76
|
+
icon: 'delete',
|
|
77
|
+
emphasis: {
|
|
78
|
+
danger: true
|
|
79
|
+
}
|
|
79
80
|
}
|
|
80
81
|
],
|
|
81
82
|
exportable: {
|
|
@@ -113,17 +114,10 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
113
114
|
return html`
|
|
114
115
|
<ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
|
|
115
116
|
<div slot="headroom" class="header">
|
|
116
|
-
<div class="title">${i18next.t('title.
|
|
117
|
+
<div class="title">${i18next.t('title.terminology')}</div>
|
|
117
118
|
|
|
118
119
|
<div class="filters">
|
|
119
|
-
<ox-
|
|
120
|
-
.value=${this.state}
|
|
121
|
-
.options=${this.getFilterStatus()}
|
|
122
|
-
@change=${(e: CustomEvent) => {
|
|
123
|
-
this.state = (e.currentTarget as any)?.value
|
|
124
|
-
this.grist.fetch()
|
|
125
|
-
}}
|
|
126
|
-
></ox-input-select-buttons>
|
|
120
|
+
<ox-filters-form autofocus without-search></ox-filters-form>
|
|
127
121
|
</div>
|
|
128
122
|
|
|
129
123
|
<ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
|
|
@@ -144,14 +138,14 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
144
138
|
{
|
|
145
139
|
type: 'string',
|
|
146
140
|
name: 'id',
|
|
147
|
-
header: i18next.t('
|
|
141
|
+
header: i18next.t('field.id'),
|
|
148
142
|
hidden: true,
|
|
149
143
|
width: 0
|
|
150
144
|
},
|
|
151
145
|
{
|
|
152
146
|
type: 'string',
|
|
153
147
|
name: 'name',
|
|
154
|
-
header: i18next.t('
|
|
148
|
+
header: i18next.t('field.name'),
|
|
155
149
|
record: {
|
|
156
150
|
editable: true
|
|
157
151
|
},
|
|
@@ -160,43 +154,48 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
160
154
|
width: 150
|
|
161
155
|
},
|
|
162
156
|
{
|
|
163
|
-
type: '
|
|
157
|
+
type: 'select',
|
|
164
158
|
name: 'locale',
|
|
165
|
-
header: i18next.t('
|
|
159
|
+
header: i18next.t('field.locale'),
|
|
166
160
|
record: {
|
|
167
|
-
editable: true
|
|
161
|
+
editable: true,
|
|
162
|
+
options: [{ display: '', value: '' }, ...this.getFilterStatus()]
|
|
168
163
|
},
|
|
169
|
-
width: 200
|
|
164
|
+
width: 200,
|
|
165
|
+
filter: {
|
|
166
|
+
type: 'select-buttons',
|
|
167
|
+
operator: 'in'
|
|
168
|
+
}
|
|
170
169
|
},
|
|
171
170
|
{
|
|
172
171
|
type: 'select',
|
|
173
172
|
name: 'category',
|
|
174
173
|
label: true,
|
|
175
|
-
header: i18next.t('
|
|
174
|
+
header: i18next.t('field.category'),
|
|
176
175
|
record: {
|
|
177
|
-
editable:
|
|
178
|
-
options: [
|
|
176
|
+
editable: true,
|
|
177
|
+
options: ['', 'button', 'field', 'label', 'menu', 'text', 'title']
|
|
179
178
|
},
|
|
180
179
|
width: 100,
|
|
181
|
-
filter:
|
|
180
|
+
filter: 'in',
|
|
182
181
|
imex: true
|
|
183
182
|
},
|
|
184
183
|
{
|
|
185
184
|
type: 'string',
|
|
186
185
|
name: 'display',
|
|
187
186
|
label: true,
|
|
188
|
-
header: i18next.t('
|
|
187
|
+
header: i18next.t('field.display'),
|
|
189
188
|
record: {
|
|
190
189
|
editable: true
|
|
191
190
|
},
|
|
192
|
-
filter:
|
|
191
|
+
filter: 'search',
|
|
193
192
|
sortable: true,
|
|
194
193
|
width: 250
|
|
195
194
|
},
|
|
196
195
|
{
|
|
197
196
|
type: 'resource-object',
|
|
198
197
|
name: 'updater',
|
|
199
|
-
header: i18next.t('
|
|
198
|
+
header: i18next.t('field.updater'),
|
|
200
199
|
record: {
|
|
201
200
|
editable: false
|
|
202
201
|
},
|
|
@@ -206,7 +205,7 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
206
205
|
{
|
|
207
206
|
type: 'datetime',
|
|
208
207
|
name: 'updatedAt',
|
|
209
|
-
header: i18next.t('
|
|
208
|
+
header: i18next.t('field.updated_at'),
|
|
210
209
|
record: {
|
|
211
210
|
editable: false
|
|
212
211
|
},
|
|
@@ -215,7 +214,7 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
215
214
|
}
|
|
216
215
|
],
|
|
217
216
|
rows: {
|
|
218
|
-
appendable:
|
|
217
|
+
appendable: true,
|
|
219
218
|
selectable: {
|
|
220
219
|
multiple: true
|
|
221
220
|
}
|
|
@@ -256,13 +255,42 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
256
255
|
}
|
|
257
256
|
|
|
258
257
|
async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
const response = await client.query({
|
|
259
|
+
query: gql`
|
|
260
|
+
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
261
|
+
terminologies(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
262
|
+
items {
|
|
263
|
+
id
|
|
264
|
+
name
|
|
265
|
+
locale
|
|
266
|
+
category
|
|
267
|
+
display
|
|
268
|
+
creator {
|
|
269
|
+
id
|
|
270
|
+
name
|
|
271
|
+
}
|
|
272
|
+
createdAt
|
|
273
|
+
updater {
|
|
274
|
+
id
|
|
275
|
+
name
|
|
276
|
+
}
|
|
277
|
+
updatedAt
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
total
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
`,
|
|
284
|
+
variables: {
|
|
285
|
+
filters,
|
|
286
|
+
pagination: { page, limit },
|
|
287
|
+
sortings
|
|
288
|
+
}
|
|
289
|
+
})
|
|
262
290
|
|
|
263
291
|
return {
|
|
264
|
-
total:
|
|
265
|
-
records:
|
|
292
|
+
total: response.data.terminologies.total || 0,
|
|
293
|
+
records: response.data.terminologies.items || []
|
|
266
294
|
}
|
|
267
295
|
}
|
|
268
296
|
|
|
@@ -309,18 +337,50 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
309
337
|
const selectedRecords = this.grist.selected
|
|
310
338
|
|
|
311
339
|
if (!selectedRecords || selectedRecords.length == 0) {
|
|
312
|
-
|
|
340
|
+
this.showToast(i18next.t('text.NOTHING_SELECTED'))
|
|
313
341
|
} else {
|
|
314
|
-
const answer =
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
342
|
+
const answer = await CustomAlert({
|
|
343
|
+
type: 'question',
|
|
344
|
+
title: i18next.t('button.delete'),
|
|
345
|
+
text: i18next.t('text.are_you_sure'),
|
|
346
|
+
confirmButton: { text: i18next.t('button.delete') },
|
|
347
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
348
|
+
})
|
|
321
349
|
|
|
322
|
-
|
|
350
|
+
if (!answer) {
|
|
351
|
+
return
|
|
323
352
|
}
|
|
353
|
+
|
|
354
|
+
let ids = selectedRecords.map(record => record.id)
|
|
355
|
+
|
|
356
|
+
const response = await client.mutate({
|
|
357
|
+
mutation: gql`
|
|
358
|
+
mutation ($ids: [String!]!) {
|
|
359
|
+
deleteTerminologies(ids: $ids)
|
|
360
|
+
}
|
|
361
|
+
`,
|
|
362
|
+
variables: {
|
|
363
|
+
ids
|
|
364
|
+
}
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
this.grist.fetch()
|
|
368
|
+
|
|
369
|
+
return response.data.deleteTerminologies
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
async clearCache() {
|
|
374
|
+
const response = await client.mutate({
|
|
375
|
+
mutation: gql`
|
|
376
|
+
mutation {
|
|
377
|
+
clearTranslationsCache
|
|
378
|
+
}
|
|
379
|
+
`
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
if (!response.errors) {
|
|
383
|
+
this.showToast(i18next.t('text.nothing_selected'))
|
|
324
384
|
}
|
|
325
385
|
}
|
|
326
386
|
|
|
@@ -328,49 +388,37 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
|
|
|
328
388
|
let changedRecords = this.grist.dirtyRecords
|
|
329
389
|
|
|
330
390
|
if (!changedRecords || changedRecords.length == 0) {
|
|
331
|
-
|
|
391
|
+
this.showToast(i18next.t('text.nothing_changed'))
|
|
332
392
|
} else {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
'__origin__',
|
|
341
|
-
'__seq__',
|
|
342
|
-
'__selected__'
|
|
343
|
-
]
|
|
393
|
+
const patches = changedRecords.map(patch => {
|
|
394
|
+
const patchField: any = patch.id ? { id: patch.id } : {}
|
|
395
|
+
const dirtyFields = patch.__dirtyfields__
|
|
396
|
+
for (let key in dirtyFields) {
|
|
397
|
+
patchField[key] = dirtyFields[key].after
|
|
398
|
+
}
|
|
399
|
+
patchField.cuFlag = patch.__dirty__
|
|
344
400
|
|
|
345
|
-
|
|
346
|
-
|
|
401
|
+
return patchField
|
|
402
|
+
})
|
|
347
403
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
404
|
+
const response = await client.mutate({
|
|
405
|
+
mutation: gql`
|
|
406
|
+
mutation ($patches: [TerminologyPatch!]!) {
|
|
407
|
+
updateMultipleTerminologies(patches: $patches) {
|
|
408
|
+
id
|
|
409
|
+
}
|
|
351
410
|
}
|
|
411
|
+
`,
|
|
412
|
+
variables: {
|
|
413
|
+
patches
|
|
352
414
|
}
|
|
353
|
-
|
|
354
|
-
patchData['cud_flag_'] = record['__dirty__'] == 'M' ? 'u' : 'c'
|
|
355
|
-
return patchData
|
|
356
415
|
})
|
|
357
416
|
|
|
358
|
-
//await ServiceUtil.updateMultiple('terminologies/update_multiple', patches)
|
|
359
417
|
this.grist.fetch()
|
|
360
418
|
}
|
|
361
419
|
}
|
|
362
420
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const ids = selected.map(record => record.id).join('|')
|
|
366
|
-
|
|
367
|
-
/* TODO Implement the desired functionality */
|
|
368
|
-
|
|
369
|
-
OxPrompt.open({
|
|
370
|
-
type: 'success',
|
|
371
|
-
title: i18next.t('text.completed'),
|
|
372
|
-
text: i18next.t('text.printed_successfully'),
|
|
373
|
-
confirmButton: { text: i18next.t('button.confirm') }
|
|
374
|
-
})
|
|
421
|
+
showToast(message: string) {
|
|
422
|
+
document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))
|
|
375
423
|
}
|
|
376
424
|
}
|
package/client/route.ts
CHANGED
|
@@ -27,11 +27,19 @@ export declare class TerminologyPage extends TerminologyPage_base {
|
|
|
27
27
|
handler: () => void;
|
|
28
28
|
};
|
|
29
29
|
help: string;
|
|
30
|
-
actions: {
|
|
30
|
+
actions: ({
|
|
31
31
|
title: string;
|
|
32
|
-
action: () => void
|
|
32
|
+
action: () => Promise<void>;
|
|
33
33
|
icon: string;
|
|
34
|
-
|
|
34
|
+
emphasis?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
title: string;
|
|
37
|
+
action: () => Promise<any>;
|
|
38
|
+
icon: string;
|
|
39
|
+
emphasis: {
|
|
40
|
+
danger: boolean;
|
|
41
|
+
};
|
|
42
|
+
})[];
|
|
35
43
|
exportable: {
|
|
36
44
|
name: string;
|
|
37
45
|
data: () => {
|
|
@@ -66,8 +74,9 @@ export declare class TerminologyPage extends TerminologyPage_base {
|
|
|
66
74
|
} | undefined)[];
|
|
67
75
|
data: any;
|
|
68
76
|
};
|
|
69
|
-
delete(): Promise<
|
|
77
|
+
delete(): Promise<any>;
|
|
78
|
+
clearCache(): Promise<void>;
|
|
70
79
|
save(): Promise<void>;
|
|
71
|
-
|
|
80
|
+
showToast(message: string): void;
|
|
72
81
|
}
|
|
73
82
|
export {};
|