@things-factory/biz-ui 4.3.99 → 4.3.109-alpha.0
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/contact-point-list.js +53 -13
- package/package.json +10 -10
|
@@ -4,6 +4,7 @@ import _ from 'lodash'
|
|
|
4
4
|
|
|
5
5
|
import gql from 'graphql-tag'
|
|
6
6
|
import { css, html } from 'lit'
|
|
7
|
+
import isEmpty from 'lodash-es/isEmpty'
|
|
7
8
|
|
|
8
9
|
import { getCodeByName } from '@things-factory/code-base'
|
|
9
10
|
import { i18next, localize } from '@things-factory/i18n-base'
|
|
@@ -87,11 +88,11 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
87
88
|
|
|
88
89
|
return patch
|
|
89
90
|
})
|
|
90
|
-
this._validateImport(patches)
|
|
91
|
+
await this._validateImport(patches)
|
|
91
92
|
await this._saveContactPoints(patches)
|
|
92
93
|
history.back()
|
|
93
94
|
} catch (e) {
|
|
94
|
-
this.showToast(e)
|
|
95
|
+
this.showToast(e.message)
|
|
95
96
|
}
|
|
96
97
|
})
|
|
97
98
|
}
|
|
@@ -138,6 +139,7 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
138
139
|
]
|
|
139
140
|
|
|
140
141
|
this.config = {
|
|
142
|
+
pagination: { limit: 50, pages: [50, 100, 200, 500] },
|
|
141
143
|
rows: {
|
|
142
144
|
selectable: {
|
|
143
145
|
multiple: true
|
|
@@ -157,7 +159,7 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
157
159
|
width: 40,
|
|
158
160
|
type: 'string'
|
|
159
161
|
},
|
|
160
|
-
header: i18next.t('field.contact_point_customer_name')
|
|
162
|
+
header: `*${i18next.t('field.contact_point_customer_name')}`,
|
|
161
163
|
width: 250
|
|
162
164
|
},
|
|
163
165
|
{
|
|
@@ -192,7 +194,7 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
192
194
|
name: 'companyName',
|
|
193
195
|
record: { editable: true },
|
|
194
196
|
imex: {
|
|
195
|
-
header:
|
|
197
|
+
header: i18next.t('field.contact_point_other_company_name'),
|
|
196
198
|
key: 'companyName',
|
|
197
199
|
width: 40,
|
|
198
200
|
type: 'string'
|
|
@@ -217,7 +219,7 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
217
219
|
type: 'string',
|
|
218
220
|
name: 'email',
|
|
219
221
|
record: { editable: true },
|
|
220
|
-
imex: { header:
|
|
222
|
+
imex: { header: i18next.t('field.contact_point_email'), key: 'email', width: 40, type: 'string' },
|
|
221
223
|
header: i18next.t('field.contact_point_email'),
|
|
222
224
|
width: 120
|
|
223
225
|
},
|
|
@@ -234,7 +236,7 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
234
236
|
name: 'phone',
|
|
235
237
|
record: { editable: true },
|
|
236
238
|
imex: { header: '*' + i18next.t('field.contact_point_phone'), key: 'phone', width: 40, type: 'string' },
|
|
237
|
-
header: i18next.t('field.contact_point_phone'),
|
|
239
|
+
header: '*' + i18next.t('field.contact_point_phone'),
|
|
238
240
|
width: 120
|
|
239
241
|
},
|
|
240
242
|
{
|
|
@@ -242,7 +244,7 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
242
244
|
name: 'accountNo',
|
|
243
245
|
record: { editable: true },
|
|
244
246
|
imex: {
|
|
245
|
-
header:
|
|
247
|
+
header: i18next.t('field.contact_point_account_no'),
|
|
246
248
|
key: 'accountNo',
|
|
247
249
|
width: 40,
|
|
248
250
|
type: 'string'
|
|
@@ -254,8 +256,13 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
254
256
|
type: 'string',
|
|
255
257
|
name: 'address',
|
|
256
258
|
record: { editable: true },
|
|
257
|
-
imex: {
|
|
258
|
-
|
|
259
|
+
imex: {
|
|
260
|
+
header: '*' + i18next.t('field.contact_point_company_address'),
|
|
261
|
+
key: 'address',
|
|
262
|
+
width: 40,
|
|
263
|
+
type: 'string'
|
|
264
|
+
},
|
|
265
|
+
header: '*' + i18next.t('field.contact_point_company_address'),
|
|
259
266
|
width: 300
|
|
260
267
|
},
|
|
261
268
|
{
|
|
@@ -300,7 +307,7 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
300
307
|
name: 'billingAddress',
|
|
301
308
|
record: { editable: true },
|
|
302
309
|
imex: {
|
|
303
|
-
header:
|
|
310
|
+
header: i18next.t('field.contact_point_billing_address'),
|
|
304
311
|
key: 'billingAddress',
|
|
305
312
|
width: 40,
|
|
306
313
|
type: 'string'
|
|
@@ -311,7 +318,7 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
311
318
|
{
|
|
312
319
|
name: 'type',
|
|
313
320
|
record: { editable: true },
|
|
314
|
-
header: i18next.t('field.contact_point_type'),
|
|
321
|
+
header: '*' + i18next.t('field.contact_point_type'),
|
|
315
322
|
type: 'code',
|
|
316
323
|
imex: {
|
|
317
324
|
header: '*' + i18next.t('field.contact_point_type'),
|
|
@@ -431,6 +438,8 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
431
438
|
return this.showToast(i18next.t('text.nothing_changed'))
|
|
432
439
|
}
|
|
433
440
|
|
|
441
|
+
this._validate()
|
|
442
|
+
|
|
434
443
|
const response = await client.mutate({
|
|
435
444
|
mutation: gql`
|
|
436
445
|
mutation updateMultipleContactPoint($patches: [ContactPointPatch!]!) {
|
|
@@ -448,7 +457,32 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
448
457
|
this.dataGrist.fetch()
|
|
449
458
|
}
|
|
450
459
|
} catch (error) {
|
|
451
|
-
this.showToast(error)
|
|
460
|
+
this.showToast(error.message)
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
_validate() {
|
|
465
|
+
let errors = []
|
|
466
|
+
|
|
467
|
+
let data = this.dataGrist._data.records.map(itm => {
|
|
468
|
+
itm.error = false
|
|
469
|
+
z
|
|
470
|
+
|
|
471
|
+
if (isEmpty(itm.name) || '') {
|
|
472
|
+
itm.error = true
|
|
473
|
+
if (!errors.find(err => err.type == 'customerName'))
|
|
474
|
+
errors.push({ type: 'customerName', value: 'customer name is required' })
|
|
475
|
+
}
|
|
476
|
+
return itm
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
if (errors.length > 0) {
|
|
480
|
+
this._data = {
|
|
481
|
+
...this.dataGrist.dirtyData,
|
|
482
|
+
records: data
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
throw new Error(errors.map(itm => itm.value).join(', '))
|
|
452
486
|
}
|
|
453
487
|
}
|
|
454
488
|
|
|
@@ -489,7 +523,8 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
489
523
|
}
|
|
490
524
|
}
|
|
491
525
|
|
|
492
|
-
_validateImport(data) {
|
|
526
|
+
async _validateImport(data) {
|
|
527
|
+
const contactTypes = await getCodeByName('CONTACT_TYPES')
|
|
493
528
|
let errors = []
|
|
494
529
|
|
|
495
530
|
data = data.map(item => {
|
|
@@ -523,6 +558,11 @@ export class ContactPointList extends localize(i18next)(PageView) {
|
|
|
523
558
|
}
|
|
524
559
|
}
|
|
525
560
|
|
|
561
|
+
let foundContactTypes = contactTypes.find(exist => exist.name == item.type)
|
|
562
|
+
if (!foundContactTypes) {
|
|
563
|
+
throw new Error(i18next.t('text.contact_type_does_not_exist'))
|
|
564
|
+
}
|
|
565
|
+
|
|
526
566
|
return item
|
|
527
567
|
})
|
|
528
568
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/biz-ui",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.109-alpha.0",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/biz-base": "^4.3.
|
|
28
|
-
"@things-factory/code-base": "^4.3.
|
|
29
|
-
"@things-factory/form-ui": "^4.3.
|
|
30
|
-
"@things-factory/grist-ui": "^4.3.
|
|
31
|
-
"@things-factory/i18n-base": "^4.3.
|
|
32
|
-
"@things-factory/import-ui": "^4.3.
|
|
33
|
-
"@things-factory/layout-base": "^4.3.
|
|
34
|
-
"@things-factory/shell": "^4.3.
|
|
27
|
+
"@things-factory/biz-base": "^4.3.109-alpha.0",
|
|
28
|
+
"@things-factory/code-base": "^4.3.109-alpha.0",
|
|
29
|
+
"@things-factory/form-ui": "^4.3.109-alpha.0",
|
|
30
|
+
"@things-factory/grist-ui": "^4.3.109-alpha.0",
|
|
31
|
+
"@things-factory/i18n-base": "^4.3.109-alpha.0",
|
|
32
|
+
"@things-factory/import-ui": "^4.3.109-alpha.0",
|
|
33
|
+
"@things-factory/layout-base": "^4.3.109-alpha.0",
|
|
34
|
+
"@things-factory/shell": "^4.3.109-alpha.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "a4e928b10c5db079df6e2a9ece616de77625ed0a"
|
|
37
37
|
}
|