@things-factory/i18n-base 7.0.1-alpha.77 → 7.0.1-alpha.81

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.
Files changed (36) hide show
  1. package/client/page/terminology-page.ts +108 -82
  2. package/client/route.ts +1 -1
  3. package/dist-client/page/terminology-page.d.ts +3 -3
  4. package/dist-client/page/terminology-page.js +105 -77
  5. package/dist-client/page/terminology-page.js.map +1 -1
  6. package/dist-client/route.js +1 -1
  7. package/dist-client/route.js.map +1 -1
  8. package/dist-client/tsconfig.tsbuildinfo +1 -1
  9. package/dist-server/service/index.js.map +1 -1
  10. package/dist-server/service/terminology/index.js +1 -2
  11. package/dist-server/service/terminology/index.js.map +1 -1
  12. package/dist-server/service/terminology/terminology-mutation.js +26 -3
  13. package/dist-server/service/terminology/terminology-mutation.js.map +1 -1
  14. package/dist-server/service/terminology/terminology-query.js +21 -0
  15. package/dist-server/service/terminology/terminology-query.js.map +1 -1
  16. package/dist-server/service/terminology/terminology-type.js +3 -3
  17. package/dist-server/service/terminology/terminology-type.js.map +1 -1
  18. package/dist-server/service/terminology/terminology.js +20 -3
  19. package/dist-server/service/terminology/terminology.js.map +1 -1
  20. package/dist-server/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +3 -2
  22. package/server/service/index.ts +5 -1
  23. package/server/service/terminology/index.ts +1 -2
  24. package/server/service/terminology/terminology-mutation.ts +48 -6
  25. package/server/service/terminology/terminology-query.ts +11 -0
  26. package/server/service/terminology/terminology-type.ts +6 -6
  27. package/server/service/terminology/terminology.ts +30 -8
  28. package/things-factory.config.js +9 -1
  29. package/translations/en.json +6 -0
  30. package/translations/ja.json +6 -0
  31. package/translations/ko.json +6 -0
  32. package/translations/ms.json +6 -0
  33. package/translations/zh.json +6 -0
  34. package/dist-server/service/terminology/event-subscriber.js +0 -40
  35. package/dist-server/service/terminology/event-subscriber.js.map +0 -1
  36. 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 { PropertyValues, css, html } from 'lit'
8
- import { customElement, property, query, state } from 'lit/decorators.js'
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('menu.Terminology'),
49
+ title: i18next.t('title.terminology'),
52
50
  search: {
53
51
  handler: (search: string) => {
54
52
  this.grist.searchText = search
@@ -71,11 +69,6 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
71
69
  title: i18next.t('button.save'),
72
70
  action: this.save.bind(this),
73
71
  icon: 'save'
74
- },
75
- {
76
- title: i18next.t('button.print'),
77
- action: this.print.bind(this),
78
- icon: 'print'
79
72
  }
80
73
  ],
