@things-factory/setting-ui 4.3.113-alpha.0 → 4.3.114
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/pages/partner-setting-list.js +7 -9
- package/client/pages/setting-list.js +42 -172
- package/package.json +10 -10
|
@@ -93,7 +93,12 @@ export class PartnerSettingList extends connect(store)(localize(i18next)(PageVie
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
pageInitialized() {
|
|
96
|
-
this.searchFields = [
|
|
96
|
+
this.searchFields = [
|
|
97
|
+
{ name: 'name', label: i18next.t('field.name'), type: 'text', props: { searchOper: 'i_like' } },
|
|
98
|
+
{ name: 'description', label: i18next.t('field.description'), type: 'text', props: { searchOper: 'i_like' } },
|
|
99
|
+
{ name: 'category', label: i18next.t('field.category'), type: 'text', props: { searchOper: 'i_like' } }
|
|
100
|
+
]
|
|
101
|
+
|
|
97
102
|
this.config = {
|
|
98
103
|
list: {
|
|
99
104
|
fields: ['name', 'description', 'value']
|
|
@@ -245,14 +250,7 @@ export class PartnerSettingList extends connect(store)(localize(i18next)(PageVie
|
|
|
245
250
|
context: gqlContext()
|
|
246
251
|
})
|
|
247
252
|
|
|
248
|
-
|
|
249
|
-
return {
|
|
250
|
-
...data,
|
|
251
|
-
category: data.setting.category,
|
|
252
|
-
description: data.setting.description
|
|
253
|
-
}
|
|
254
|
-
})
|
|
255
|
-
return { records: res || [], total: response.data.partnerSettings.total || 0 }
|
|
253
|
+
return { records: response.data.partnerSettings.items || [], total: response.data.partnerSettings.total || 0 }
|
|
256
254
|
}
|
|
257
255
|
|
|
258
256
|
async save() {
|
|
@@ -8,9 +8,6 @@ import gql from 'graphql-tag'
|
|
|
8
8
|
import { css, html } from 'lit'
|
|
9
9
|
import { connect } from 'pwa-helpers/connect-mixin'
|
|
10
10
|
import { CommonButtonStyles } from '../../../styles/src'
|
|
11
|
-
import { openImportPopUp } from '@things-factory/import-ui'
|
|
12
|
-
import _ from 'lodash'
|
|
13
|
-
import isEmpty from 'lodash-es/isEmpty'
|
|
14
11
|
|
|
15
12
|
export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
16
13
|
static get styles() {
|
|
@@ -65,7 +62,7 @@ export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
|
65
62
|
actions: [
|
|
66
63
|
{
|
|
67
64
|
title: i18next.t('button.save'),
|
|
68
|
-
action:
|
|
65
|
+
action: this._saveSettings.bind(this),
|
|
69
66
|
...CommonButtonStyles.save
|
|
70
67
|
},
|
|
71
68
|
{
|
|
@@ -79,26 +76,7 @@ export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
|
79
76
|
data: this._exportableData.bind(this)
|
|
80
77
|
},
|
|
81
78
|
importable: {
|
|
82
|
-
handler:
|
|
83
|
-
const config = {
|
|
84
|
-
rows: this.config.rows,
|
|
85
|
-
columns: [...this.config.columns.filter(column => column.imex !== undefined)]
|
|
86
|
-
}
|
|
87
|
-
openImportPopUp(records, config, async patches => {
|
|
88
|
-
try {
|
|
89
|
-
patches = patches.map(patch => {
|
|
90
|
-
if (!patch?.id) delete patch.id
|
|
91
|
-
|
|
92
|
-
return patch
|
|
93
|
-
})
|
|
94
|
-
this._validateImport(patches)
|
|
95
|
-
await this._saveSettings(patches)
|
|
96
|
-
history.back()
|
|
97
|
-
} catch (e) {
|
|
98
|
-
this.showToast(e.message)
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
}
|
|
79
|
+
handler: () => {}
|
|
102
80
|
}
|
|
103
81
|
}
|
|
104
82
|
}
|
|
@@ -143,13 +121,7 @@ export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
|
143
121
|
header: i18next.t('field.name'),
|
|
144
122
|
record: { editable: true, align: 'left' },
|
|
145
123
|
sortable: true,
|
|
146
|
-
width: 100
|
|
147
|
-
imex: {
|
|
148
|
-
header: i18next.t('field.name'),
|
|
149
|
-
key: 'name',
|
|
150
|
-
width: 50,
|
|
151
|
-
type: 'string'
|
|
152
|
-
}
|
|
124
|
+
width: 100
|
|
153
125
|
},
|
|
154
126
|
{
|
|
155
127
|
type: 'string',
|
|
@@ -157,13 +129,7 @@ export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
|
157
129
|
header: i18next.t('field.description'),
|
|
158
130
|
record: { editable: true, align: 'left' },
|
|
159
131
|
sortable: true,
|
|
160
|
-
width: 200
|
|
161
|
-
imex: {
|
|
162
|
-
header: i18next.t('field.description'),
|
|
163
|
-
key: 'description',
|
|
164
|
-
width: 50,
|
|
165
|
-
type: 'string'
|
|
166
|
-
}
|
|
132
|
+
width: 200
|
|
167
133
|
},
|
|
168
134
|
{
|
|
169
135
|
type: 'code',
|
|
@@ -171,13 +137,7 @@ export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
|
171
137
|
header: i18next.t('field.category'),
|
|
172
138
|
record: { editable: true, codeName: 'SETTING_CATEGORIES' },
|
|
173
139
|
sortable: true,
|
|
174
|
-
width: 150
|
|
175
|
-
imex: {
|
|
176
|
-
header: i18next.t('field.category'),
|
|
177
|
-
key: 'category',
|
|
178
|
-
width: 30,
|
|
179
|
-
type: 'code'
|
|
180
|
-
}
|
|
140
|
+
width: 150
|
|
181
141
|
},
|
|
182
142
|
{
|
|
183
143
|
type: 'string',
|
|
@@ -193,28 +153,15 @@ export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
|
193
153
|
editable: true
|
|
194
154
|
},
|
|
195
155
|
sortable: true,
|
|
196
|
-
width: 180
|
|
197
|
-
imex: {
|
|
198
|
-
header: i18next.t('field.value'),
|
|
199
|
-
key: 'value',
|
|
200
|
-
width: 40,
|
|
201
|
-
type: 'string'
|
|
202
|
-
}
|
|
156
|
+
width: 180
|
|
203
157
|
},
|
|
204
158
|
{
|
|
205
|
-
type: '
|
|
159
|
+
type: 'datetime',
|
|
206
160
|
name: 'updatedAt',
|
|
207
161
|
header: i18next.t('field.updated_at'),
|
|
208
162
|
record: { editable: false, align: 'left' },
|
|
209
163
|
sortable: true,
|
|
210
164
|
width: 150
|
|
211
|
-
// imex:
|
|
212
|
-
// {
|
|
213
|
-
// header: i18next.t('field.updated_at'),
|
|
214
|
-
// key: 'updatedAt',
|
|
215
|
-
// width: 20,
|
|
216
|
-
// type: 'date'
|
|
217
|
-
// }
|
|
218
165
|
},
|
|
219
166
|
{
|
|
220
167
|
type: 'object',
|
|
@@ -223,13 +170,6 @@ export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
|
223
170
|
record: { editable: false, align: 'left' },
|
|
224
171
|
sortable: true,
|
|
225
172
|
width: 150
|
|
226
|
-
// imex:
|
|
227
|
-
// {
|
|
228
|
-
// header: i18next.t('field.updater'),
|
|
229
|
-
// key: 'updater.name',
|
|
230
|
-
// width: 30,
|
|
231
|
-
// type: 'object'
|
|
232
|
-
// }
|
|
233
173
|
}
|
|
234
174
|
]
|
|
235
175
|
}
|
|
@@ -280,55 +220,47 @@ export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
|
280
220
|
}
|
|
281
221
|
}
|
|
282
222
|
|
|
283
|
-
async _saveSettings(
|
|
284
|
-
|
|
285
|
-
if (!patches?.length) {
|
|
286
|
-
return this.showToast(i18next.t('text.nothing_changed'))
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
this._validate()
|
|
290
|
-
|
|
291
|
-
const response = await client.mutate({
|
|
292
|
-
mutation: gql`
|
|
293
|
-
mutation updateMultipleSetting($patches: [SettingPatch!]!) {
|
|
294
|
-
updateMultipleSetting(patches: $patches) {
|
|
295
|
-
name
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
`,
|
|
299
|
-
variables: { patches },
|
|
300
|
-
context: gqlContext()
|
|
301
|
-
})
|
|
223
|
+
async _saveSettings() {
|
|
224
|
+
let patches = this.dataGrist.dirtyRecords
|
|
302
225
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
this.dataGrist.fetch()
|
|
306
|
-
}
|
|
307
|
-
} catch (error) {
|
|
308
|
-
this.showToast(error.message)
|
|
226
|
+
if (!patches?.length) {
|
|
227
|
+
return this.showToast(i18next.t('text.nothing_changed'))
|
|
309
228
|
}
|
|
310
|
-
}
|
|
311
229
|
|
|
312
|
-
|
|
313
|
-
|
|
230
|
+
patches = patches.map(setting => {
|
|
231
|
+
let patchField = setting.id ? { id: setting.id } : {}
|
|
232
|
+
const dirtyFields = setting.__dirtyfields__
|
|
233
|
+
for (let key in dirtyFields) {
|
|
234
|
+
patchField[key] = dirtyFields[key].after
|
|
235
|
+
}
|
|
236
|
+
patchField.cuFlag = setting.__dirty__
|
|
314
237
|
|
|
315
|
-
|
|
316
|
-
|
|
238
|
+
return patchField
|
|
239
|
+
})
|
|
317
240
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
return itm
|
|
241
|
+
let checkValidation = true
|
|
242
|
+
patches.forEach(patch => {
|
|
243
|
+
if (patch.cuFlag === '+' && (!patch.name || !patch.category)) return (checkValidation = false)
|
|
323
244
|
})
|
|
324
245
|
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
246
|
+
if (!checkValidation) return this.showToast(i18next.t('error.value is empty', { value: 'name or category' }))
|
|
247
|
+
|
|
248
|
+
const response = await client.mutate({
|
|
249
|
+
mutation: gql`
|
|
250
|
+
mutation updateMultipleSetting($patches: [SettingPatch!]!) {
|
|
251
|
+
updateMultipleSetting(patches: $patches) {
|
|
252
|
+
name
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
`,
|
|
256
|
+
variables: { patches },
|
|
257
|
+
context: gqlContext()
|
|
258
|
+
})
|
|
330
259
|
|
|
331
|
-
|
|
260
|
+
if (!response.errors) {
|
|
261
|
+
this.showToast(i18next.t('text.data_updated_successfully'))
|
|
262
|
+
this.dataGrist.fetch()
|
|
263
|
+
this.applyRefreshHandlers()
|
|
332
264
|
}
|
|
333
265
|
}
|
|
334
266
|
|
|
@@ -374,70 +306,8 @@ export class SettingList extends connect(store)(localize(i18next)(PageView)) {
|
|
|
374
306
|
this.refreshHandlers.forEach(refreshHandler => refreshHandler())
|
|
375
307
|
}
|
|
376
308
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
if (this.dataGrist.selected && this.dataGrist.selected.length > 0) {
|
|
380
|
-
records = this.dataGrist.selected
|
|
381
|
-
} else {
|
|
382
|
-
records = (await this.fetchHandler({ page: 0, limit: 999999 })).records || []
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
var headerSetting = this.dataGrist._config.columns
|
|
386
|
-
.filter(column => column.type !== 'gutter' && column.record !== undefined && column.imex !== undefined)
|
|
387
|
-
.map(column => {
|
|
388
|
-
return column.imex
|
|
389
|
-
})
|
|
390
|
-
|
|
391
|
-
var data = records.map(item => {
|
|
392
|
-
return {
|
|
393
|
-
id: item.id,
|
|
394
|
-
...this.config.columns
|
|
395
|
-
.filter(column => column.type !== 'gutter' && column.record !== undefined && column.imex !== undefined)
|
|
396
|
-
.reduce((record, column) => {
|
|
397
|
-
record[column.imex.key] = column.imex.key
|
|
398
|
-
.split('.')
|
|
399
|
-
.reduce((obj, key) => (obj && obj[key] !== 'undefined' ? obj[key] : undefined), item)
|
|
400
|
-
return record
|
|
401
|
-
}, {})
|
|
402
|
-
}
|
|
403
|
-
})
|
|
404
|
-
return { header: headerSetting, data: data }
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
_validateImport(data) {
|
|
408
|
-
let errors = []
|
|
409
|
-
|
|
410
|
-
data = data.map(item => {
|
|
411
|
-
if (_.isEmpty(item.name) || '') {
|
|
412
|
-
if (!errors.find(error => error.type == 'name')) {
|
|
413
|
-
errors.push({ type: 'name', value: 'Name is required' })
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
if (_.isEmpty(item.description) || '') {
|
|
418
|
-
if (!errors.find(error => error.type == 'description')) {
|
|
419
|
-
errors.push({ type: 'description', value: 'Description is required' })
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
if (_.isEmpty(item.category) || '') {
|
|
424
|
-
if (!errors.find(error => error.type == 'category')) {
|
|
425
|
-
errors.push({ type: 'category', value: 'Category is required' })
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
if (_.isEmpty(item.value) || '') {
|
|
430
|
-
if (!errors.find(error => error.type == 'value')) {
|
|
431
|
-
errors.push({ type: 'value', value: 'Value is required' })
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
return item
|
|
436
|
-
})
|
|
437
|
-
|
|
438
|
-
if (errors.length > 0) {
|
|
439
|
-
throw new Error(`${errors.map(item => item.value).join(', ')}`)
|
|
440
|
-
}
|
|
309
|
+
_exportableData() {
|
|
310
|
+
return this.dataGrist.exportRecords()
|
|
441
311
|
}
|
|
442
312
|
|
|
443
313
|
stateChanged(state) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/setting-ui",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.114",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@material/mwc-button": "^0.25.3",
|
|
28
|
-
"@things-factory/form-ui": "^4.3.
|
|
29
|
-
"@things-factory/grist-ui": "^4.3.
|
|
30
|
-
"@things-factory/i18n-base": "^4.3.
|
|
31
|
-
"@things-factory/layout-base": "^4.3.
|
|
32
|
-
"@things-factory/more-base": "^4.3.
|
|
33
|
-
"@things-factory/setting-base": "^4.3.
|
|
34
|
-
"@things-factory/styles": "^4.3.
|
|
35
|
-
"@things-factory/utils": "^4.3.
|
|
28
|
+
"@things-factory/form-ui": "^4.3.114",
|
|
29
|
+
"@things-factory/grist-ui": "^4.3.114",
|
|
30
|
+
"@things-factory/i18n-base": "^4.3.114",
|
|
31
|
+
"@things-factory/layout-base": "^4.3.114",
|
|
32
|
+
"@things-factory/more-base": "^4.3.114",
|
|
33
|
+
"@things-factory/setting-base": "^4.3.114",
|
|
34
|
+
"@things-factory/styles": "^4.3.114",
|
|
35
|
+
"@things-factory/utils": "^4.3.114"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "6f16bd9dfb3210e848e5118d894424972ed83773"
|
|
38
38
|
}
|