admin-lib-cms 1.2.11 → 1.2.12
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/index.js +17 -5
- package/dist/index.mjs +17 -5
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2496,6 +2496,7 @@ function CollectionEditor({ collection }) {
|
|
|
2496
2496
|
const t = useAdminI18n();
|
|
2497
2497
|
const [entries, setEntries] = (0, import_react5.useState)([]);
|
|
2498
2498
|
const [editing, setEditing] = (0, import_react5.useState)(null);
|
|
2499
|
+
const [isCreatingManual, setIsCreatingManual] = (0, import_react5.useState)(false);
|
|
2499
2500
|
const [saving, setSaving] = (0, import_react5.useState)(false);
|
|
2500
2501
|
const [deletingId, setDeletingId] = (0, import_react5.useState)(null);
|
|
2501
2502
|
const [loadingEntries, setLoadingEntries] = (0, import_react5.useState)(true);
|
|
@@ -2521,6 +2522,7 @@ function CollectionEditor({ collection }) {
|
|
|
2521
2522
|
load();
|
|
2522
2523
|
}, [load]);
|
|
2523
2524
|
const startNew = () => {
|
|
2525
|
+
setIsCreatingManual(true);
|
|
2524
2526
|
const base = { id: crypto.randomUUID() };
|
|
2525
2527
|
collection.fields.forEach((f) => {
|
|
2526
2528
|
if (f.id === "order") {
|
|
@@ -2577,6 +2579,7 @@ function CollectionEditor({ collection }) {
|
|
|
2577
2579
|
await ctx.adapter.putEntry(collection.id, finalEditing);
|
|
2578
2580
|
ctx.notifyCollectionChanged();
|
|
2579
2581
|
setEditing(null);
|
|
2582
|
+
setIsCreatingManual(false);
|
|
2580
2583
|
load();
|
|
2581
2584
|
} finally {
|
|
2582
2585
|
setSaving(false);
|
|
@@ -2629,7 +2632,7 @@ function CollectionEditor({ collection }) {
|
|
|
2629
2632
|
setDragOverIdx(null);
|
|
2630
2633
|
};
|
|
2631
2634
|
const visibleFields = collection.tableFields?.length ? collection.tableFields.map((tf) => collection.fields.find((f) => f.id === tf)).filter(Boolean) : collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0, 6);
|
|
2632
|
-
const isCreatingEntry = editing ? !entries.some((entry) => entry.id === editing.id) : false;
|
|
2635
|
+
const isCreatingEntry = isCreatingManual || (editing ? !entries.some((entry) => entry.id && entry.id === editing.id || entry._id && entry._id === (editing._id || editing.id)) : false);
|
|
2633
2636
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mx-auto max-w-5xl", children: [
|
|
2634
2637
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-8 flex items-center justify-between", children: [
|
|
2635
2638
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
@@ -2742,7 +2745,10 @@ function CollectionEditor({ collection }) {
|
|
|
2742
2745
|
] })
|
|
2743
2746
|
] }),
|
|
2744
2747
|
onCancel: () => {
|
|
2745
|
-
if (!saving)
|
|
2748
|
+
if (!saving) {
|
|
2749
|
+
setEditing(null);
|
|
2750
|
+
setIsCreatingManual(false);
|
|
2751
|
+
}
|
|
2746
2752
|
},
|
|
2747
2753
|
footer: null,
|
|
2748
2754
|
centered: true,
|
|
@@ -3288,7 +3294,10 @@ function CollectionEditor({ collection }) {
|
|
|
3288
3294
|
import_antd.Button,
|
|
3289
3295
|
{
|
|
3290
3296
|
size: "large",
|
|
3291
|
-
onClick: () =>
|
|
3297
|
+
onClick: () => {
|
|
3298
|
+
setEditing(null);
|
|
3299
|
+
setIsCreatingManual(false);
|
|
3300
|
+
},
|
|
3292
3301
|
disabled: saving,
|
|
3293
3302
|
className: "rounded-xl font-medium",
|
|
3294
3303
|
children: t.cancel
|
|
@@ -3302,7 +3311,7 @@ function CollectionEditor({ collection }) {
|
|
|
3302
3311
|
onClick: save,
|
|
3303
3312
|
loading: saving,
|
|
3304
3313
|
className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700",
|
|
3305
|
-
children: collection.submitLabel || (
|
|
3314
|
+
children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
|
|
3306
3315
|
}
|
|
3307
3316
|
)
|
|
3308
3317
|
] })
|
|
@@ -3383,7 +3392,10 @@ function CollectionEditor({ collection }) {
|
|
|
3383
3392
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3384
3393
|
"button",
|
|
3385
3394
|
{
|
|
3386
|
-
onClick: () =>
|
|
3395
|
+
onClick: () => {
|
|
3396
|
+
setIsCreatingManual(false);
|
|
3397
|
+
setEditing(e);
|
|
3398
|
+
},
|
|
3387
3399
|
className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
|
|
3388
3400
|
title: t.edit,
|
|
3389
3401
|
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4" })
|
package/dist/index.mjs
CHANGED
|
@@ -1733,6 +1733,7 @@ function CollectionEditor({ collection }) {
|
|
|
1733
1733
|
const t = useAdminI18n();
|
|
1734
1734
|
const [entries, setEntries] = useState([]);
|
|
1735
1735
|
const [editing, setEditing] = useState(null);
|
|
1736
|
+
const [isCreatingManual, setIsCreatingManual] = useState(false);
|
|
1736
1737
|
const [saving, setSaving] = useState(false);
|
|
1737
1738
|
const [deletingId, setDeletingId] = useState(null);
|
|
1738
1739
|
const [loadingEntries, setLoadingEntries] = useState(true);
|
|
@@ -1758,6 +1759,7 @@ function CollectionEditor({ collection }) {
|
|
|
1758
1759
|
load();
|
|
1759
1760
|
}, [load]);
|
|
1760
1761
|
const startNew = () => {
|
|
1762
|
+
setIsCreatingManual(true);
|
|
1761
1763
|
const base = { id: crypto.randomUUID() };
|
|
1762
1764
|
collection.fields.forEach((f) => {
|
|
1763
1765
|
if (f.id === "order") {
|
|
@@ -1814,6 +1816,7 @@ function CollectionEditor({ collection }) {
|
|
|
1814
1816
|
await ctx.adapter.putEntry(collection.id, finalEditing);
|
|
1815
1817
|
ctx.notifyCollectionChanged();
|
|
1816
1818
|
setEditing(null);
|
|
1819
|
+
setIsCreatingManual(false);
|
|
1817
1820
|
load();
|
|
1818
1821
|
} finally {
|
|
1819
1822
|
setSaving(false);
|
|
@@ -1866,7 +1869,7 @@ function CollectionEditor({ collection }) {
|
|
|
1866
1869
|
setDragOverIdx(null);
|
|
1867
1870
|
};
|
|
1868
1871
|
const visibleFields = collection.tableFields?.length ? collection.tableFields.map((tf) => collection.fields.find((f) => f.id === tf)).filter(Boolean) : collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0, 6);
|
|
1869
|
-
const isCreatingEntry = editing ? !entries.some((entry) => entry.id === editing.id) : false;
|
|
1872
|
+
const isCreatingEntry = isCreatingManual || (editing ? !entries.some((entry) => entry.id && entry.id === editing.id || entry._id && entry._id === (editing._id || editing.id)) : false);
|
|
1870
1873
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-5xl", children: [
|
|
1871
1874
|
/* @__PURE__ */ jsxs("div", { className: "mb-8 flex items-center justify-between", children: [
|
|
1872
1875
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -1979,7 +1982,10 @@ function CollectionEditor({ collection }) {
|
|
|
1979
1982
|
] })
|
|
1980
1983
|
] }),
|
|
1981
1984
|
onCancel: () => {
|
|
1982
|
-
if (!saving)
|
|
1985
|
+
if (!saving) {
|
|
1986
|
+
setEditing(null);
|
|
1987
|
+
setIsCreatingManual(false);
|
|
1988
|
+
}
|
|
1983
1989
|
},
|
|
1984
1990
|
footer: null,
|
|
1985
1991
|
centered: true,
|
|
@@ -2525,7 +2531,10 @@ function CollectionEditor({ collection }) {
|
|
|
2525
2531
|
Button,
|
|
2526
2532
|
{
|
|
2527
2533
|
size: "large",
|
|
2528
|
-
onClick: () =>
|
|
2534
|
+
onClick: () => {
|
|
2535
|
+
setEditing(null);
|
|
2536
|
+
setIsCreatingManual(false);
|
|
2537
|
+
},
|
|
2529
2538
|
disabled: saving,
|
|
2530
2539
|
className: "rounded-xl font-medium",
|
|
2531
2540
|
children: t.cancel
|
|
@@ -2539,7 +2548,7 @@ function CollectionEditor({ collection }) {
|
|
|
2539
2548
|
onClick: save,
|
|
2540
2549
|
loading: saving,
|
|
2541
2550
|
className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700",
|
|
2542
|
-
children: collection.submitLabel || (
|
|
2551
|
+
children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
|
|
2543
2552
|
}
|
|
2544
2553
|
)
|
|
2545
2554
|
] })
|
|
@@ -2620,7 +2629,10 @@ function CollectionEditor({ collection }) {
|
|
|
2620
2629
|
/* @__PURE__ */ jsx(
|
|
2621
2630
|
"button",
|
|
2622
2631
|
{
|
|
2623
|
-
onClick: () =>
|
|
2632
|
+
onClick: () => {
|
|
2633
|
+
setIsCreatingManual(false);
|
|
2634
|
+
setEditing(e);
|
|
2635
|
+
},
|
|
2624
2636
|
className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
|
|
2625
2637
|
title: t.edit,
|
|
2626
2638
|
children: /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4" })
|
package/dist/types.d.mts
CHANGED
package/dist/types.d.ts
CHANGED