81
74
  exportable: {
@@ -113,17 +106,10 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
113
106
  return html`
114
107
  <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
115
108
  <div slot="headroom" class="header">
116
- <div class="title">${i18next.t('title.Terminology')}</div>
109
+ <div class="title">${i18next.t('title.terminology')}</div>
117
110
 
118
111
  <div class="filters">
119
- <ox-input-select-buttons
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>
112
+ <ox-filters-form autofocus without-search></ox-filters-form>
127
113
  </div>
128
114
 
129
115
  <ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
@@ -144,14 +130,14 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
144
130
  {
145
131
  type: 'string',
146
132
  name: 'id',
147
- header: i18next.t('label.id'),
133
+ header: i18next.t('field.id'),
148
134
  hidden: true,
149
135
  width: 0
150
136
  },
151
137
  {
152
138
  type: 'string',
153
139
  name: 'name',
154
- header: i18next.t('label.name'),
140
+ header: i18next.t('field.name'),
155
141
  record: {
156
142
  editable: true
157
143
  },
@@ -160,43 +146,48 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
160
146
  width: 150
161
147
  },
162
148
  {
163
- type: 'string',
149
+ type: 'select',
164
150
  name: 'locale',
165
- header: i18next.t('label.locale'),
151
+ header: i18next.t('field.locale'),
166
152
  record: {
167
- editable: true
153
+ editable: true,
154
+ options: [{ display: '', value: '' }, ...this.getFilterStatus()]
168
155
  },
169
- width: 200
156
+ width: 200,
157
+ filter: {
158
+ type: 'select-buttons',
159
+ operator: 'in'
160
+ }
170
161
  },
171
162
  {
172
163
  type: 'select',
173
164
  name: 'category',
174
165
  label: true,
175
- header: i18next.t('label.category'),
166
+ header: i18next.t('field.category'),
176
167
  record: {
177
- editable: false,
178
- options: [{ display: '', value: '' }, ...this.getFilterStatus()]
168
+ editable: true,
169
+ options: ['', 'button', 'field', 'label', 'menu', 'text', 'title']
179
170
  },
180
171
  width: 100,
181
- filter: true,
172
+ filter: 'in',
182
173
  imex: true
183
174
  },
184
175
  {
185
176
  type: 'string',
186
177
  name: 'display',
187
178
  label: true,
188
- header: i18next.t('label.display'),
179
+ header: i18next.t('field.display'),
189
180
  record: {
190
181
  editable: true
191
182
  },
192
- filter: true,
183
+ filter: 'search',
193
184
  sortable: true,
194
185
  width: 250
195
186
  },
196
187
  {
197
188
  type: 'resource-object',
198
189
  name: 'updater',
199
- header: i18next.t('label.updater'),
190
+ header: i18next.t('field.updater'),
200
191
  record: {
201
192
  editable: false
202
193
  },
@@ -206,7 +197,7 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
206
197
  {
207
198
  type: 'datetime',
208
199
  name: 'updatedAt',
209
- header: i18next.t('label.updated_at'),
200
+ header: i18next.t('field.updated_at'),
210
201
  record: {
211
202
  editable: false
212
203
  },
@@ -215,7 +206,7 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
215
206
  }
216
207
  ],
217
208
  rows: {
218
- appendable: false,
209
+ appendable: true,
219
210
  selectable: {
220
211
  multiple: true
221
212
  }
@@ -256,13 +247,42 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
256
247
  }
257
248
 
258
249
  async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
259
- let url = 'terminologies'
260
- let selectFields = 'id,name,locale,category,display,created_at,updated_at,creator,updater'
261
- let result = null as any // await ServiceUtil.searchByPagination(url, filters, sortings, page, limit, selectFields)
250
+ const response = await client.query({
251
+ query: gql`
252
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
253
+ terminologies(filters: $filters, pagination: $pagination, sortings: $sortings) {
254
+ items {
255
+ id
256
+ name
257
+ locale
258
+ category
259
+ display
260
+ creator {
261
+ id
262
+ name
263
+ }
264
+ createdAt
265
+ updater {
266
+ id
267
+ name
268
+ }
269
+ updatedAt
270
+ }
271
+
272
+ total
273
+ }
274
+ }
275
+ `,
276
+ variables: {
277
+ filters,
278
+ pagination: { page, limit },
279
+ sortings
280
+ }
281
+ })
262
282
 
263
283
  return {
264
- total: result ? result.total : 0,
265
- records: result ? result.items : []
284
+ total: response.data.terminologies.total || 0,
285
+ records: response.data.terminologies.items || []
266
286
  }
267
287
  }
268
288
 
@@ -309,18 +329,36 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
309
329
  const selectedRecords = this.grist.selected
310
330
 
311
331
  if (!selectedRecords || selectedRecords.length == 0) {
312
- // showToast('info', i18next.t('text.NOTHING_SELECTED'))
332
+ this.showToast('info', i18next.t('text.NOTHING_SELECTED'))
313
333
  } else {
314
- const answer = null // await showAlertPopup('button.delete', 'text.are_you_sure', 'question', 'delete', 'cancel')
315
-
316
- if (answer) {
317
- let patches = selectedRecords.map(record => {
318
- record['cud_flag_'] = 'd'
319
- return record
320
- })
334
+ const answer = await CustomAlert({
335
+ type: 'question',
336
+ title: i18next.t('button.delete'),
337
+ text: i18next.t('text.are_you_sure'),
338
+ confirmButton: { text: i18next.t('button.delete') },
339
+ cancelButton: { text: i18next.t('button.cancel') }
340
+ })
321
341
 
322
- return null // await ServiceUtil.deleteMultiple('terminologies/update_multiple', patches)
342
+ if (!answer) {
343
+ return
323
344
  }
345
+
346
+ let ids = selectedRecords.map(record => record.id)
347
+
348
+ const response = await client.mutate({
349
+ mutation: gql`
350
+ mutation ($ids: [String!]!) {
351
+ deleteTerminologies(ids: $ids)
352
+ }
353
+ `,
354
+ variables: {
355
+ ids
356
+ }
357
+ })
358
+
359
+ this.grist.fetch()
360
+
361
+ return response.data.deleteTerminologies
324
362
  }
325
363
  }
326
364
 
@@ -328,49 +366,37 @@ export class TerminologyPage extends connect(store)(localize(i18next)(PageView))
328
366
  let changedRecords = this.grist.dirtyRecords
329
367
 
330
368
  if (!changedRecords || changedRecords.length == 0) {
331
- // showToast('info', i18next.t('text.NOTHING_CHANGED'))
369
+ this.showToast('info', i18next.t('text.nothing_changed'))
332
370
  } else {
333
- let metaFields = [
334
- 'creator',
335
- 'updater',
336
- 'createdAt',
337
- 'updatedAt',
338
- '__dirty__',
339
- '__dirtyfields__',
340
- '__origin__',
341
- '__seq__',
342
- '__selected__'
343
- ]
371
+ const patches = changedRecords.map(patch => {
372
+ const patchField: any = patch.id ? { id: patch.id } : {}
373
+ const dirtyFields = patch.__dirtyfields__
374
+ for (let key in dirtyFields) {
375
+ patchField[key] = dirtyFields[key].after
376
+ }
377
+ patchField.cuFlag = patch.__dirty__
344
378
 
345
- let patches = changedRecords.map(record => {
346
- let patchData = record.id ? { id: record.id } : {}
379
+ return patchField
380
+ })
347
381
 
348
- for (let key in record) {
349
- if (!metaFields.includes(key)) {
350
- patchData[key] = record[key]
382
+ const response = await client.mutate({
383
+ mutation: gql`
384
+ mutation ($patches: [TerminologyPatch!]!) {
385
+ updateMultipleTerminologies(patches: $patches) {
386
+ id
387
+ }
351
388
  }
