@acorex/platform 20.6.3 → 20.6.5

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.
@@ -599,7 +599,30 @@ class AXPEntityFormBuilderService {
599
599
  //#endregion
600
600
  //#region ---- Public API ----
601
601
  entity(fullName) {
602
- return new InterfaceSelector(this.entityRegistry, this.layoutBuilder, this.deviceService, fullName);
602
+ return new InterfaceSelector(this.entityRegistry, this.layoutBuilder, this.deviceService, fullName, this);
603
+ }
604
+ /**
605
+ * Fetches a record by ID for the specified entity.
606
+ * @param fullName - Entity full name in "module.entity" format
607
+ * @param id - Record ID to fetch
608
+ * @returns Promise resolving to the record data, or empty object if not found
609
+ */
610
+ async getRecordById(fullName, id) {
611
+ if (!id) {
612
+ throw new Error('Record id is required.');
613
+ }
614
+ const { moduleName, entityName } = parseEntityFullName(fullName);
615
+ const entity = await this.entityRegistry.resolve(moduleName, entityName);
616
+ try {
617
+ const byKeyFn = entity?.queries?.byKey?.execute;
618
+ if (typeof byKeyFn === 'function') {
619
+ return (await byKeyFn(id)) ?? {};
620
+ }
621
+ }
622
+ catch {
623
+ // Return empty object if fetch fails
624
+ }
625
+ return {};
603
626
  }
604
627
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityFormBuilderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
605
628
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityFormBuilderService, providedIn: 'root' }); }
@@ -610,14 +633,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
610
633
  }] });
611
634
  //#region ---- Builders ----
612
635
  class InterfaceSelector {
613
- constructor(entityRegistry, layoutBuilder, deviceService, fullName) {
636
+ constructor(entityRegistry, layoutBuilder, deviceService, fullName, formBuilderService) {
614
637
  this.entityRegistry = entityRegistry;
615
638
  this.layoutBuilder = layoutBuilder;
616
639
  this.deviceService = deviceService;
617
640
  this.fullName = fullName;
641
+ this.formBuilderService = formBuilderService;
618
642
  }
619
643
  create(initialData) {
620
- const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'create');
644
+ const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'create', undefined, this.formBuilderService);
621
645
  if (initialData) {
622
646
  filter.context(initialData);
623
647
  }
@@ -633,7 +657,7 @@ class InterfaceSelector {
633
657
  initialData = data;
634
658
  recordId = data['id'] || data['_id'];
635
659
  }
636
- const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'update', recordId);
660
+ const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'update', recordId, this.formBuilderService);
637
661
  return filter;
638
662
  }
639
663
  single(data) {
@@ -646,7 +670,7 @@ class InterfaceSelector {
646
670
  initialData = data;
647
671
  recordId = data['id'] || data['_id'];
648
672
  }
649
- const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'single', recordId);
673
+ const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'single', recordId, this.formBuilderService);
650
674
  if (Object.keys(initialData).length > 0) {
651
675
  filter.context(initialData);
652
676
  }
@@ -654,12 +678,13 @@ class InterfaceSelector {
654
678
  }
655
679
  }
