@vgip/meta-ui 1.2.8 → 1.3.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.
@@ -654,6 +654,9 @@ const metaNormalizer = (meta, integration, resourceType) => {
654
654
  for (const ff of f.fields) {
655
655
  fieldFixesByIntegration(ff);
656
656
  }
657
+ if (f.name && /^composite_(.*)/.test(f.name)) {
658
+ delete f.name;
659
+ }
657
660
  }
658
661
  };
659
662
  // common fixes for all integrations
@@ -970,6 +973,18 @@ class FieldAbstract {
970
973
  case 'object': {
971
974
  return m ? { id: m.id, label: m.label, type: m.type } : m;
972
975
  }
976
+ case 'number': {
977
+ if (m != null) {
978
+ const v = m.id || m;
979
+ try {
980
+ return parseInt(v, 10);
981
+ }
982
+ catch (e) {
983
+ return v;
984
+ }
985
+ }
986
+ break;
987
+ }
973
988
  default: {
974
989
  if (m != null) {
975
990
  return m.id || m;
@@ -2792,13 +2807,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.2", ngImpor
2792
2807
  class FieldComposite extends FieldAbstract {
2793
2808
  ngOnInit() {
2794
2809
  // super.ngOnInit()
2795
- if (this.isRow) {
2810
+ let nestedFieldsRegex;
2811
+ if (this.meta.name) {
2812
+ this.value = this.parent[this.meta.name] || {};
2813
+ nestedFieldsRegex = new RegExp(`${this.meta.name}\.(.*)`);
2814
+ Object.defineProperty(this.parent, this.meta.name, {
2815
+ set: (value) => {
2816
+ if (value) {
2817
+ for (const v of Object.keys(value)) {
2818
+ this.value[v] = value[v];
2819
+ }
2820
+ }
2821
+ },
2822
+ get: () => {
2823
+ if (JSON.stringify(this.value) !== '{}') {
2824
+ return this.value;
2825
+ }
2826
+ },
2827
+ enumerable: this.sendToServer,
2828
+ configurable: true
2829
+ });
2796
2830
  for (const f of this.meta.fields) {
2797
- if (f.type === 'text') {
2798
- f.type = 'string';
2831
+ if (this.isRow) {
2832
+ if (f.type === 'text') {
2833
+ f.type = 'string';
2834
+ }
2835
+ }
2836
+ if (nestedFieldsRegex) {
2837
+ const nestedFieldMatch = f.name.match(nestedFieldsRegex);
2838
+ if (nestedFieldMatch) {
2839
+ f.name = nestedFieldMatch[1];
2840
+ }
2799
2841
  }
2800
2842
  }
2801
2843
  }
2844
+ else {
2845
+ this.value = this.parent;
2846
+ }
2802
2847
  }
2803
2848
  get isRow() {
2804
2849
  return this.meta.subtype !== 'column';
@@ -2813,10 +2858,10 @@ class FieldComposite extends FieldAbstract {
2813
2858
  }
2814
2859
  }
2815
2860
  FieldComposite.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.2", ngImport: i0, type: FieldComposite, deps: null, target: i0.ɵɵFactoryTarget.Component });
2816
- FieldComposite.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.2", type: FieldComposite, selector: "ng-component", inputs: { meta: "meta" }, usesInheritance: true, ngImport: i0, template: "<div [ngClass]=\"{ 'Vlt-grid Vlt-grid--narrow': isRow }\" >\n <div style='margin: 0;' [ngClass]=\"{ 'Vlt-col': isRow, 'Vlt-col--1of3': isRow && fields.length > 3 }\" *ngFor='let field of fields'>\n <vgip-meta-field class='shown' [index]='index' [meta]='field' [parent]='parent' [integrationCode]='integrationCode' [preview]='preview' theme='inherit' [ngClass]=\"{ shown: !field.$invisible }\"></vgip-meta-field>\n </div>\n</div>", styles: ["div>vgip-meta-field{display:none}div>vgip-meta-field.shown{display:initial}\n"], components: [{ type: i0.forwardRef(function () { return MetaField; }), selector: "vgip-meta-field", inputs: ["meta", "parent", "integrationCode", "resourceType", "index", "preview", "theme"], outputs: ["onChange", "onLeave"] }], directives: [{ type: i0.forwardRef(function () { return i1.NgClass; }), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i0.forwardRef(function () { return i1.NgForOf; }), selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
2861
+ FieldComposite.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.2", type: FieldComposite, selector: "ng-component", inputs: { meta: "meta" }, usesInheritance: true, ngImport: i0, template: "<div [ngClass]=\"{ 'Vlt-grid Vlt-grid--narrow': isRow }\" >\n <div style='margin: 0;' [ngClass]=\"{ 'Vlt-col': isRow, 'Vlt-col--1of3': isRow && fields.length > 3 }\" *ngFor='let field of fields'>\n <vgip-meta-field class='shown' [index]='index' [meta]='field' [parent]='value' [integrationCode]='integrationCode' [preview]='preview' theme='inherit' [ngClass]=\"{ shown: !field.$invisible }\"></vgip-meta-field>\n </div>\n</div>\n", styles: ["div>vgip-meta-field{display:none}div>vgip-meta-field.shown{display:initial}\n"], components: [{ type: i0.forwardRef(function () { return MetaField; }), selector: "vgip-meta-field", inputs: ["meta", "parent", "integrationCode", "resourceType", "index", "preview", "theme"], outputs: ["onChange", "onLeave"] }], directives: [{ type: i0.forwardRef(function () { return i1.NgClass; }), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i0.forwardRef(function () { return i1.NgForOf; }), selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
2817
2862
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.2", ngImport: i0, type: FieldComposite, decorators: [{
2818
2863
  type: Component,
2819
- args: [{ template: "<div [ngClass]=\"{ 'Vlt-grid Vlt-grid--narrow': isRow }\" >\n <div style='margin: 0;' [ngClass]=\"{ 'Vlt-col': isRow, 'Vlt-col--1of3': isRow && fields.length > 3 }\" *ngFor='let field of fields'>\n <vgip-meta-field class='shown' [index]='index' [meta]='field' [parent]='parent' [integrationCode]='integrationCode' [preview]='preview' theme='inherit' [ngClass]=\"{ shown: !field.$invisible }\"></vgip-meta-field>\n </div>\n</div>", styles: ["div>vgip-meta-field{display:none}div>vgip-meta-field.shown{display:initial}\n"] }]
2864
+ args: [{ template: "<div [ngClass]=\"{ 'Vlt-grid Vlt-grid--narrow': isRow }\" >\n <div style='margin: 0;' [ngClass]=\"{ 'Vlt-col': isRow, 'Vlt-col--1of3': isRow && fields.length > 3 }\" *ngFor='let field of fields'>\n <vgip-meta-field class='shown' [index]='index' [meta]='field' [parent]='value' [integrationCode]='integrationCode' [preview]='preview' theme='inherit' [ngClass]=\"{ shown: !field.$invisible }\"></vgip-meta-field>\n </div>\n</div>\n", styles: ["div>vgip-meta-field{display:none}div>vgip-meta-field.shown{display:initial}\n"] }]
2820
2865
  }], propDecorators: { meta: [{
2821
2866
  type: Input
2822
2867
  }] } });
@@ -3424,7 +3469,7 @@ class FieldReference extends FieldAbstract {
3424
3469
  // }
3425
3470
  }
3426
3471
  this.model = value;
3427
- this.value = value;
3472
+ this.value = this.modelToValue(value, this.meta.valueType || 'object');
3428
3473
  if (!this.multiple) {
3429
3474
  this.buildExternalLink();
3430
3475
  }
@@ -4533,12 +4578,12 @@ class MetaResource {
4533
4578
  && this.resource.meta.layout.sections) {
4534
4579
  const extractSectionFields = (s) => {
4535
4580
  for (const f of s.fields) {
4581
+ if (f.name) {
4582
+ this.resource.niceFields[f.name] = f;
4583
+ }
4536
4584
  if (f.fields && f.fields.length) {
4537
4585
  extractSectionFields(f);
4538
4586
  }
4539
- else {
4540
- this.resource.niceFields[f.name] = f;
4541
- }
4542
4587
  }
4543
4588
  };
4544
4589
  this.resource.niceFields = {};