389
+ `,
390
+ variables: {
391
+ patches
352
392
  }
353
-
354
- patchData['cud_flag_'] = record['__dirty__'] == 'M' ? 'u' : 'c'
355
- return patchData
356
393
  })
357
394
 
358
- //await ServiceUtil.updateMultiple('terminologies/update_multiple', patches)
359
395
  this.grist.fetch()
360
396
  }
361
397
  }
362
398
 
363
- print() {
364
- const selected = this.grist.selected
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
- })
399
+ showToast(type: 'notify' | 'info' | 'warning' | 'error', message: string) {
400
+ document.dispatchEvent(new CustomEvent(type, { detail: { message } }))
375
401
  }
376
402
  }
package/client/route.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export default function route(page) {
2
2
  switch (page) {
3
- case 'terminology':
3
+ case 'terminology-page':
4
4
  import('./page/terminology-page.js')
5
5
  return page
6
6
  }
@@ -29,7 +29,7 @@ export declare class TerminologyPage extends TerminologyPage_base {
29
29
  help: string;
30
30
  actions: {
31
31
  title: string;
32
- action: () => void;
32
+ action: () => Promise<any>;
33
33
  icon: string;
34
34
  }[];
35
35
  exportable: {
@@ -66,8 +66,8 @@ export declare class TerminologyPage extends TerminologyPage_base {
66
66
  } | undefined)[];
67
67
  data: any;
68
68
  };
69
- delete(): Promise<null | undefined>;
69
+ delete(): Promise<any>;
70
70
  save(): Promise<void>;
71
- print(): void;
71
+ showToast(type: 'notify' | 'info' | 'warning' | 'error', message: string): void;
72
72
  }
73
73
  export {};
@@ -6,11 +6,12 @@ import '@operato/input/ox-input-select-buttons.js';
6
6
  import { css, html } from 'lit';
7
7
  import { customElement, query, state } from 'lit/decorators.js';
8
8
  import { connect } from 'pwa-helpers/connect-mixin.js';
9
- import { store, PageView } from '@operato/shell';
9
+ import gql from 'graphql-tag';
10
+ import { store, CustomAlert, PageView } from '@operato/shell';
11
+ import { client } from '@operato/graphql';
10
12
  import { DataGrist } from '@operato/data-grist';
11
13
  import { i18next, localize } from '@operato/i18n';
12
14
  import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles';
13
- import { OxPrompt } from '@operato/popup/ox-prompt.js';
14
15
  import { isMobileDevice } from '@operato/utils';
15
16
  let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18next)(PageView)) {
16
17
  constructor() {
@@ -20,7 +21,7 @@ let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18n
20
21
  get context() {
21
22
  var _a;
22
23
  return {
23
- title: i18next.t('menu.Terminology'),
24
+ title: i18next.t('title.terminology'),
24
25
  search: {
25
26
  handler: (search) => {
26
27
  this.grist.searchText = search;
@@ -43,11 +44,6 @@ let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18n
43
44
  title: i18next.t('button.save'),
44
45
  action: this.save.bind(this),
45
46
  icon: 'save'
46
- },
47
- {
48
- title: i18next.t('button.print'),
49
- action: this.print.bind(this),
50
- icon: 'print'
51
47
  }
52
48
  ],
53
49
  exportable: {
@@ -82,18 +78,10 @@ let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18n
82
78
  return html `
