@vgip/meta-ui 1.2.8 → 1.2.9

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.
@@ -970,6 +970,18 @@ class FieldAbstract {
970
970
  case 'object': {
971
971
  return m ? { id: m.id, label: m.label, type: m.type } : m;
972
972
  }
973
+ case 'number': {
974
+ if (m != null) {
975
+ const v = m.id || m;
976
+ try {
977
+ return parseInt(v, 10);
978
+ }
979
+ catch (e) {
980
+ return v;
981
+ }
982
+ }
983
+ break;
984
+ }
973
985
  default: {
974
986
  if (m != null) {
975
987
  return m.id || m;
@@ -2792,13 +2804,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.2", ngImpor
2792
2804
  class FieldComposite extends FieldAbstract {
2793
2805
  ngOnInit() {
2794
2806
  // super.ngOnInit()
2795
- if (this.isRow) {
2807
+ let nestedFieldsRegex;
2808
+ if (this.meta.name) {
2809
+ this.value = this.parent[this.meta.name] || {};
2810
+ nestedFieldsRegex = new RegExp(`${this.meta.name}\.(.*)`);
2811
+ Object.defineProperty(this.parent, this.meta.name, {
2812
+ set: (value) => {
2813
+ if (value) {
2814
+ for (const v of Object.keys(value)) {
2815
+ this.value[v] = value[v];
2816
+ }
2817
+ }
2818
+ },
2819
+ get: () => {
2820
+ if (JSON.stringify(this.value) !== '{}') {
2821
+ return this.value;
2822
+ }
2823
+ },
2824
+ enumerable: this.sendToServer,
2825
+ configurable: true
2826
+ });
2796
2827
  for (const f of this.meta.fields) {
2797
- if (f.type === 'text') {
2798
- f.type = 'string';
2828
+ if (this.isRow) {
2829
+ if (f.type === 'text') {
2830
+ f.type = 'string';
2831
+ }
2832
+ }
2833
+ if (nestedFieldsRegex) {
2834
+ const nestedFieldMatch = f.name.match(nestedFieldsRegex);
2835
+ if (nestedFieldMatch) {
2836
+ f.name = nestedFieldMatch[1];
2837
+ }
2799
2838
  }
2800
2839
  }
2801
2840
  }
2841
+ else {
2842
+ this.value = this.parent;
2843
+ }
2802
2844
  }
2803
2845
  get isRow() {
2804
2846
  return this.meta.subtype !== 'column';
@@ -2813,10 +2855,10 @@ class FieldComposite extends FieldAbstract {
2813
2855
  }
2814
2856
  }
2815
2857
  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"] }] });
2858
+ 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
2859
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.2", ngImport: i0, type: FieldComposite, decorators: [{
2818
2860
  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"] }]
2861
+ 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
2862
  }], propDecorators: { meta: [{
2821
2863
  type: Input
2822
2864
  }] } });
@@ -3424,7 +3466,7 @@ class FieldReference extends FieldAbstract {
3424
3466
  // }
3425
3467
  }
3426
3468
  this.model = value;
3427
- this.value = value;
3469
+ this.value = this.modelToValue(value, this.meta.valueType || 'object');
3428
3470
  if (!this.multiple) {
3429
3471
  this.buildExternalLink();
3430
3472
  }
@@ -4533,12 +4575,12 @@ class MetaResource {
4533
4575
  && this.resource.meta.layout.sections) {
4534
4576
  const extractSectionFields = (s) => {
4535
4577
  for (const f of s.fields) {
4578
+ if (f.name) {
4579
+ this.resource.niceFields[f.name] = f;
4580
+ }
4536
4581
  if (f.fields && f.fields.length) {
4537
4582
  extractSectionFields(f);
4538
4583
  }
4539
- else {
4540
- this.resource.niceFields[f.name] = f;
4541
- }
4542
4584
  }
4543
4585
  };
4544
4586
  this.resource.niceFields = {};
@@ -5316,3 +5358,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.2", ngImpor
5316
5358
  */
5317
5359
 
5318
5360
  export { FieldBoolean, FieldComposite, FieldDatetime, FieldInput, FieldList, FieldRadio, FieldReference, FieldRichtext, FieldSelect, FieldText, FieldUnknown, MetaAutofocusDirective, MetaContextService, MetaField, MetaFieldContentDirective, MetaHttpClient, MetaIconsPipe, MetaLayout, MetaModelPipe, MetaModule, MetaMsgService, MetaRefDialog, MetaReferenceService, MetaResource, MetaResourceCard, MetaResourceService, MetaStripHtmlPipe, MetaTrackerService, ResourceDraftsService, metaDark, metaLight, metaNormalizer, relativeTimeBuilder };
5361
+ //# sourceMappingURL=vgip-meta-ui.mjs.map