@asteby/metacore-runtime-react 49.0.0 → 49.1.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.
@@ -33,7 +33,13 @@ import { useApi } from './api-context'
33
33
  import { useMetadataCache } from './metadata-cache'
34
34
  import { DynamicTable } from './dynamic-table'
35
35
  import { DynamicRecordDialog } from './dialogs/dynamic-record'
36
- import { DocumentFormDialog, resolveDocumentForms, scopeDocumentFormsToFilter } from './document-form-dialog'
36
+ import {
37
+ DocumentFormDialog,
38
+ resolveDocumentForms,
39
+ scopeDocumentFormsToFilter,
40
+ withoutDelegatedTypes,
41
+ type DelegatedCreate,
42
+ } from './document-form-dialog'
37
43
  import { ExportDialog } from './dialogs/export'
38
44
  import { ImportDialog } from './dialogs/import'
39
45
  import { getModelExtension } from './model-extension-registry'
@@ -108,6 +114,12 @@ export interface DynamicCRUDPageProps {
108
114
  * `?create=<tipo>&from=<fuente>&from_id=<id>`. Solo con document_forms.
109
115
  */
110
116
  initialCreate?: { type?: string; source?: { key: string; id: string } }
117
+ /**
118
+ * Alta delegada (`document_forms.types[].create_model`): el host abre la
119
+ * página del modelo destino con su alta abierta. Sin él, esos tipos no se
120
+ * ofrecen (y si la vista queda acotada a uno, no hay «Crear»).
121
+ */
122
+ onDelegateCreate?: (target: DelegatedCreate) => void
111
123
  }
112
124
 
113
125
  /**
@@ -133,6 +145,7 @@ export function DynamicCRUDPage(props: DynamicCRUDPageProps) {
133
145
  documentForms,
134
146
  filter,
135
147
  initialCreate,
148
+ onDelegateCreate,
136
149
  } = props
137
150
 
138
151
  const strings = { ...defaultStrings, ...(i18n ?? {}) }
@@ -203,7 +216,11 @@ export function DynamicCRUDPage(props: DynamicCRUDPageProps) {
203
216
  // (useCan defaults to always-true), in which case create/export/import
204
217
  // require `lowercase(model).create|export|import`.
205
218
  const can = useCan()
206
- const scoped = scopeDocumentFormsToFilter(resolveDocumentForms(metadata, documentForms), filter)
219
+ const declaredForms = resolveDocumentForms(metadata, documentForms)
220
+ const scoped = scopeDocumentFormsToFilter(
221
+ onDelegateCreate ? declaredForms : withoutDelegatedTypes(declaredForms),
222
+ filter,
223
+ )
207
224
  const guidedForms = scoped.forms
208
225
  const showCreate = primary.showGenericCreate && !scoped.hideCreate && can(modelCapability(model, 'create'))
209
226
  const showImport = enableCRUD && !effectiveHideImport && can(modelCapability(model, 'import'))
@@ -318,6 +335,7 @@ export function DynamicCRUDPage(props: DynamicCRUDPageProps) {
318
335
  initialType={initialCreate?.type}
319
336
  initialSource={initialCreate?.source}
320
337
  onSaved={handleRefresh}
338
+ onDelegateCreate={onDelegateCreate}
321
339
  />
322
340
  )}
323
341
 
package/src/index.ts CHANGED
@@ -179,8 +179,11 @@ export { FieldGrid, FieldCell, FieldLabel } from './field-grid'
179
179
  export {
180
180
  ActionModalDispatcher,
181
181
  FEDERATED_ACTION_MODAL_TIMEOUT_MS,
182
+ resolveFieldDefault,
182
183
  type ActionModalProps,
184
+ type FieldDefaultContext,
183
185
  } from './action-modal-dispatcher'
186
+ export { todayInZone, isTodayToken } from './calendar-date'
184
187
  export { setFederatedActionLoader, type FederatedActionLoader } from './federated-action-loader'
185
188
  export {
186
189
  ModelActionToolbar,
@@ -207,6 +210,9 @@ export {
207
210
  DocumentFormDialog,
208
211
  resolveDocumentForms,
209
212
  scopeDocumentFormsToFilter,
213
+ delegatedCreate,
214
+ withoutDelegatedTypes,
215
+ type DelegatedCreate,
210
216
  type DocumentFormDialogProps,
211
217
  } from './document-form-dialog'
212
218
  export {
package/src/types.ts CHANGED
@@ -107,6 +107,13 @@ export interface DocumentFormType {
107
107
  * reparte el pago en PaymentAllocation dentro de una transacción.
108
108
  */
109
109
  submit_action?: string
110
+ /**
111
+ * El alta de este tipo vive en OTRO modelo (`customers.Invoice`): «Crear»
112
+ * no pinta formulario, el host abre la página de ese modelo con su alta
113
+ * abierta (`onDelegateCreate`). P. ej. Documentos fiscales → Facturas: la
114
+ * factura nace en customers y se timbra después. Sin campos ni renglones.
115
+ */
116
+ create_model?: string
110
117
  }
111
118
 
112
119
  /** Contraparte: qué campo del encabezado la elige y qué muestra su tarjeta. */