83
79
  <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
84
80
  <div slot="headroom" class="header">
85
- <div class="title">${i18next.t('title.Terminology')}</div>
81
+ <div class="title">${i18next.t('title.terminology')}</div>
86
82
 
87
83
  <div class="filters">
88
- <ox-input-select-buttons
89
- .value=${this.state}
90
- .options=${this.getFilterStatus()}
91
- @change=${(e) => {
92
- var _a;
93
- this.state = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.value;
94
- this.grist.fetch();
95
- }}
96
- ></ox-input-select-buttons>
84
+ <ox-filters-form autofocus without-search></ox-filters-form>
97
85
  </div>
98
86
 
99
87
  <ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
@@ -113,14 +101,14 @@ let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18n
113
101
  {
114
102
  type: 'string',
115
103
  name: 'id',
116
- header: i18next.t('label.id'),
104
+ header: i18next.t('field.id'),
117
105
  hidden: true,
118
106
  width: 0
119
107
  },
120
108
  {
121
109
  type: 'string',
122
110
  name: 'name',
123
- header: i18next.t('label.name'),
111
+ header: i18next.t('field.name'),
124
112
  record: {
125
113
  editable: true
126
114
  },
@@ -129,43 +117,48 @@ let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18n
129
117
  width: 150
130
118
  },
