@things-factory/biz-ui 4.3.798 → 4.3.819

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.
@@ -38,6 +38,8 @@ export class ContactPointList extends localize(i18next)(PageView) {
38
38
  data-grist {
39
39
  overflow-y: auto;
40
40
  flex: 1;
41
+ --grid-record-emphasized-background-color: #ffdbdb;
42
+ --grid-record-emphasized-color: #703f3f;
41
43
  }
42
44
  `
43
45
  ]
@@ -153,7 +155,8 @@ export class ContactPointList extends localize(i18next)(PageView) {
153
155
  rows: {
154
156
  selectable: {
155
157
  multiple: true
156
- }
158
+ },
159
+ classifier: record => ({ emphasized: record.error || false })
157
160
  },
158
161
  columns: [
159
162
  { type: 'gutter', gutterName: 'dirty' },
@@ -172,12 +175,12 @@ export class ContactPointList extends localize(i18next)(PageView) {
172
175
  name: 'name',
173
176
  record: { editable: true },
174
177
  imex: {
175
- header: '*' + i18next.t('field.contact_point_customer_name'),
178
+ header: i18next.t('field.contact_point_customer_name'),
176
179
  key: 'name',
177
180
  width: 40,
178
181
  type: 'string'
179
182
  },
180
- header: `*${i18next.t('field.contact_point_customer_name')}`,
183
+ header: i18next.t('field.contact_point_customer_name'),
181
184
  width: 250
182
185
  },
183
186
  {
@@ -212,12 +215,12 @@ export class ContactPointList extends localize(i18next)(PageView) {
212
215
  name: 'companyName',
213
216
  record: { editable: true },
214
217
  imex: {
215
- header: i18next.t('field.contact_point_other_company_name'),
218
+ header: '*' + i18next.t('field.contact_point_other_company_name'),
216
219
  key: 'companyName',
217
220
  width: 40,
218
221
  type: 'string'
219
222
  },
220
- header: i18next.t('field.contact_point_other_company_name'),
223
+ header: '*' + i18next.t('field.contact_point_other_company_name'),
221
224
  width: 200
222
225
  },
223
226
  {
@@ -253,8 +256,8 @@ export class ContactPointList extends localize(i18next)(PageView) {
253
256
  type: 'string',
254
257
  name: 'phone',
255
258
  record: { editable: true },
256
- imex: { header: '*' + i18next.t('field.contact_point_phone'), key: 'phone', width: 40, type: 'string' },
257
- header: '*' + i18next.t('field.contact_point_phone'),
259
+ imex: { header: i18next.t('field.contact_point_phone'), key: 'phone', width: 40, type: 'string' },
260
+ header: i18next.t('field.contact_point_phone'),
258
261
  width: 120
259
262
  },
260
263
  {
@@ -300,32 +303,32 @@ export class ContactPointList extends localize(i18next)(PageView) {
300
303
  type: 'string',
301
304
  name: 'postCode',
302
305
  record: { editable: true },
303
- imex: { header: i18next.t('field.contact_point_postal_code'), key: 'postCode', width: 40, type: 'string' },
304
- header: i18next.t('field.contact_point_postal_code'),
306
+ imex: { header: '*' + i18next.t('field.contact_point_postal_code'), key: 'postCode', width: 40, type: 'string' },
307
+ header: '*' + i18next.t('field.contact_point_postal_code'),
305
308
  width: 150
306
309
  },
307
310
  {
308
311
  type: 'string',
309
312
  name: 'city',
310
313
  record: { editable: true },
311
- imex: { header: i18next.t('field.contact_point_city'), key: 'city', width: 40, type: 'string' },
312
- header: i18next.t('field.contact_point_city'),
314
+ imex: { header: '*' + i18next.t('field.contact_point_city'), key: 'city', width: 40, type: 'string' },
315
+ header: '*' + i18next.t('field.contact_point_city'),
313
316
  width: 150
314
317
  },
315
318
  {
316
319
  type: 'string',
317
320
  name: 'state',
318
321
  record: { editable: true },
319
- imex: { header: i18next.t('field.contact_point_state'), key: 'state', width: 40, type: 'string' },
320
- header: i18next.t('field.contact_point_state'),
322
+ imex: { header: '*' + i18next.t('field.contact_point_state'), key: 'state', width: 40, type: 'string' },
323
+ header: '*' + i18next.t('field.contact_point_state'),
321
324
  width: 150
322
325
  },
323
326
  {
324
327
  type: 'string',
325
328
  name: 'country',
326
329
  record: { editable: true },
327
- imex: { header: i18next.t('field.country'), key: 'country', width: 40, type: 'string' },
328
- header: i18next.t('field.country'),
330
+ imex: { header: '*' + i18next.t('field.country'), key: 'country', width: 40, type: 'string' },
331
+ header: '*' + i18next.t('field.country'),
329
332
  width: 150
330
333
  },
331
334
  {
@@ -716,7 +719,7 @@ export class ContactPointList extends localize(i18next)(PageView) {
716
719
  return this.showToast(i18next.t('text.nothing_changed'))
717
720
  }
718
721
 
719
- this._validate()
722
+ this._validate(patches)
720
723
 
721
724
  const normalizedPatches = patches.map(patch => ({
722
725
  ...patch,
@@ -744,51 +747,79 @@ export class ContactPointList extends localize(i18next)(PageView) {
744
747
  }
745
748
  }
746
749
 
747
- _validate() {
750
+ _validate(patches) {
748
751
  let errors = []
752
+ const errorIds = new Set()
753
+ const recordsMap = new Map(this.dataGrist._data.records.map(r => [r.id, r]))
749
754
 
750
- let data = this.dataGrist._data.records.map(itm => {
751
- itm.error = false
755
+ for (const patch of patches) {
756
+ const itm = patch.cuFlag === '+' ? patch : { ...recordsMap.get(patch.id), ...patch }
757
+ let hasError = false
752
758
 
753
- if (isEmpty(itm.name) || '') {
754
- itm.error = true
755
- if (!errors.find(err => err.type == 'customerName'))
756
- errors.push({ type: 'customerName', value: 'customer name is required' })
759
+ if (isEmpty(itm.type) || '') {
760
+ hasError = true
761
+ if (!errors.find(err => err.type == 'type'))
762
+ errors.push({ type: 'type', value: 'Type is required' })
763
+ }
764
+
765
+ if (isEmpty(itm.companyName) || '') {
766
+ hasError = true
767
+ if (!errors.find(err => err.type == 'companyName'))
768
+ errors.push({ type: 'companyName', value: 'Company name is required' })
769
+ }
770
+
771
+ if (isEmpty(itm.address) || '') {
772
+ hasError = true
773
+ if (!errors.find(err => err.type == 'address'))
774
+ errors.push({ type: 'address', value: 'Shipping address is required' })
775
+ }
776
+
777
+ if (isEmpty(itm.country) || '') {
778
+ hasError = true
779
+ if (!errors.find(err => err.type == 'country'))
780
+ errors.push({ type: 'country', value: 'Country is required' })
781
+ }
782
+
783
+ if (isEmpty(itm.state) || '') {
784
+ hasError = true
785
+ if (!errors.find(err => err.type == 'state'))
786
+ errors.push({ type: 'state', value: 'State is required' })
787
+ }
788
+
789
+ if (isEmpty(itm.city) || '') {
790
+ hasError = true
791
+ if (!errors.find(err => err.type == 'city'))
792
+ errors.push({ type: 'city', value: 'City is required' })
793
+ }
794
+
795
+ if (isEmpty(itm.postCode) || '') {
796
+ hasError = true
797
+ if (!errors.find(err => err.type == 'postCode'))
798
+ errors.push({ type: 'postCode', value: 'Postal code is required' })
757
799
  }
758
800
 
759
- // Validate releaseShelfLife: must be non-negative integer
760
801
  const releaseShelfLifeValidation = this._validateReleaseShelfLife(itm.releaseShelfLife, true)
761
802
  if (!releaseShelfLifeValidation.valid) {
762
- itm.error = true
763
- if (!errors.find(err => err.type == 'releaseShelfLife')) {
764
- errors.push({
765
- type: 'releaseShelfLife',
766
- value: releaseShelfLifeValidation.error
767
- })
768
- }
803
+ hasError = true
804
+ if (!errors.find(err => err.type == 'releaseShelfLife'))
805
+ errors.push({ type: 'releaseShelfLife', value: releaseShelfLifeValidation.error })
769
806
  }
770
807
 
771
- // Validate businessRestDay: must be valid day(s)
772
808
  const businessRestDayValidation = this._validateBusinessRestDay(itm.businessRestDay, true)
773
809
  if (!businessRestDayValidation.valid) {
774
- itm.error = true
775
- if (!errors.find(err => err.type == 'businessRestDay')) {
776
- errors.push({
777
- type: 'businessRestDay',
778
- value: businessRestDayValidation.error
779
- })
780
- }
810
+ hasError = true
811
+ if (!errors.find(err => err.type == 'businessRestDay'))
812
+ errors.push({ type: 'businessRestDay', value: businessRestDayValidation.error })
781
813
  }
782
814
 
783
- return itm
784
- })
815
+ if (hasError && patch.id) errorIds.add(patch.id)
816
+ }
785
817
 
786
818
  if (errors.length > 0) {
787
- this._data = {
788
- ...this.dataGrist.dirtyData,
789
- records: data
790
- }
791
-
819
+ this.dataGrist._data.records.forEach(r => {
820
+ r.error = errorIds.has(r.id)
821
+ })
822
+ this.dataGrist.refresh()
792
823
  throw new Error(errors.map(itm => itm.value).join(', '))
793
824
  }
794
825
  }
@@ -835,33 +866,45 @@ export class ContactPointList extends localize(i18next)(PageView) {
835
866
  let errors = []
836
867
 
837
868
  data = data.map(item => {
838
- if (_.isEmpty(item.name) || '') {
839
- if (!errors.find(error => error.type == 'name')) {
840
- errors.push({ type: 'name', value: 'Name is required' })
869
+ if (_.isEmpty(item.type) || '') {
870
+ if (!errors.find(error => error.type == 'type')) {
871
+ errors.push({ type: 'type', value: 'Type is required' })
841
872
  }
842
873
  }
843
874
 
844
- if (_.isEmpty(item.phone) || '') {
845
- if (!errors.find(error => error.type == 'phone')) {
846
- errors.push({ type: 'phone', value: 'Phone is required' })
875
+ if (_.isEmpty(item.bizplace?.id) || '') {
876
+ if (!errors.find(error => error.type == 'companyName')) {
877
+ errors.push({ type: 'companyName', value: 'Company name is required' })
847
878
  }
848
879
  }
849
880
 
850
881
  if (_.isEmpty(item.address) || '') {
851
882
  if (!errors.find(error => error.type == 'address')) {
852
- errors.push({ type: 'address', value: 'Address is required' })
883
+ errors.push({ type: 'address', value: 'Shipping address is required' })
853
884
  }
854
885
  }
855
886
 
856
- if (_.isEmpty(item.bizplace?.id) || '') {
857
- if (!errors.find(error => error.type == 'companyName')) {
858
- errors.push({ type: 'companyName', value: 'Company name is required' })
887
+ if (_.isEmpty(item.country) || '') {
888
+ if (!errors.find(error => error.type == 'country')) {
889
+ errors.push({ type: 'country', value: 'Country is required' })
859
890
  }
860
891
  }
861
892
 
862
- if (_.isEmpty(item.type) || '') {
863
- if (!errors.find(error => error.type == 'type')) {
864
- errors.push({ type: 'type', value: 'Type is required' })
893
+ if (_.isEmpty(item.state) || '') {
894
+ if (!errors.find(error => error.type == 'state')) {
895
+ errors.push({ type: 'state', value: 'State is required' })
896
+ }
897
+ }
898
+
899
+ if (_.isEmpty(item.city) || '') {
900
+ if (!errors.find(error => error.type == 'city')) {
901
+ errors.push({ type: 'city', value: 'City is required' })
902
+ }
903
+ }
904
+
905
+ if (_.isEmpty(item.postCode) || '') {
906
+ if (!errors.find(error => error.type == 'postCode')) {
907
+ errors.push({ type: 'postCode', value: 'Postal code is required' })
865
908
  }
866
909
  }
867
910
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/biz-ui",
3
- "version": "4.3.798",
3
+ "version": "4.3.819",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -23,14 +23,14 @@
23
23
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
24
24
  },
25
25
  "dependencies": {
26
- "@things-factory/biz-base": "^4.3.798",
27
- "@things-factory/code-base": "^4.3.767",
28
- "@things-factory/form-ui": "^4.3.767",
29
- "@things-factory/grist-ui": "^4.3.770",
30
- "@things-factory/i18n-base": "^4.3.767",
31
- "@things-factory/import-ui": "^4.3.790",
32
- "@things-factory/layout-base": "^4.3.767",
33
- "@things-factory/shell": "^4.3.767"
26
+ "@things-factory/biz-base": "^4.3.819",
27
+ "@things-factory/code-base": "^4.3.815",
28
+ "@things-factory/form-ui": "^4.3.815",
29
+ "@things-factory/grist-ui": "^4.3.815",
30
+ "@things-factory/i18n-base": "^4.3.815",
31
+ "@things-factory/import-ui": "^4.3.815",
32
+ "@things-factory/layout-base": "^4.3.815",
33
+ "@things-factory/shell": "^4.3.815"
34
34
  },
35
- "gitHead": "d9c29bdfadad409e12de40cadabd329080f7501d"
35
+ "gitHead": "c6a6478dad09702aeafad6a491bf9936ade6a1fe"
36
36
  }