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