131
119
  {
132
- type: 'string',
120
+ type: 'select',
133
121
  name: 'locale',
134
- header: i18next.t('label.locale'),
122
+ header: i18next.t('field.locale'),
135
123
  record: {
136
- editable: true
124
+ editable: true,
125
+ options: [{ display: '', value: '' }, ...this.getFilterStatus()]
137
126
  },
138
- width: 200
127
+ width: 200,
128
+ filter: {
129
+ type: 'select-buttons',
130
+ operator: 'in'
131
+ }
139
132
  },
140
133
  {
141
134
  type: 'select',
142
135
  name: 'category',
143
136
  label: true,
144
- header: i18next.t('label.category'),
137
+ header: i18next.t('field.category'),
145
138
  record: {
146
- editable: false,
147
- options: [{ display: '', value: '' }, ...this.getFilterStatus()]
139
+ editable: true,
140
+ options: ['', 'button', 'field', 'label', 'menu', 'text', 'title']
148
141
  },
149
142
  width: 100,
150
- filter: true,
143
+ filter: 'in',
151
144
  imex: true
152
145
  },
153
146
  {
154
147
  type: 'string',
155
148
  name: 'display',
156
149
  label: true,
157
- header: i18next.t('label.display'),
150
+ header: i18next.t('field.display'),
158
151
  record: {
159
152
  editable: true
160
153
  },
161
- filter: true,
154
+ filter: 'search',
162
155
  sortable: true,
163
156
  width: 250
164
157
  },
165
158
  {
166
159
  type: 'resource-object',
167
160
  name: 'updater',
168
- header: i18next.t('label.updater'),
161
+ header: i18next.t('field.updater'),
169
162
  record: {
170
163
  editable: false
171
164
  },
@@ -175,7 +168,7 @@ let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18n
175
168
  {
176
169
  type: 'datetime',
177
170
  name: 'updatedAt',
178
- header: i18next.t('label.updated_at'),
171
+ header: i18next.t('field.updated_at'),
179
172
  record: {
180
173
  editable: false
181
174
  },
@@ -184,7 +177,7 @@ let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18n
184
177
  }
185
178
  ],
186
179
  rows: {
187
- appendable: false,
180
+ appendable: true,
188
181
  selectable: {
189
182
  multiple: true
190
183
  }
@@ -221,12 +214,41 @@ let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18n
221
214
  }
222
215
  }
223
216
  async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
224
- let url = 'terminologies';
225
- let selectFields = 'id,name,locale,category,display,created_at,updated_at,creator,updater';
226
- let result = null; // await ServiceUtil.searchByPagination(url, filters, sortings, page, limit, selectFields)
217
+ const response = await client.query({
218
+ query: gql `
219
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
220
+ terminologies(filters: $filters, pagination: $pagination, sortings: $sortings) {
221
+ items {
222
+ id
223
+ name
224
+ locale
225
+ category
226
+ display
227
+ creator {
228
+ id
229
+ name
230
+ }
231
+ createdAt
232
+ updater {
233
+ id
234
+ name
235
+ }
236
+ updatedAt
237
+ }
238
+
239
+ total
240
+ }
241
+ }
242
+ `,
243
+ variables: {
244
+ filters,
245
+ pagination: { page, limit },
246
+ sortings
247
+ }
248
+ });
227
249
  return {
228
- total: result ? result.total : 0,
229
- records: result ? result.items : []
250
+ total: response.data.terminologies.total || 0,
251
+ records: response.data.terminologies.items || []
230
252
  };
231
253
  }