656
680
  class PropertyFilter {
657
- constructor(entityRegistry, layoutBuilder, deviceService, fullName, kind, recordId) {
681
+ constructor(entityRegistry, layoutBuilder, deviceService, fullName, kind, recordId, formBuilderService) {
658
682
  this.entityRegistry = entityRegistry;
659
683
  this.layoutBuilder = layoutBuilder;
660
684
  this.deviceService = deviceService;
661
685
  this.fullName = fullName;
662
686
  this.kind = kind;
687
+ this.formBuilderService = formBuilderService;
663
688
  this.includeList = null;
664
689
  this.excludeList = null;
665
690
  this.initialContext = {};
@@ -714,21 +739,28 @@ class PropertyFilter {
714
739
  // Only fetch by key if we don't already have initial data
715
740
  const hasInitialData = this.initialContext && Object.keys(this.initialContext).length > 0;
716
741
  if ((this.kind === 'update' || this.kind === 'single') && !hasInitialData) {
717
- const { moduleName, entityName } = parseEntityFullName(this.fullName);
718
- const entity = await this.entityRegistry.resolve(moduleName, entityName);
719
- try {
720
- const id = this.recordId;
721
- if (!id) {
722
- throw new Error(`Record id is required for ${this.kind}().`);
742
+ const id = this.recordId;
743
+ if (!id) {
744
+ throw new Error(`Record id is required for ${this.kind}().`);
745
+ }
746
+ // Use the public method if service is available, otherwise fallback to direct entity access
747
+ if (this.formBuilderService) {
748
+ baseContext = await this.formBuilderService.getRecordById(this.fullName, id);
749
+ }
750
+ else {
751
+ // Fallback to original implementation if service is not available
752
+ const { moduleName, entityName } = parseEntityFullName(this.fullName);
753
+ const entity = await this.entityRegistry.resolve(moduleName, entityName);
754
+ try {
755
+ const byKeyFn = entity?.queries?.byKey?.execute;
756
+ if (typeof byKeyFn === 'function') {
757
+ baseContext = (await byKeyFn(id)) ?? {};
758
+ }
723
759
  }
724
- const byKeyFn = entity?.queries?.byKey?.execute;
725
- if (typeof byKeyFn === 'function') {
726
- baseContext = (await byKeyFn(id)) ?? {};
760
+ catch {
761
+ baseContext = {};
727
762
  }
728
763
  }
729
- catch {
730
- baseContext = {};
731
- }
732
764
  }
733
765
  const effectiveContext = merge({}, baseContext, this.initialContext);
734
766
  dialog.setContext(effectiveContext);
@@ -2247,7 +2279,7 @@ class AXPEntityCreateViewElementViewModel {
2247
2279
  triggers: widget.triggers,
2248
2280
  defaultValue: schema.defaultValue,
2249
2281
  valueTransforms: widget.valueTransforms,
2250
- options: merge(schema.interface?.options, {
2282
+ options: merge({}, schema.interface?.options, {
2251
2283
  validations: this.property.validations?.map((c) => ({ rule: c.rule, message: c.message, options: c.options })),
2252
2284
  }),
2253
2285
  };
@@ -3193,7 +3225,7 @@ class AXPEntityMasterUpdateElementViewModel {
3193
3225
  formula: widget.formula,
3194
3226
  triggers: widget.triggers,
3195
3227
  valueTransforms: widget.valueTransforms,
3196
- options: merge(schema.interface?.options, {
3228
+ options: merge({}, schema.interface?.options, {
3197
3229
  validations: this.property.validations?.map((c) => ({ rule: c.rule, message: c.message, options: c.options })),
3198
3230
  }),
3199
3231
  };
@@ -3450,7 +3482,7 @@ class AXPEntityMasterSingleElementViewModel {
3450
3482
  children: widget.children,
3451
3483
  formula: widget.formula,
3452
3484
  valueTransforms: widget.valueTransforms,
3453
- options: merge(schema.interface?.options),
3485
+ options: merge({}, schema.interface?.options),
3454
3486
  };
3455
3487
  }, ...(ngDevMode ? [{ debugName: "node" }] : []));
3456
3488
  }
@@ -5018,7 +5050,6 @@ class AXPMainEntityContentBuilder {
5018
5050
  : editablePropertyNames.has(p.name);
5019
5051
  // Check if property has its own disabled option
5020
5052
  const hasOwnDisabled = p.schema.interface?.options?.disabled !== undefined;
5021
- console.log('visible: ', p.schema.visible);
5022
5053
  return {
5023
5054
  type: 'grid-item-layout',
5024
5055
  name: prefixed,
@@ -5044,7 +5075,7 @@ class AXPMainEntityContentBuilder {
5044
5075
  children: p.schema.interface?.children,
5045
5076
  triggers: p.schema.interface?.triggers,
5046
5077
  valueTransforms: p.schema.interface?.valueTransforms,
5047
- options: merge(p.schema.interface?.options, {
5078
+ options: merge({}, p.schema.interface?.options, {
5048
5079
  validations: p.validations?.map((c) => ({
5049
5080
  rule: c.rule,
5050
5081
  message: c.message,