strapi-plugin-bulk-updater 1.5.16 → 1.6.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.
- package/dist/_chunks/{BulkUpdater-Bj-8DvpD.mjs → BulkUpdater-CTKfvKhE.mjs} +2044 -280
- package/dist/_chunks/BulkUpdater-CTKfvKhE.mjs.map +1 -0
- package/dist/_chunks/{BulkUpdater-C7-KHLWq.js → BulkUpdater-D12SUhTd.js} +2042 -278
- package/dist/_chunks/BulkUpdater-D12SUhTd.js.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +5992 -4757
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +5992 -4757
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/_chunks/BulkUpdater-Bj-8DvpD.mjs.map +0 -1
- package/dist/_chunks/BulkUpdater-C7-KHLWq.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React__default, { useRef, useState, useEffect, useMemo } from "react";
|
|
3
3
|
import { useFetchClient, useNotification } from "@strapi/strapi/admin";
|
|
4
|
-
import { Box, Flex, Typography, Button, Combobox, ComboboxOption, Badge, SingleSelect, SingleSelectOption, TextInput, Checkbox, Alert, Table, Thead, Tr, Th, Tbody, Td, Loader, Field } from "@strapi/design-system";
|
|
5
|
-
import { ArrowClockwise, Download, Upload, ChevronLeft, ChevronRight, Eye, Check, Cog, Play } from "@strapi/icons";
|
|
4
|
+
import { Box, Flex, Typography, Button, Combobox, ComboboxOption, Badge, SingleSelect, SingleSelectOption, TextInput, Checkbox, Alert, Table, Thead, Tr, Th, Tbody, Td, Loader, Textarea, Field } from "@strapi/design-system";
|
|
5
|
+
import { ArrowClockwise, Download, Upload, ChevronLeft, ChevronRight, Eye, Check, Search, Cog, Play } from "@strapi/icons";
|
|
6
6
|
import { i as isAbortError, V as ValidationRulesTab } from "./ValidationRulesTab-BtOCWK8E.mjs";
|
|
7
7
|
function parseCsvRows(csvText) {
|
|
8
8
|
if (!csvText) return [];
|
|
@@ -2743,6 +2743,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
2743
2743
|
previewData,
|
|
2744
2744
|
attribute,
|
|
2745
2745
|
targetValueDisplay,
|
|
2746
|
+
editMode = "common",
|
|
2746
2747
|
publishOnApproval = true,
|
|
2747
2748
|
lifecycleStats
|
|
2748
2749
|
}) => {
|
|
@@ -2757,12 +2758,14 @@ const BulkUpdatePreviewModal = ({
|
|
|
2757
2758
|
if (searchQuery.trim()) {
|
|
2758
2759
|
const q = searchQuery.toLowerCase().trim();
|
|
2759
2760
|
items = items.filter(
|
|
2760
|
-
(d) => d.label.toLowerCase().includes(q) || d.documentId.toLowerCase().includes(q) || d.collectionName.toLowerCase().includes(q) || String(d.oldDisplay || "").toLowerCase().includes(q) || String(d.newDisplay || "").toLowerCase().includes(q)
|
|
2761
|
+
(d) => d.label.toLowerCase().includes(q) || d.documentId.toLowerCase().includes(q) || d.collectionName.toLowerCase().includes(q) || String(d.attribute || "").toLowerCase().includes(q) || String(d.oldDisplay || "").toLowerCase().includes(q) || String(d.newDisplay || "").toLowerCase().includes(q)
|
|
2761
2762
|
);
|
|
2762
2763
|
}
|
|
2763
2764
|
return items;
|
|
2764
2765
|
}, [previewData, filterTab, searchQuery]);
|
|
2765
2766
|
if (!isOpen) return null;
|
|
2767
|
+
const isGridMode = editMode === "grid" || previewData?.editMode === "grid";
|
|
2768
|
+
const willErrorCount = previewData?.summary?.willError || 0;
|
|
2766
2769
|
return /* @__PURE__ */ jsx(
|
|
2767
2770
|
"div",
|
|
2768
2771
|
{
|
|
@@ -2786,7 +2789,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
2786
2789
|
hasRadius: true,
|
|
2787
2790
|
shadow: "popupShadow",
|
|
2788
2791
|
style: {
|
|
2789
|
-
maxWidth:
|
|
2792
|
+
maxWidth: 1120,
|
|
2790
2793
|
width: "95%",
|
|
2791
2794
|
maxHeight: "calc(100vh - 48px)",
|
|
2792
2795
|
display: "flex",
|
|
@@ -2813,13 +2816,16 @@ const BulkUpdatePreviewModal = ({
|
|
|
2813
2816
|
/* @__PURE__ */ jsxs(Badge, { backgroundColor: "primary100", textColor: "primary700", children: [
|
|
2814
2817
|
"Target: ",
|
|
2815
2818
|
attribute
|
|
2816
|
-
] })
|
|
2819
|
+
] }),
|
|
2820
|
+
isGridMode && /* @__PURE__ */ jsx(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: "GRID EDITING MODE" })
|
|
2817
2821
|
] }),
|
|
2818
2822
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Inspect exact before & after values across target records before applying changes to the database." })
|
|
2819
2823
|
] }),
|
|
2820
2824
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
|
|
2821
|
-
/* @__PURE__ */
|
|
2822
|
-
|
|
2825
|
+
!isGridMode ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2826
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "New Value:" }),
|
|
2827
|
+
/* @__PURE__ */ jsx(Badge, { backgroundColor: "success100", textColor: "success700", children: targetValueDisplay || "(empty)" })
|
|
2828
|
+
] }) : /* @__PURE__ */ jsx(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: targetValueDisplay || "Per-Record & Component Grid Edits" }),
|
|
2823
2829
|
/* @__PURE__ */ jsx(
|
|
2824
2830
|
Badge,
|
|
2825
2831
|
{
|
|
@@ -2847,6 +2853,13 @@ const BulkUpdatePreviewModal = ({
|
|
|
2847
2853
|
/* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "semiBold", children: "Inspecting Target Records..." }),
|
|
2848
2854
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Computing proposed diffs and verifying against database schema." })
|
|
2849
2855
|
] }) }) : !previewData ? /* @__PURE__ */ jsx(Box, { padding: 6, style: { textAlign: "center" }, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: "No preview data available." }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2856
|
+
willErrorCount > 0 && /* @__PURE__ */ jsx(Box, { marginBottom: 4, padding: 3, background: "danger100", hasRadius: true, style: { border: "1px solid #f5c0b8" }, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
2857
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "danger700", children: "⚠️ Validation / Quota Violation Detected:" }),
|
|
2858
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "danger700", children: [
|
|
2859
|
+
willErrorCount,
|
|
2860
|
+
' item(s) failed schema or quota validation rules. Inspect the rows marked "Validation Error" below; invalid records will be rejected during batch execution and retained for editing.'
|
|
2861
|
+
] })
|
|
2862
|
+
] }) }),
|
|
2850
2863
|
publishOnApproval && lifecycleStats && lifecycleStats.unreviewedCount > 0 && /* @__PURE__ */ jsx(Box, { marginBottom: 4, padding: 3, background: "warning100", hasRadius: true, style: { border: "1px solid #f5c0b8" }, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
2851
2864
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "warning700", children: "⚠️ Safe Publishing Active:" }),
|
|
2852
2865
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "warning700", children: [
|
|
@@ -2912,7 +2925,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
2912
2925
|
variant: "sigma",
|
|
2913
2926
|
textColor: previewData.summary.skipped > 0 ? "warning700" : "neutral600",
|
|
2914
2927
|
display: "block",
|
|
2915
|
-
children: "WILL SKIP
|
|
2928
|
+
children: "WILL SKIP"
|
|
2916
2929
|
}
|
|
2917
2930
|
),
|
|
2918
2931
|
/* @__PURE__ */ jsx(
|
|
@@ -2926,6 +2939,19 @@ const BulkUpdatePreviewModal = ({
|
|
|
2926
2939
|
)
|
|
2927
2940
|
]
|
|
2928
2941
|
}
|
|
2942
|
+
),
|
|
2943
|
+
willErrorCount > 0 && /* @__PURE__ */ jsxs(
|
|
2944
|
+
Box,
|
|
2945
|
+
{
|
|
2946
|
+
padding: 3,
|
|
2947
|
+
background: "danger100",
|
|
2948
|
+
hasRadius: true,
|
|
2949
|
+
style: { flex: 1, minWidth: 140, border: "1px solid #ffa39e" },
|
|
2950
|
+
children: [
|
|
2951
|
+
/* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "danger700", display: "block", children: "VALIDATION ERRORS" }),
|
|
2952
|
+
/* @__PURE__ */ jsx(Typography, { variant: "beta", fontWeight: "bold", textColor: "danger700", children: willErrorCount })
|
|
2953
|
+
]
|
|
2954
|
+
}
|
|
2929
2955
|
)
|
|
2930
2956
|
] }),
|
|
2931
2957
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 3, wrap: "wrap", gap: 3, children: [
|
|
@@ -2938,7 +2964,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
2938
2964
|
onClick: () => setFilterTab("all"),
|
|
2939
2965
|
children: [
|
|
2940
2966
|
"All (",
|
|
2941
|
-
previewData.summary.total,
|
|
2967
|
+
isGridMode ? previewData.diffs.length : previewData.summary.total,
|
|
2942
2968
|
")"
|
|
2943
2969
|
]
|
|
2944
2970
|
}
|
|
@@ -2981,6 +3007,19 @@ const BulkUpdatePreviewModal = ({
|
|
|
2981
3007
|
")"
|
|
2982
3008
|
]
|
|
2983
3009
|
}
|
|
3010
|
+
),
|
|
3011
|
+
willErrorCount > 0 && /* @__PURE__ */ jsxs(
|
|
3012
|
+
Button,
|
|
3013
|
+
{
|
|
3014
|
+
variant: filterTab === "will_error" ? "default" : "tertiary",
|
|
3015
|
+
size: "S",
|
|
3016
|
+
onClick: () => setFilterTab("will_error"),
|
|
3017
|
+
children: [
|
|
3018
|
+
"Errors (",
|
|
3019
|
+
willErrorCount,
|
|
3020
|
+
")"
|
|
3021
|
+
]
|
|
3022
|
+
}
|
|
2984
3023
|
)
|
|
2985
3024
|
] }),
|
|
2986
3025
|
/* @__PURE__ */ jsx(Box, { style: { width: 260 }, children: /* @__PURE__ */ jsx(
|
|
@@ -3003,20 +3042,22 @@ const BulkUpdatePreviewModal = ({
|
|
|
3003
3042
|
overflowY: "auto",
|
|
3004
3043
|
overflowX: "auto"
|
|
3005
3044
|
},
|
|
3006
|
-
children: /* @__PURE__ */ jsxs(Table, { colCount:
|
|
3045
|
+
children: /* @__PURE__ */ jsxs(Table, { colCount: 6, rowCount: filteredDiffs.length + 1, style: { width: "100%", minWidth: 880 }, children: [
|
|
3007
3046
|
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
3008
|
-
/* @__PURE__ */ jsx(Th, { style: { width:
|
|
3009
|
-
/* @__PURE__ */ jsx(Th, { style: { minWidth:
|
|
3010
|
-
/* @__PURE__ */ jsx(Th, { style: { minWidth:
|
|
3011
|
-
/* @__PURE__ */ jsx(Th, { style: { minWidth:
|
|
3012
|
-
/* @__PURE__ */ jsx(Th, { style: {
|
|
3047
|
+
/* @__PURE__ */ jsx(Th, { style: { width: 140 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "COLLECTION" }) }),
|
|
3048
|
+
/* @__PURE__ */ jsx(Th, { style: { minWidth: 185 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "RECORD IDENTIFIER" }) }),
|
|
3049
|
+
/* @__PURE__ */ jsx(Th, { style: { minWidth: 165 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "ATTRIBUTE / BLOCK" }) }),
|
|
3050
|
+
/* @__PURE__ */ jsx(Th, { style: { minWidth: 170 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "CURRENT VALUE (BEFORE)" }) }),
|
|
3051
|
+
/* @__PURE__ */ jsx(Th, { style: { minWidth: 170 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "NEW VALUE (AFTER)" }) }),
|
|
3052
|
+
/* @__PURE__ */ jsx(Th, { style: { width: 150, textAlign: "right" }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "IMPACT" }) })
|
|
3013
3053
|
] }) }),
|
|
3014
|
-
/* @__PURE__ */ jsx(Tbody, { children: filteredDiffs.length === 0 ? /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan:
|
|
3054
|
+
/* @__PURE__ */ jsx(Tbody, { children: filteredDiffs.length === 0 ? /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: 6, style: { textAlign: "center", padding: "24px" }, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: "No records match the current filter or search criteria." }) }) }) : filteredDiffs.map((diff, idx) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
3015
3055
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral700", children: diff.collectionName }) }),
|
|
3016
3056
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
3017
3057
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", display: "block", children: diff.label }),
|
|
3018
3058
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: /* @__PURE__ */ jsx("code", { children: diff.documentId }) })
|
|
3019
3059
|
] }) }),
|
|
3060
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "semiBold", textColor: "primary700", children: diff.attribute || attribute }) }),
|
|
3020
3061
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
3021
3062
|
Typography,
|
|
3022
3063
|
{
|
|
@@ -3029,13 +3070,14 @@ const BulkUpdatePreviewModal = ({
|
|
|
3029
3070
|
children: diff.oldDisplay || "(empty)"
|
|
3030
3071
|
}
|
|
3031
3072
|
) }),
|
|
3032
|
-
/* @__PURE__ */ jsx(Td, { children: diff.status === "will_skip" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", children: "— Skipped (field absent) —" }) : diff.hasChange ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(already matching)" }) }),
|
|
3073
|
+
/* @__PURE__ */ jsx(Td, { children: diff.status === "will_error" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: diff.validationError || diff.message }) : diff.status === "will_skip" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", children: "— Skipped (field absent) —" }) : diff.hasChange ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(already matching)" }) }),
|
|
3033
3074
|
/* @__PURE__ */ jsxs(Td, { style: { textAlign: "right" }, children: [
|
|
3034
3075
|
diff.status === "will_update" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "success100", textColor: "success700", children: "✓ Will Update" }),
|
|
3035
3076
|
diff.status === "unchanged" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral600", children: "= Unchanged" }),
|
|
3036
|
-
diff.status === "will_skip" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "⚠ Will Skip" })
|
|
3077
|
+
diff.status === "will_skip" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "⚠ Will Skip" }),
|
|
3078
|
+
diff.status === "will_error" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "danger100", textColor: "danger700", children: "✕ Error" })
|
|
3037
3079
|
] })
|
|
3038
|
-
] }, `${diff.uid}-${diff.documentId}`)) })
|
|
3080
|
+
] }, `${diff.uid}-${diff.documentId}-${diff.attribute || "root"}-${idx}`)) })
|
|
3039
3081
|
] })
|
|
3040
3082
|
}
|
|
3041
3083
|
)
|
|
@@ -3063,7 +3105,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
3063
3105
|
onClose();
|
|
3064
3106
|
onProceed();
|
|
3065
3107
|
},
|
|
3066
|
-
disabled: loading || !previewData || previewData.summary.total === 0,
|
|
3108
|
+
disabled: loading || !previewData || previewData.summary.total === 0 || isGridMode && previewData.summary.willUpdate === 0,
|
|
3067
3109
|
children: [
|
|
3068
3110
|
"Proceed to Execute (",
|
|
3069
3111
|
previewData?.summary.willUpdate || 0,
|
|
@@ -3502,12 +3544,13 @@ const CheckerReviewModal = ({
|
|
|
3502
3544
|
children: diff.oldDisplay || "(empty)"
|
|
3503
3545
|
}
|
|
3504
3546
|
) }),
|
|
3505
|
-
/* @__PURE__ */ jsx(Td, { children: diff.status === "will_create" ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(new value)" }) : diff.status === "will_skip" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", children: "— Skipped —" }) : diff.hasChange ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(matching)" }) }),
|
|
3547
|
+
/* @__PURE__ */ jsx(Td, { children: diff.status === "will_create" ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(new value)" }) : diff.status === "will_error" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: diff.validationError || diff.message || "Validation error" }) : diff.status === "will_skip" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", children: "— Skipped —" }) : diff.hasChange ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(matching)" }) }),
|
|
3506
3548
|
/* @__PURE__ */ jsxs(Td, { style: { textAlign: "right" }, children: [
|
|
3507
3549
|
diff.status === "will_create" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "success100", textColor: "success700", children: "+ Will Create" }),
|
|
3508
3550
|
diff.status === "will_update" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "✎ Will Update" }),
|
|
3509
3551
|
diff.status === "unchanged" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral600", children: "= Unchanged" }),
|
|
3510
|
-
diff.status === "will_skip" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "
|
|
3552
|
+
diff.status === "will_skip" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "⚠ Will Skip" }),
|
|
3553
|
+
diff.status === "will_error" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "danger100", textColor: "danger700", children: "✕ Validation Error" })
|
|
3511
3554
|
] })
|
|
3512
3555
|
] }, `${diff.uid}-${diff.documentId}-${diff.attribute}-${idx}`)) })
|
|
3513
3556
|
] })
|
|
@@ -3585,6 +3628,1295 @@ const CheckerReviewModal = ({
|
|
|
3585
3628
|
}
|
|
3586
3629
|
);
|
|
3587
3630
|
};
|
|
3631
|
+
function formatComponentNameFriendly(compUid) {
|
|
3632
|
+
if (!compUid) return "Component";
|
|
3633
|
+
const name = compUid.includes(".") ? compUid.split(".")[1] : compUid;
|
|
3634
|
+
return name.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3635
|
+
}
|
|
3636
|
+
function parseAttrPathClient(path) {
|
|
3637
|
+
if (!path) return { cleanPath: "", rootKey: "", subPath: "" };
|
|
3638
|
+
const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\](?:\.(.+))?$/);
|
|
3639
|
+
if (bracketMatch) {
|
|
3640
|
+
const rootKey = bracketMatch[1];
|
|
3641
|
+
const selector = bracketMatch[2].trim();
|
|
3642
|
+
const subPath = bracketMatch[3] || "";
|
|
3643
|
+
const cleanPath = subPath ? `${rootKey}.${subPath}` : rootKey;
|
|
3644
|
+
if (/^\d+$/.test(selector)) {
|
|
3645
|
+
return { cleanPath, rootKey, subPath, targetIndex: parseInt(selector, 10) };
|
|
3646
|
+
}
|
|
3647
|
+
return { cleanPath, rootKey, subPath, targetComponentUid: selector };
|
|
3648
|
+
}
|
|
3649
|
+
const parts = path.split(".");
|
|
3650
|
+
return {
|
|
3651
|
+
cleanPath: path,
|
|
3652
|
+
rootKey: parts[0] || "",
|
|
3653
|
+
subPath: parts.slice(1).join(".")
|
|
3654
|
+
};
|
|
3655
|
+
}
|
|
3656
|
+
function buildOccurrenceKey(segments) {
|
|
3657
|
+
if (!segments || segments.length === 0) return "__scalar__";
|
|
3658
|
+
return segments.map((seg) => {
|
|
3659
|
+
if (seg.index !== void 0) {
|
|
3660
|
+
return seg.componentId !== void 0 && seg.componentId !== null ? `${seg.key}[${seg.index}#${seg.componentId}]` : `${seg.key}[${seg.index}]`;
|
|
3661
|
+
}
|
|
3662
|
+
return seg.key;
|
|
3663
|
+
}).join(".");
|
|
3664
|
+
}
|
|
3665
|
+
function buildReadablePath(segments) {
|
|
3666
|
+
if (!segments || segments.length === 0) return "";
|
|
3667
|
+
return segments.map((seg) => {
|
|
3668
|
+
if (seg.index !== void 0) {
|
|
3669
|
+
const label = seg.componentUid ? ` ${formatComponentNameFriendly(seg.componentUid)}` : "";
|
|
3670
|
+
return `${seg.key}[#${seg.index}${label}]`;
|
|
3671
|
+
}
|
|
3672
|
+
return seg.key;
|
|
3673
|
+
}).join(".");
|
|
3674
|
+
}
|
|
3675
|
+
function getDirectProp(obj, key) {
|
|
3676
|
+
if (!obj || typeof obj !== "object") return void 0;
|
|
3677
|
+
if (obj[key] !== void 0) return obj[key];
|
|
3678
|
+
const camel = key.replace(/_([a-z0-9])/g, (_, l) => l.toUpperCase());
|
|
3679
|
+
if (obj[camel] !== void 0) return obj[camel];
|
|
3680
|
+
const snake = key.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
3681
|
+
if (obj[snake] !== void 0) return obj[snake];
|
|
3682
|
+
return void 0;
|
|
3683
|
+
}
|
|
3684
|
+
function resolveTailExistsOrValue(obj, parts) {
|
|
3685
|
+
let cur = obj;
|
|
3686
|
+
for (const p of parts) {
|
|
3687
|
+
if (cur === null || cur === void 0) return void 0;
|
|
3688
|
+
if (Array.isArray(cur)) {
|
|
3689
|
+
for (const item of cur) {
|
|
3690
|
+
const found = resolveTailExistsOrValue(item, parts.slice(parts.indexOf(p)));
|
|
3691
|
+
if (found !== void 0) return found;
|
|
3692
|
+
}
|
|
3693
|
+
return void 0;
|
|
3694
|
+
}
|
|
3695
|
+
cur = getDirectProp(cur, p);
|
|
3696
|
+
}
|
|
3697
|
+
return cur;
|
|
3698
|
+
}
|
|
3699
|
+
function enumerateClientOccurrences(entry, attrPath, availableAttributes, attrMeta) {
|
|
3700
|
+
if (!entry || !attrPath) return [];
|
|
3701
|
+
const parsed = parseAttrPathClient(attrPath);
|
|
3702
|
+
const parts = parsed.cleanPath.split(".").filter(Boolean);
|
|
3703
|
+
if (parts.length === 0) return [];
|
|
3704
|
+
if (parts.length === 1 && !parsed.targetComponentUid && parsed.targetIndex === void 0) {
|
|
3705
|
+
const val = getDirectProp(entry, parts[0]);
|
|
3706
|
+
return [
|
|
3707
|
+
{
|
|
3708
|
+
occurrenceKey: "__scalar__",
|
|
3709
|
+
displayPath: parts[0],
|
|
3710
|
+
segments: [{ key: parts[0] }],
|
|
3711
|
+
value: val !== void 0 ? val : null,
|
|
3712
|
+
index: 0,
|
|
3713
|
+
isMissingIntermediate: false
|
|
3714
|
+
}
|
|
3715
|
+
];
|
|
3716
|
+
}
|
|
3717
|
+
const results = [];
|
|
3718
|
+
function walk(currentVal, remainingParts, segments, missingIntermediate, firstArrayIndex, resolvedCompUid, resolvedCompId, isRootLevel) {
|
|
3719
|
+
if (remainingParts.length === 0) return;
|
|
3720
|
+
const [head, ...tail] = remainingParts;
|
|
3721
|
+
if (tail.length === 0) {
|
|
3722
|
+
const val = currentVal && typeof currentVal === "object" ? getDirectProp(currentVal, head) : void 0;
|
|
3723
|
+
const nextSegs = [...segments, { key: head }];
|
|
3724
|
+
results.push({
|
|
3725
|
+
occurrenceKey: buildOccurrenceKey(nextSegs),
|
|
3726
|
+
displayPath: buildReadablePath(nextSegs),
|
|
3727
|
+
segments: nextSegs,
|
|
3728
|
+
value: val !== void 0 ? val : null,
|
|
3729
|
+
componentUid: resolvedCompUid,
|
|
3730
|
+
componentName: resolvedCompUid ? formatComponentNameFriendly(resolvedCompUid) : void 0,
|
|
3731
|
+
componentId: resolvedCompId,
|
|
3732
|
+
index: firstArrayIndex ?? 0,
|
|
3733
|
+
isMissingIntermediate: missingIntermediate
|
|
3734
|
+
});
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3737
|
+
const nextVal = currentVal && typeof currentVal === "object" ? getDirectProp(currentVal, head) : void 0;
|
|
3738
|
+
const isExpectingRootArray = isRootLevel && (attrMeta?.rootType === "dynamiczone" || attrMeta?.rootRepeatable);
|
|
3739
|
+
if (Array.isArray(nextVal)) {
|
|
3740
|
+
const subPath = tail.join(".");
|
|
3741
|
+
nextVal.forEach((item, idx) => {
|
|
3742
|
+
if (!item || typeof item !== "object") return;
|
|
3743
|
+
if (isRootLevel && parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
|
|
3744
|
+
if (isRootLevel && parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
|
|
3745
|
+
if (item.__component && isRootLevel) {
|
|
3746
|
+
const scopedAttr = `${head}[${item.__component}].${subPath}`;
|
|
3747
|
+
const supportedBySchema = Array.isArray(availableAttributes) && availableAttributes.includes(scopedAttr);
|
|
3748
|
+
const presentInData = resolveTailExistsOrValue(item, tail) !== void 0;
|
|
3749
|
+
if (!supportedBySchema && !presentInData) {
|
|
3750
|
+
return;
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
const seg2 = {
|
|
3754
|
+
key: head,
|
|
3755
|
+
index: idx,
|
|
3756
|
+
componentId: item.id,
|
|
3757
|
+
componentUid: item.__component || (isRootLevel ? attrMeta?.component : void 0)
|
|
3758
|
+
};
|
|
3759
|
+
walk(
|
|
3760
|
+
item,
|
|
3761
|
+
tail,
|
|
3762
|
+
[...segments, seg2],
|
|
3763
|
+
missingIntermediate,
|
|
3764
|
+
firstArrayIndex ?? idx,
|
|
3765
|
+
item.__component || resolvedCompUid,
|
|
3766
|
+
resolvedCompId ?? item.id,
|
|
3767
|
+
false
|
|
3768
|
+
);
|
|
3769
|
+
});
|
|
3770
|
+
return;
|
|
3771
|
+
}
|
|
3772
|
+
if (isExpectingRootArray) {
|
|
3773
|
+
return;
|
|
3774
|
+
}
|
|
3775
|
+
const isMissing = !nextVal || typeof nextVal !== "object";
|
|
3776
|
+
const seg = {
|
|
3777
|
+
key: head,
|
|
3778
|
+
componentId: !isMissing ? nextVal.id : void 0,
|
|
3779
|
+
componentUid: !isMissing && nextVal.__component ? nextVal.__component : void 0
|
|
3780
|
+
};
|
|
3781
|
+
walk(
|
|
3782
|
+
isMissing ? void 0 : nextVal,
|
|
3783
|
+
tail,
|
|
3784
|
+
[...segments, seg],
|
|
3785
|
+
missingIntermediate || isMissing,
|
|
3786
|
+
firstArrayIndex,
|
|
3787
|
+
resolvedCompUid,
|
|
3788
|
+
resolvedCompId,
|
|
3789
|
+
false
|
|
3790
|
+
);
|
|
3791
|
+
}
|
|
3792
|
+
walk(entry, parts, [], false, void 0, void 0, void 0, true);
|
|
3793
|
+
return results;
|
|
3794
|
+
}
|
|
3795
|
+
function normalizeDisplayCompareValue(v) {
|
|
3796
|
+
if (v === void 0 || v === null) return null;
|
|
3797
|
+
if (typeof v === "object" && v.isRelation) return v;
|
|
3798
|
+
return v;
|
|
3799
|
+
}
|
|
3800
|
+
function areClientValuesEqual(a, b) {
|
|
3801
|
+
const na = normalizeDisplayCompareValue(a);
|
|
3802
|
+
const nb = normalizeDisplayCompareValue(b);
|
|
3803
|
+
if (na === nb) return true;
|
|
3804
|
+
if (na === null || nb === null) return na === nb;
|
|
3805
|
+
if (typeof na === "object" || typeof nb === "object") {
|
|
3806
|
+
try {
|
|
3807
|
+
return JSON.stringify(na) === JSON.stringify(nb);
|
|
3808
|
+
} catch {
|
|
3809
|
+
return false;
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
return String(na) === String(nb);
|
|
3813
|
+
}
|
|
3814
|
+
function extractRelationEditCommand(rawVal, currentDisplayVal, isMulti = false) {
|
|
3815
|
+
if (rawVal && typeof rawVal === "object" && !Array.isArray(rawVal) && rawVal.mode) {
|
|
3816
|
+
return {
|
|
3817
|
+
mode: rawVal.mode,
|
|
3818
|
+
documentIds: Array.isArray(rawVal.documentIds) ? rawVal.documentIds : rawVal.documentId ? [rawVal.documentId] : [],
|
|
3819
|
+
label: rawVal.label || ""
|
|
3820
|
+
};
|
|
3821
|
+
}
|
|
3822
|
+
if (Array.isArray(rawVal)) {
|
|
3823
|
+
return {
|
|
3824
|
+
mode: "set",
|
|
3825
|
+
documentIds: rawVal.map((r) => r?.documentId).filter(Boolean),
|
|
3826
|
+
label: rawVal.map((r) => r?.name || r?.title || r?.email || r?.documentId).filter(Boolean).join(", ")
|
|
3827
|
+
};
|
|
3828
|
+
}
|
|
3829
|
+
if (rawVal && typeof rawVal === "object" && rawVal.documentId) {
|
|
3830
|
+
return {
|
|
3831
|
+
mode: "set",
|
|
3832
|
+
documentIds: [rawVal.documentId],
|
|
3833
|
+
label: rawVal.name || rawVal.title || rawVal.email || rawVal.documentId
|
|
3834
|
+
};
|
|
3835
|
+
}
|
|
3836
|
+
if (typeof rawVal === "string") {
|
|
3837
|
+
try {
|
|
3838
|
+
const parsed = JSON.parse(rawVal);
|
|
3839
|
+
if (parsed && typeof parsed === "object" && parsed.mode) {
|
|
3840
|
+
return {
|
|
3841
|
+
mode: parsed.mode,
|
|
3842
|
+
documentIds: Array.isArray(parsed.documentIds) ? parsed.documentIds : [],
|
|
3843
|
+
label: parsed.label || ""
|
|
3844
|
+
};
|
|
3845
|
+
}
|
|
3846
|
+
} catch {
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
if (currentDisplayVal) {
|
|
3850
|
+
return extractRelationEditCommand(currentDisplayVal, void 0, isMulti);
|
|
3851
|
+
}
|
|
3852
|
+
return { mode: "clear", documentIds: [], label: "" };
|
|
3853
|
+
}
|
|
3854
|
+
function validateClientFieldValue(value, attrMeta) {
|
|
3855
|
+
if (!attrMeta) return null;
|
|
3856
|
+
const type = String(attrMeta.type || "").toLowerCase();
|
|
3857
|
+
const isEmpty = value === null || value === void 0 || value === "";
|
|
3858
|
+
if (attrMeta.required && isEmpty && type !== "boolean") {
|
|
3859
|
+
return "Required field";
|
|
3860
|
+
}
|
|
3861
|
+
if (attrMeta.required && type === "boolean" && (value === null || value === void 0 || value === "")) {
|
|
3862
|
+
return "Required boolean";
|
|
3863
|
+
}
|
|
3864
|
+
if (isEmpty) return null;
|
|
3865
|
+
switch (type) {
|
|
3866
|
+
case "integer":
|
|
3867
|
+
case "biginteger": {
|
|
3868
|
+
const s = String(value).trim();
|
|
3869
|
+
if (!/^-?\d+$/.test(s)) return "Must be a valid integer";
|
|
3870
|
+
if (type === "integer") {
|
|
3871
|
+
const n = Number(s);
|
|
3872
|
+
if (!Number.isSafeInteger(n)) return "Integer out of range";
|
|
3873
|
+
if (typeof attrMeta.min === "number" && n < attrMeta.min) return `Min ${attrMeta.min}`;
|
|
3874
|
+
if (typeof attrMeta.max === "number" && n > attrMeta.max) return `Max ${attrMeta.max}`;
|
|
3875
|
+
}
|
|
3876
|
+
return null;
|
|
3877
|
+
}
|
|
3878
|
+
case "float":
|
|
3879
|
+
case "decimal": {
|
|
3880
|
+
const s = String(value).trim();
|
|
3881
|
+
if (!/^-?\d+(\.\d+)?$/.test(s)) return "Must be a valid number";
|
|
3882
|
+
const n = Number(s);
|
|
3883
|
+
if (typeof attrMeta.min === "number" && n < attrMeta.min) return `Min ${attrMeta.min}`;
|
|
3884
|
+
if (typeof attrMeta.max === "number" && n > attrMeta.max) return `Max ${attrMeta.max}`;
|
|
3885
|
+
return null;
|
|
3886
|
+
}
|
|
3887
|
+
case "boolean": {
|
|
3888
|
+
if (typeof value === "boolean") return null;
|
|
3889
|
+
const lower = String(value).trim().toLowerCase();
|
|
3890
|
+
if (!["true", "false", "1", "0"].includes(lower)) return "Must be true or false";
|
|
3891
|
+
return null;
|
|
3892
|
+
}
|
|
3893
|
+
case "enumeration": {
|
|
3894
|
+
if (Array.isArray(attrMeta.enumOptions) && !attrMeta.enumOptions.includes(String(value))) {
|
|
3895
|
+
return `Must be one of: ${attrMeta.enumOptions.join(", ")}`;
|
|
3896
|
+
}
|
|
3897
|
+
return null;
|
|
3898
|
+
}
|
|
3899
|
+
case "email": {
|
|
3900
|
+
const s = String(value).trim();
|
|
3901
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)) return "Invalid email";
|
|
3902
|
+
return null;
|
|
3903
|
+
}
|
|
3904
|
+
case "uid": {
|
|
3905
|
+
const s = String(value).trim();
|
|
3906
|
+
if (!/^[A-Za-z0-9\-_.~]*$/.test(s)) return "Invalid UID format";
|
|
3907
|
+
return null;
|
|
3908
|
+
}
|
|
3909
|
+
case "json":
|
|
3910
|
+
case "blocks": {
|
|
3911
|
+
if (typeof value === "string") {
|
|
3912
|
+
try {
|
|
3913
|
+
const parsed = JSON.parse(value);
|
|
3914
|
+
if (type === "blocks" && parsed !== null && !Array.isArray(parsed)) {
|
|
3915
|
+
return "Blocks must be a JSON array";
|
|
3916
|
+
}
|
|
3917
|
+
} catch (err) {
|
|
3918
|
+
return `Invalid JSON: ${err.message}`;
|
|
3919
|
+
}
|
|
3920
|
+
} else if (type === "blocks" && !Array.isArray(value)) {
|
|
3921
|
+
return "Blocks must be an array";
|
|
3922
|
+
}
|
|
3923
|
+
return null;
|
|
3924
|
+
}
|
|
3925
|
+
case "date":
|
|
3926
|
+
case "datetime": {
|
|
3927
|
+
const d = new Date(String(value).trim());
|
|
3928
|
+
if (isNaN(d.getTime())) return "Invalid date/datetime";
|
|
3929
|
+
return null;
|
|
3930
|
+
}
|
|
3931
|
+
case "time": {
|
|
3932
|
+
if (!/^\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/.test(String(value).trim())) {
|
|
3933
|
+
return "Invalid time (HH:mm or HH:mm:ss)";
|
|
3934
|
+
}
|
|
3935
|
+
return null;
|
|
3936
|
+
}
|
|
3937
|
+
default: {
|
|
3938
|
+
const str = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
3939
|
+
if (typeof attrMeta.minLength === "number" && str.length < attrMeta.minLength) {
|
|
3940
|
+
return `Min length ${attrMeta.minLength}`;
|
|
3941
|
+
}
|
|
3942
|
+
if (typeof attrMeta.maxLength === "number" && str.length > attrMeta.maxLength) {
|
|
3943
|
+
return `Max length ${attrMeta.maxLength}`;
|
|
3944
|
+
}
|
|
3945
|
+
if (attrMeta.regex) {
|
|
3946
|
+
try {
|
|
3947
|
+
if (!new RegExp(attrMeta.regex).test(str)) return `Must match /${attrMeta.regex}/`;
|
|
3948
|
+
} catch {
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
return null;
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
function cleanRuleKey(str) {
|
|
3956
|
+
return (str || "").replace(/[-_]/g, "").toLowerCase().trim();
|
|
3957
|
+
}
|
|
3958
|
+
function matchesFieldRulePath(attrPath, targetField) {
|
|
3959
|
+
if (!attrPath || !targetField) return false;
|
|
3960
|
+
const cleanAttr = parseAttrPathClient(attrPath).cleanPath;
|
|
3961
|
+
const parts = cleanAttr.split(".").map(cleanRuleKey).filter(Boolean);
|
|
3962
|
+
const leaf = parts[parts.length - 1] || "";
|
|
3963
|
+
const targetClean = cleanRuleKey(targetField.replace(/^api::/i, ""));
|
|
3964
|
+
if (leaf === targetClean || cleanRuleKey(cleanAttr) === targetClean) return true;
|
|
3965
|
+
const tSegs = targetField.replace(/^api::/i, "").split(".").map(cleanRuleKey).filter(Boolean);
|
|
3966
|
+
if (tSegs.length === 1) return leaf === tSegs[0];
|
|
3967
|
+
return tSegs.every((t) => t === "*" || parts.includes(t));
|
|
3968
|
+
}
|
|
3969
|
+
function computeRecordQuotaUsage(entry, attrPath, excludeOccurrenceKey, recordEdits, colAttributes, attrMeta, validationRules) {
|
|
3970
|
+
const occs = enumerateClientOccurrences(entry, attrPath, colAttributes, attrMeta);
|
|
3971
|
+
const usageCounts = {};
|
|
3972
|
+
for (const occ of occs) {
|
|
3973
|
+
if (occ.occurrenceKey === excludeOccurrenceKey) continue;
|
|
3974
|
+
const edited = recordEdits?.occurrences?.[occ.occurrenceKey];
|
|
3975
|
+
const effectiveVal = edited ? edited.value : occ.value;
|
|
3976
|
+
if (effectiveVal !== void 0 && effectiveVal !== null && String(effectiveVal).trim() !== "") {
|
|
3977
|
+
const k = String(effectiveVal).toLowerCase().trim();
|
|
3978
|
+
usageCounts[k] = (usageCounts[k] || 0) + 1;
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
const quotas = {};
|
|
3982
|
+
if (attrMeta?.options?.items) {
|
|
3983
|
+
for (const item of attrMeta.options.items) {
|
|
3984
|
+
if (typeof item.maxAllowed === "number" && item.maxAllowed > 0) {
|
|
3985
|
+
quotas[item.value.toLowerCase().trim()] = item.maxAllowed;
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
if (attrMeta?.options?.quotas) {
|
|
3990
|
+
for (const [k, v] of Object.entries(attrMeta.options.quotas)) {
|
|
3991
|
+
if (typeof v === "number" && v > 0) quotas[k.toLowerCase().trim()] = v;
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
for (const rule of validationRules || []) {
|
|
3995
|
+
if (!rule.enabled) continue;
|
|
3996
|
+
if (rule.targetField && !matchesFieldRulePath(attrPath, rule.targetField)) continue;
|
|
3997
|
+
for (const [k, v] of Object.entries(rule.quotas || {})) {
|
|
3998
|
+
if (typeof v === "number" && v > 0) quotas[k.toLowerCase().trim()] = v;
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
return { usageCounts, quotas };
|
|
4002
|
+
}
|
|
4003
|
+
function serializeGridTargets(gridEdits, selectedEntries, collectionPages = {}, attrMeta) {
|
|
4004
|
+
const targets = [];
|
|
4005
|
+
let totalEditCount = 0;
|
|
4006
|
+
let hasValidationErrors = false;
|
|
4007
|
+
for (const [key, rec] of Object.entries(gridEdits)) {
|
|
4008
|
+
if (!selectedEntries[key]) continue;
|
|
4009
|
+
const occEntries = Object.values(rec.occurrences || {});
|
|
4010
|
+
if (occEntries.length === 0) continue;
|
|
4011
|
+
for (const occ of occEntries) {
|
|
4012
|
+
if (occ.validationError) {
|
|
4013
|
+
hasValidationErrors = true;
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
const colPage = collectionPages[rec.uid];
|
|
4017
|
+
const cachedEntry = colPage?.entries?.find((e) => e.documentId === rec.documentId);
|
|
4018
|
+
const targetObj = {
|
|
4019
|
+
uid: rec.uid,
|
|
4020
|
+
documentId: rec.documentId,
|
|
4021
|
+
status: cachedEntry?.status ?? rec.status,
|
|
4022
|
+
publishedAt: cachedEntry?.publishedAt ?? rec.publishedAt,
|
|
4023
|
+
locale: cachedEntry?.locale ?? rec.locale
|
|
4024
|
+
};
|
|
4025
|
+
const isScalarOnly = occEntries.length === 1 && occEntries[0].occurrenceKey === "__scalar__" && !attrMeta?.rootType;
|
|
4026
|
+
if (isScalarOnly) {
|
|
4027
|
+
targetObj.overrideValue = occEntries[0].value;
|
|
4028
|
+
totalEditCount += 1;
|
|
4029
|
+
} else {
|
|
4030
|
+
targetObj.occurrenceUpdates = occEntries.map((occ) => ({
|
|
4031
|
+
occurrenceKey: occ.occurrenceKey,
|
|
4032
|
+
segments: occ.segments,
|
|
4033
|
+
dynamicZoneIndex: occ.segments?.[0]?.index,
|
|
4034
|
+
componentId: occ.segments?.find((s) => s.componentId !== void 0)?.componentId,
|
|
4035
|
+
componentUid: occ.segments?.find((s) => s.componentUid)?.componentUid,
|
|
4036
|
+
value: occ.value
|
|
4037
|
+
}));
|
|
4038
|
+
totalEditCount += occEntries.length;
|
|
4039
|
+
}
|
|
4040
|
+
targets.push(targetObj);
|
|
4041
|
+
}
|
|
4042
|
+
return { targets, totalEditCount, hasValidationErrors };
|
|
4043
|
+
}
|
|
4044
|
+
const DEFAULT_HEADING_ITEMS = [
|
|
4045
|
+
{ value: "h1", label: "H1 - Main Page Title", maxAllowed: 1 },
|
|
4046
|
+
{ value: "h2", label: "H2 - Primary Section Heading", maxAllowed: 3 },
|
|
4047
|
+
{ value: "h3", label: "H3 - Sub-section Heading", maxAllowed: null },
|
|
4048
|
+
{ value: "h4", label: "H4 - Component Title", maxAllowed: null },
|
|
4049
|
+
{ value: "h5", label: "H5 - Card / Item Heading", maxAllowed: null },
|
|
4050
|
+
{ value: "h6", label: "H6 - Minor Heading", maxAllowed: null }
|
|
4051
|
+
];
|
|
4052
|
+
function toTextInputString(val, type) {
|
|
4053
|
+
if (val === null || val === void 0) return "";
|
|
4054
|
+
if (type === "date" && typeof val === "string") {
|
|
4055
|
+
return val.slice(0, 10);
|
|
4056
|
+
}
|
|
4057
|
+
if (type === "datetime" && typeof val === "string") {
|
|
4058
|
+
const d = new Date(val);
|
|
4059
|
+
if (!isNaN(d.getTime())) {
|
|
4060
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
4061
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
4062
|
+
}
|
|
4063
|
+
return val.slice(0, 16);
|
|
4064
|
+
}
|
|
4065
|
+
if (type === "time" && typeof val === "string") {
|
|
4066
|
+
return val.slice(0, 8);
|
|
4067
|
+
}
|
|
4068
|
+
if (typeof val === "object") {
|
|
4069
|
+
try {
|
|
4070
|
+
return JSON.stringify(val);
|
|
4071
|
+
} catch {
|
|
4072
|
+
return String(val);
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
return String(val);
|
|
4076
|
+
}
|
|
4077
|
+
const GridCellEditor = React__default.memo(
|
|
4078
|
+
({
|
|
4079
|
+
entry,
|
|
4080
|
+
attribute,
|
|
4081
|
+
occurrence,
|
|
4082
|
+
attrMeta,
|
|
4083
|
+
editedValue,
|
|
4084
|
+
isDirty,
|
|
4085
|
+
validationError,
|
|
4086
|
+
relationOptions = [],
|
|
4087
|
+
relationOptionsLoading = false,
|
|
4088
|
+
relationIsMulti = false,
|
|
4089
|
+
validationRules = [],
|
|
4090
|
+
recordEdits,
|
|
4091
|
+
colAttributes,
|
|
4092
|
+
compact = false,
|
|
4093
|
+
onCommit,
|
|
4094
|
+
onReset
|
|
4095
|
+
}) => {
|
|
4096
|
+
const { get } = useFetchClient();
|
|
4097
|
+
const fieldType = String(attrMeta?.type || "").toLowerCase();
|
|
4098
|
+
const isScopedSelect = attrMeta?.customField === "plugin::bulk-updater.scoped-select" || attrMeta?.customField === "global::scoped-select";
|
|
4099
|
+
const isRelation = Boolean(attrMeta?.isRelation || fieldType === "relation");
|
|
4100
|
+
const isMultiRelation = isRelation && Boolean(relationIsMulti || ["oneToMany", "manyToMany"].includes(attrMeta?.relationType || ""));
|
|
4101
|
+
const effectiveValue = isDirty ? editedValue : occurrence.value;
|
|
4102
|
+
const [localText, setLocalText] = useState(() => toTextInputString(effectiveValue, fieldType));
|
|
4103
|
+
const [showRichModal, setShowRichModal] = useState(false);
|
|
4104
|
+
const [richDraft, setRichDraft] = useState("");
|
|
4105
|
+
const [richError, setRichError] = useState(null);
|
|
4106
|
+
const [showMultiRelModal, setShowMultiRelModal] = useState(false);
|
|
4107
|
+
const [multiRelSelected, setMultiRelSelected] = useState([]);
|
|
4108
|
+
const [multiRelMode, setMultiRelMode] = useState("set");
|
|
4109
|
+
const [multiRelSearch, setMultiRelSearch] = useState("");
|
|
4110
|
+
const [showMediaModal, setShowMediaModal] = useState(false);
|
|
4111
|
+
const [mediaOptions, setMediaOptions] = useState([]);
|
|
4112
|
+
const [mediaSearch, setMediaSearch] = useState("");
|
|
4113
|
+
const [mediaLoading, setMediaLoading] = useState(false);
|
|
4114
|
+
const [selectedMediaIds, setSelectedMediaIds] = useState([]);
|
|
4115
|
+
useEffect(() => {
|
|
4116
|
+
setLocalText(toTextInputString(effectiveValue, fieldType));
|
|
4117
|
+
}, [effectiveValue, fieldType, occurrence.occurrenceKey]);
|
|
4118
|
+
const commitTypedValue = (rawVal) => {
|
|
4119
|
+
if (areClientValuesEqual(rawVal, occurrence.value)) {
|
|
4120
|
+
onReset(occurrence.occurrenceKey);
|
|
4121
|
+
return;
|
|
4122
|
+
}
|
|
4123
|
+
const err = validateClientFieldValue(rawVal, attrMeta);
|
|
4124
|
+
onCommit(occurrence, rawVal, err);
|
|
4125
|
+
};
|
|
4126
|
+
const loadMediaLibrary = async (query = "") => {
|
|
4127
|
+
try {
|
|
4128
|
+
setMediaLoading(true);
|
|
4129
|
+
const res = await get(`/bulk-updater/media-options?search=${encodeURIComponent(query)}`);
|
|
4130
|
+
if (res.data?.success && Array.isArray(res.data.options)) {
|
|
4131
|
+
setMediaOptions(res.data.options);
|
|
4132
|
+
}
|
|
4133
|
+
} catch {
|
|
4134
|
+
setMediaOptions([]);
|
|
4135
|
+
} finally {
|
|
4136
|
+
setMediaLoading(false);
|
|
4137
|
+
}
|
|
4138
|
+
};
|
|
4139
|
+
const quotaContext = useMemo(() => {
|
|
4140
|
+
if (!isScopedSelect) return null;
|
|
4141
|
+
return computeRecordQuotaUsage(
|
|
4142
|
+
entry,
|
|
4143
|
+
attribute,
|
|
4144
|
+
occurrence.occurrenceKey,
|
|
4145
|
+
recordEdits,
|
|
4146
|
+
colAttributes,
|
|
4147
|
+
attrMeta,
|
|
4148
|
+
validationRules
|
|
4149
|
+
);
|
|
4150
|
+
}, [isScopedSelect, entry, attribute, occurrence.occurrenceKey, recordEdits, colAttributes, attrMeta, validationRules]);
|
|
4151
|
+
const scopedItems = useMemo(() => {
|
|
4152
|
+
if (!isScopedSelect) return [];
|
|
4153
|
+
const base = attrMeta?.options?.items && attrMeta.options.items.length > 0 ? attrMeta.options.items : DEFAULT_HEADING_ITEMS;
|
|
4154
|
+
const quotas = quotaContext?.quotas || {};
|
|
4155
|
+
return base.map((it) => {
|
|
4156
|
+
const key = it.value.toLowerCase().trim();
|
|
4157
|
+
const maxAllowed = typeof quotas[key] === "number" ? quotas[key] : it.maxAllowed;
|
|
4158
|
+
const usedBySiblings = quotaContext?.usageCounts?.[key] || 0;
|
|
4159
|
+
return {
|
|
4160
|
+
...it,
|
|
4161
|
+
maxAllowed,
|
|
4162
|
+
usedBySiblings,
|
|
4163
|
+
atLimit: typeof maxAllowed === "number" && maxAllowed > 0 && usedBySiblings >= maxAllowed
|
|
4164
|
+
};
|
|
4165
|
+
});
|
|
4166
|
+
}, [isScopedSelect, attrMeta, quotaContext]);
|
|
4167
|
+
const wrapperStyle = {
|
|
4168
|
+
borderLeft: isDirty ? "3px solid #4945ff" : "3px solid transparent",
|
|
4169
|
+
paddingLeft: 6,
|
|
4170
|
+
backgroundColor: validationError ? "rgba(208, 43, 32, 0.06)" : isDirty ? "rgba(73, 69, 255, 0.05)" : "transparent",
|
|
4171
|
+
borderRadius: 4,
|
|
4172
|
+
minWidth: compact ? 180 : 210,
|
|
4173
|
+
maxWidth: 320
|
|
4174
|
+
};
|
|
4175
|
+
const renderResetBtn = () => isDirty ? /* @__PURE__ */ jsx(
|
|
4176
|
+
Button,
|
|
4177
|
+
{
|
|
4178
|
+
variant: "ghost",
|
|
4179
|
+
size: "S",
|
|
4180
|
+
onClick: () => onReset(occurrence.occurrenceKey),
|
|
4181
|
+
title: "Revert this cell back to original database value",
|
|
4182
|
+
style: { padding: "4px 6px", minWidth: 28, height: 28 },
|
|
4183
|
+
children: /* @__PURE__ */ jsx(ArrowClockwise, {})
|
|
4184
|
+
}
|
|
4185
|
+
) : null;
|
|
4186
|
+
if (isScopedSelect) {
|
|
4187
|
+
const currentValStr = effectiveValue !== null && effectiveValue !== void 0 ? String(effectiveValue) : "__clear__";
|
|
4188
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4189
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4190
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 145 }, children: /* @__PURE__ */ jsxs(
|
|
4191
|
+
SingleSelect,
|
|
4192
|
+
{
|
|
4193
|
+
size: "S",
|
|
4194
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4195
|
+
value: currentValStr,
|
|
4196
|
+
onChange: (val) => {
|
|
4197
|
+
const s = String(val);
|
|
4198
|
+
commitTypedValue(s === "__clear__" ? null : s);
|
|
4199
|
+
},
|
|
4200
|
+
children: [
|
|
4201
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "__clear__", children: "-- Unset --" }),
|
|
4202
|
+
scopedItems.map((it) => {
|
|
4203
|
+
const isCurrentlySelected = currentValStr.toLowerCase() === it.value.toLowerCase();
|
|
4204
|
+
const quotaNote = typeof it.maxAllowed === "number" && it.maxAllowed > 0 ? ` (${it.usedBySiblings + (isCurrentlySelected ? 1 : 0)}/${it.maxAllowed})` : "";
|
|
4205
|
+
return /* @__PURE__ */ jsxs(SingleSelectOption, { value: it.value, children: [
|
|
4206
|
+
it.label,
|
|
4207
|
+
quotaNote,
|
|
4208
|
+
it.atLimit && !isCurrentlySelected ? " [QUOTA FULL]" : ""
|
|
4209
|
+
] }, it.value);
|
|
4210
|
+
})
|
|
4211
|
+
]
|
|
4212
|
+
}
|
|
4213
|
+
) }),
|
|
4214
|
+
renderResetBtn()
|
|
4215
|
+
] }),
|
|
4216
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem", marginTop: 2 }, children: validationError })
|
|
4217
|
+
] });
|
|
4218
|
+
}
|
|
4219
|
+
if (fieldType === "enumeration" && Array.isArray(attrMeta?.enumOptions)) {
|
|
4220
|
+
const currentValStr = effectiveValue !== null && effectiveValue !== void 0 && effectiveValue !== "" ? String(effectiveValue) : "__clear__";
|
|
4221
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4222
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4223
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 145 }, children: /* @__PURE__ */ jsxs(
|
|
4224
|
+
SingleSelect,
|
|
4225
|
+
{
|
|
4226
|
+
size: "S",
|
|
4227
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4228
|
+
value: currentValStr,
|
|
4229
|
+
onChange: (val) => {
|
|
4230
|
+
const s = String(val);
|
|
4231
|
+
commitTypedValue(s === "__clear__" ? null : s);
|
|
4232
|
+
},
|
|
4233
|
+
children: [
|
|
4234
|
+
!attrMeta.required && /* @__PURE__ */ jsx(SingleSelectOption, { value: "__clear__", children: "-- Clear (null) --" }),
|
|
4235
|
+
attrMeta.enumOptions.map((opt) => /* @__PURE__ */ jsx(SingleSelectOption, { value: opt, children: opt }, opt))
|
|
4236
|
+
]
|
|
4237
|
+
}
|
|
4238
|
+
) }),
|
|
4239
|
+
renderResetBtn()
|
|
4240
|
+
] }),
|
|
4241
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
|
|
4242
|
+
] });
|
|
4243
|
+
}
|
|
4244
|
+
if (fieldType === "boolean") {
|
|
4245
|
+
const strVal = effectiveValue === true ? "true" : effectiveValue === false ? "false" : "__unset__";
|
|
4246
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4247
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4248
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 120 }, children: /* @__PURE__ */ jsxs(
|
|
4249
|
+
SingleSelect,
|
|
4250
|
+
{
|
|
4251
|
+
size: "S",
|
|
4252
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4253
|
+
value: strVal,
|
|
4254
|
+
onChange: (val) => {
|
|
4255
|
+
const s = String(val);
|
|
4256
|
+
commitTypedValue(s === "true" ? true : s === "false" ? false : null);
|
|
4257
|
+
},
|
|
4258
|
+
children: [
|
|
4259
|
+
!attrMeta?.required && /* @__PURE__ */ jsx(SingleSelectOption, { value: "__unset__", children: "-- Unset --" }),
|
|
4260
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "true", children: "true" }),
|
|
4261
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "false", children: "false" })
|
|
4262
|
+
]
|
|
4263
|
+
}
|
|
4264
|
+
) }),
|
|
4265
|
+
renderResetBtn()
|
|
4266
|
+
] }),
|
|
4267
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
|
|
4268
|
+
] });
|
|
4269
|
+
}
|
|
4270
|
+
if (isRelation) {
|
|
4271
|
+
const cmd = extractRelationEditCommand(effectiveValue, occurrence.value, isMultiRelation);
|
|
4272
|
+
if (!isMultiRelation) {
|
|
4273
|
+
const selectedDocId = cmd.mode === "clear" ? "__clear__" : cmd.documentIds[0] || "__clear__";
|
|
4274
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4275
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4276
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 165 }, children: /* @__PURE__ */ jsxs(
|
|
4277
|
+
Combobox,
|
|
4278
|
+
{
|
|
4279
|
+
autocomplete: { type: "list", filter: "contains" },
|
|
4280
|
+
placeholder: relationOptionsLoading ? "Loading..." : "Pick relation...",
|
|
4281
|
+
value: selectedDocId,
|
|
4282
|
+
onChange: (val) => {
|
|
4283
|
+
const docId = val ? String(val) : "__clear__";
|
|
4284
|
+
if (docId === "__clear__") {
|
|
4285
|
+
commitTypedValue({ mode: "clear", documentIds: [], label: "(cleared / unlinked)" });
|
|
4286
|
+
} else {
|
|
4287
|
+
const opt = relationOptions.find((o) => o.documentId === docId);
|
|
4288
|
+
commitTypedValue({ mode: "set", documentIds: [docId], label: opt?.label || docId });
|
|
4289
|
+
}
|
|
4290
|
+
},
|
|
4291
|
+
children: [
|
|
4292
|
+
/* @__PURE__ */ jsx(ComboboxOption, { value: "__clear__", textValue: "Clear / Unlink Relation", children: "-- Clear / Unlink --" }),
|
|
4293
|
+
relationOptions.map((opt) => /* @__PURE__ */ jsx(ComboboxOption, { value: opt.documentId, textValue: opt.label, children: opt.label }, opt.documentId))
|
|
4294
|
+
]
|
|
4295
|
+
}
|
|
4296
|
+
) }),
|
|
4297
|
+
renderResetBtn()
|
|
4298
|
+
] }),
|
|
4299
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
|
|
4300
|
+
] });
|
|
4301
|
+
}
|
|
4302
|
+
const displaySummary = cmd.mode === "clear" ? "(cleared / empty)" : cmd.label || (cmd.documentIds.length > 0 ? `${cmd.documentIds.length} linked (${cmd.mode})` : "(unlinked)");
|
|
4303
|
+
const filteredRelOpts = relationOptions.filter(
|
|
4304
|
+
(o) => !multiRelSearch.trim() || o.label.toLowerCase().includes(multiRelSearch.toLowerCase())
|
|
4305
|
+
);
|
|
4306
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4307
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4308
|
+
/* @__PURE__ */ jsx(
|
|
4309
|
+
Button,
|
|
4310
|
+
{
|
|
4311
|
+
variant: "tertiary",
|
|
4312
|
+
size: "S",
|
|
4313
|
+
onClick: () => {
|
|
4314
|
+
setMultiRelSelected(cmd.documentIds || []);
|
|
4315
|
+
setMultiRelMode(cmd.mode === "clear" && (cmd.documentIds || []).length === 0 ? "set" : cmd.mode);
|
|
4316
|
+
setMultiRelSearch("");
|
|
4317
|
+
setShowMultiRelModal(true);
|
|
4318
|
+
},
|
|
4319
|
+
style: { maxWidth: 230, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
4320
|
+
children: displaySummary
|
|
4321
|
+
}
|
|
4322
|
+
),
|
|
4323
|
+
renderResetBtn()
|
|
4324
|
+
] }),
|
|
4325
|
+
showMultiRelModal && /* @__PURE__ */ jsx(
|
|
4326
|
+
"div",
|
|
4327
|
+
{
|
|
4328
|
+
style: {
|
|
4329
|
+
position: "fixed",
|
|
4330
|
+
inset: 0,
|
|
4331
|
+
backgroundColor: "rgba(20, 20, 30, 0.55)",
|
|
4332
|
+
zIndex: 9999,
|
|
4333
|
+
display: "flex",
|
|
4334
|
+
alignItems: "center",
|
|
4335
|
+
justifyContent: "center",
|
|
4336
|
+
padding: 16
|
|
4337
|
+
},
|
|
4338
|
+
onClick: () => setShowMultiRelModal(false),
|
|
4339
|
+
children: /* @__PURE__ */ jsxs(
|
|
4340
|
+
Box,
|
|
4341
|
+
{
|
|
4342
|
+
padding: 5,
|
|
4343
|
+
background: "neutral0",
|
|
4344
|
+
hasRadius: true,
|
|
4345
|
+
shadow: "popupShadow",
|
|
4346
|
+
style: { width: "92%", maxWidth: 520, maxHeight: "80vh", display: "flex", flexDirection: "column" },
|
|
4347
|
+
onClick: (e) => e.stopPropagation(),
|
|
4348
|
+
children: [
|
|
4349
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "delta", fontWeight: "bold", marginBottom: 2, children: [
|
|
4350
|
+
"Edit Multi-Relation: ",
|
|
4351
|
+
occurrence.displayPath
|
|
4352
|
+
] }),
|
|
4353
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, marginBottom: 3, alignItems: "center", children: [
|
|
4354
|
+
/* @__PURE__ */ jsx(Box, { style: { width: 180 }, children: /* @__PURE__ */ jsxs(
|
|
4355
|
+
SingleSelect,
|
|
4356
|
+
{
|
|
4357
|
+
label: "Operation",
|
|
4358
|
+
value: multiRelMode,
|
|
4359
|
+
onChange: (v) => setMultiRelMode(String(v)),
|
|
4360
|
+
children: [
|
|
4361
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "set", children: "Set / Replace All" }),
|
|
4362
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "connect", children: "Add / Connect" }),
|
|
4363
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "disconnect", children: "Remove / Disconnect" }),
|
|
4364
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "clear", children: "Clear All" })
|
|
4365
|
+
]
|
|
4366
|
+
}
|
|
4367
|
+
) }),
|
|
4368
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
|
|
4369
|
+
TextInput,
|
|
4370
|
+
{
|
|
4371
|
+
label: "Filter items",
|
|
4372
|
+
placeholder: "Search relations...",
|
|
4373
|
+
value: multiRelSearch,
|
|
4374
|
+
onChange: (e) => setMultiRelSearch(e.target.value)
|
|
4375
|
+
}
|
|
4376
|
+
) })
|
|
4377
|
+
] }),
|
|
4378
|
+
multiRelMode !== "clear" && /* @__PURE__ */ jsx(
|
|
4379
|
+
Box,
|
|
4380
|
+
{
|
|
4381
|
+
padding: 2,
|
|
4382
|
+
hasRadius: true,
|
|
4383
|
+
style: { border: "1px solid #eaeaef", overflowY: "auto", maxHeight: 280, marginBottom: 16 },
|
|
4384
|
+
children: filteredRelOpts.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "No target entities found." }) : filteredRelOpts.map((opt) => {
|
|
4385
|
+
const checked = multiRelSelected.includes(opt.documentId);
|
|
4386
|
+
return /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(
|
|
4387
|
+
Checkbox,
|
|
4388
|
+
{
|
|
4389
|
+
checked,
|
|
4390
|
+
onCheckedChange: (isChecked) => {
|
|
4391
|
+
setMultiRelSelected(
|
|
4392
|
+
(prev) => isChecked ? [...prev, opt.documentId] : prev.filter((id) => id !== opt.documentId)
|
|
4393
|
+
);
|
|
4394
|
+
},
|
|
4395
|
+
children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: opt.label })
|
|
4396
|
+
}
|
|
4397
|
+
) }, opt.documentId);
|
|
4398
|
+
})
|
|
4399
|
+
}
|
|
4400
|
+
),
|
|
4401
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "flex-end", gap: 2, children: [
|
|
4402
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: () => setShowMultiRelModal(false), children: "Cancel" }),
|
|
4403
|
+
/* @__PURE__ */ jsx(
|
|
4404
|
+
Button,
|
|
4405
|
+
{
|
|
4406
|
+
variant: "default",
|
|
4407
|
+
startIcon: /* @__PURE__ */ jsx(Check, {}),
|
|
4408
|
+
onClick: () => {
|
|
4409
|
+
if (multiRelMode === "clear") {
|
|
4410
|
+
commitTypedValue({ mode: "clear", documentIds: [], label: "(cleared / unlinked)" });
|
|
4411
|
+
} else {
|
|
4412
|
+
const labels = relationOptions.filter((o) => multiRelSelected.includes(o.documentId)).map((o) => o.label).join(", ");
|
|
4413
|
+
commitTypedValue({
|
|
4414
|
+
mode: multiRelMode,
|
|
4415
|
+
documentIds: multiRelSelected,
|
|
4416
|
+
label: labels || `${multiRelSelected.length} selected`
|
|
4417
|
+
});
|
|
4418
|
+
}
|
|
4419
|
+
setShowMultiRelModal(false);
|
|
4420
|
+
},
|
|
4421
|
+
children: "Apply Relation Edit"
|
|
4422
|
+
}
|
|
4423
|
+
)
|
|
4424
|
+
] })
|
|
4425
|
+
]
|
|
4426
|
+
}
|
|
4427
|
+
)
|
|
4428
|
+
}
|
|
4429
|
+
)
|
|
4430
|
+
] });
|
|
4431
|
+
}
|
|
4432
|
+
if (fieldType === "media") {
|
|
4433
|
+
const isMultiMedia = Boolean(attrMeta?.multiple);
|
|
4434
|
+
const currentIds = Array.isArray(effectiveValue) ? effectiveValue.map((v) => typeof v === "object" ? Number(v?.id) : Number(v)).filter((n) => !isNaN(n)) : typeof effectiveValue === "object" && effectiveValue?.id ? [Number(effectiveValue.id)] : typeof effectiveValue === "number" ? [effectiveValue] : [];
|
|
4435
|
+
const mediaSummary = currentIds.length === 0 ? "(no media — pick)" : Array.isArray(effectiveValue) ? `${currentIds.length} asset(s)` : effectiveValue?.name ? `${effectiveValue.name} (#${currentIds[0]})` : `Media #${currentIds[0]}`;
|
|
4436
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4437
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4438
|
+
/* @__PURE__ */ jsx(
|
|
4439
|
+
Button,
|
|
4440
|
+
{
|
|
4441
|
+
variant: "tertiary",
|
|
4442
|
+
size: "S",
|
|
4443
|
+
onClick: () => {
|
|
4444
|
+
setSelectedMediaIds(currentIds);
|
|
4445
|
+
setMediaSearch("");
|
|
4446
|
+
setShowMediaModal(true);
|
|
4447
|
+
loadMediaLibrary("");
|
|
4448
|
+
},
|
|
4449
|
+
style: { maxWidth: 220, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
4450
|
+
children: mediaSummary
|
|
4451
|
+
}
|
|
4452
|
+
),
|
|
4453
|
+
renderResetBtn()
|
|
4454
|
+
] }),
|
|
4455
|
+
showMediaModal && /* @__PURE__ */ jsx(
|
|
4456
|
+
"div",
|
|
4457
|
+
{
|
|
4458
|
+
style: {
|
|
4459
|
+
position: "fixed",
|
|
4460
|
+
inset: 0,
|
|
4461
|
+
backgroundColor: "rgba(20, 20, 30, 0.55)",
|
|
4462
|
+
zIndex: 9999,
|
|
4463
|
+
display: "flex",
|
|
4464
|
+
alignItems: "center",
|
|
4465
|
+
justifyContent: "center",
|
|
4466
|
+
padding: 16
|
|
4467
|
+
},
|
|
4468
|
+
onClick: () => setShowMediaModal(false),
|
|
4469
|
+
children: /* @__PURE__ */ jsxs(
|
|
4470
|
+
Box,
|
|
4471
|
+
{
|
|
4472
|
+
padding: 5,
|
|
4473
|
+
background: "neutral0",
|
|
4474
|
+
hasRadius: true,
|
|
4475
|
+
shadow: "popupShadow",
|
|
4476
|
+
style: { width: "92%", maxWidth: 620, maxHeight: "82vh", display: "flex", flexDirection: "column" },
|
|
4477
|
+
onClick: (e) => e.stopPropagation(),
|
|
4478
|
+
children: [
|
|
4479
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "delta", fontWeight: "bold", marginBottom: 3, children: [
|
|
4480
|
+
"Select Media Asset",
|
|
4481
|
+
isMultiMedia ? "s" : "",
|
|
4482
|
+
": ",
|
|
4483
|
+
occurrence.displayPath
|
|
4484
|
+
] }),
|
|
4485
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, marginBottom: 3, children: [
|
|
4486
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
|
|
4487
|
+
TextInput,
|
|
4488
|
+
{
|
|
4489
|
+
placeholder: "Search media filename or MIME...",
|
|
4490
|
+
value: mediaSearch,
|
|
4491
|
+
onChange: (e) => setMediaSearch(e.target.value)
|
|
4492
|
+
}
|
|
4493
|
+
) }),
|
|
4494
|
+
/* @__PURE__ */ jsx(
|
|
4495
|
+
Button,
|
|
4496
|
+
{
|
|
4497
|
+
variant: "secondary",
|
|
4498
|
+
startIcon: /* @__PURE__ */ jsx(Search, {}),
|
|
4499
|
+
onClick: () => loadMediaLibrary(mediaSearch),
|
|
4500
|
+
loading: mediaLoading,
|
|
4501
|
+
children: "Search"
|
|
4502
|
+
}
|
|
4503
|
+
)
|
|
4504
|
+
] }),
|
|
4505
|
+
/* @__PURE__ */ jsx(
|
|
4506
|
+
Box,
|
|
4507
|
+
{
|
|
4508
|
+
padding: 2,
|
|
4509
|
+
hasRadius: true,
|
|
4510
|
+
style: { border: "1px solid #eaeaef", overflowY: "auto", maxHeight: 320, marginBottom: 16 },
|
|
4511
|
+
children: mediaLoading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Loader, { small: true, children: "Loading Media Library..." }) }) : mediaOptions.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "No media files matched." }) : mediaOptions.map((file) => {
|
|
4512
|
+
const isChecked = selectedMediaIds.includes(file.id);
|
|
4513
|
+
return /* @__PURE__ */ jsx(Box, { padding: 2, style: { borderBottom: "1px solid #f0f0f5" }, children: /* @__PURE__ */ jsx(
|
|
4514
|
+
Checkbox,
|
|
4515
|
+
{
|
|
4516
|
+
checked: isChecked,
|
|
4517
|
+
onCheckedChange: (checked) => {
|
|
4518
|
+
if (isMultiMedia) {
|
|
4519
|
+
setSelectedMediaIds(
|
|
4520
|
+
(prev) => checked ? [...prev, file.id] : prev.filter((id) => id !== file.id)
|
|
4521
|
+
);
|
|
4522
|
+
} else {
|
|
4523
|
+
setSelectedMediaIds(checked ? [file.id] : []);
|
|
4524
|
+
}
|
|
4525
|
+
},
|
|
4526
|
+
children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
4527
|
+
/* @__PURE__ */ jsxs(Badge, { backgroundColor: "neutral150", textColor: "neutral700", size: "S", children: [
|
|
4528
|
+
"#",
|
|
4529
|
+
file.id
|
|
4530
|
+
] }),
|
|
4531
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", children: file.name }),
|
|
4532
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", children: [
|
|
4533
|
+
"(",
|
|
4534
|
+
file.mime,
|
|
4535
|
+
")"
|
|
4536
|
+
] })
|
|
4537
|
+
] })
|
|
4538
|
+
}
|
|
4539
|
+
) }, file.id);
|
|
4540
|
+
})
|
|
4541
|
+
}
|
|
4542
|
+
),
|
|
4543
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 2, children: [
|
|
4544
|
+
/* @__PURE__ */ jsx(
|
|
4545
|
+
Button,
|
|
4546
|
+
{
|
|
4547
|
+
variant: "danger-light",
|
|
4548
|
+
onClick: () => {
|
|
4549
|
+
commitTypedValue(isMultiMedia ? [] : null);
|
|
4550
|
+
setShowMediaModal(false);
|
|
4551
|
+
},
|
|
4552
|
+
children: "Clear Media"
|
|
4553
|
+
}
|
|
4554
|
+
),
|
|
4555
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
4556
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: () => setShowMediaModal(false), children: "Cancel" }),
|
|
4557
|
+
/* @__PURE__ */ jsx(
|
|
4558
|
+
Button,
|
|
4559
|
+
{
|
|
4560
|
+
variant: "default",
|
|
4561
|
+
startIcon: /* @__PURE__ */ jsx(Check, {}),
|
|
4562
|
+
onClick: () => {
|
|
4563
|
+
commitTypedValue(isMultiMedia ? selectedMediaIds : selectedMediaIds[0] ?? null);
|
|
4564
|
+
setShowMediaModal(false);
|
|
4565
|
+
},
|
|
4566
|
+
children: "Apply Selection"
|
|
4567
|
+
}
|
|
4568
|
+
)
|
|
4569
|
+
] })
|
|
4570
|
+
] })
|
|
4571
|
+
]
|
|
4572
|
+
}
|
|
4573
|
+
)
|
|
4574
|
+
}
|
|
4575
|
+
)
|
|
4576
|
+
] });
|
|
4577
|
+
}
|
|
4578
|
+
if (fieldType === "richtext" || fieldType === "blocks" || fieldType === "json") {
|
|
4579
|
+
const isJsonOrBlocks = fieldType === "blocks" || fieldType === "json";
|
|
4580
|
+
const displayLabel = effectiveValue === null || effectiveValue === void 0 || effectiveValue === "" ? "(empty — edit)" : typeof effectiveValue === "object" ? JSON.stringify(effectiveValue).slice(0, 32) + (JSON.stringify(effectiveValue).length > 32 ? "…" : "") : String(effectiveValue).slice(0, 32) + (String(effectiveValue).length > 32 ? "…" : "");
|
|
4581
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4582
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4583
|
+
/* @__PURE__ */ jsx(
|
|
4584
|
+
Button,
|
|
4585
|
+
{
|
|
4586
|
+
variant: "tertiary",
|
|
4587
|
+
size: "S",
|
|
4588
|
+
onClick: () => {
|
|
4589
|
+
const formatted = effectiveValue === null || effectiveValue === void 0 ? "" : typeof effectiveValue === "object" ? JSON.stringify(effectiveValue, null, 2) : String(effectiveValue);
|
|
4590
|
+
setRichDraft(formatted);
|
|
4591
|
+
setRichError(null);
|
|
4592
|
+
setShowRichModal(true);
|
|
4593
|
+
},
|
|
4594
|
+
style: { maxWidth: 230, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
4595
|
+
children: displayLabel
|
|
4596
|
+
}
|
|
4597
|
+
),
|
|
4598
|
+
renderResetBtn()
|
|
4599
|
+
] }),
|
|
4600
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError }),
|
|
4601
|
+
showRichModal && /* @__PURE__ */ jsx(
|
|
4602
|
+
"div",
|
|
4603
|
+
{
|
|
4604
|
+
style: {
|
|
4605
|
+
position: "fixed",
|
|
4606
|
+
inset: 0,
|
|
4607
|
+
backgroundColor: "rgba(20, 20, 30, 0.55)",
|
|
4608
|
+
zIndex: 9999,
|
|
4609
|
+
display: "flex",
|
|
4610
|
+
alignItems: "center",
|
|
4611
|
+
justifyContent: "center",
|
|
4612
|
+
padding: 16
|
|
4613
|
+
},
|
|
4614
|
+
onClick: () => setShowRichModal(false),
|
|
4615
|
+
children: /* @__PURE__ */ jsxs(
|
|
4616
|
+
Box,
|
|
4617
|
+
{
|
|
4618
|
+
padding: 5,
|
|
4619
|
+
background: "neutral0",
|
|
4620
|
+
hasRadius: true,
|
|
4621
|
+
shadow: "popupShadow",
|
|
4622
|
+
style: { width: "92%", maxWidth: 640, display: "flex", flexDirection: "column", gap: 12 },
|
|
4623
|
+
onClick: (e) => e.stopPropagation(),
|
|
4624
|
+
children: [
|
|
4625
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "delta", fontWeight: "bold", children: [
|
|
4626
|
+
"Edit ",
|
|
4627
|
+
fieldType.toUpperCase(),
|
|
4628
|
+
": ",
|
|
4629
|
+
occurrence.displayPath
|
|
4630
|
+
] }),
|
|
4631
|
+
/* @__PURE__ */ jsx(
|
|
4632
|
+
Textarea,
|
|
4633
|
+
{
|
|
4634
|
+
name: "richDraft",
|
|
4635
|
+
"aria-label": "Rich content editor",
|
|
4636
|
+
value: richDraft,
|
|
4637
|
+
onChange: (e) => {
|
|
4638
|
+
setRichDraft(e.target.value);
|
|
4639
|
+
if (isJsonOrBlocks && e.target.value.trim()) {
|
|
4640
|
+
try {
|
|
4641
|
+
const parsed = JSON.parse(e.target.value);
|
|
4642
|
+
if (fieldType === "blocks" && !Array.isArray(parsed)) {
|
|
4643
|
+
setRichError("Strapi Blocks value must be a JSON array.");
|
|
4644
|
+
} else {
|
|
4645
|
+
setRichError(null);
|
|
4646
|
+
}
|
|
4647
|
+
} catch (err) {
|
|
4648
|
+
setRichError(`Invalid JSON: ${err.message}`);
|
|
4649
|
+
}
|
|
4650
|
+
} else {
|
|
4651
|
+
setRichError(null);
|
|
4652
|
+
}
|
|
4653
|
+
},
|
|
4654
|
+
style: { minHeight: 220, fontFamily: isJsonOrBlocks ? "monospace" : "inherit" }
|
|
4655
|
+
}
|
|
4656
|
+
),
|
|
4657
|
+
richError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: richError }),
|
|
4658
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 2, children: [
|
|
4659
|
+
/* @__PURE__ */ jsx(
|
|
4660
|
+
Button,
|
|
4661
|
+
{
|
|
4662
|
+
variant: "danger-light",
|
|
4663
|
+
onClick: () => {
|
|
4664
|
+
commitTypedValue(isJsonOrBlocks ? null : "");
|
|
4665
|
+
setShowRichModal(false);
|
|
4666
|
+
},
|
|
4667
|
+
children: "Clear Value"
|
|
4668
|
+
}
|
|
4669
|
+
),
|
|
4670
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
4671
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: () => setShowRichModal(false), children: "Cancel" }),
|
|
4672
|
+
/* @__PURE__ */ jsx(
|
|
4673
|
+
Button,
|
|
4674
|
+
{
|
|
4675
|
+
variant: "default",
|
|
4676
|
+
disabled: Boolean(richError),
|
|
4677
|
+
startIcon: /* @__PURE__ */ jsx(Check, {}),
|
|
4678
|
+
onClick: () => {
|
|
4679
|
+
if (isJsonOrBlocks) {
|
|
4680
|
+
if (!richDraft.trim()) {
|
|
4681
|
+
commitTypedValue(null);
|
|
4682
|
+
} else {
|
|
4683
|
+
commitTypedValue(JSON.parse(richDraft));
|
|
4684
|
+
}
|
|
4685
|
+
} else {
|
|
4686
|
+
commitTypedValue(richDraft);
|
|
4687
|
+
}
|
|
4688
|
+
setShowRichModal(false);
|
|
4689
|
+
},
|
|
4690
|
+
children: "Apply Edit"
|
|
4691
|
+
}
|
|
4692
|
+
)
|
|
4693
|
+
] })
|
|
4694
|
+
] })
|
|
4695
|
+
]
|
|
4696
|
+
}
|
|
4697
|
+
)
|
|
4698
|
+
}
|
|
4699
|
+
)
|
|
4700
|
+
] });
|
|
4701
|
+
}
|
|
4702
|
+
if (fieldType === "date" || fieldType === "time" || fieldType === "datetime") {
|
|
4703
|
+
const inputType = fieldType === "datetime" ? "datetime-local" : fieldType;
|
|
4704
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4705
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4706
|
+
/* @__PURE__ */ jsx(
|
|
4707
|
+
"input",
|
|
4708
|
+
{
|
|
4709
|
+
type: inputType,
|
|
4710
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4711
|
+
value: localText,
|
|
4712
|
+
step: fieldType === "time" ? 1 : void 0,
|
|
4713
|
+
onChange: (e) => {
|
|
4714
|
+
const v = e.target.value;
|
|
4715
|
+
setLocalText(v);
|
|
4716
|
+
commitTypedValue(v === "" ? null : v);
|
|
4717
|
+
},
|
|
4718
|
+
style: {
|
|
4719
|
+
padding: "6px 8px",
|
|
4720
|
+
borderRadius: 4,
|
|
4721
|
+
border: "1px solid #dcdce4",
|
|
4722
|
+
fontSize: "0.85rem",
|
|
4723
|
+
minWidth: 165
|
|
4724
|
+
}
|
|
4725
|
+
}
|
|
4726
|
+
),
|
|
4727
|
+
renderResetBtn()
|
|
4728
|
+
] }),
|
|
4729
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
|
|
4730
|
+
] });
|
|
4731
|
+
}
|
|
4732
|
+
const isNumeric = ["integer", "biginteger", "float", "decimal", "number"].includes(fieldType);
|
|
4733
|
+
const inputStep = fieldType === "integer" || fieldType === "biginteger" ? "1" : isNumeric ? "any" : void 0;
|
|
4734
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4735
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4736
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 150 }, children: /* @__PURE__ */ jsx(
|
|
4737
|
+
TextInput,
|
|
4738
|
+
{
|
|
4739
|
+
size: "S",
|
|
4740
|
+
type: isNumeric && fieldType !== "biginteger" ? "number" : "text",
|
|
4741
|
+
step: inputStep,
|
|
4742
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4743
|
+
placeholder: occurrence.isMissingIntermediate ? "Click to initialize..." : "(empty)",
|
|
4744
|
+
value: localText,
|
|
4745
|
+
onChange: (e) => {
|
|
4746
|
+
const next = e.target.value;
|
|
4747
|
+
setLocalText(next);
|
|
4748
|
+
commitTypedValue(isNumeric && next === "" ? null : next);
|
|
4749
|
+
}
|
|
4750
|
+
}
|
|
4751
|
+
) }),
|
|
4752
|
+
renderResetBtn()
|
|
4753
|
+
] }),
|
|
4754
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem", marginTop: 2 }, children: validationError })
|
|
4755
|
+
] });
|
|
4756
|
+
}
|
|
4757
|
+
);
|
|
4758
|
+
const ComponentOccurrencesDrawer = React__default.memo(
|
|
4759
|
+
({
|
|
4760
|
+
colUid,
|
|
4761
|
+
rootKey,
|
|
4762
|
+
entry,
|
|
4763
|
+
selectedAttribute,
|
|
4764
|
+
attrMeta,
|
|
4765
|
+
colAttributes,
|
|
4766
|
+
gridEditMode,
|
|
4767
|
+
isSelected,
|
|
4768
|
+
selectedDzBlocks,
|
|
4769
|
+
occurrences,
|
|
4770
|
+
recordEdits,
|
|
4771
|
+
relationOptions,
|
|
4772
|
+
relationOptionsLoading,
|
|
4773
|
+
relationIsMulti,
|
|
4774
|
+
validationRules,
|
|
4775
|
+
onToggleDzBlock,
|
|
4776
|
+
onCommitEdit,
|
|
4777
|
+
onResetEdit
|
|
4778
|
+
}) => {
|
|
4779
|
+
const cleanRootKey = rootKey || (selectedAttribute || "").split("[")[0].split(".")[0];
|
|
4780
|
+
const selectedRootKey = selectedAttribute ? selectedAttribute.split("[")[0].split(".")[0] : "";
|
|
4781
|
+
const targetsThisRoot = Boolean(selectedAttribute && selectedRootKey === cleanRootKey);
|
|
4782
|
+
const blocks = Array.isArray(entry?.[cleanRootKey]) ? entry[cleanRootKey] : [];
|
|
4783
|
+
const isDynamicZone = blocks.some((b) => Boolean(b?.__component));
|
|
4784
|
+
if (blocks.length === 0) return null;
|
|
4785
|
+
const occByRootIndex = /* @__PURE__ */ new Map();
|
|
4786
|
+
occurrences.forEach((occ) => {
|
|
4787
|
+
if (occ.segments?.[0]?.key !== cleanRootKey || occ.segments?.[0]?.index === void 0) return;
|
|
4788
|
+
const rootIdx = occ.segments[0].index;
|
|
4789
|
+
const list = occByRootIndex.get(rootIdx) || [];
|
|
4790
|
+
list.push(occ);
|
|
4791
|
+
occByRootIndex.set(rootIdx, list);
|
|
4792
|
+
});
|
|
4793
|
+
const allApplicableIndexes = blocks.map((_, bIdx) => bIdx).filter((bIdx) => targetsThisRoot ? (occByRootIndex.get(bIdx) || []).length > 0 : true);
|
|
4794
|
+
return /* @__PURE__ */ jsxs(
|
|
4795
|
+
Box,
|
|
4796
|
+
{
|
|
4797
|
+
padding: 3,
|
|
4798
|
+
background: "neutral0",
|
|
4799
|
+
hasRadius: true,
|
|
4800
|
+
style: { border: "1px solid rgba(73, 69, 255, 0.25)", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" },
|
|
4801
|
+
children: [
|
|
4802
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 2, children: [
|
|
4803
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
4804
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "sigma", textColor: "primary700", children: [
|
|
4805
|
+
isDynamicZone ? "DYNAMIC ZONE" : "REPEATABLE COMPONENT",
|
|
4806
|
+
': "',
|
|
4807
|
+
cleanRootKey,
|
|
4808
|
+
'" (',
|
|
4809
|
+
blocks.length,
|
|
4810
|
+
" ",
|
|
4811
|
+
blocks.length === 1 ? "item" : "items",
|
|
4812
|
+
")"
|
|
4813
|
+
] }),
|
|
4814
|
+
/* @__PURE__ */ jsx(Badge, { backgroundColor: "primary100", textColor: "primary700", children: gridEditMode ? "Inline Per-Block Grid Editing" : "Selective Block Targeting" })
|
|
4815
|
+
] }),
|
|
4816
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: gridEditMode ? "Edit each occurrence independently — component IDs & sibling blocks stay intact" : "Selectively choose which blocks to update for this entry" })
|
|
4817
|
+
] }),
|
|
4818
|
+
/* @__PURE__ */ jsxs(Table, { colCount: gridEditMode ? 4 : 5, rowCount: blocks.length + 1, style: { width: "100%", background: "#fff" }, children: [
|
|
4819
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
4820
|
+
!gridEditMode && /* @__PURE__ */ jsx(Th, { style: { width: 64 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Update?" }) }),
|
|
4821
|
+
/* @__PURE__ */ jsx(Th, { style: { width: 85 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Pos / ID" }) }),
|
|
4822
|
+
/* @__PURE__ */ jsx(Th, { style: { width: 210 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Component" }) }),
|
|
4823
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsxs(Typography, { variant: "sigma", children: [
|
|
4824
|
+
"Target Field Value (",
|
|
4825
|
+
selectedAttribute || "selected",
|
|
4826
|
+
")"
|
|
4827
|
+
] }) }),
|
|
4828
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Block Summary" }) })
|
|
4829
|
+
] }) }),
|
|
4830
|
+
/* @__PURE__ */ jsx(Tbody, { children: blocks.map((block, bIdx) => {
|
|
4831
|
+
const compUid = block?.__component || attrMeta?.component;
|
|
4832
|
+
const compLabel = formatComponentNameFriendly(compUid);
|
|
4833
|
+
const blockOccs = occByRootIndex.get(bIdx) || [];
|
|
4834
|
+
const hasTargetAttr = blockOccs.length > 0;
|
|
4835
|
+
const isBlockSelectable = targetsThisRoot ? hasTargetAttr : true;
|
|
4836
|
+
const isBlockChecked = !gridEditMode && isBlockSelectable && isSelected && (selectedDzBlocks !== void 0 ? selectedDzBlocks.includes(bIdx) : true);
|
|
4837
|
+
const hasDirtyOcc = blockOccs.some((o) => Boolean(recordEdits?.occurrences?.[o.occurrenceKey]));
|
|
4838
|
+
const blockSummaryText = block?.title || block?.name || block?.heading || block?.body || Object.keys(block || {}).filter((k) => !k.startsWith("_") && k !== "id").slice(0, 3).map((k) => {
|
|
4839
|
+
const v = block[k];
|
|
4840
|
+
if (v === null || v === void 0) return null;
|
|
4841
|
+
return `${k}: ${typeof v === "object" ? JSON.stringify(v).slice(0, 24) : String(v).slice(0, 24)}`;
|
|
4842
|
+
}).filter(Boolean).join(", ") || "-";
|
|
4843
|
+
return /* @__PURE__ */ jsxs(
|
|
4844
|
+
Tr,
|
|
4845
|
+
{
|
|
4846
|
+
style: {
|
|
4847
|
+
backgroundColor: hasDirtyOcc || isBlockChecked ? "rgba(73, 69, 255, 0.07)" : void 0
|
|
4848
|
+
},
|
|
4849
|
+
children: [
|
|
4850
|
+
!gridEditMode && /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
4851
|
+
Checkbox,
|
|
4852
|
+
{
|
|
4853
|
+
checked: isBlockChecked,
|
|
4854
|
+
disabled: !isBlockSelectable,
|
|
4855
|
+
onCheckedChange: () => {
|
|
4856
|
+
onToggleDzBlock(colUid, entry.documentId, bIdx, allApplicableIndexes);
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
) }),
|
|
4860
|
+
/* @__PURE__ */ jsxs(Td, { children: [
|
|
4861
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", display: "block", children: [
|
|
4862
|
+
"#",
|
|
4863
|
+
bIdx
|
|
4864
|
+
] }),
|
|
4865
|
+
block?.id !== void 0 && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
|
|
4866
|
+
"id:",
|
|
4867
|
+
block.id
|
|
4868
|
+
] })
|
|
4869
|
+
] }),
|
|
4870
|
+
/* @__PURE__ */ jsxs(Td, { children: [
|
|
4871
|
+
/* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: compLabel }),
|
|
4872
|
+
compUid && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", display: "block", style: { fontSize: "0.68rem", marginTop: 2 }, children: compUid })
|
|
4873
|
+
] }),
|
|
4874
|
+
/* @__PURE__ */ jsx(Td, { children: !targetsThisRoot ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: selectedAttribute ? `(targets "${selectedAttribute}")` : "(select attribute to inspect)" }) : !hasTargetAttr ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral100", textColor: "neutral500", children: "Does not contain attribute" }) : gridEditMode ? /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: blockOccs.map((occ) => {
|
|
4875
|
+
const editObj = recordEdits?.occurrences?.[occ.occurrenceKey];
|
|
4876
|
+
return /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
|
|
4877
|
+
blockOccs.length > 1 && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", display: "block", style: { fontSize: "0.7rem", marginBottom: 2 }, children: occ.displayPath }),
|
|
4878
|
+
/* @__PURE__ */ jsx(
|
|
4879
|
+
GridCellEditor,
|
|
4880
|
+
{
|
|
4881
|
+
entry,
|
|
4882
|
+
attribute: selectedAttribute,
|
|
4883
|
+
occurrence: occ,
|
|
4884
|
+
attrMeta,
|
|
4885
|
+
editedValue: editObj?.value,
|
|
4886
|
+
isDirty: Boolean(editObj),
|
|
4887
|
+
validationError: editObj?.validationError,
|
|
4888
|
+
relationOptions,
|
|
4889
|
+
relationOptionsLoading,
|
|
4890
|
+
relationIsMulti,
|
|
4891
|
+
validationRules,
|
|
4892
|
+
recordEdits,
|
|
4893
|
+
colAttributes,
|
|
4894
|
+
onCommit: (o, val, err) => onCommitEdit(entry, colUid, o, val, err),
|
|
4895
|
+
onReset: (k) => onResetEdit(colUid, entry.documentId, k)
|
|
4896
|
+
}
|
|
4897
|
+
)
|
|
4898
|
+
] }, occ.occurrenceKey);
|
|
4899
|
+
}) }) : /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: blockOccs.map((occ) => /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "primary700", children: occ.value !== null && occ.value !== void 0 && occ.value !== "" ? typeof occ.value === "object" ? JSON.stringify(occ.value) : String(occ.value) : "(empty / not set)" }, occ.occurrenceKey)) }) }),
|
|
4900
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
4901
|
+
Typography,
|
|
4902
|
+
{
|
|
4903
|
+
variant: "pi",
|
|
4904
|
+
textColor: "neutral600",
|
|
4905
|
+
style: { maxWidth: 280, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
4906
|
+
children: blockSummaryText
|
|
4907
|
+
}
|
|
4908
|
+
) })
|
|
4909
|
+
]
|
|
4910
|
+
},
|
|
4911
|
+
block?.id ? `id_${block.id}_idx_${bIdx}` : `idx_${bIdx}`
|
|
4912
|
+
);
|
|
4913
|
+
}) })
|
|
4914
|
+
] })
|
|
4915
|
+
]
|
|
4916
|
+
}
|
|
4917
|
+
);
|
|
4918
|
+
}
|
|
4919
|
+
);
|
|
3588
4920
|
function parseDynamicZonePath(path) {
|
|
3589
4921
|
if (!path) return { cleanPath: "", rootKey: "", subPath: "" };
|
|
3590
4922
|
const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
|
|
@@ -3997,7 +5329,7 @@ function formatDisplayValue(val) {
|
|
|
3997
5329
|
}
|
|
3998
5330
|
return String(val);
|
|
3999
5331
|
}
|
|
4000
|
-
function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribute, isMatch, hasAttr, isSelected, onToggleSelect, pendingBatches = [], isDzExpanded = false, onToggleExpandDz, filterQuery = "") {
|
|
5332
|
+
function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribute, isMatch, hasAttr, isSelected, onToggleSelect, pendingBatches = [], isDzExpanded = false, onToggleExpandDz, filterQuery = "", gridCtx) {
|
|
4001
5333
|
switch (colDef.key) {
|
|
4002
5334
|
case "select":
|
|
4003
5335
|
return /* @__PURE__ */ jsx(
|
|
@@ -4012,7 +5344,10 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
|
|
|
4012
5344
|
const dzField = Object.keys(entry).find(
|
|
4013
5345
|
(k) => Array.isArray(entry[k]) && entry[k].length > 0 && entry[k].some((item) => item && item.__component)
|
|
4014
5346
|
);
|
|
4015
|
-
const
|
|
5347
|
+
const selectedRootKey = selectedAttribute ? selectedAttribute.split("[")[0].split(".")[0] : "";
|
|
5348
|
+
const repeatableRoot = !dzField && gridCtx?.gridEditMode && selectedRootKey && gridCtx?.selectedAttrMeta?.rootRepeatable && Array.isArray(entry[selectedRootKey]) && entry[selectedRootKey].length > 0 ? selectedRootKey : void 0;
|
|
5349
|
+
const expandField = dzField || repeatableRoot;
|
|
5350
|
+
const dzItemsCount = expandField ? entry[expandField].length : 0;
|
|
4016
5351
|
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
4017
5352
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: mainText }),
|
|
4018
5353
|
entry.email && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", display: "block", children: entry.email }),
|
|
@@ -4030,7 +5365,7 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
|
|
|
4030
5365
|
backgroundColor: isDzExpanded ? "rgba(73, 69, 255, 0.08)" : "rgba(0, 0, 0, 0.04)",
|
|
4031
5366
|
borderRadius: 4
|
|
4032
5367
|
},
|
|
4033
|
-
children: isDzExpanded ? `▲ Hide ${
|
|
5368
|
+
children: isDzExpanded ? `▲ Hide ${expandField} (${dzItemsCount} ${dzField ? "blocks" : "items"})` : `▼ ${gridCtx?.gridEditMode ? "Edit" : "View"} ${expandField} (${dzItemsCount} ${dzField ? "blocks" : "items"})`
|
|
4034
5369
|
}
|
|
4035
5370
|
) })
|
|
4036
5371
|
] });
|
|
@@ -4097,13 +5432,95 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
|
|
|
4097
5432
|
children: displayStr
|
|
4098
5433
|
}
|
|
4099
5434
|
)
|
|
4100
|
-
]
|
|
4101
|
-
},
|
|
4102
|
-
m.index
|
|
4103
|
-
);
|
|
4104
|
-
}) });
|
|
4105
|
-
}
|
|
4106
|
-
case "target_attr": {
|
|
5435
|
+
]
|
|
5436
|
+
},
|
|
5437
|
+
m.index
|
|
5438
|
+
);
|
|
5439
|
+
}) });
|
|
5440
|
+
}
|
|
5441
|
+
case "target_attr": {
|
|
5442
|
+
if (gridCtx?.gridEditMode) {
|
|
5443
|
+
if (selectedAttribute && !hasAttr) {
|
|
5444
|
+
return /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral200", textColor: "neutral600", children: "Ignored (absent in schema)" });
|
|
5445
|
+
}
|
|
5446
|
+
const occs = enumerateClientOccurrences(
|
|
5447
|
+
entry,
|
|
5448
|
+
selectedAttribute,
|
|
5449
|
+
col?.attributes,
|
|
5450
|
+
gridCtx.selectedAttrMeta
|
|
5451
|
+
);
|
|
5452
|
+
if (occs.length === 0) {
|
|
5453
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", style: { fontStyle: "italic" }, children: "(no applicable block / item)" });
|
|
5454
|
+
}
|
|
5455
|
+
if (occs.length === 1 && !occs[0].segments.some((s) => s.index !== void 0)) {
|
|
5456
|
+
const occ = occs[0];
|
|
5457
|
+
const editObj = gridCtx.recordEdits?.occurrences?.[occ.occurrenceKey];
|
|
5458
|
+
return /* @__PURE__ */ jsx(
|
|
5459
|
+
GridCellEditor,
|
|
5460
|
+
{
|
|
5461
|
+
entry,
|
|
5462
|
+
attribute: selectedAttribute,
|
|
5463
|
+
occurrence: occ,
|
|
5464
|
+
attrMeta: gridCtx.selectedAttrMeta,
|
|
5465
|
+
editedValue: editObj?.value,
|
|
5466
|
+
isDirty: Boolean(editObj),
|
|
5467
|
+
validationError: editObj?.validationError,
|
|
5468
|
+
relationOptions: gridCtx.relationOptions,
|
|
5469
|
+
relationOptionsLoading: gridCtx.relationOptionsLoading,
|
|
5470
|
+
relationIsMulti: gridCtx.relationIsMulti,
|
|
5471
|
+
validationRules: gridCtx.validationRules,
|
|
5472
|
+
recordEdits: gridCtx.recordEdits,
|
|
5473
|
+
colAttributes: col?.attributes,
|
|
5474
|
+
onCommit: (o, val, err) => gridCtx.onCommitEdit(entry, col.uid, o, val, err),
|
|
5475
|
+
onReset: (k) => gridCtx.onResetEdit(col.uid, entry.documentId, k)
|
|
5476
|
+
}
|
|
5477
|
+
);
|
|
5478
|
+
}
|
|
5479
|
+
const maxInline = 3;
|
|
5480
|
+
const visibleOccs = occs.slice(0, maxInline);
|
|
5481
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: [
|
|
5482
|
+
visibleOccs.map((occ) => {
|
|
5483
|
+
const editObj = gridCtx.recordEdits?.occurrences?.[occ.occurrenceKey];
|
|
5484
|
+
return /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
|
|
5485
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", marginBottom: 1, children: [
|
|
5486
|
+
/* @__PURE__ */ jsxs(Badge, { size: "S", backgroundColor: editObj ? "primary100" : "neutral200", textColor: editObj ? "primary700" : "neutral800", children: [
|
|
5487
|
+
"#",
|
|
5488
|
+
occ.index,
|
|
5489
|
+
" ",
|
|
5490
|
+
occ.componentName || "Item"
|
|
5491
|
+
] }),
|
|
5492
|
+
occ.componentId !== void 0 && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
|
|
5493
|
+
"id:",
|
|
5494
|
+
occ.componentId
|
|
5495
|
+
] }),
|
|
5496
|
+
editObj && /* @__PURE__ */ jsx(Badge, { size: "S", backgroundColor: "secondary100", textColor: "secondary700", children: "Edited" })
|
|
5497
|
+
] }),
|
|
5498
|
+
/* @__PURE__ */ jsx(
|
|
5499
|
+
GridCellEditor,
|
|
5500
|
+
{
|
|
5501
|
+
compact: true,
|
|
5502
|
+
entry,
|
|
5503
|
+
attribute: selectedAttribute,
|
|
5504
|
+
occurrence: occ,
|
|
5505
|
+
attrMeta: gridCtx.selectedAttrMeta,
|
|
5506
|
+
editedValue: editObj?.value,
|
|
5507
|
+
isDirty: Boolean(editObj),
|
|
5508
|
+
validationError: editObj?.validationError,
|
|
5509
|
+
relationOptions: gridCtx.relationOptions,
|
|
5510
|
+
relationOptionsLoading: gridCtx.relationOptionsLoading,
|
|
5511
|
+
relationIsMulti: gridCtx.relationIsMulti,
|
|
5512
|
+
validationRules: gridCtx.validationRules,
|
|
5513
|
+
recordEdits: gridCtx.recordEdits,
|
|
5514
|
+
colAttributes: col?.attributes,
|
|
5515
|
+
onCommit: (o, val, err) => gridCtx.onCommitEdit(entry, col.uid, o, val, err),
|
|
5516
|
+
onReset: (k) => gridCtx.onResetEdit(col.uid, entry.documentId, k)
|
|
5517
|
+
}
|
|
5518
|
+
)
|
|
5519
|
+
] }, occ.occurrenceKey);
|
|
5520
|
+
}),
|
|
5521
|
+
occs.length > maxInline && onToggleExpandDz && /* @__PURE__ */ jsx(Button, { variant: "tertiary", size: "S", onClick: onToggleExpandDz, children: isDzExpanded ? `▲ Collapse drawer` : `▼ Edit all ${occs.length} occurrences in drawer` })
|
|
5522
|
+
] });
|
|
5523
|
+
}
|
|
4107
5524
|
const matches = getAllNestedValues(entry, selectedAttribute, col?.attributes);
|
|
4108
5525
|
if (matches.length === 0) {
|
|
4109
5526
|
return /* @__PURE__ */ jsx(Typography, { textColor: "neutral500", style: { fontStyle: "italic" }, children: "(empty / not set)" });
|
|
@@ -4310,6 +5727,10 @@ const BulkUpdater = () => {
|
|
|
4310
5727
|
const [searchAttribute, setSearchAttribute] = useState("");
|
|
4311
5728
|
const [searchAttributeInput, setSearchAttributeInput] = useState("");
|
|
4312
5729
|
const [attributesMeta, setAttributesMeta] = useState({});
|
|
5730
|
+
const [gridEditMode, setGridEditMode] = useState(false);
|
|
5731
|
+
const [gridEdits, setGridEdits] = useState({});
|
|
5732
|
+
const [gridFilterModifiedOnly, setGridFilterModifiedOnly] = useState(false);
|
|
5733
|
+
const [validationRules, setValidationRules] = useState([]);
|
|
4313
5734
|
const effectiveSearchAttribute = searchAttribute || selectedAttribute;
|
|
4314
5735
|
useEffect(() => {
|
|
4315
5736
|
if (effectiveSearchAttribute && relationsMeta[effectiveSearchAttribute]) {
|
|
@@ -4624,10 +6045,20 @@ const BulkUpdater = () => {
|
|
|
4624
6045
|
setPendingBatchesLoading(false);
|
|
4625
6046
|
}
|
|
4626
6047
|
};
|
|
6048
|
+
const fetchValidationRules = async () => {
|
|
6049
|
+
try {
|
|
6050
|
+
const res = await get("/bulk-updater/validation-rules");
|
|
6051
|
+
if (res.data?.success && Array.isArray(res.data.rules)) {
|
|
6052
|
+
setValidationRules(res.data.rules);
|
|
6053
|
+
}
|
|
6054
|
+
} catch {
|
|
6055
|
+
}
|
|
6056
|
+
};
|
|
4627
6057
|
useEffect(() => {
|
|
4628
6058
|
fetchModels();
|
|
4629
6059
|
fetchAuditHistory();
|
|
4630
6060
|
fetchPendingBatches();
|
|
6061
|
+
fetchValidationRules();
|
|
4631
6062
|
}, []);
|
|
4632
6063
|
useEffect(() => {
|
|
4633
6064
|
if (activeTab === "audit") {
|
|
@@ -4645,7 +6076,17 @@ const BulkUpdater = () => {
|
|
|
4645
6076
|
if (selectedCollectionUid) {
|
|
4646
6077
|
const isFilterActiveNow = Boolean(searchAttribute && searchAttribute !== selectedAttribute) || filterOperator !== "none" && (["empty", "not_empty"].includes(filterOperator) || Boolean(filterQuery.trim())) || Boolean(entrySearch.trim()) || Boolean(useRegex && regexPattern.trim());
|
|
4647
6078
|
if (isFilterActiveNow) {
|
|
4648
|
-
|
|
6079
|
+
if (gridEditMode) {
|
|
6080
|
+
setSelectedEntries((prev) => {
|
|
6081
|
+
const retained = {};
|
|
6082
|
+
Object.keys(gridEdits).forEach((k) => {
|
|
6083
|
+
if (prev[k]) retained[k] = true;
|
|
6084
|
+
});
|
|
6085
|
+
return retained;
|
|
6086
|
+
});
|
|
6087
|
+
} else {
|
|
6088
|
+
setSelectedEntries({});
|
|
6089
|
+
}
|
|
4649
6090
|
}
|
|
4650
6091
|
loadCollectionPage(
|
|
4651
6092
|
selectedCollectionUid,
|
|
@@ -4668,12 +6109,131 @@ const BulkUpdater = () => {
|
|
|
4668
6109
|
if (!collections.length || !selectedCollectionUid) return null;
|
|
4669
6110
|
return collections.find((c) => c.uid === selectedCollectionUid) || null;
|
|
4670
6111
|
}, [collections, selectedCollectionUid]);
|
|
6112
|
+
const activeAttrMeta = useMemo(() => {
|
|
6113
|
+
if (!selectedAttribute) return void 0;
|
|
6114
|
+
const base = selectedCol?.attributesMeta?.[selectedAttribute] || attributesMeta[selectedAttribute];
|
|
6115
|
+
const relMeta = selectedCol?.relations?.[selectedAttribute] || relationsMeta[selectedAttribute];
|
|
6116
|
+
if (!base && !relMeta) return void 0;
|
|
6117
|
+
if (relMeta && (!base || !base.isRelation)) {
|
|
6118
|
+
return {
|
|
6119
|
+
...base || { depth: 0, type: "relation" },
|
|
6120
|
+
isRelation: true,
|
|
6121
|
+
relationType: relMeta.relationType,
|
|
6122
|
+
target: relMeta.targetUid
|
|
6123
|
+
};
|
|
6124
|
+
}
|
|
6125
|
+
return base;
|
|
6126
|
+
}, [selectedAttribute, selectedCol, attributesMeta, relationsMeta]);
|
|
6127
|
+
const totalDirtyRecordsCount = useMemo(() => Object.keys(gridEdits).length, [gridEdits]);
|
|
6128
|
+
const totalDirtyCellsCount = useMemo(
|
|
6129
|
+
() => Object.values(gridEdits).reduce(
|
|
6130
|
+
(sum, rec) => sum + Object.keys(rec.occurrences || {}).length,
|
|
6131
|
+
0
|
|
6132
|
+
),
|
|
6133
|
+
[gridEdits]
|
|
6134
|
+
);
|
|
6135
|
+
const gridSerialized = useMemo(
|
|
6136
|
+
() => serializeGridTargets(gridEdits, selectedEntries, collectionPages, activeAttrMeta),
|
|
6137
|
+
[gridEdits, selectedEntries, collectionPages, activeAttrMeta]
|
|
6138
|
+
);
|
|
6139
|
+
const handleGridCellCommit = React__default.useCallback(
|
|
6140
|
+
(entry, colUid, occ, newValue, validationError) => {
|
|
6141
|
+
const key = `${colUid}${KEY_SEP}${entry.documentId}`;
|
|
6142
|
+
const recordLabel = entry.name || entry.title || entry.email || `Entry #${entry.id || entry.documentId}`;
|
|
6143
|
+
setGridEdits((prev) => {
|
|
6144
|
+
const existingRec = prev[key] || {
|
|
6145
|
+
uid: colUid,
|
|
6146
|
+
documentId: entry.documentId,
|
|
6147
|
+
locale: entry.locale,
|
|
6148
|
+
status: entry.status,
|
|
6149
|
+
publishedAt: entry.publishedAt,
|
|
6150
|
+
recordLabel,
|
|
6151
|
+
occurrences: {}
|
|
6152
|
+
};
|
|
6153
|
+
return {
|
|
6154
|
+
...prev,
|
|
6155
|
+
[key]: {
|
|
6156
|
+
...existingRec,
|
|
6157
|
+
occurrences: {
|
|
6158
|
+
...existingRec.occurrences,
|
|
6159
|
+
[occ.occurrenceKey]: {
|
|
6160
|
+
occurrenceKey: occ.occurrenceKey,
|
|
6161
|
+
displayPath: occ.displayPath,
|
|
6162
|
+
segments: occ.segments,
|
|
6163
|
+
originalValue: occ.value,
|
|
6164
|
+
value: newValue,
|
|
6165
|
+
fieldType: activeAttrMeta?.type || "string",
|
|
6166
|
+
validationError,
|
|
6167
|
+
touchedAt: Date.now()
|
|
6168
|
+
}
|
|
6169
|
+
}
|
|
6170
|
+
}
|
|
6171
|
+
};
|
|
6172
|
+
});
|
|
6173
|
+
setSelectedEntries((prev) => prev[key] ? prev : { ...prev, [key]: true });
|
|
6174
|
+
},
|
|
6175
|
+
[activeAttrMeta?.type]
|
|
6176
|
+
);
|
|
6177
|
+
const handleGridCellReset = React__default.useCallback((colUid, documentId, occKey) => {
|
|
6178
|
+
const key = `${colUid}${KEY_SEP}${documentId}`;
|
|
6179
|
+
setGridEdits((prev) => {
|
|
6180
|
+
const existingRec = prev[key];
|
|
6181
|
+
if (!existingRec) return prev;
|
|
6182
|
+
const nextOccs = { ...existingRec.occurrences };
|
|
6183
|
+
delete nextOccs[occKey];
|
|
6184
|
+
if (Object.keys(nextOccs).length === 0) {
|
|
6185
|
+
const next = { ...prev };
|
|
6186
|
+
delete next[key];
|
|
6187
|
+
return next;
|
|
6188
|
+
}
|
|
6189
|
+
return {
|
|
6190
|
+
...prev,
|
|
6191
|
+
[key]: {
|
|
6192
|
+
...existingRec,
|
|
6193
|
+
occurrences: nextOccs
|
|
6194
|
+
}
|
|
6195
|
+
};
|
|
6196
|
+
});
|
|
6197
|
+
}, []);
|
|
6198
|
+
const handleToggleGridEditMode = (checked) => {
|
|
6199
|
+
if (!checked && totalDirtyCellsCount > 0) {
|
|
6200
|
+
if (!window.confirm(`Disable Grid Editing Mode and discard ${totalDirtyCellsCount} unsaved edit(s)?`)) {
|
|
6201
|
+
return;
|
|
6202
|
+
}
|
|
6203
|
+
setGridEdits({});
|
|
6204
|
+
}
|
|
6205
|
+
setGridEditMode(checked);
|
|
6206
|
+
setGridFilterModifiedOnly(false);
|
|
6207
|
+
if (checked) {
|
|
6208
|
+
if (useRegex) setUseRegex(false);
|
|
6209
|
+
setRegexPattern("");
|
|
6210
|
+
if (selectedCollectionUid) {
|
|
6211
|
+
setCollectionColumnVisibility((prev) => {
|
|
6212
|
+
const existing = prev[selectedCollectionUid];
|
|
6213
|
+
if (existing && !existing.includes("target_attr")) {
|
|
6214
|
+
return { ...prev, [selectedCollectionUid]: [...existing, "target_attr"] };
|
|
6215
|
+
}
|
|
6216
|
+
return prev;
|
|
6217
|
+
});
|
|
6218
|
+
}
|
|
6219
|
+
}
|
|
6220
|
+
};
|
|
4671
6221
|
const handleCollectionChange = (newUid) => {
|
|
4672
6222
|
if (newUid === selectedCollectionUid) return;
|
|
6223
|
+
if (totalDirtyCellsCount > 0) {
|
|
6224
|
+
if (!window.confirm(
|
|
6225
|
+
`You have ${totalDirtyCellsCount} unsaved Grid Edit(s) in the current collection. Switching collections will discard them. Continue?`
|
|
6226
|
+
)) {
|
|
6227
|
+
return;
|
|
6228
|
+
}
|
|
6229
|
+
}
|
|
4673
6230
|
if (abortControllersRef.current) {
|
|
4674
|
-
Object.values(abortControllersRef.current).forEach((ctrl) => ctrl
|
|
6231
|
+
Object.values(abortControllersRef.current).forEach((ctrl) => ctrl?.abort());
|
|
4675
6232
|
}
|
|
4676
6233
|
setSelectedCollectionUid(newUid);
|
|
6234
|
+
setGridEdits({});
|
|
6235
|
+
setSelectedDzBlocks({});
|
|
6236
|
+
setExpandedDzEntries({});
|
|
4677
6237
|
try {
|
|
4678
6238
|
if (newUid) {
|
|
4679
6239
|
localStorage.setItem(LAST_COLLECTION_KEY, newUid);
|
|
@@ -4707,6 +6267,14 @@ const BulkUpdater = () => {
|
|
|
4707
6267
|
};
|
|
4708
6268
|
const handleAttributeChange = (newAttr) => {
|
|
4709
6269
|
if (newAttr !== selectedAttribute) {
|
|
6270
|
+
if (totalDirtyCellsCount > 0) {
|
|
6271
|
+
if (!window.confirm(
|
|
6272
|
+
`You have ${totalDirtyCellsCount} unsaved Grid Edit(s) for "${selectedAttribute}". Switching Target Attribute will discard them. Continue?`
|
|
6273
|
+
)) {
|
|
6274
|
+
return;
|
|
6275
|
+
}
|
|
6276
|
+
}
|
|
6277
|
+
setGridEdits({});
|
|
4710
6278
|
setSelectedAttribute(newAttr);
|
|
4711
6279
|
try {
|
|
4712
6280
|
if (newAttr) {
|
|
@@ -4728,13 +6296,13 @@ const BulkUpdater = () => {
|
|
|
4728
6296
|
const filteredCollections = useMemo(() => {
|
|
4729
6297
|
return selectedCol ? [selectedCol] : [];
|
|
4730
6298
|
}, [selectedCol]);
|
|
4731
|
-
const getAttrDepth = (attr) => attributesMeta[attr]?.depth ?? (attr.includes(".") ? attr.split(".").length - 1 : 0);
|
|
6299
|
+
const getAttrDepth = (attr) => selectedCol?.attributesMeta?.[attr]?.depth ?? attributesMeta[attr]?.depth ?? (attr.includes(".") ? attr.split(".").length - 1 : 0);
|
|
4732
6300
|
const availableColAttributes = useMemo(() => {
|
|
4733
6301
|
return selectedCol?.attributes || attributes || [];
|
|
4734
6302
|
}, [selectedCol, attributes]);
|
|
4735
6303
|
const depthFilteredAttributes = useMemo(() => {
|
|
4736
6304
|
return availableColAttributes.filter((attr) => getAttrDepth(attr) <= componentDepth);
|
|
4737
|
-
}, [availableColAttributes, componentDepth, attributesMeta]);
|
|
6305
|
+
}, [availableColAttributes, componentDepth, attributesMeta, selectedCol]);
|
|
4738
6306
|
const memoizedComboboxOptions = useMemo(() => {
|
|
4739
6307
|
if (depthFilteredAttributes.length === 0) {
|
|
4740
6308
|
return /* @__PURE__ */ jsx(ComboboxOption, { value: "__none__", disabled: true, textValue: "No attributes available", children: /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
@@ -4915,7 +6483,10 @@ const BulkUpdater = () => {
|
|
|
4915
6483
|
};
|
|
4916
6484
|
const getVisibleEntries = (col) => {
|
|
4917
6485
|
const pageState = collectionPages[col.uid];
|
|
4918
|
-
|
|
6486
|
+
let raw = pageState ? pageState.entries : col.entries || [];
|
|
6487
|
+
if (gridEditMode && gridFilterModifiedOnly) {
|
|
6488
|
+
raw = raw.filter((entry) => Boolean(gridEdits[`${col.uid}${KEY_SEP}${entry.documentId}`]));
|
|
6489
|
+
}
|
|
4919
6490
|
if (statusFilter === "all") return raw;
|
|
4920
6491
|
return raw.filter((entry) => {
|
|
4921
6492
|
const lifecycle = getEntryLifecycleStatus(entry, col, pendingBatches);
|
|
@@ -4929,7 +6500,7 @@ const BulkUpdater = () => {
|
|
|
4929
6500
|
count += getVisibleEntries(col).length;
|
|
4930
6501
|
});
|
|
4931
6502
|
return count;
|
|
4932
|
-
}, [filteredCollections, collectionPages, isFilterActive, statusFilter, pendingBatches]);
|
|
6503
|
+
}, [filteredCollections, collectionPages, isFilterActive, statusFilter, pendingBatches, gridEditMode, gridFilterModifiedOnly, gridEdits]);
|
|
4933
6504
|
const selectAllMatching = () => {
|
|
4934
6505
|
const updated = { ...selectedEntries };
|
|
4935
6506
|
filteredCollections.forEach((col) => {
|
|
@@ -4957,7 +6528,17 @@ const BulkUpdater = () => {
|
|
|
4957
6528
|
setEntrySearch("");
|
|
4958
6529
|
setStatusFilter("all");
|
|
4959
6530
|
setRegexPattern("");
|
|
4960
|
-
|
|
6531
|
+
if (gridEditMode) {
|
|
6532
|
+
setSelectedEntries((prev) => {
|
|
6533
|
+
const retained = {};
|
|
6534
|
+
Object.keys(gridEdits).forEach((k) => {
|
|
6535
|
+
if (prev[k]) retained[k] = true;
|
|
6536
|
+
});
|
|
6537
|
+
return retained;
|
|
6538
|
+
});
|
|
6539
|
+
} else {
|
|
6540
|
+
setSelectedEntries({});
|
|
6541
|
+
}
|
|
4961
6542
|
collections.forEach((col) => {
|
|
4962
6543
|
loadCollectionPage(col.uid, 1, void 0, void 0, void 0, "none", "", "", false, "");
|
|
4963
6544
|
});
|
|
@@ -5002,58 +6583,71 @@ const BulkUpdater = () => {
|
|
|
5002
6583
|
const deselectAll = () => {
|
|
5003
6584
|
setSelectedEntries({});
|
|
5004
6585
|
};
|
|
5005
|
-
const getSelectedBreakdown = () => {
|
|
6586
|
+
const getSelectedBreakdown = (onlyKeys) => {
|
|
5006
6587
|
const breakdown = {};
|
|
5007
|
-
Object.keys(selectedEntries).
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
}
|
|
6588
|
+
const keysToCount = onlyKeys || Object.keys(selectedEntries).filter((k) => selectedEntries[k]);
|
|
6589
|
+
keysToCount.forEach((key) => {
|
|
6590
|
+
const parts = key.split(KEY_SEP);
|
|
6591
|
+
if (parts.length === 2) {
|
|
6592
|
+
const uid = parts[0];
|
|
6593
|
+
const col = collections.find((c) => c.uid === uid);
|
|
6594
|
+
const name = col?.displayName || uid;
|
|
6595
|
+
breakdown[name] = (breakdown[name] || 0) + 1;
|
|
5016
6596
|
}
|
|
5017
6597
|
});
|
|
5018
6598
|
return breakdown;
|
|
5019
6599
|
};
|
|
5020
|
-
const
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
6600
|
+
const computeLifecycleStatsForKeys = React__default.useCallback(
|
|
6601
|
+
(keys) => {
|
|
6602
|
+
let published = 0;
|
|
6603
|
+
let modified = 0;
|
|
6604
|
+
let draft = 0;
|
|
6605
|
+
let pendingReview = 0;
|
|
6606
|
+
let unknown = 0;
|
|
6607
|
+
keys.forEach((key) => {
|
|
6608
|
+
const parts = key.split(KEY_SEP);
|
|
6609
|
+
if (parts.length !== 2) return;
|
|
6610
|
+
const [uid, docId] = parts;
|
|
6611
|
+
const col = collections.find((c) => c.uid === uid) || null;
|
|
6612
|
+
const entry = collectionPages[uid]?.entries?.find((e) => e.documentId === docId || String(e.id) === docId) || col?.entries?.find((e) => e.documentId === docId || String(e.id) === docId);
|
|
6613
|
+
if (col && col.draftAndPublish === false) {
|
|
6614
|
+
published++;
|
|
6615
|
+
} else if (entry) {
|
|
6616
|
+
const { status } = getEntryLifecycleStatus(entry, col, pendingBatches);
|
|
6617
|
+
if (status === "published") published++;
|
|
6618
|
+
else if (status === "modified") modified++;
|
|
6619
|
+
else if (status === "draft") draft++;
|
|
6620
|
+
else if (status === "pending_review") pendingReview++;
|
|
6621
|
+
else unknown++;
|
|
6622
|
+
} else {
|
|
6623
|
+
draft++;
|
|
6624
|
+
}
|
|
6625
|
+
});
|
|
6626
|
+
const unreviewedCount = draft + modified + pendingReview + unknown;
|
|
6627
|
+
return {
|
|
6628
|
+
published,
|
|
6629
|
+
modified,
|
|
6630
|
+
draft,
|
|
6631
|
+
pendingReview,
|
|
6632
|
+
unknown,
|
|
6633
|
+
unreviewedCount,
|
|
6634
|
+
total: published + modified + draft + pendingReview + unknown
|
|
6635
|
+
};
|
|
6636
|
+
},
|
|
6637
|
+
[collections, collectionPages, pendingBatches]
|
|
6638
|
+
);
|
|
6639
|
+
const selectedLifecycleStats = useMemo(
|
|
6640
|
+
() => computeLifecycleStatsForKeys(Object.keys(selectedEntries).filter((k) => selectedEntries[k])),
|
|
6641
|
+
[selectedEntries, computeLifecycleStatsForKeys]
|
|
6642
|
+
);
|
|
6643
|
+
const gridTargetKeys = useMemo(
|
|
6644
|
+
() => gridSerialized.targets.map((t) => `${t.uid}${KEY_SEP}${t.documentId}`),
|
|
6645
|
+
[gridSerialized]
|
|
6646
|
+
);
|
|
6647
|
+
const updateModalLifecycleStats = useMemo(
|
|
6648
|
+
() => gridEditMode ? computeLifecycleStatsForKeys(gridTargetKeys) : selectedLifecycleStats,
|
|
6649
|
+
[gridEditMode, gridTargetKeys, computeLifecycleStatsForKeys, selectedLifecycleStats]
|
|
6650
|
+
);
|
|
5057
6651
|
const handleOpenConfirmModal = () => {
|
|
5058
6652
|
if (!selectedAttribute) {
|
|
5059
6653
|
toggleNotification({
|
|
@@ -5062,13 +6656,30 @@ const BulkUpdater = () => {
|
|
|
5062
6656
|
});
|
|
5063
6657
|
return;
|
|
5064
6658
|
}
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
6659
|
+
if (gridEditMode) {
|
|
6660
|
+
if (gridSerialized.targets.length === 0) {
|
|
6661
|
+
toggleNotification({
|
|
6662
|
+
type: "warning",
|
|
6663
|
+
message: "Please edit at least one selected cell or block in the grid before updating"
|
|
6664
|
+
});
|
|
6665
|
+
return;
|
|
6666
|
+
}
|
|
6667
|
+
if (gridSerialized.hasValidationErrors) {
|
|
6668
|
+
toggleNotification({
|
|
6669
|
+
type: "danger",
|
|
6670
|
+
message: "Please resolve inline validation errors highlighted in red before updating"
|
|
6671
|
+
});
|
|
6672
|
+
return;
|
|
6673
|
+
}
|
|
6674
|
+
} else {
|
|
6675
|
+
const totalSelected = Object.values(selectedEntries).filter(Boolean).length;
|
|
6676
|
+
if (totalSelected === 0) {
|
|
6677
|
+
toggleNotification({
|
|
6678
|
+
type: "warning",
|
|
6679
|
+
message: "Please select at least one collection type or entry to update"
|
|
6680
|
+
});
|
|
6681
|
+
return;
|
|
6682
|
+
}
|
|
5072
6683
|
}
|
|
5073
6684
|
setPublishStrategy("safe");
|
|
5074
6685
|
setUnreviewedConsent(false);
|
|
@@ -5082,44 +6693,63 @@ const BulkUpdater = () => {
|
|
|
5082
6693
|
});
|
|
5083
6694
|
return;
|
|
5084
6695
|
}
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
if (
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
6696
|
+
let targets = [];
|
|
6697
|
+
if (gridEditMode) {
|
|
6698
|
+
if (gridSerialized.hasValidationErrors) {
|
|
6699
|
+
toggleNotification({
|
|
6700
|
+
type: "danger",
|
|
6701
|
+
message: "Please fix inline validation errors before previewing changes"
|
|
6702
|
+
});
|
|
6703
|
+
return;
|
|
6704
|
+
}
|
|
6705
|
+
targets = gridSerialized.targets;
|
|
6706
|
+
if (targets.length === 0) {
|
|
6707
|
+
toggleNotification({
|
|
6708
|
+
type: "warning",
|
|
6709
|
+
message: "Please modify and select at least one grid cell or block to preview"
|
|
6710
|
+
});
|
|
6711
|
+
return;
|
|
6712
|
+
}
|
|
6713
|
+
} else {
|
|
6714
|
+
Object.keys(selectedEntries).forEach((key) => {
|
|
6715
|
+
if (selectedEntries[key]) {
|
|
6716
|
+
const parts = key.split(KEY_SEP);
|
|
6717
|
+
if (parts.length === 2) {
|
|
6718
|
+
const colUid = parts[0];
|
|
6719
|
+
const docId = parts[1];
|
|
6720
|
+
const targetObj = { uid: colUid, documentId: docId };
|
|
6721
|
+
if (selectedDzBlocks[key] && selectedDzBlocks[key].length > 0) {
|
|
6722
|
+
targetObj.dynamicZoneIndexes = selectedDzBlocks[key];
|
|
6723
|
+
}
|
|
6724
|
+
const colPage = collectionPages[colUid];
|
|
6725
|
+
const cachedEntry = colPage?.entries?.find((e) => e.documentId === docId);
|
|
6726
|
+
if (cachedEntry) {
|
|
6727
|
+
if (cachedEntry.status) targetObj.status = cachedEntry.status;
|
|
6728
|
+
if (cachedEntry.publishedAt) targetObj.publishedAt = cachedEntry.publishedAt;
|
|
6729
|
+
if (cachedEntry.locale) targetObj.locale = cachedEntry.locale;
|
|
6730
|
+
}
|
|
6731
|
+
targets.push(targetObj);
|
|
5102
6732
|
}
|
|
5103
|
-
targets.push(targetObj);
|
|
5104
6733
|
}
|
|
5105
|
-
}
|
|
5106
|
-
});
|
|
5107
|
-
if (targets.length === 0) {
|
|
5108
|
-
toggleNotification({
|
|
5109
|
-
type: "warning",
|
|
5110
|
-
message: "Please select at least one collection type or entry to preview"
|
|
5111
6734
|
});
|
|
5112
|
-
|
|
6735
|
+
if (targets.length === 0) {
|
|
6736
|
+
toggleNotification({
|
|
6737
|
+
type: "warning",
|
|
6738
|
+
message: "Please select at least one collection type or entry to preview"
|
|
6739
|
+
});
|
|
6740
|
+
return;
|
|
6741
|
+
}
|
|
5113
6742
|
}
|
|
5114
6743
|
setShowPreviewModal(true);
|
|
5115
6744
|
setPreviewLoading(true);
|
|
5116
6745
|
try {
|
|
5117
6746
|
const res = await post("/bulk-updater/preview", {
|
|
5118
6747
|
attribute: selectedAttribute,
|
|
5119
|
-
value: attributeValue,
|
|
6748
|
+
value: gridEditMode ? "" : attributeValue,
|
|
6749
|
+
editMode: gridEditMode ? "grid" : "common",
|
|
5120
6750
|
selectedEntries: targets,
|
|
5121
|
-
isRegex: useRegex,
|
|
5122
|
-
regexPattern,
|
|
6751
|
+
isRegex: gridEditMode ? false : useRegex,
|
|
6752
|
+
regexPattern: gridEditMode ? "" : regexPattern,
|
|
5123
6753
|
publishOnApproval
|
|
5124
6754
|
});
|
|
5125
6755
|
if (res.data && res.data.success) {
|
|
@@ -5140,28 +6770,33 @@ const BulkUpdater = () => {
|
|
|
5140
6770
|
}
|
|
5141
6771
|
};
|
|
5142
6772
|
const executeBatchWithMode = async (executionMode, forceImmediate = false) => {
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
const
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
if (cachedEntry
|
|
6773
|
+
let targets = [];
|
|
6774
|
+
if (gridEditMode) {
|
|
6775
|
+
targets = gridSerialized.targets;
|
|
6776
|
+
} else {
|
|
6777
|
+
Object.keys(selectedEntries).forEach((key) => {
|
|
6778
|
+
if (selectedEntries[key]) {
|
|
6779
|
+
const parts = key.split(KEY_SEP);
|
|
6780
|
+
if (parts.length === 2) {
|
|
6781
|
+
const colUid = parts[0];
|
|
6782
|
+
const docId = parts[1];
|
|
6783
|
+
const targetObj = { uid: colUid, documentId: docId };
|
|
6784
|
+
if (selectedDzBlocks[key] && selectedDzBlocks[key].length > 0) {
|
|
6785
|
+
targetObj.dynamicZoneIndexes = selectedDzBlocks[key];
|
|
6786
|
+
}
|
|
6787
|
+
const colPage = collectionPages[colUid];
|
|
6788
|
+
const cachedEntry = colPage?.entries?.find((e) => e.documentId === docId);
|
|
6789
|
+
if (cachedEntry) {
|
|
6790
|
+
if (cachedEntry.status) targetObj.status = cachedEntry.status;
|
|
6791
|
+
if (cachedEntry.publishedAt) targetObj.publishedAt = cachedEntry.publishedAt;
|
|
6792
|
+
if (cachedEntry.locale) targetObj.locale = cachedEntry.locale;
|
|
6793
|
+
}
|
|
6794
|
+
targets.push(targetObj);
|
|
5160
6795
|
}
|
|
5161
|
-
targets.push(targetObj);
|
|
5162
6796
|
}
|
|
5163
|
-
}
|
|
5164
|
-
}
|
|
6797
|
+
});
|
|
6798
|
+
}
|
|
6799
|
+
const displaySummaryVal = gridEditMode ? `Grid Editing (${gridSerialized.totalEditCount} edits across ${targets.length} records)` : attributeValue;
|
|
5165
6800
|
try {
|
|
5166
6801
|
setUpdating(true);
|
|
5167
6802
|
setShowConfirmModal(false);
|
|
@@ -5176,7 +6811,7 @@ const BulkUpdater = () => {
|
|
|
5176
6811
|
status: "processing",
|
|
5177
6812
|
executionMode,
|
|
5178
6813
|
attribute: selectedAttribute,
|
|
5179
|
-
value:
|
|
6814
|
+
value: displaySummaryVal,
|
|
5180
6815
|
totalTargets: targets.length,
|
|
5181
6816
|
processedCount: 0,
|
|
5182
6817
|
updatedCount: 0,
|
|
@@ -5191,10 +6826,11 @@ const BulkUpdater = () => {
|
|
|
5191
6826
|
});
|
|
5192
6827
|
const payload = {
|
|
5193
6828
|
attribute: selectedAttribute,
|
|
5194
|
-
value: attributeValue,
|
|
6829
|
+
value: gridEditMode ? "" : attributeValue,
|
|
6830
|
+
editMode: gridEditMode ? "grid" : "common",
|
|
5195
6831
|
selectedEntries: targets,
|
|
5196
|
-
isRegex: useRegex,
|
|
5197
|
-
regexPattern,
|
|
6832
|
+
isRegex: gridEditMode ? false : useRegex,
|
|
6833
|
+
regexPattern: gridEditMode ? "" : regexPattern,
|
|
5198
6834
|
executionMode,
|
|
5199
6835
|
makerNotes: makerNotesInput,
|
|
5200
6836
|
forceImmediate,
|
|
@@ -5206,11 +6842,12 @@ const BulkUpdater = () => {
|
|
|
5206
6842
|
const res = await post("/bulk-updater/batch-update", payload);
|
|
5207
6843
|
setIsSubmittingBatch(false);
|
|
5208
6844
|
if (res.data && res.data.success) {
|
|
5209
|
-
setSelectedEntries({});
|
|
5210
|
-
setSelectedDzBlocks({});
|
|
5211
6845
|
const finalBatchId = res.data.batchId;
|
|
5212
6846
|
setDashboardBatchId(finalBatchId);
|
|
5213
6847
|
if (res.data.pending) {
|
|
6848
|
+
setSelectedEntries({});
|
|
6849
|
+
setSelectedDzBlocks({});
|
|
6850
|
+
if (gridEditMode) setGridEdits({});
|
|
5214
6851
|
setDashboardJob({
|
|
5215
6852
|
id: finalBatchId,
|
|
5216
6853
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -5218,7 +6855,7 @@ const BulkUpdater = () => {
|
|
|
5218
6855
|
executionMode,
|
|
5219
6856
|
scheduledFor: res.data.scheduledFor,
|
|
5220
6857
|
attribute: selectedAttribute,
|
|
5221
|
-
value:
|
|
6858
|
+
value: displaySummaryVal,
|
|
5222
6859
|
totalTargets: targets.length,
|
|
5223
6860
|
processedCount: 0,
|
|
5224
6861
|
updatedCount: 0,
|
|
@@ -5236,7 +6873,31 @@ const BulkUpdater = () => {
|
|
|
5236
6873
|
});
|
|
5237
6874
|
await fetchPendingBatches();
|
|
5238
6875
|
} else {
|
|
5239
|
-
|
|
6876
|
+
const resultList = res.data.results || [];
|
|
6877
|
+
if (gridEditMode) {
|
|
6878
|
+
const failedKeys = new Set(
|
|
6879
|
+
resultList.filter((r) => r.status === "error" && r.uid && r.documentId).map((r) => `${r.uid}${KEY_SEP}${r.documentId}`)
|
|
6880
|
+
);
|
|
6881
|
+
setGridEdits((prev) => {
|
|
6882
|
+
const next = {};
|
|
6883
|
+
for (const k of Object.keys(prev)) {
|
|
6884
|
+
if (failedKeys.has(k)) next[k] = prev[k];
|
|
6885
|
+
}
|
|
6886
|
+
return next;
|
|
6887
|
+
});
|
|
6888
|
+
setSelectedEntries((prev) => {
|
|
6889
|
+
const next = {};
|
|
6890
|
+
for (const k of Object.keys(prev)) {
|
|
6891
|
+
if (failedKeys.has(k) && prev[k]) next[k] = true;
|
|
6892
|
+
}
|
|
6893
|
+
return next;
|
|
6894
|
+
});
|
|
6895
|
+
setSelectedDzBlocks({});
|
|
6896
|
+
} else {
|
|
6897
|
+
setSelectedEntries({});
|
|
6898
|
+
setSelectedDzBlocks({});
|
|
6899
|
+
}
|
|
6900
|
+
setLastResults(resultList);
|
|
5240
6901
|
setUpdateSummary({
|
|
5241
6902
|
updatedCount: res.data.updatedCount || 0,
|
|
5242
6903
|
skippedCount: res.data.skippedCount || 0,
|
|
@@ -5249,15 +6910,15 @@ const BulkUpdater = () => {
|
|
|
5249
6910
|
status: res.data.status || "successful",
|
|
5250
6911
|
executionMode: "immediate",
|
|
5251
6912
|
attribute: selectedAttribute,
|
|
5252
|
-
value:
|
|
6913
|
+
value: res.data.value || displaySummaryVal,
|
|
5253
6914
|
totalTargets: res.data.totalTargets || targets.length,
|
|
5254
|
-
processedCount:
|
|
6915
|
+
processedCount: resultList.length || targets.length,
|
|
5255
6916
|
updatedCount: res.data.updatedCount || 0,
|
|
5256
6917
|
skippedCount: res.data.skippedCount || 0,
|
|
5257
6918
|
failedCount: res.data.failedCount || 0,
|
|
5258
6919
|
isLive: res.data.isLive !== false && res.data.updatedCount > 0,
|
|
5259
6920
|
publishOnApproval,
|
|
5260
|
-
results:
|
|
6921
|
+
results: resultList
|
|
5261
6922
|
});
|
|
5262
6923
|
toggleNotification({
|
|
5263
6924
|
type: "success",
|
|
@@ -6110,6 +7771,7 @@ const BulkUpdater = () => {
|
|
|
6110
7771
|
Checkbox,
|
|
6111
7772
|
{
|
|
6112
7773
|
checked: useRegex,
|
|
7774
|
+
disabled: gridEditMode,
|
|
6113
7775
|
onCheckedChange: (checked) => setUseRegex(Boolean(checked)),
|
|
6114
7776
|
children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: "Enable Regex Search & Replace" })
|
|
6115
7777
|
}
|
|
@@ -6117,10 +7779,10 @@ const BulkUpdater = () => {
|
|
|
6117
7779
|
/* @__PURE__ */ jsx(
|
|
6118
7780
|
Badge,
|
|
6119
7781
|
{
|
|
6120
|
-
backgroundColor: useRegex ? "secondary100" : "neutral200",
|
|
6121
|
-
textColor: useRegex ? "secondary700" : "neutral600",
|
|
7782
|
+
backgroundColor: gridEditMode ? "neutral200" : useRegex ? "secondary100" : "neutral200",
|
|
7783
|
+
textColor: gridEditMode ? "neutral600" : useRegex ? "secondary700" : "neutral600",
|
|
6122
7784
|
size: "S",
|
|
6123
|
-
children: useRegex ? "REGEX SEARCH ACTIVE" : "REGEX OFF"
|
|
7785
|
+
children: gridEditMode ? "DISABLED IN GRID EDIT" : useRegex ? "REGEX SEARCH ACTIVE" : "REGEX OFF"
|
|
6124
7786
|
}
|
|
6125
7787
|
)
|
|
6126
7788
|
] }),
|
|
@@ -6545,6 +8207,72 @@ const BulkUpdater = () => {
|
|
|
6545
8207
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: col.isSingleType ? "1 single entry" : isFilterActive ? `${totalEntries} matching entries in DB` : `${totalEntries} entries` })
|
|
6546
8208
|
] })
|
|
6547
8209
|
] }),
|
|
8210
|
+
gridEditMode && /* @__PURE__ */ jsx(
|
|
8211
|
+
Box,
|
|
8212
|
+
{
|
|
8213
|
+
padding: 3,
|
|
8214
|
+
marginBottom: 3,
|
|
8215
|
+
background: "primary100",
|
|
8216
|
+
hasRadius: true,
|
|
8217
|
+
style: { border: "1px solid #d9d8ff" },
|
|
8218
|
+
children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", wrap: "wrap", gap: 2, children: [
|
|
8219
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
|
|
8220
|
+
/* @__PURE__ */ jsx(Badge, { backgroundColor: "primary600", textColor: "neutral0", children: "GRID EDITING MODE" }),
|
|
8221
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "primary700", children: selectedAttribute ? `Editing "${selectedAttribute}" directly per record & component block` : 'Select an "Attribute to Update" below to enable inline cell editors' }),
|
|
8222
|
+
/* @__PURE__ */ jsxs(Badge, { backgroundColor: "neutral0", textColor: "primary700", children: [
|
|
8223
|
+
totalDirtyCellsCount,
|
|
8224
|
+
" edit",
|
|
8225
|
+
totalDirtyCellsCount === 1 ? "" : "s",
|
|
8226
|
+
" across ",
|
|
8227
|
+
totalDirtyRecordsCount,
|
|
8228
|
+
" record",
|
|
8229
|
+
totalDirtyRecordsCount === 1 ? "" : "s"
|
|
8230
|
+
] })
|
|
8231
|
+
] }),
|
|
8232
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
|
|
8233
|
+
(activeAttrMeta?.rootType === "dynamiczone" || activeAttrMeta?.rootRepeatable) && visibleEntries.length > 0 && /* @__PURE__ */ jsx(
|
|
8234
|
+
Button,
|
|
8235
|
+
{
|
|
8236
|
+
variant: "secondary",
|
|
8237
|
+
size: "S",
|
|
8238
|
+
onClick: () => {
|
|
8239
|
+
const allVisibleKeys = visibleEntries.map((e) => `${col.uid}${KEY_SEP}${e.documentId}`);
|
|
8240
|
+
const anyCollapsed = allVisibleKeys.some((k) => !expandedDzEntries[k]);
|
|
8241
|
+
setExpandedDzEntries((prev) => {
|
|
8242
|
+
const next = { ...prev };
|
|
8243
|
+
allVisibleKeys.forEach((k) => {
|
|
8244
|
+
next[k] = anyCollapsed;
|
|
8245
|
+
});
|
|
8246
|
+
return next;
|
|
8247
|
+
});
|
|
8248
|
+
},
|
|
8249
|
+
children: visibleEntries.some((e) => !expandedDzEntries[`${col.uid}${KEY_SEP}${e.documentId}`]) ? "Expand All Blocks" : "Collapse All Blocks"
|
|
8250
|
+
}
|
|
8251
|
+
),
|
|
8252
|
+
/* @__PURE__ */ jsx(
|
|
8253
|
+
Button,
|
|
8254
|
+
{
|
|
8255
|
+
variant: gridFilterModifiedOnly ? "default" : "tertiary",
|
|
8256
|
+
size: "S",
|
|
8257
|
+
onClick: () => setGridFilterModifiedOnly((v) => !v),
|
|
8258
|
+
disabled: totalDirtyRecordsCount === 0 && !gridFilterModifiedOnly,
|
|
8259
|
+
children: gridFilterModifiedOnly ? "Showing Modified Only" : "Filter: Modified Only"
|
|
8260
|
+
}
|
|
8261
|
+
),
|
|
8262
|
+
/* @__PURE__ */ jsx(
|
|
8263
|
+
Button,
|
|
8264
|
+
{
|
|
8265
|
+
variant: "danger-light",
|
|
8266
|
+
size: "S",
|
|
8267
|
+
disabled: totalDirtyCellsCount === 0,
|
|
8268
|
+
onClick: () => setGridEdits({}),
|
|
8269
|
+
children: "Discard All Edits"
|
|
8270
|
+
}
|
|
8271
|
+
)
|
|
8272
|
+
] })
|
|
8273
|
+
] })
|
|
8274
|
+
}
|
|
8275
|
+
),
|
|
6548
8276
|
/* @__PURE__ */ jsx(Box, { className: "bulk-updater-table-container", style: { width: "100%", maxWidth: "100%", minWidth: 0, overflowX: "auto" }, children: /* @__PURE__ */ jsxs(Table, { colCount: activeColumns.length, rowCount: visibleEntries.length + 1, style: { width: "100%" }, children: [
|
|
6549
8277
|
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsx(Tr, { children: activeColumns.map(
|
|
6550
8278
|
(colDef) => renderHeaderCell(colDef, col, currentSort, selectedAttribute, searchAttribute, handleHeaderSortClick)
|
|
@@ -6561,12 +8289,27 @@ const BulkUpdater = () => {
|
|
|
6561
8289
|
const dzFields = Object.keys(entry).filter(
|
|
6562
8290
|
(k) => Array.isArray(entry[k]) && entry[k].length > 0 && entry[k].some((item) => item && item.__component)
|
|
6563
8291
|
);
|
|
8292
|
+
const selectedRootKey = selectedAttribute ? selectedAttribute.split("[")[0].split(".")[0] : "";
|
|
8293
|
+
const expandableArrayFields = gridEditMode && selectedRootKey && activeAttrMeta?.rootRepeatable && !dzFields.includes(selectedRootKey) && Array.isArray(entry[selectedRootKey]) && entry[selectedRootKey].length > 0 ? [...dzFields, selectedRootKey] : dzFields;
|
|
8294
|
+
const recordEdits = gridEdits[key];
|
|
8295
|
+
const gridCtx = gridEditMode ? {
|
|
8296
|
+
gridEditMode: true,
|
|
8297
|
+
selectedAttrMeta: activeAttrMeta,
|
|
8298
|
+
recordEdits,
|
|
8299
|
+
relationOptions,
|
|
8300
|
+
relationOptionsLoading,
|
|
8301
|
+
relationIsMulti: Boolean(relationsMeta[selectedAttribute]?.isMulti),
|
|
8302
|
+
validationRules,
|
|
8303
|
+
onCommitEdit: handleGridCellCommit,
|
|
8304
|
+
onResetEdit: handleGridCellReset
|
|
8305
|
+
} : void 0;
|
|
8306
|
+
const rowOccs = gridEditMode && isDzExpanded && selectedAttribute ? enumerateClientOccurrences(entry, selectedAttribute, col?.attributes, activeAttrMeta) : [];
|
|
6564
8307
|
return /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
|
|
6565
8308
|
/* @__PURE__ */ jsx(
|
|
6566
8309
|
Tr,
|
|
6567
8310
|
{
|
|
6568
8311
|
style: {
|
|
6569
|
-
backgroundColor: isSelected ? "rgba(73, 69, 255, 0.14)" : isMatch ? "rgba(46, 213, 115, 0.08)" : void 0,
|
|
8312
|
+
backgroundColor: recordEdits ? "rgba(73, 69, 255, 0.10)" : isSelected ? "rgba(73, 69, 255, 0.14)" : isMatch ? "rgba(46, 213, 115, 0.08)" : void 0,
|
|
6570
8313
|
boxShadow: isSelected ? "inset 3px 0 0 0 #4945ff" : isMatch ? "inset 3px 0 0 0 #2ed573" : void 0
|
|
6571
8314
|
},
|
|
6572
8315
|
children: activeColumns.map((colDef) => /* @__PURE__ */ jsx(Td, { children: renderCellContent(
|
|
@@ -6582,97 +8325,47 @@ const BulkUpdater = () => {
|
|
|
6582
8325
|
pendingBatches,
|
|
6583
8326
|
isDzExpanded,
|
|
6584
8327
|
onToggleExpandDz,
|
|
6585
|
-
filterQuery
|
|
8328
|
+
filterQuery,
|
|
8329
|
+
gridCtx
|
|
6586
8330
|
) }, colDef.key))
|
|
6587
8331
|
}
|
|
6588
8332
|
),
|
|
6589
|
-
isDzExpanded &&
|
|
6590
|
-
const
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
if (!targetParsed.subPath) return true;
|
|
6594
|
-
const scopedPath = `${dzKey}[${blockItem?.__component}].${targetParsed.subPath}`;
|
|
6595
|
-
const componentSupports = (col?.attributes || attributes || []).includes(scopedPath);
|
|
6596
|
-
return componentSupports || getNestedValue(blockItem, targetParsed.subPath) !== void 0;
|
|
6597
|
-
};
|
|
6598
|
-
const allApplicableIndexes = blocks.map((_, i) => i).filter((i) => isBlockApplicable(blocks[i]));
|
|
6599
|
-
return /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: activeColumns.length, style: { padding: "12px 16px", backgroundColor: "rgba(73, 69, 255, 0.02)", borderBottom: "2px solid rgba(73, 69, 255, 0.15)" }, children: /* @__PURE__ */ jsxs(
|
|
6600
|
-
Box,
|
|
8333
|
+
isDzExpanded && expandableArrayFields.map((dzKey) => {
|
|
8334
|
+
const drawerOccurrences = gridEditMode && selectedAttribute ? rowOccs : enumerateClientOccurrences(entry, selectedAttribute, col?.attributes, activeAttrMeta);
|
|
8335
|
+
return /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(
|
|
8336
|
+
Td,
|
|
6601
8337
|
{
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
] }) }),
|
|
6632
|
-
/* @__PURE__ */ jsx(Tbody, { children: blocks.map((block, bIdx) => {
|
|
6633
|
-
const compUid = block.__component;
|
|
6634
|
-
const compLabel = formatComponentName(compUid);
|
|
6635
|
-
const scopedPath = `${dzKey}[${compUid}].${targetParsed.subPath}`;
|
|
6636
|
-
const componentSupports = (col?.attributes || attributes || []).includes(scopedPath);
|
|
6637
|
-
const blockVal = targetParsed.subPath ? getNestedValue(block, targetParsed.subPath) : void 0;
|
|
6638
|
-
const hasTargetAttr = componentSupports || blockVal !== void 0;
|
|
6639
|
-
const isBlockChecked = hasTargetAttr && isSelected && (selectedDzBlocks[key] !== void 0 ? selectedDzBlocks[key].includes(bIdx) : true);
|
|
6640
|
-
return /* @__PURE__ */ jsxs(
|
|
6641
|
-
Tr,
|
|
6642
|
-
{
|
|
6643
|
-
style: {
|
|
6644
|
-
backgroundColor: isBlockChecked ? "rgba(73, 69, 255, 0.08)" : void 0
|
|
6645
|
-
},
|
|
6646
|
-
children: [
|
|
6647
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
6648
|
-
Checkbox,
|
|
6649
|
-
{
|
|
6650
|
-
checked: isBlockChecked,
|
|
6651
|
-
disabled: !hasTargetAttr,
|
|
6652
|
-
onCheckedChange: () => {
|
|
6653
|
-
toggleDzBlock(col.uid, entry.documentId, bIdx, allApplicableIndexes);
|
|
6654
|
-
}
|
|
6655
|
-
}
|
|
6656
|
-
) }),
|
|
6657
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", children: [
|
|
6658
|
-
"#",
|
|
6659
|
-
bIdx
|
|
6660
|
-
] }) }),
|
|
6661
|
-
/* @__PURE__ */ jsxs(Td, { children: [
|
|
6662
|
-
/* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: compLabel }),
|
|
6663
|
-
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", display: "block", style: { fontSize: "0.68rem", marginTop: 2 }, children: compUid })
|
|
6664
|
-
] }),
|
|
6665
|
-
/* @__PURE__ */ jsx(Td, { children: hasTargetAttr ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "primary700", children: formatDisplayValue(blockVal) }) : /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral100", textColor: "neutral500", children: "Does not contain attribute" }) }),
|
|
6666
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { maxWidth: 300, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: block.title || block.name || block.heading || block.body || Object.keys(block).filter((k) => !k.startsWith("_") && k !== "id").slice(0, 3).map((k) => `${k}: ${formatDisplayValue(block[k])}`).join(", ") || "-" }) })
|
|
6667
|
-
]
|
|
6668
|
-
},
|
|
6669
|
-
bIdx
|
|
6670
|
-
);
|
|
6671
|
-
}) })
|
|
6672
|
-
] })
|
|
6673
|
-
]
|
|
8338
|
+
colSpan: activeColumns.length,
|
|
8339
|
+
style: {
|
|
8340
|
+
padding: "12px 16px",
|
|
8341
|
+
backgroundColor: "rgba(73, 69, 255, 0.02)",
|
|
8342
|
+
borderBottom: "2px solid rgba(73, 69, 255, 0.15)"
|
|
8343
|
+
},
|
|
8344
|
+
children: /* @__PURE__ */ jsx(
|
|
8345
|
+
ComponentOccurrencesDrawer,
|
|
8346
|
+
{
|
|
8347
|
+
colUid: col.uid,
|
|
8348
|
+
rootKey: dzKey,
|
|
8349
|
+
entry,
|
|
8350
|
+
selectedAttribute,
|
|
8351
|
+
attrMeta: activeAttrMeta,
|
|
8352
|
+
colAttributes: col?.attributes || attributes || [],
|
|
8353
|
+
gridEditMode,
|
|
8354
|
+
isSelected,
|
|
8355
|
+
selectedDzBlocks: selectedDzBlocks[key],
|
|
8356
|
+
occurrences: drawerOccurrences,
|
|
8357
|
+
recordEdits,
|
|
8358
|
+
relationOptions,
|
|
8359
|
+
relationOptionsLoading,
|
|
8360
|
+
relationIsMulti: Boolean(relationsMeta[selectedAttribute]?.isMulti),
|
|
8361
|
+
validationRules,
|
|
8362
|
+
onToggleDzBlock: toggleDzBlock,
|
|
8363
|
+
onCommitEdit: handleGridCellCommit,
|
|
8364
|
+
onResetEdit: handleGridCellReset
|
|
8365
|
+
}
|
|
8366
|
+
)
|
|
6674
8367
|
}
|
|
6675
|
-
) }
|
|
8368
|
+
) }, `${key}-dz-${dzKey}`);
|
|
6676
8369
|
})
|
|
6677
8370
|
] }, key);
|
|
6678
8371
|
}) })
|
|
@@ -6771,10 +8464,38 @@ const BulkUpdater = () => {
|
|
|
6771
8464
|
marginBottom: 6,
|
|
6772
8465
|
style: { width: "100%", maxWidth: "100%", minWidth: 0, boxSizing: "border-box" },
|
|
6773
8466
|
children: [
|
|
6774
|
-
/* @__PURE__ */
|
|
6775
|
-
/* @__PURE__ */
|
|
6776
|
-
|
|
6777
|
-
|
|
8467
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 4, wrap: "wrap", gap: 3, children: [
|
|
8468
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
8469
|
+
/* @__PURE__ */ jsx(Typography, { variant: "delta", tag: "h2", fontWeight: "semiBold", children: "2. Configure Attribute Update" }),
|
|
8470
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Select the target attribute to update and either apply a common value or enable inline Grid Editing." })
|
|
8471
|
+
] }),
|
|
8472
|
+
/* @__PURE__ */ jsx(Flex, { gap: 3, alignItems: "center", wrap: "wrap", children: /* @__PURE__ */ jsx(
|
|
8473
|
+
Box,
|
|
8474
|
+
{
|
|
8475
|
+
padding: 2,
|
|
8476
|
+
paddingLeft: 3,
|
|
8477
|
+
paddingRight: 3,
|
|
8478
|
+
background: gridEditMode ? "primary100" : "neutral100",
|
|
8479
|
+
hasRadius: true,
|
|
8480
|
+
style: { border: gridEditMode ? "1px solid #4945ff" : "1px solid #eaeaef" },
|
|
8481
|
+
children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
8482
|
+
/* @__PURE__ */ jsx(
|
|
8483
|
+
Checkbox,
|
|
8484
|
+
{
|
|
8485
|
+
checked: gridEditMode,
|
|
8486
|
+
onCheckedChange: (checked) => handleToggleGridEditMode(Boolean(checked)),
|
|
8487
|
+
children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: gridEditMode ? "primary700" : "neutral800", children: "Edit Values in Grid" })
|
|
8488
|
+
}
|
|
8489
|
+
),
|
|
8490
|
+
gridEditMode && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "primary600", textColor: "neutral0", size: "S", children: [
|
|
8491
|
+
"ON (",
|
|
8492
|
+
gridSerialized.totalEditCount,
|
|
8493
|
+
" edits)"
|
|
8494
|
+
] })
|
|
8495
|
+
] })
|
|
8496
|
+
}
|
|
8497
|
+
) })
|
|
8498
|
+
] }),
|
|
6778
8499
|
/* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
|
|
6779
8500
|
/* @__PURE__ */ jsx(Box, { style: { width: 280, minWidth: 230 }, children: /* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
6780
8501
|
/* @__PURE__ */ jsx(Field.Label, { children: "Attribute to Update" }),
|
|
@@ -6801,7 +8522,35 @@ const BulkUpdater = () => {
|
|
|
6801
8522
|
`update-attr-${selectedCollectionUid}`
|
|
6802
8523
|
)
|
|
6803
8524
|
] }) }),
|
|
6804
|
-
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 340 }, children:
|
|
8525
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 340 }, children: gridEditMode ? /* @__PURE__ */ jsx(
|
|
8526
|
+
Box,
|
|
8527
|
+
{
|
|
8528
|
+
padding: 3,
|
|
8529
|
+
background: "primary100",
|
|
8530
|
+
hasRadius: true,
|
|
8531
|
+
style: { border: "1px solid #d9d8ff" },
|
|
8532
|
+
children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", wrap: "wrap", gap: 2, children: [
|
|
8533
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
8534
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "primary700", display: "block", children: "Common value input hidden — Grid Editing Mode active" }),
|
|
8535
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral700", children: gridSerialized.targets.length > 0 ? `Ready: ${gridSerialized.totalEditCount} edited field/block value(s) across ${gridSerialized.targets.length} selected record(s).` : "Edit cell values directly in the table above (or expand component blocks) to queue heterogeneous updates." }),
|
|
8536
|
+
gridSerialized.hasValidationErrors && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", display: "block", children: "⚠️ Resolve inline red validation errors before previewing or updating." })
|
|
8537
|
+
] }),
|
|
8538
|
+
totalDirtyCellsCount > 0 && /* @__PURE__ */ jsxs(
|
|
8539
|
+
Button,
|
|
8540
|
+
{
|
|
8541
|
+
variant: "danger-light",
|
|
8542
|
+
size: "S",
|
|
8543
|
+
onClick: () => setGridEdits({}),
|
|
8544
|
+
children: [
|
|
8545
|
+
"Discard Edits (",
|
|
8546
|
+
totalDirtyCellsCount,
|
|
8547
|
+
")"
|
|
8548
|
+
]
|
|
8549
|
+
}
|
|
8550
|
+
)
|
|
8551
|
+
] })
|
|
8552
|
+
}
|
|
8553
|
+
) : relationsMeta[selectedAttribute] ? /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, style: { width: "100%" }, children: [
|
|
6805
8554
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
|
|
6806
8555
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral700", children: [
|
|
6807
8556
|
"Target ",
|
|
@@ -6886,10 +8635,10 @@ const BulkUpdater = () => {
|
|
|
6886
8635
|
size: "L",
|
|
6887
8636
|
onClick: handleOpenPreviewModal,
|
|
6888
8637
|
loading: previewLoading,
|
|
6889
|
-
disabled: loading ||
|
|
8638
|
+
disabled: loading || !selectedAttribute || !selectedAttribute.trim() || (gridEditMode ? gridSerialized.targets.length === 0 || gridSerialized.hasValidationErrors : totalSelectedCount === 0),
|
|
6890
8639
|
children: [
|
|
6891
8640
|
"Preview Changes (",
|
|
6892
|
-
totalSelectedCount,
|
|
8641
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
6893
8642
|
")"
|
|
6894
8643
|
]
|
|
6895
8644
|
}
|
|
@@ -6902,10 +8651,10 @@ const BulkUpdater = () => {
|
|
|
6902
8651
|
size: "L",
|
|
6903
8652
|
onClick: handleOpenConfirmModal,
|
|
6904
8653
|
loading: updating,
|
|
6905
|
-
disabled: loading ||
|
|
8654
|
+
disabled: loading || !selectedAttribute || !selectedAttribute.trim() || (gridEditMode ? gridSerialized.targets.length === 0 || gridSerialized.hasValidationErrors : totalSelectedCount === 0),
|
|
6906
8655
|
children: [
|
|
6907
8656
|
"Update Selected (",
|
|
6908
|
-
totalSelectedCount,
|
|
8657
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
6909
8658
|
")"
|
|
6910
8659
|
]
|
|
6911
8660
|
}
|
|
@@ -6992,11 +8741,11 @@ const BulkUpdater = () => {
|
|
|
6992
8741
|
"Attribute: ",
|
|
6993
8742
|
selectedAttribute,
|
|
6994
8743
|
" ",
|
|
6995
|
-
|
|
8744
|
+
activeAttrMeta?.type ? `(${activeAttrMeta.type})` : ""
|
|
6996
8745
|
] }),
|
|
6997
|
-
|
|
8746
|
+
activeAttrMeta?.depth ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: "neutral200", textColor: "neutral700", children: [
|
|
6998
8747
|
"Nesting Level: L",
|
|
6999
|
-
|
|
8748
|
+
activeAttrMeta.depth
|
|
7000
8749
|
] }) : null,
|
|
7001
8750
|
selectedCol.draftAndPublish ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "success100", textColor: "success700", children: "Draft & Publish Enabled" }) : /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "Direct Publish Only" })
|
|
7002
8751
|
] }) }) })
|
|
@@ -7434,7 +9183,15 @@ const BulkUpdater = () => {
|
|
|
7434
9183
|
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Previous Value" }) }),
|
|
7435
9184
|
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Applied Value" }) })
|
|
7436
9185
|
] }) }),
|
|
7437
|
-
/* @__PURE__ */ jsx(Tbody, { children: rec.diffs.
|
|
9186
|
+
/* @__PURE__ */ jsx(Tbody, { children: rec.diffs.flatMap(
|
|
9187
|
+
(d) => Array.isArray(d.dynamicZoneDiffs) && d.dynamicZoneDiffs.length > 0 ? d.dynamicZoneDiffs.map((dz) => ({
|
|
9188
|
+
collectionName: d.collectionName,
|
|
9189
|
+
label: `${d.label}${dz.componentName ? ` [${dz.componentName}]` : ""}`,
|
|
9190
|
+
attribute: dz.attribute || d.attribute,
|
|
9191
|
+
oldValue: dz.oldValue,
|
|
9192
|
+
newValue: dz.newValue
|
|
9193
|
+
})) : [d]
|
|
9194
|
+
).map((d, dIdx) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
7438
9195
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: d.collectionName }) }),
|
|
7439
9196
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { children: d.label }) }),
|
|
7440
9197
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: d.attribute || "field" }) }),
|
|
@@ -7523,7 +9280,13 @@ const BulkUpdater = () => {
|
|
|
7523
9280
|
] }),
|
|
7524
9281
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
|
|
7525
9282
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: "Target Value:" }),
|
|
7526
|
-
/* @__PURE__ */ jsx(Typography, { variant: "omega", style: { wordBreak: "break-all", maxWidth: 360 }, children:
|
|
9283
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", style: { wordBreak: "break-all", maxWidth: 360 }, children: gridEditMode ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
|
|
9284
|
+
"Grid Editing (",
|
|
9285
|
+
gridSerialized.totalEditCount,
|
|
9286
|
+
" heterogeneous edits across ",
|
|
9287
|
+
gridSerialized.targets.length,
|
|
9288
|
+
" records)"
|
|
9289
|
+
] }) : relationsMeta[selectedAttribute] ? /* @__PURE__ */ jsx("span", { children: selectedRelationDocId === "__clear__" ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "danger100", textColor: "danger700", children: "Clear / Unlink Relation" }) : /* @__PURE__ */ jsxs(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
|
|
7527
9290
|
relationsMeta[selectedAttribute].isMulti ? `[${relationMode.toUpperCase()}] ` : "",
|
|
7528
9291
|
relationOptions.find((o) => o.documentId === selectedRelationDocId)?.label || selectedRelationDocId || "(none selected)"
|
|
7529
9292
|
] }) }) : useRegex ? /* @__PURE__ */ jsxs("span", { children: [
|
|
@@ -7548,7 +9311,7 @@ const BulkUpdater = () => {
|
|
|
7548
9311
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
|
|
7549
9312
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: "Total Selected Records:" }),
|
|
7550
9313
|
/* @__PURE__ */ jsxs(Typography, { fontWeight: "bold", textColor: "primary600", children: [
|
|
7551
|
-
totalSelectedCount,
|
|
9314
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
7552
9315
|
" records"
|
|
7553
9316
|
] })
|
|
7554
9317
|
] }),
|
|
@@ -7584,31 +9347,31 @@ const BulkUpdater = () => {
|
|
|
7584
9347
|
/* @__PURE__ */ jsxs(Box, { marginBottom: 4, padding: 3, background: "neutral100", hasRadius: true, style: { border: "1px solid rgba(120, 120, 150, 0.15)" }, children: [
|
|
7585
9348
|
/* @__PURE__ */ jsxs(Typography, { variant: "sigma", textColor: "neutral600", marginBottom: 2, display: "block", children: [
|
|
7586
9349
|
"LIFECYCLE STATUS BREAKDOWN (",
|
|
7587
|
-
totalSelectedCount,
|
|
9350
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
7588
9351
|
" Selected)"
|
|
7589
9352
|
] }),
|
|
7590
9353
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", children: [
|
|
7591
9354
|
/* @__PURE__ */ jsxs(Badge, { backgroundColor: "success100", textColor: "success700", children: [
|
|
7592
9355
|
"✓ Published / Approved: ",
|
|
7593
|
-
|
|
9356
|
+
updateModalLifecycleStats.published
|
|
7594
9357
|
] }),
|
|
7595
|
-
|
|
9358
|
+
updateModalLifecycleStats.modified > 0 && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "primary100", textColor: "primary700", children: [
|
|
7596
9359
|
"📝 Modified (Unreviewed Revisions): ",
|
|
7597
|
-
|
|
9360
|
+
updateModalLifecycleStats.modified
|
|
7598
9361
|
] }),
|
|
7599
|
-
|
|
9362
|
+
updateModalLifecycleStats.draft > 0 && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "neutral200", textColor: "neutral800", children: [
|
|
7600
9363
|
"📄 Draft (Never Published): ",
|
|
7601
|
-
|
|
9364
|
+
updateModalLifecycleStats.draft
|
|
7602
9365
|
] }),
|
|
7603
|
-
|
|
9366
|
+
updateModalLifecycleStats.pendingReview > 0 && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "warning100", textColor: "warning700", children: [
|
|
7604
9367
|
"⏳ Pending Review: ",
|
|
7605
|
-
|
|
9368
|
+
updateModalLifecycleStats.pendingReview
|
|
7606
9369
|
] })
|
|
7607
9370
|
] })
|
|
7608
9371
|
] }),
|
|
7609
9372
|
/* @__PURE__ */ jsxs(Box, { marginBottom: 4, children: [
|
|
7610
9373
|
/* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", marginBottom: 2, display: "block", children: "COLLECTION BREAKDOWN" }),
|
|
7611
|
-
/* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, children: Object.entries(getSelectedBreakdown()).map(([name, count]) => /* @__PURE__ */ jsxs(
|
|
9374
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, children: Object.entries(getSelectedBreakdown(gridEditMode ? gridTargetKeys : void 0)).map(([name, count]) => /* @__PURE__ */ jsxs(
|
|
7612
9375
|
Flex,
|
|
7613
9376
|
{
|
|
7614
9377
|
justifyContent: "space-between",
|
|
@@ -7656,7 +9419,7 @@ const BulkUpdater = () => {
|
|
|
7656
9419
|
] })
|
|
7657
9420
|
}
|
|
7658
9421
|
),
|
|
7659
|
-
publishOnApproval &&
|
|
9422
|
+
publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && /* @__PURE__ */ jsxs(
|
|
7660
9423
|
Box,
|
|
7661
9424
|
{
|
|
7662
9425
|
padding: 4,
|
|
@@ -7700,11 +9463,11 @@ const BulkUpdater = () => {
|
|
|
7700
9463
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", display: "block", children: "🛡️ Safe Publishing (Recommended)" }),
|
|
7701
9464
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
7702
9465
|
"Only publish records that are already approved & live (",
|
|
7703
|
-
|
|
9466
|
+
updateModalLifecycleStats.published,
|
|
7704
9467
|
" record",
|
|
7705
|
-
|
|
9468
|
+
updateModalLifecycleStats.published === 1 ? "" : "s",
|
|
7706
9469
|
"). The ",
|
|
7707
|
-
|
|
9470
|
+
updateModalLifecycleStats.unreviewedCount,
|
|
7708
9471
|
" unreviewed or draft record(s) will receive the bulk update in Draft mode without publishing unreviewed draft revisions to visitors."
|
|
7709
9472
|
] })
|
|
7710
9473
|
] })
|
|
@@ -7738,9 +9501,9 @@ const BulkUpdater = () => {
|
|
|
7738
9501
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "danger700", display: "block", children: "⚠️ Publish All Selected Records (Includes Unreviewed Drafts)" }),
|
|
7739
9502
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
7740
9503
|
"Publish all ",
|
|
7741
|
-
totalSelectedCount,
|
|
9504
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
7742
9505
|
" records live to production immediately, pushing all pending unreviewed draft edits in the ",
|
|
7743
|
-
|
|
9506
|
+
updateModalLifecycleStats.unreviewedCount,
|
|
7744
9507
|
" draft/modified record(s) live."
|
|
7745
9508
|
] })
|
|
7746
9509
|
] })
|
|
@@ -7767,7 +9530,7 @@ const BulkUpdater = () => {
|
|
|
7767
9530
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "danger700", display: "block", children: "Mandatory Risk Consent Required" }),
|
|
7768
9531
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "danger700", children: [
|
|
7769
9532
|
"I understand and explicitly consent that ",
|
|
7770
|
-
|
|
9533
|
+
updateModalLifecycleStats.unreviewedCount,
|
|
7771
9534
|
" record(s) with unreviewed draft revisions or saved draft states will be published live to production visitors."
|
|
7772
9535
|
] })
|
|
7773
9536
|
] })
|
|
@@ -7805,7 +9568,7 @@ const BulkUpdater = () => {
|
|
|
7805
9568
|
boxShadow: "0 -4px 16px rgba(0, 0, 0, 0.08)"
|
|
7806
9569
|
},
|
|
7807
9570
|
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, style: { width: "100%" }, children: [
|
|
7808
|
-
publishOnApproval &&
|
|
9571
|
+
publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: "⚠️ Explicit consent is required before publishing records with unreviewed draft revisions." }),
|
|
7809
9572
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", gap: 3, style: { width: "100%" }, children: [
|
|
7810
9573
|
/* @__PURE__ */ jsx(Button, { variant: "tertiary", size: "M", onClick: () => setShowConfirmModal(false), children: "Cancel" }),
|
|
7811
9574
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", alignItems: "center", children: [
|
|
@@ -7816,7 +9579,7 @@ const BulkUpdater = () => {
|
|
|
7816
9579
|
size: "M",
|
|
7817
9580
|
onClick: () => executeBatchWithMode("maker_checker"),
|
|
7818
9581
|
loading: updating,
|
|
7819
|
-
disabled: updating || publishOnApproval &&
|
|
9582
|
+
disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
|
|
7820
9583
|
children: "Submit for Checker Approval"
|
|
7821
9584
|
}
|
|
7822
9585
|
),
|
|
@@ -7828,7 +9591,7 @@ const BulkUpdater = () => {
|
|
|
7828
9591
|
size: "M",
|
|
7829
9592
|
onClick: () => executeBatchWithMode("queue_offpeak"),
|
|
7830
9593
|
loading: updating,
|
|
7831
|
-
disabled: updating || publishOnApproval &&
|
|
9594
|
+
disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
|
|
7832
9595
|
children: [
|
|
7833
9596
|
"Queue for Off-Peak (",
|
|
7834
9597
|
executionWindow?.offPeakStartTime || "18:00",
|
|
@@ -7843,7 +9606,7 @@ const BulkUpdater = () => {
|
|
|
7843
9606
|
size: "S",
|
|
7844
9607
|
onClick: () => executeBatchWithMode("immediate", true),
|
|
7845
9608
|
loading: updating,
|
|
7846
|
-
disabled: updating || publishOnApproval &&
|
|
9609
|
+
disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
|
|
7847
9610
|
children: "Force Run Now"
|
|
7848
9611
|
}
|
|
7849
9612
|
)
|
|
@@ -7854,7 +9617,7 @@ const BulkUpdater = () => {
|
|
|
7854
9617
|
size: "M",
|
|
7855
9618
|
onClick: () => executeBatchWithMode("immediate"),
|
|
7856
9619
|
loading: updating,
|
|
7857
|
-
disabled: updating || publishOnApproval &&
|
|
9620
|
+
disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
|
|
7858
9621
|
children: "Confirm & Execute Now"
|
|
7859
9622
|
}
|
|
7860
9623
|
)
|
|
@@ -8143,9 +9906,10 @@ const BulkUpdater = () => {
|
|
|
8143
9906
|
loading: previewLoading,
|
|
8144
9907
|
previewData,
|
|
8145
9908
|
attribute: selectedAttribute,
|
|
9909
|
+
editMode: gridEditMode ? "grid" : "common",
|
|
8146
9910
|
publishOnApproval,
|
|
8147
9911
|
lifecycleStats: selectedLifecycleStats,
|
|
8148
|
-
targetValueDisplay: relationsMeta[selectedAttribute] ? selectedRelationDocId === "__clear__" ? "Clear / Unlink Relation" : relationOptions.find((o) => o.documentId === selectedRelationDocId)?.label || selectedRelationDocId || "(none)" : useRegex ? `Replace /${regexPattern}/g with "${attributeValue}"` : attributeValue
|
|
9912
|
+
targetValueDisplay: gridEditMode ? `Grid Editing (${gridSerialized.totalEditCount} edits across ${gridSerialized.targets.length} records)` : relationsMeta[selectedAttribute] ? selectedRelationDocId === "__clear__" ? "Clear / Unlink Relation" : relationOptions.find((o) => o.documentId === selectedRelationDocId)?.label || selectedRelationDocId || "(none)" : useRegex ? `Replace /${regexPattern}/g with "${attributeValue}"` : attributeValue
|
|
8149
9913
|
}
|
|
8150
9914
|
),
|
|
8151
9915
|
/* @__PURE__ */ jsx(
|
|
@@ -8187,4 +9951,4 @@ export {
|
|
|
8187
9951
|
getSortOptionsForCollection,
|
|
8188
9952
|
parseDynamicZonePath
|
|
8189
9953
|
};
|
|
8190
|
-
//# sourceMappingURL=BulkUpdater-
|
|
9954
|
+
//# sourceMappingURL=BulkUpdater-CTKfvKhE.mjs.map
|