232
254
  exportHandler() {
@@ -265,60 +287,66 @@ let TerminologyPage = class TerminologyPage extends connect(store)(localize(i18n
265
287
  async delete() {
266
288
  const selectedRecords = this.grist.selected;
267
289
  if (!selectedRecords || selectedRecords.length == 0) {
268
- // showToast('info', i18next.t('text.NOTHING_SELECTED'))
290
+ this.showToast('info', i18next.t('text.NOTHING_SELECTED'));
269
291
  }
270
292
  else {
271
- const answer = null; // await showAlertPopup('button.delete', 'text.are_you_sure', 'question', 'delete', 'cancel')
272
- if (answer) {
273
- let patches = selectedRecords.map(record => {
274
- record['cud_flag_'] = 'd';
275
- return record;
276
- });
277
- return null; // await ServiceUtil.deleteMultiple('terminologies/update_multiple', patches)
293
+ const answer = await CustomAlert({
294
+ type: 'question',
295
+ title: i18next.t('button.delete'),
296
+ text: i18next.t('text.are_you_sure'),
297
+ confirmButton: { text: i18next.t('button.delete') },
298
+ cancelButton: { text: i18next.t('button.cancel') }
299
+ });
300
+ if (!answer) {
301
+ return;
278
302
  }
303
+ let ids = selectedRecords.map(record => record.id);
304
+ const response = await client.mutate({
305
+ mutation: gql `
306
+ mutation ($ids: [String!]!) {
307
+ deleteTerminologies(ids: $ids)
308
+ }
309
+ `,
310
+ variables: {
311
+ ids
312
+ }
313
+ });
314
+ this.grist.fetch();
315
+ return response.data.deleteTerminologies;
279
316
  }
280
317
  }
281
318
  async save() {
282
319
  let changedRecords = this.grist.dirtyRecords;
283
320
  if (!changedRecords || changedRecords.length == 0) {
284
- // showToast('info', i18next.t('text.NOTHING_CHANGED'))
321
+ this.showToast('info', i18next.t('text.nothing_changed'));
285
322
  }
286
323
  else {
287
- let metaFields = [
288
- 'creator',
289
- 'updater',
290
- 'createdAt',
291
- 'updatedAt',
292
- '__dirty__',
293
- '__dirtyfields__',
294
- '__origin__',
295
- '__seq__',
296
- '__selected__'
297
- ];
298
- let patches = changedRecords.map(record => {
299
- let patchData = record.id ? { id: record.id } : {};
300
- for (let key in record) {
301
- if (!metaFields.includes(key)) {
302
- patchData[key] = record[key];
303
- }
324
+ const patches = changedRecords.map(patch => {
325
+ const patchField = patch.id ? { id: patch.id } : {};
326
+ const dirtyFields = patch.__dirtyfields__;
327
+ for (let key in dirtyFields) {
328
+ patchField[key] = dirtyFields[key].after;
329
+ }
330
+ patchField.cuFlag = patch.__dirty__;
331
+ return patchField;
332
+ });
333
+ const response = await client.mutate({
334
+ mutation: gql `
335
+ mutation ($patches: [TerminologyPatch!]!) {
336
+ updateMultipleTerminologies(patches: $patches) {
337
+ id
338
+ }
339
+ }
340
+ `,
341
+ variables: {
342
+ patches
304
343
  }
305
- patchData['cud_flag_'] = record['__dirty__'] == 'M' ? 'u' : 'c';
306
- return patchData;
307
344
  });
308
- //await ServiceUtil.updateMultiple('terminologies/update_multiple', patches)
309
345
  this.grist.fetch();
310
346
  }
311
347
  }
312
- print() {
313
- const selected = this.grist.selected;
314
- const ids = selected.map(record => record.id).join('|');
315
- /* TODO Implement the desired functionality */
316
- OxPrompt.open({
317
- type: 'success',
318
- title: i18next.t('text.completed'),
319
- text: i18next.t('text.printed_successfully'),
320
- confirmButton: { text: i18next.t('button.confirm') }
321
- });
348
+ showToast(type, message) {
349
+ document.dispatchEvent(new CustomEvent(type, { detail: { message } }));
322
350
  }
323
351
  };
324
352
  TerminologyPage.styles = [