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