@firecms/core 3.0.0-canary.126 → 3.0.0-canary.127
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/components/EntityCollectionView/utils.d.ts +3 -0
- package/dist/components/EntityPreview.d.ts +1 -1
- package/dist/index.es.js +96 -45
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +96 -45
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +66 -39
- package/src/components/EntityCollectionView/utils.ts +19 -0
- package/src/components/EntityPreview.tsx +1 -1
- package/src/components/common/default_entity_actions.tsx +4 -0
- package/src/util/make_properties_editable.ts +13 -5
package/dist/index.es.js
CHANGED
|
@@ -2960,9 +2960,11 @@ function getArrayValuesCount(array) {
|
|
|
2960
2960
|
function makePropertiesEditable(properties) {
|
|
2961
2961
|
Object.keys(properties).forEach((key) => {
|
|
2962
2962
|
const property = properties[key];
|
|
2963
|
-
property
|
|
2964
|
-
|
|
2965
|
-
|
|
2963
|
+
if (property) {
|
|
2964
|
+
property.editable = true;
|
|
2965
|
+
if (property.dataType === "map" && property.properties) {
|
|
2966
|
+
makePropertiesEditable(property.properties);
|
|
2967
|
+
}
|
|
2966
2968
|
}
|
|
2967
2969
|
});
|
|
2968
2970
|
return properties;
|
|
@@ -2970,13 +2972,19 @@ function makePropertiesEditable(properties) {
|
|
|
2970
2972
|
function makePropertiesNonEditable(properties) {
|
|
2971
2973
|
return Object.entries(properties).reduce((acc, [key, property]) => {
|
|
2972
2974
|
if (!isPropertyBuilder(property) && property.dataType === "map" && property.properties) {
|
|
2973
|
-
const updated = {
|
|
2975
|
+
const updated = {
|
|
2976
|
+
...property,
|
|
2977
|
+
properties: makePropertiesNonEditable(property.properties)
|
|
2978
|
+
};
|
|
2974
2979
|
acc[key] = updated;
|
|
2975
2980
|
}
|
|
2976
2981
|
if (isPropertyBuilder(property)) {
|
|
2977
2982
|
acc[key] = property;
|
|
2978
2983
|
} else {
|
|
2979
|
-
acc[key] = {
|
|
2984
|
+
acc[key] = {
|
|
2985
|
+
...property,
|
|
2986
|
+
editable: false
|
|
2987
|
+
};
|
|
2980
2988
|
}
|
|
2981
2989
|
return acc;
|
|
2982
2990
|
}, {});
|
|
@@ -10782,6 +10790,23 @@ function DeleteEntityDialog({
|
|
|
10782
10790
|
}
|
|
10783
10791
|
);
|
|
10784
10792
|
}
|
|
10793
|
+
function addRecentId(collectionId, id) {
|
|
10794
|
+
const recentIds = getRecentIds(collectionId);
|
|
10795
|
+
const newRecentIds = [id, ...recentIds.filter((i) => i !== id)];
|
|
10796
|
+
if (newRecentIds.length > 5) {
|
|
10797
|
+
newRecentIds.pop();
|
|
10798
|
+
}
|
|
10799
|
+
saveSearchedIdsLocally(collectionId, newRecentIds);
|
|
10800
|
+
return newRecentIds;
|
|
10801
|
+
}
|
|
10802
|
+
function saveSearchedIdsLocally(collectionId, ids) {
|
|
10803
|
+
localStorage.setItem("recent_id_searches::" + collectionId, JSON.stringify(ids));
|
|
10804
|
+
}
|
|
10805
|
+
function getRecentIds(collectionId) {
|
|
10806
|
+
const stored = localStorage.getItem("recent_id_searches::" + collectionId);
|
|
10807
|
+
if (!stored) return [];
|
|
10808
|
+
return JSON.parse(stored);
|
|
10809
|
+
}
|
|
10785
10810
|
const editEntityAction = {
|
|
10786
10811
|
icon: /* @__PURE__ */ jsx(KeyboardTabIcon, {}),
|
|
10787
10812
|
name: "Edit",
|
|
@@ -10799,6 +10824,9 @@ const editEntityAction = {
|
|
|
10799
10824
|
path: entity.path,
|
|
10800
10825
|
entityId: entity.id
|
|
10801
10826
|
});
|
|
10827
|
+
if (collection) {
|
|
10828
|
+
addRecentId(collection.id, entity.id);
|
|
10829
|
+
}
|
|
10802
10830
|
const path = collection?.collectionGroup ? entity.path : fullPath ?? entity.path;
|
|
10803
10831
|
context.sideEntityController.open({
|
|
10804
10832
|
entityId: entity.id,
|
|
@@ -12837,6 +12865,7 @@ function EntityIdHeaderWidget({
|
|
|
12837
12865
|
}) {
|
|
12838
12866
|
const [openPopup, setOpenPopup] = React__default.useState(false);
|
|
12839
12867
|
const [searchString, setSearchString] = React__default.useState("");
|
|
12868
|
+
const [recentIds, setRecentIds] = React__default.useState(getRecentIds(collection.id));
|
|
12840
12869
|
const sideEntityController = useSideEntityController();
|
|
12841
12870
|
return /* @__PURE__ */ jsx(Tooltip, { title: !openPopup ? "Find by ID" : void 0, asChild: false, children: /* @__PURE__ */ jsx(
|
|
12842
12871
|
Popover,
|
|
@@ -12847,47 +12876,69 @@ function EntityIdHeaderWidget({
|
|
|
12847
12876
|
align: "start",
|
|
12848
12877
|
alignOffset: -117,
|
|
12849
12878
|
trigger: /* @__PURE__ */ jsx(IconButton, { size: "small", children: /* @__PURE__ */ jsx(SearchIcon, { size: "small" }) }),
|
|
12850
|
-
children: /* @__PURE__ */
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
e
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12879
|
+
children: /* @__PURE__ */ jsxs("div", { className: cls("my-2 rounded-lg bg-gray-50 dark:bg-gray-950 text-gray-900 dark:text-white"), children: [
|
|
12880
|
+
/* @__PURE__ */ jsx(
|
|
12881
|
+
"form",
|
|
12882
|
+
{
|
|
12883
|
+
noValidate: true,
|
|
12884
|
+
onSubmit: (e) => {
|
|
12885
|
+
e.preventDefault();
|
|
12886
|
+
if (!searchString) return;
|
|
12887
|
+
setOpenPopup(false);
|
|
12888
|
+
setRecentIds(addRecentId(collection.id, searchString.trim()));
|
|
12889
|
+
return sideEntityController.open({
|
|
12890
|
+
entityId: searchString.trim(),
|
|
12891
|
+
path,
|
|
12892
|
+
collection,
|
|
12893
|
+
updateUrl: true
|
|
12894
|
+
});
|
|
12895
|
+
},
|
|
12896
|
+
className: "w-96 max-w-full",
|
|
12897
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex p-2 w-full gap-2", children: [
|
|
12898
|
+
/* @__PURE__ */ jsx(
|
|
12899
|
+
"input",
|
|
12900
|
+
{
|
|
12901
|
+
autoFocus: openPopup,
|
|
12902
|
+
placeholder: "Find entity by ID",
|
|
12903
|
+
onChange: (e) => {
|
|
12904
|
+
setSearchString(e.target.value);
|
|
12905
|
+
},
|
|
12906
|
+
value: searchString,
|
|
12907
|
+
className: "rounded-lg bg-white dark:bg-gray-800 flex-grow bg-transparent outline-none p-2 " + focusedDisabled
|
|
12908
|
+
}
|
|
12909
|
+
),
|
|
12910
|
+
/* @__PURE__ */ jsx(
|
|
12911
|
+
Button,
|
|
12912
|
+
{
|
|
12913
|
+
variant: "text",
|
|
12914
|
+
disabled: !searchString.trim(),
|
|
12915
|
+
type: "submit",
|
|
12916
|
+
children: /* @__PURE__ */ jsx(KeyboardTabIcon, {})
|
|
12917
|
+
}
|
|
12918
|
+
)
|
|
12919
|
+
] })
|
|
12920
|
+
}
|
|
12921
|
+
),
|
|
12922
|
+
recentIds && recentIds.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 p-2", children: recentIds.map((id) => /* @__PURE__ */ jsx(
|
|
12923
|
+
ReferencePreview,
|
|
12924
|
+
{
|
|
12925
|
+
reference: new EntityReference(id, path),
|
|
12926
|
+
hover: true,
|
|
12927
|
+
onClick: () => {
|
|
12928
|
+
setOpenPopup(false);
|
|
12929
|
+
sideEntityController.open({
|
|
12930
|
+
entityId: id,
|
|
12931
|
+
path,
|
|
12932
|
+
collection,
|
|
12933
|
+
updateUrl: true
|
|
12934
|
+
});
|
|
12935
|
+
},
|
|
12936
|
+
includeEntityLink: false,
|
|
12937
|
+
size: "small"
|
|
12864
12938
|
},
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
"input",
|
|
12869
|
-
{
|
|
12870
|
-
autoFocus: openPopup,
|
|
12871
|
-
placeholder: "Find entity by ID",
|
|
12872
|
-
onChange: (e) => {
|
|
12873
|
-
setSearchString(e.target.value);
|
|
12874
|
-
},
|
|
12875
|
-
value: searchString,
|
|
12876
|
-
className: "flex-grow bg-transparent outline-none p-1 " + focusedDisabled
|
|
12877
|
-
}
|
|
12878
|
-
),
|
|
12879
|
-
/* @__PURE__ */ jsx(
|
|
12880
|
-
Button,
|
|
12881
|
-
{
|
|
12882
|
-
variant: "outlined",
|
|
12883
|
-
disabled: !searchString.trim(),
|
|
12884
|
-
type: "submit",
|
|
12885
|
-
children: "Go"
|
|
12886
|
-
}
|
|
12887
|
-
)
|
|
12888
|
-
] })
|
|
12889
|
-
}
|
|
12890
|
-
)
|
|
12939
|
+
id
|
|
12940
|
+
)) })
|
|
12941
|
+
] })
|
|
12891
12942
|
}
|
|
12892
12943
|
) });
|
|
12893
12944
|
}
|