@firecms/core 3.0.0-canary.216 → 3.0.0-canary.218
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.
- package/dist/core/EntityEditView.d.ts +2 -1
- package/dist/index.es.js +141 -132
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +141 -132
- package/dist/index.umd.js.map +1 -1
- package/dist/types/fields.d.ts +3 -1
- package/dist/util/createFormexStub.d.ts +2 -0
- package/dist/util/objects.d.ts +1 -1
- package/dist/util/resolutions.d.ts +4 -4
- package/package.json +5 -5
- package/src/components/EntityJsonPreview.tsx +3 -3
- package/src/core/EntityEditView.tsx +106 -60
- package/src/form/EntityForm.tsx +5 -3
- package/src/hooks/useBuildNavigationController.tsx +1 -1
- package/src/routes/FireCMSRoute.tsx +1 -1
- package/src/types/fields.tsx +3 -1
- package/src/util/createFormexStub.tsx +62 -0
- package/src/util/join_collections.ts +3 -1
- package/src/util/objects.ts +5 -1
- package/src/util/resolutions.ts +4 -2
package/dist/index.umd.js
CHANGED
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
function isObject(item) {
|
|
207
207
|
return item && typeof item === "object" && !Array.isArray(item);
|
|
208
208
|
}
|
|
209
|
-
function mergeDeep(target, source) {
|
|
209
|
+
function mergeDeep(target, source, ignoreUndefined = false) {
|
|
210
210
|
const targetIsObject = isObject(target);
|
|
211
211
|
const output = targetIsObject ? {
|
|
212
212
|
...target
|
|
@@ -214,6 +214,9 @@
|
|
|
214
214
|
if (targetIsObject && isObject(source)) {
|
|
215
215
|
Object.keys(source).forEach((key) => {
|
|
216
216
|
const sourceElement = source[key];
|
|
217
|
+
if (ignoreUndefined && sourceElement === void 0) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
217
220
|
if (sourceElement instanceof Date) {
|
|
218
221
|
Object.assign(output, {
|
|
219
222
|
[key]: new Date(sourceElement.getTime())
|
|
@@ -856,8 +859,8 @@
|
|
|
856
859
|
return entityView;
|
|
857
860
|
}
|
|
858
861
|
}
|
|
859
|
-
function resolvedSelectedEntityView(customViews, customizationController, selectedTab) {
|
|
860
|
-
const resolvedEntityViews = customViews ? customViews.map((e) => resolveEntityView(e, customizationController.entityViews)).filter(Boolean) : [];
|
|
862
|
+
function resolvedSelectedEntityView(customViews, customizationController, selectedTab, canEdit) {
|
|
863
|
+
const resolvedEntityViews = customViews ? customViews.map((e) => resolveEntityView(e, customizationController.entityViews)).filter((e) => Boolean(e)).filter((e) => canEdit || !e.includeActions) : [];
|
|
861
864
|
const selectedEntityView = resolvedEntityViews.find((e) => e.key === selectedTab);
|
|
862
865
|
const selectedSecondaryForm = customViews && resolvedEntityViews.filter((e) => e.includeActions).find((e) => e.key === selectedTab);
|
|
863
866
|
return {
|
|
@@ -3499,7 +3502,7 @@
|
|
|
3499
3502
|
if (property) propertiesMerged[key] = mergePropertyOrBuilder(property, source.properties[key]);
|
|
3500
3503
|
else propertiesMerged[key] = source.properties[key];
|
|
3501
3504
|
});
|
|
3502
|
-
const mergedCollection = mergeDeep(target, source);
|
|
3505
|
+
const mergedCollection = mergeDeep(target, source, true);
|
|
3503
3506
|
const targetPropertiesOrder = getCollectionKeys(target);
|
|
3504
3507
|
const sourcePropertiesOrder = getCollectionKeys(source);
|
|
3505
3508
|
const mergedPropertiesOrder = [.../* @__PURE__ */ new Set([...sourcePropertiesOrder, ...targetPropertiesOrder])];
|
|
@@ -14325,11 +14328,11 @@
|
|
|
14325
14328
|
throw Error("INTERNAL: Collection and path must be defined in form context");
|
|
14326
14329
|
}
|
|
14327
14330
|
const dialogActions = /* @__PURE__ */ jsxRuntime.jsx(EntityFormActionsComponent, { collection: resolvedCollection, path, entity, layout: forceActionsAtTheBottom ? "bottom" : "side", savingError, formex: formex$1, disabled: disabled_0, status, pluginActions, openEntityMode, showDefaultActions });
|
|
14328
|
-
return /* @__PURE__ */ jsxRuntime.jsx(formex.Formex, { value:
|
|
14331
|
+
return /* @__PURE__ */ jsxRuntime.jsx(formex.Formex, { value: formex$1, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: formex$1.handleSubmit, onReset: () => formex$1.resetForm({
|
|
14329
14332
|
values: getInitialEntityValues(authController, collection, path, status, entity, customizationController.propertyConfigs)
|
|
14330
14333
|
}), noValidate: true, className: ui.cls("flex-1 flex flex-row w-full overflow-y-auto justify-center", className), children: [
|
|
14331
14334
|
/* @__PURE__ */ jsxRuntime.jsx("div", { id: `form_${path}`, className: ui.cls("relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit"), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10"), children: [
|
|
14332
|
-
|
|
14335
|
+
formex$1.dirty ? /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "Local unsaved changes", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Chip, { size: "small", colorScheme: "orangeDarker", children: /* @__PURE__ */ jsxRuntime.jsx(ui.EditIcon, { size: "smallest" }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "In sync with the database", className: "self-end sticky top-4 z-10", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Chip, { size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CheckIcon, { size: "smallest" }) }) }),
|
|
14333
14336
|
formView
|
|
14334
14337
|
] }) }),
|
|
14335
14338
|
dialogActions
|
|
@@ -21112,7 +21115,7 @@
|
|
|
21112
21115
|
t4 = $[4];
|
|
21113
21116
|
}
|
|
21114
21117
|
React.useEffect(t3, t4);
|
|
21115
|
-
const t5 = mode === "dark" ? prismReactRenderer.themes.vsDark : prismReactRenderer.themes.
|
|
21118
|
+
const t5 = mode === "dark" ? prismReactRenderer.themes.vsDark : prismReactRenderer.themes.github;
|
|
21116
21119
|
let t6;
|
|
21117
21120
|
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
21118
21121
|
t6 = (t72) => {
|
|
@@ -21124,8 +21127,8 @@
|
|
|
21124
21127
|
} = t72;
|
|
21125
21128
|
return /* @__PURE__ */ jsxRuntime.jsx("pre", { ref: preRef, style: {
|
|
21126
21129
|
...style,
|
|
21127
|
-
|
|
21128
|
-
}, className: "
|
|
21130
|
+
backgroundColor: "inherit"
|
|
21131
|
+
}, className: "max-w-6xl mx-auto p-8 rounded text-sm", children: tokens.map((line, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { ...getLineProps({
|
|
21129
21132
|
line
|
|
21130
21133
|
}), className: "text-wrap", children: line.map((token, key) => /* @__PURE__ */ jsxRuntime.jsx("span", { ...getTokenProps({
|
|
21131
21134
|
token
|
|
@@ -21146,128 +21149,100 @@
|
|
|
21146
21149
|
}
|
|
21147
21150
|
return t7;
|
|
21148
21151
|
}
|
|
21152
|
+
function createFormexStub(values) {
|
|
21153
|
+
const errorMessage = "You are in a read-only context. You cannot modify the formex controller.";
|
|
21154
|
+
return {
|
|
21155
|
+
values,
|
|
21156
|
+
initialValues: values,
|
|
21157
|
+
touched: {},
|
|
21158
|
+
dirty: false,
|
|
21159
|
+
errors: {},
|
|
21160
|
+
submitCount: 0,
|
|
21161
|
+
isSubmitting: false,
|
|
21162
|
+
isValidating: false,
|
|
21163
|
+
version: 0,
|
|
21164
|
+
canUndo: false,
|
|
21165
|
+
canRedo: false,
|
|
21166
|
+
setValues: () => {
|
|
21167
|
+
throw new Error(errorMessage);
|
|
21168
|
+
},
|
|
21169
|
+
setFieldValue: () => {
|
|
21170
|
+
throw new Error(errorMessage);
|
|
21171
|
+
},
|
|
21172
|
+
setFieldTouched: () => {
|
|
21173
|
+
throw new Error(errorMessage);
|
|
21174
|
+
},
|
|
21175
|
+
setDirty: () => {
|
|
21176
|
+
throw new Error(errorMessage);
|
|
21177
|
+
},
|
|
21178
|
+
setSubmitCount: () => {
|
|
21179
|
+
throw new Error(errorMessage);
|
|
21180
|
+
},
|
|
21181
|
+
setFieldError: () => {
|
|
21182
|
+
throw new Error(errorMessage);
|
|
21183
|
+
},
|
|
21184
|
+
handleChange: () => {
|
|
21185
|
+
throw new Error(errorMessage);
|
|
21186
|
+
},
|
|
21187
|
+
handleBlur: () => {
|
|
21188
|
+
throw new Error(errorMessage);
|
|
21189
|
+
},
|
|
21190
|
+
handleSubmit: () => {
|
|
21191
|
+
throw new Error(errorMessage);
|
|
21192
|
+
},
|
|
21193
|
+
validate: () => {
|
|
21194
|
+
throw new Error(errorMessage);
|
|
21195
|
+
},
|
|
21196
|
+
resetForm: () => {
|
|
21197
|
+
throw new Error(errorMessage);
|
|
21198
|
+
},
|
|
21199
|
+
setSubmitting: () => {
|
|
21200
|
+
throw new Error(errorMessage);
|
|
21201
|
+
},
|
|
21202
|
+
undo: () => {
|
|
21203
|
+
throw new Error(errorMessage);
|
|
21204
|
+
},
|
|
21205
|
+
redo: () => {
|
|
21206
|
+
throw new Error(errorMessage);
|
|
21207
|
+
}
|
|
21208
|
+
};
|
|
21209
|
+
}
|
|
21149
21210
|
const MAIN_TAB_VALUE = "__main_##Q$SC^#S6";
|
|
21150
21211
|
const JSON_TAB_VALUE = "__json";
|
|
21151
|
-
function EntityEditView(
|
|
21152
|
-
|
|
21153
|
-
|
|
21154
|
-
|
|
21155
|
-
if ($[0] !== t0) {
|
|
21156
|
-
({
|
|
21157
|
-
entityId,
|
|
21158
|
-
...props
|
|
21159
|
-
} = t0);
|
|
21160
|
-
$[0] = t0;
|
|
21161
|
-
$[1] = entityId;
|
|
21162
|
-
$[2] = props;
|
|
21163
|
-
} else {
|
|
21164
|
-
entityId = $[1];
|
|
21165
|
-
props = $[2];
|
|
21166
|
-
}
|
|
21167
|
-
let t1;
|
|
21168
|
-
if ($[3] !== entityId || $[4] !== props.collection || $[5] !== props.databaseId || $[6] !== props.path) {
|
|
21169
|
-
t1 = {
|
|
21170
|
-
path: props.path,
|
|
21171
|
-
entityId,
|
|
21172
|
-
collection: props.collection,
|
|
21173
|
-
databaseId: props.databaseId,
|
|
21174
|
-
useCache: false
|
|
21175
|
-
};
|
|
21176
|
-
$[3] = entityId;
|
|
21177
|
-
$[4] = props.collection;
|
|
21178
|
-
$[5] = props.databaseId;
|
|
21179
|
-
$[6] = props.path;
|
|
21180
|
-
$[7] = t1;
|
|
21181
|
-
} else {
|
|
21182
|
-
t1 = $[7];
|
|
21183
|
-
}
|
|
21212
|
+
function EntityEditView({
|
|
21213
|
+
entityId,
|
|
21214
|
+
...props
|
|
21215
|
+
}) {
|
|
21184
21216
|
const {
|
|
21185
21217
|
entity,
|
|
21186
|
-
dataLoading
|
|
21187
|
-
|
|
21188
|
-
|
|
21189
|
-
|
|
21190
|
-
|
|
21191
|
-
|
|
21192
|
-
|
|
21193
|
-
|
|
21194
|
-
|
|
21195
|
-
|
|
21196
|
-
|
|
21197
|
-
const cachedValues = t2;
|
|
21218
|
+
dataLoading,
|
|
21219
|
+
// eslint-disable-next-line no-unused-vars
|
|
21220
|
+
dataLoadingError
|
|
21221
|
+
} = useEntityFetch({
|
|
21222
|
+
path: props.path,
|
|
21223
|
+
entityId,
|
|
21224
|
+
collection: props.collection,
|
|
21225
|
+
databaseId: props.databaseId,
|
|
21226
|
+
useCache: false
|
|
21227
|
+
});
|
|
21228
|
+
const cachedValues = entityId ? getEntityFromCache(props.path + "/" + entityId) : getEntityFromCache(props.path + "#new");
|
|
21198
21229
|
const authController = useAuthController();
|
|
21199
21230
|
const initialStatus = props.copy ? "copy" : entityId ? "existing" : "new";
|
|
21200
21231
|
const [status, setStatus] = React.useState(initialStatus);
|
|
21201
|
-
|
|
21202
|
-
|
|
21203
|
-
|
|
21204
|
-
} else {
|
|
21205
|
-
t3 = entity ? canEditEntity(props.collection, authController, props.path, entity ?? null) : void 0;
|
|
21206
|
-
}
|
|
21207
|
-
const canEdit = t3;
|
|
21208
|
-
if (dataLoading && !cachedValues || (!entity || canEdit === void 0) && (status === "existing" || status === "copy")) {
|
|
21209
|
-
let t42;
|
|
21210
|
-
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
21211
|
-
t42 = /* @__PURE__ */ jsxRuntime.jsx(CircularProgressCenter, {});
|
|
21212
|
-
$[11] = t42;
|
|
21232
|
+
const canEdit = React.useMemo(() => {
|
|
21233
|
+
if (status === "new" || status === "copy") {
|
|
21234
|
+
return true;
|
|
21213
21235
|
} else {
|
|
21214
|
-
|
|
21236
|
+
return entity ? canEditEntity(props.collection, authController, props.path, entity ?? null) : void 0;
|
|
21215
21237
|
}
|
|
21216
|
-
|
|
21238
|
+
}, [authController, entity, status]);
|
|
21239
|
+
if (dataLoading && !cachedValues || (!entity || canEdit === void 0) && (status === "existing" || status === "copy")) {
|
|
21240
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CircularProgressCenter, {});
|
|
21217
21241
|
}
|
|
21218
21242
|
if (entityId && !entity && !cachedValues) {
|
|
21219
21243
|
console.error(`Entity with id ${entityId} not found in collection ${props.path}`);
|
|
21220
21244
|
}
|
|
21221
|
-
|
|
21222
|
-
const t42 = props.collection.singularName ?? props.collection.name;
|
|
21223
|
-
let t52;
|
|
21224
|
-
if ($[12] !== t42) {
|
|
21225
|
-
t52 = /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { className: "mt-16 mb-8 mx-8", variant: "h4", children: t42 });
|
|
21226
|
-
$[12] = t42;
|
|
21227
|
-
$[13] = t52;
|
|
21228
|
-
} else {
|
|
21229
|
-
t52 = $[13];
|
|
21230
|
-
}
|
|
21231
|
-
const t6 = entity;
|
|
21232
|
-
let t7;
|
|
21233
|
-
if ($[14] !== props.collection || $[15] !== props.path || $[16] !== t6) {
|
|
21234
|
-
t7 = /* @__PURE__ */ jsxRuntime.jsx(EntityView, { className: "px-8", entity: t6, path: props.path, collection: props.collection });
|
|
21235
|
-
$[14] = props.collection;
|
|
21236
|
-
$[15] = props.path;
|
|
21237
|
-
$[16] = t6;
|
|
21238
|
-
$[17] = t7;
|
|
21239
|
-
} else {
|
|
21240
|
-
t7 = $[17];
|
|
21241
|
-
}
|
|
21242
|
-
let t8;
|
|
21243
|
-
if ($[18] !== t52 || $[19] !== t7) {
|
|
21244
|
-
t8 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
21245
|
-
t52,
|
|
21246
|
-
t7
|
|
21247
|
-
] });
|
|
21248
|
-
$[18] = t52;
|
|
21249
|
-
$[19] = t7;
|
|
21250
|
-
$[20] = t8;
|
|
21251
|
-
} else {
|
|
21252
|
-
t8 = $[20];
|
|
21253
|
-
}
|
|
21254
|
-
return t8;
|
|
21255
|
-
}
|
|
21256
|
-
const t4 = cachedValues;
|
|
21257
|
-
let t5;
|
|
21258
|
-
if ($[21] !== dataLoading || $[22] !== entity || $[23] !== entityId || $[24] !== props || $[25] !== status || $[26] !== t4) {
|
|
21259
|
-
t5 = /* @__PURE__ */ jsxRuntime.jsx(EntityEditViewInner, { ...props, entityId, entity, cachedDirtyValues: t4, dataLoading, status, setStatus });
|
|
21260
|
-
$[21] = dataLoading;
|
|
21261
|
-
$[22] = entity;
|
|
21262
|
-
$[23] = entityId;
|
|
21263
|
-
$[24] = props;
|
|
21264
|
-
$[25] = status;
|
|
21265
|
-
$[26] = t4;
|
|
21266
|
-
$[27] = t5;
|
|
21267
|
-
} else {
|
|
21268
|
-
t5 = $[27];
|
|
21269
|
-
}
|
|
21270
|
-
return t5;
|
|
21245
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EntityEditViewInner, { ...props, entityId, entity, cachedDirtyValues: cachedValues, dataLoading, status, setStatus, canEdit });
|
|
21271
21246
|
}
|
|
21272
21247
|
function EntityEditViewInner({
|
|
21273
21248
|
path,
|
|
@@ -21285,7 +21260,8 @@
|
|
|
21285
21260
|
barActions,
|
|
21286
21261
|
status,
|
|
21287
21262
|
setStatus,
|
|
21288
|
-
formProps
|
|
21263
|
+
formProps,
|
|
21264
|
+
canEdit
|
|
21289
21265
|
}) {
|
|
21290
21266
|
const context = useFireCMSContext();
|
|
21291
21267
|
const [usedEntity, setUsedEntity] = React.useState(entity);
|
|
@@ -21301,8 +21277,8 @@
|
|
|
21301
21277
|
}), []);
|
|
21302
21278
|
const [selectedTab, setSelectedTab] = React.useState(selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);
|
|
21303
21279
|
React.useEffect(() => {
|
|
21304
|
-
if ((selectedTabProp ?? MAIN_TAB_VALUE) !== selectedTab) {
|
|
21305
|
-
setSelectedTab(selectedTabProp ?? MAIN_TAB_VALUE);
|
|
21280
|
+
if ((selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE) !== selectedTab) {
|
|
21281
|
+
setSelectedTab(selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);
|
|
21306
21282
|
}
|
|
21307
21283
|
}, [selectedTabProp]);
|
|
21308
21284
|
const subcollections = (collection.subcollections ?? []).filter((c) => !c.hideFromNavigation);
|
|
@@ -21315,24 +21291,55 @@
|
|
|
21315
21291
|
resolvedEntityViews,
|
|
21316
21292
|
selectedEntityView,
|
|
21317
21293
|
selectedSecondaryForm
|
|
21318
|
-
} = resolvedSelectedEntityView(customViews, customizationController, selectedTab);
|
|
21294
|
+
} = resolvedSelectedEntityView(customViews, customizationController, selectedTab, canEdit);
|
|
21319
21295
|
const actionsAtTheBottom = !largeLayout || layout === "side_panel" || selectedEntityView?.includeActions === "bottom";
|
|
21320
21296
|
const mainViewVisible = selectedTab === MAIN_TAB_VALUE || Boolean(selectedSecondaryForm);
|
|
21297
|
+
const authController = useAuthController();
|
|
21321
21298
|
const customViewsView = customViews && resolvedEntityViews.filter((e) => !e.includeActions).map((customView) => {
|
|
21322
21299
|
if (!customView) return null;
|
|
21323
21300
|
const Builder = customView.Builder;
|
|
21324
21301
|
if (!Builder) {
|
|
21325
|
-
console.error("customView.Builder is not defined");
|
|
21302
|
+
console.error("INTERNAL: customView.Builder is not defined");
|
|
21303
|
+
return null;
|
|
21304
|
+
}
|
|
21305
|
+
if (!entityId) {
|
|
21306
|
+
console.error("INTERNAL: entityId is not defined");
|
|
21326
21307
|
return null;
|
|
21327
21308
|
}
|
|
21309
|
+
const formexStub = createFormexStub(usedEntity?.values ?? {});
|
|
21310
|
+
const usedFormContext = formContext ?? {
|
|
21311
|
+
entityId,
|
|
21312
|
+
openEntityMode: layout,
|
|
21313
|
+
status,
|
|
21314
|
+
values: usedEntity?.values ?? {},
|
|
21315
|
+
setFieldValue: (key, value) => {
|
|
21316
|
+
throw new Error("You can't update values in read only mode");
|
|
21317
|
+
},
|
|
21318
|
+
save: () => {
|
|
21319
|
+
throw new Error("You can't save in read only mode");
|
|
21320
|
+
},
|
|
21321
|
+
collection: resolveCollection({
|
|
21322
|
+
collection,
|
|
21323
|
+
path,
|
|
21324
|
+
entityId,
|
|
21325
|
+
values: usedEntity?.values ?? {},
|
|
21326
|
+
previousValues: usedEntity?.values ?? {},
|
|
21327
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
21328
|
+
authController
|
|
21329
|
+
}),
|
|
21330
|
+
path,
|
|
21331
|
+
entity: usedEntity,
|
|
21332
|
+
savingError: void 0,
|
|
21333
|
+
formex: formexStub
|
|
21334
|
+
};
|
|
21328
21335
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls(ui.defaultBorderMixin, "relative flex-1 w-full h-full overflow-auto", {
|
|
21329
21336
|
"hidden": selectedTab !== customView.key
|
|
21330
|
-
}), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children:
|
|
21337
|
+
}), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: usedFormContext && /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity: usedEntity, modifiedValues: usedFormContext?.formex?.values ?? usedEntity?.values, formContext: usedFormContext }) }) }, `custom_view_${customView.key}`);
|
|
21331
21338
|
}).filter(Boolean);
|
|
21332
21339
|
const globalLoading = dataLoading && !usedEntity;
|
|
21333
21340
|
const jsonView = /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls("relative flex-1 h-full overflow-auto w-full", {
|
|
21334
21341
|
"hidden": selectedTab !== JSON_TAB_VALUE
|
|
21335
|
-
}), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(EntityJsonPreview, { values: formContext?.values ?? {} }) }) }, "json_view");
|
|
21342
|
+
}), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(EntityJsonPreview, { values: formContext?.values ?? entity?.values ?? {} }) }) }, "json_view");
|
|
21336
21343
|
const subCollectionsViews = subcollections && subcollections.map((subcollection) => {
|
|
21337
21344
|
const subcollectionId = subcollection.id ?? subcollection.path;
|
|
21338
21345
|
const fullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : void 0;
|
|
@@ -21342,18 +21349,21 @@
|
|
|
21342
21349
|
!globalLoading && (usedEntity && fullPath ? /* @__PURE__ */ jsxRuntime.jsx(EntityCollectionView, { fullPath, parentCollectionIds: [...parentCollectionIds, collection.id], isSubCollection: true, updateUrl: false, ...subcollection, openEntityMode: layout }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center w-full h-full p-3", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "label", children: "You need to save your entity before adding additional collections" }) }))
|
|
21343
21350
|
] }, `subcol_${subcollectionId}`);
|
|
21344
21351
|
}).filter(Boolean);
|
|
21345
|
-
const onSideTabClick = (
|
|
21346
|
-
setSelectedTab(
|
|
21352
|
+
const onSideTabClick = (value_0) => {
|
|
21353
|
+
setSelectedTab(value_0);
|
|
21347
21354
|
if (status === "existing") {
|
|
21348
21355
|
onTabChange?.({
|
|
21349
21356
|
path,
|
|
21350
21357
|
entityId,
|
|
21351
|
-
selectedTab:
|
|
21358
|
+
selectedTab: value_0 === MAIN_TAB_VALUE ? void 0 : value_0,
|
|
21352
21359
|
collection
|
|
21353
21360
|
});
|
|
21354
21361
|
}
|
|
21355
21362
|
};
|
|
21356
|
-
const entityView = /* @__PURE__ */ jsxRuntime.jsx(
|
|
21363
|
+
const entityView = !canEdit ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls("flex-1 flex flex-row w-full overflow-y-auto justify-center", !mainViewVisible ? "hidden" : ""), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("relative flex flex-col max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit"), children: [
|
|
21364
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { className: "mt-16 mb-8 mx-8", variant: "h4", children: collection.singularName ?? collection.name }),
|
|
21365
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntityView, { className: "px-8 h-full overflow-auto", entity, path, collection })
|
|
21366
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(EntityForm, { collection, path, entityId: entityId ?? usedEntity?.id, onValuesModified, entity, initialDirtyValues: cachedDirtyValues, openEntityMode: layout, forceActionsAtTheBottom: actionsAtTheBottom, initialStatus: status, className: ui.cls(!mainViewVisible ? "hidden" : "", formProps?.className), EntityFormActionsComponent: EntityEditViewFormActions, ...formProps, onEntityChange: (entity_0) => {
|
|
21357
21367
|
setUsedEntity(entity_0);
|
|
21358
21368
|
formProps?.onEntityChange?.(entity_0);
|
|
21359
21369
|
}, onStatusChange: (status_0) => {
|
|
@@ -21377,8 +21387,8 @@
|
|
|
21377
21387
|
barActions,
|
|
21378
21388
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow" }),
|
|
21379
21389
|
globalLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "self-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CircularProgress, { size: "small" }) }),
|
|
21380
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { value: selectedTab, onValueChange: (
|
|
21381
|
-
onSideTabClick(
|
|
21390
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { value: selectedTab, onValueChange: (value_1) => {
|
|
21391
|
+
onSideTabClick(value_1);
|
|
21382
21392
|
}, children: [
|
|
21383
21393
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, innerClassName: "block", className: "text-sm", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CodeIcon, { size: "small" }) }),
|
|
21384
21394
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: MAIN_TAB_VALUE, className: "text-sm min-w-[120px]", children: collection.singularName ?? collection.name }),
|
|
@@ -23253,7 +23263,6 @@
|
|
|
23253
23263
|
return blocked.current;
|
|
23254
23264
|
});
|
|
23255
23265
|
} catch (e) {
|
|
23256
|
-
console.warn("Blocker not available, navigation will not be blocked");
|
|
23257
23266
|
}
|
|
23258
23267
|
const lastCollectionEntry = navigationEntries.findLast((entry_1) => entry_1.type === "collection");
|
|
23259
23268
|
if (isNew && !lastCollectionEntry) {
|