@acorex/platform 20.6.2 → 20.6.4

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 = {};
@@ -703,7 +728,49 @@ class PropertyFilter {
703
728
  this.externalMode = mode;
704
729
  return this;
705
730
  }
731
+ async build() {
732
+ const dialog = await this.buildDialog();
733
+ return dialog.build();
734
+ }
706
735
  async show() {
736
+ const dialog = await this.buildDialog();
737
+ // Context: load record by id for update/single and merge with provided context (context overrides)
738
+ let baseContext = {};
739
+ // Only fetch by key if we don't already have initial data
740
+ const hasInitialData = this.initialContext && Object.keys(this.initialContext).length > 0;
741
+ if ((this.kind === 'update' || this.kind === 'single') && !hasInitialData) {
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
+ }
759
+ }
760
+ catch {
761
+ baseContext = {};
762
+ }
763
+ }
764
+ }
765
+ const effectiveContext = merge({}, baseContext, this.initialContext);
766
+ dialog.setContext(effectiveContext);
767
+ return await dialog.show();
768
+ }
769
+ /**
770
+ * Builds the dialog node structure without showing it.
771
+ * This method is shared by both build() and show() methods.
772
+ */
773
+ async buildDialog() {
707
774
  const { moduleName, entityName } = parseEntityFullName(this.fullName);
708
775
  const entity = await this.entityRegistry.resolve(moduleName, entityName);
709
776
  // Select the appropriate interface based on kind
@@ -812,28 +879,7 @@ class PropertyFilter {
812
879
  d.setActions((a) => a.cancel().submit());
813
880
  }
814
881
  });
815
- // Context: load record by id for update/single and merge with provided context (context overrides)
816
- let baseContext = {};
817
- // Only fetch by key if we don't already have initial data
818
- const hasInitialData = this.initialContext && Object.keys(this.initialContext).length > 0;
819
- if ((this.kind === 'update' || this.kind === 'single') && !hasInitialData) {
820
- try {
821
- const id = this.recordId;
822
- if (!id) {
823
- throw new Error(`Record id is required for ${this.kind}().`);
824
- }
825
- const byKeyFn = entity?.queries?.byKey?.execute;
826
- if (typeof byKeyFn === 'function') {
827
- baseContext = (await byKeyFn(id)) ?? {};
828
- }
829
- }
830
- catch {
831
- baseContext = {};
832
- }
833
- }
834
- const effectiveContext = merge({}, baseContext, this.initialContext);
835
- dialog.setContext(effectiveContext);
836
- return await dialog.show();
882
+ return dialog;
837
883
  }
838
884
  computeAllowedNames(allNames) {
839
885
  if (this.includeList && this.includeList.size > 0) {
@@ -7896,7 +7942,7 @@ class AXPEntityCategoryTreeSelectorComponent extends AXBasePageComponent {
7896
7942
  ></ax-button>
7897
7943
  </ax-suffix>
7898
7944
  </ax-footer>
7899
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i3.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "ngmodule", type: AXCheckBoxModule }, { kind: "component", type: i2$1.AXCheckBoxComponent, selector: "ax-check-box", inputs: ["disabled", "tabIndex", "readonly", "color", "value", "name", "id", "isLoading", "indeterminate"], outputs: ["onBlur", "onFocus", "valueChange", "onValueChanged"] }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "component", type: i3$2.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }, { kind: "component", type: i3$2.AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "ngmodule", type: AXSearchBoxModule }, { kind: "component", type: i4$2.AXSearchBoxComponent, selector: "ax-search-box", inputs: ["disabled", "readonly", "tabIndex", "placeholder", "value", "state", "name", "id", "look", "class", "delayTime", "type", "autoSearch"], outputs: ["valueChange", "stateChange", "onValueChanged", "onBlur", "onFocus", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress"] }, { kind: "ngmodule", type: AXSkeletonModule }, { kind: "component", type: i5$1.AXSkeletonComponent, selector: "ax-skeleton", inputs: ["animated"] }, { kind: "component", type: AXTreeViewComponent, selector: "ax-tree-view", inputs: ["datasource", "selectMode", "selectionBehavior", "dragArea", "dragBehavior", "showIcons", "showChildrenBadge", "expandedIcon", "collapsedIcon", "indentSize", "look", "nodeTemplate", "idField", "titleField", "tooltipField", "iconField", "expandedField", "selectedField", "indeterminateField", "disabledField", "hiddenField", "childrenField", "childrenCountField", "dataField", "inheritDisabled", "expandOnDoubleClick"], outputs: ["datasourceChange", "onBeforeDrop", "onNodeToggle", "onNodeSelect", "onNodeDoubleClick", "onNodeClick", "onSelectionChange", "onOrderChange", "onMoveChange", "onItemsChange"] }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "component", type: AXPStateMessageComponent, selector: "axp-state-message", inputs: ["mode", "icon", "title", "description", "variant"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }, { kind: "pipe", type: i6.AXTranslatorPipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
7945
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i3.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "ngmodule", type: AXCheckBoxModule }, { kind: "component", type: i2$1.AXCheckBoxComponent, selector: "ax-check-box", inputs: ["disabled", "tabIndex", "readonly", "color", "value", "name", "id", "isLoading", "indeterminate"], outputs: ["onBlur", "onFocus", "valueChange", "onValueChanged"] }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "component", type: i3$2.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }, { kind: "component", type: i3$2.AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "ngmodule", type: AXSearchBoxModule }, { kind: "component", type: i4$2.AXSearchBoxComponent, selector: "ax-search-box", inputs: ["disabled", "readonly", "tabIndex", "placeholder", "value", "state", "name", "id", "look", "class", "delayTime", "type", "autoSearch"], outputs: ["valueChange", "stateChange", "onValueChanged", "onBlur", "onFocus", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress"] }, { kind: "ngmodule", type: AXSkeletonModule }, { kind: "component", type: i5$1.AXSkeletonComponent, selector: "ax-skeleton", inputs: ["animated"] }, { kind: "component", type: AXTreeViewComponent, selector: "ax-tree-view", inputs: ["datasource", "selectMode", "selectionBehavior", "dragArea", "dragBehavior", "showIcons", "showChildrenBadge", "expandedIcon", "collapsedIcon", "indentSize", "look", "nodeTemplate", "idField", "titleField", "tooltipField", "iconField", "expandedField", "selectedField", "indeterminateField", "disabledField", "hiddenField", "childrenField", "childrenCountField", "dataField", "inheritDisabled", "expandOnDoubleClick", "doubleClickDuration", "tooltipDelay"], outputs: ["datasourceChange", "onBeforeDrop", "onNodeToggle", "onNodeSelect", "onNodeDoubleClick", "onNodeClick", "onSelectionChange", "onOrderChange", "onMoveChange", "onItemsChange"] }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "component", type: AXPStateMessageComponent, selector: "axp-state-message", inputs: ["mode", "icon", "title", "description", "variant"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }, { kind: "pipe", type: i6.AXTranslatorPipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
7900
7946
  }
7901
7947
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityCategoryTreeSelectorComponent, decorators: [{
7902
7948
  type: Component,