@maro-tech/form 0.0.10 → 0.0.11

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.
@@ -2900,7 +2900,7 @@ class UiActionFormModalComponent {
2900
2900
  formConfig = signal(null, ...(ngDevMode ? [{ debugName: "formConfig" }] : /* istanbul ignore next */ []));
2901
2901
  formValue = signal({}, ...(ngDevMode ? [{ debugName: "formValue" }] : /* istanbul ignore next */ []));
2902
2902
  fields = computed(() => this.formConfig()?.fields ?? [], ...(ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []));
2903
- submitAction = computed(() => this.formConfig()?.actions?.find((action) => String(action.type).toUpperCase() === 'ACTION_SUBMIT' || String(action.type).toUpperCase() === 'ACTION_API'), ...(ngDevMode ? [{ debugName: "submitAction" }] : /* istanbul ignore next */ []));
2903
+ submitAction = computed(() => this.formConfig()?.actions?.find((action) => this.isSubmitAction(action)), ...(ngDevMode ? [{ debugName: "submitAction" }] : /* istanbul ignore next */ []));
2904
2904
  submitLabel = computed(() => this.submitAction()?.submit || this.submitAction()?.label || 'Save', ...(ngDevMode ? [{ debugName: "submitLabel" }] : /* istanbul ignore next */ []));
2905
2905
  panelClass = computed(() => ({
2906
2906
  'max-w-xl': this.size() === 'sm',
@@ -2969,7 +2969,15 @@ class UiActionFormModalComponent {
2969
2969
  const endpoint = `/api/crud/form/${encodeURIComponent(formId)}${recordId ? `/${encodeURIComponent(recordId)}` : ''}`;
2970
2970
  this.http.get(endpoint).subscribe({
2971
2971
  next: (response) => {
2972
- const config = response.form || response;
2972
+ const raw = response.form || response;
2973
+ const config = {
2974
+ ...raw,
2975
+ title: raw.title || raw.meta?.title,
2976
+ actions: (raw.actions || []).map((action) => ({
2977
+ ...action,
2978
+ type: this.normalizeActionType(action.type),
2979
+ })),
2980
+ };
2973
2981
  this.formConfig.set(config);
2974
2982
  this.formValue.set({ ...(config.defaults || {}), ...(config.item || {}), ...(this.initialValue() || {}), ...(recordId ? { id: recordId } : {}) });
2975
2983
  this.isLoading.set(false);
@@ -2988,6 +2996,18 @@ class UiActionFormModalComponent {
2988
2996
  return value;
2989
2997
  return `/api${value.startsWith('/') ? value : `/${value}`}`;
2990
2998
  }
2999
+ normalizeActionType(type) {
3000
+ const normalized = String(type || '').trim().toLowerCase();
3001
+ if (normalized === 'api' || normalized === 'action_api')
3002
+ return 'ACTION_API';
3003
+ if (normalized === 'submit' || normalized === 'action_submit')
3004
+ return 'ACTION_SUBMIT';
3005
+ return String(type || '');
3006
+ }
3007
+ isSubmitAction(action) {
3008
+ const type = this.normalizeActionType(action.type);
3009
+ return type === 'ACTION_API' || type === 'ACTION_SUBMIT';
3010
+ }
2991
3011
  resolveMethod(method) {
2992
3012
  return String(method || 'POST').toUpperCase();
2993
3013
  }