strapi-plugin-bulk-updater 1.5.16 → 1.6.1
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-C7-KHLWq.js → BulkUpdater-DTJLdJJy.js} +2473 -534
- package/dist/_chunks/BulkUpdater-DTJLdJJy.js.map +1 -0
- package/dist/_chunks/{BulkUpdater-Bj-8DvpD.mjs → BulkUpdater-xj4wH_iI.mjs} +2475 -536
- package/dist/_chunks/BulkUpdater-xj4wH_iI.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +6926 -4911
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +6926 -4911
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/_chunks/BulkUpdater-Bj-8DvpD.mjs.map +0 -1
- package/dist/_chunks/BulkUpdater-C7-KHLWq.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React__default, { useRef, useState, useEffect, useMemo } from "react";
|
|
3
3
|
import { useFetchClient, useNotification } from "@strapi/strapi/admin";
|
|
4
|
-
import { Box, Flex, Typography, Button, Combobox, ComboboxOption, Badge, SingleSelect, SingleSelectOption, TextInput, Checkbox, Alert, Table, Thead, Tr, Th, Tbody, Td, Loader, Field } from "@strapi/design-system";
|
|
5
|
-
import { ArrowClockwise, Download, Upload, ChevronLeft, ChevronRight, Eye, Check, Cog, Play } from "@strapi/icons";
|
|
4
|
+
import { Box, Flex, Typography, Button, Combobox, ComboboxOption, Badge, SingleSelect, SingleSelectOption, TextInput, Checkbox, Alert, Table, Thead, Tr, Th, Tbody, Td, Loader, Textarea, Field } from "@strapi/design-system";
|
|
5
|
+
import { ArrowClockwise, Download, Search, Upload, ChevronLeft, ChevronRight, Eye, Check, Cog, Play } from "@strapi/icons";
|
|
6
6
|
import { i as isAbortError, V as ValidationRulesTab } from "./ValidationRulesTab-BtOCWK8E.mjs";
|
|
7
7
|
function parseCsvRows(csvText) {
|
|
8
8
|
if (!csvText) return [];
|
|
@@ -350,6 +350,86 @@ function getEntryLifecycleStatus(entry, col, pendingBatches = []) {
|
|
|
350
350
|
textColor: "neutral700"
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
|
+
const EMPTY_SEARCH_FILTER = {
|
|
354
|
+
searchAttribute: "",
|
|
355
|
+
filterOperator: "none",
|
|
356
|
+
filterQuery: "",
|
|
357
|
+
entrySearch: "",
|
|
358
|
+
statusFilter: "all",
|
|
359
|
+
useRegex: false,
|
|
360
|
+
regexPattern: ""
|
|
361
|
+
};
|
|
362
|
+
function areSearchFiltersEqual(a, b, options = {}) {
|
|
363
|
+
if ((a.searchAttribute || "") !== (b.searchAttribute || "") || (a.filterOperator || "none") !== (b.filterOperator || "none") || (a.filterQuery || "") !== (b.filterQuery || "") || (a.entrySearch || "") !== (b.entrySearch || "")) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
if (options.includeWorkspaceExtras) {
|
|
367
|
+
if ((a.statusFilter || "all") !== (b.statusFilter || "all") || Boolean(a.useRegex) !== Boolean(b.useRegex) || (a.regexPattern || "") !== (b.regexPattern || "")) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return true;
|
|
372
|
+
}
|
|
373
|
+
function isSearchFilterActive(filter, selectedTargetAttribute = "") {
|
|
374
|
+
const hasAttrFilter = Boolean(filter.searchAttribute && filter.searchAttribute !== selectedTargetAttribute);
|
|
375
|
+
const hasOp = filter.filterOperator !== "none" && (["empty", "not_empty"].includes(filter.filterOperator) || Boolean((filter.filterQuery || "").trim()));
|
|
376
|
+
const hasSearchText = Boolean((filter.entrySearch || "").trim());
|
|
377
|
+
const hasStatus = Boolean(filter.statusFilter && filter.statusFilter !== "all");
|
|
378
|
+
const hasRegex = Boolean(filter.useRegex && (filter.regexPattern || "").trim());
|
|
379
|
+
return hasAttrFilter || hasOp || hasSearchText || hasStatus || hasRegex;
|
|
380
|
+
}
|
|
381
|
+
function buildEntriesQueryParams(options) {
|
|
382
|
+
const { page, pageSize, filter, selectedAttribute, sortField, sortOrder, includeAttributeEvenIfSame } = options;
|
|
383
|
+
const params = new URLSearchParams({
|
|
384
|
+
page: String(page),
|
|
385
|
+
pageSize: String(pageSize)
|
|
386
|
+
});
|
|
387
|
+
if (includeAttributeEvenIfSame) {
|
|
388
|
+
if (filter.searchAttribute) {
|
|
389
|
+
params.set("attribute", filter.searchAttribute);
|
|
390
|
+
params.set("searchAttribute", filter.searchAttribute);
|
|
391
|
+
}
|
|
392
|
+
} else {
|
|
393
|
+
if (selectedAttribute) params.set("attribute", selectedAttribute);
|
|
394
|
+
if (filter.searchAttribute && filter.searchAttribute !== selectedAttribute) {
|
|
395
|
+
params.set("searchAttribute", filter.searchAttribute);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (filter.filterOperator && filter.filterOperator !== "none") {
|
|
399
|
+
params.set("filterOperator", filter.filterOperator);
|
|
400
|
+
if (filter.filterQuery) {
|
|
401
|
+
params.set("filterQuery", filter.filterQuery);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (filter.entrySearch && filter.entrySearch.trim()) {
|
|
405
|
+
params.set("search", filter.entrySearch.trim());
|
|
406
|
+
}
|
|
407
|
+
if (sortField) {
|
|
408
|
+
params.set("sortField", sortField);
|
|
409
|
+
if (sortOrder) params.set("sortOrder", sortOrder);
|
|
410
|
+
}
|
|
411
|
+
return params;
|
|
412
|
+
}
|
|
413
|
+
function buildCsvExportQueryParams(options) {
|
|
414
|
+
const { limit, filter } = options;
|
|
415
|
+
const queryParams = new URLSearchParams();
|
|
416
|
+
if (limit && limit > 0) {
|
|
417
|
+
queryParams.set("limit", String(limit));
|
|
418
|
+
}
|
|
419
|
+
if (filter.searchAttribute) {
|
|
420
|
+
queryParams.set("searchAttribute", filter.searchAttribute);
|
|
421
|
+
}
|
|
422
|
+
if (filter.filterOperator && filter.filterOperator !== "none") {
|
|
423
|
+
queryParams.set("filterOperator", filter.filterOperator);
|
|
424
|
+
if (filter.filterQuery) {
|
|
425
|
+
queryParams.set("filterQuery", filter.filterQuery);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (filter.entrySearch && filter.entrySearch.trim()) {
|
|
429
|
+
queryParams.set("search", filter.entrySearch.trim());
|
|
430
|
+
}
|
|
431
|
+
return queryParams;
|
|
432
|
+
}
|
|
353
433
|
function CsvManagerTab() {
|
|
354
434
|
const { get, post } = useFetchClient();
|
|
355
435
|
const { toggleNotification } = useNotification();
|
|
@@ -366,8 +446,17 @@ function CsvManagerTab() {
|
|
|
366
446
|
const [filterOperator, setFilterOperator] = useState("none");
|
|
367
447
|
const [filterQuery, setFilterQuery] = useState("");
|
|
368
448
|
const [entrySearch, setEntrySearch] = useState("");
|
|
449
|
+
const [appliedFilter, setAppliedFilter] = useState(EMPTY_SEARCH_FILTER);
|
|
450
|
+
const appliedFilterRef = useRef(EMPTY_SEARCH_FILTER);
|
|
369
451
|
const [matchingCount, setMatchingCount] = useState(null);
|
|
370
452
|
const [countLoading, setCountLoading] = useState(false);
|
|
453
|
+
const draftFilter = {
|
|
454
|
+
searchAttribute,
|
|
455
|
+
filterOperator,
|
|
456
|
+
filterQuery,
|
|
457
|
+
entrySearch
|
|
458
|
+
};
|
|
459
|
+
const hasPendingFilterChanges = !areSearchFiltersEqual(draftFilter, appliedFilter);
|
|
371
460
|
const [searchRelationOptions, setSearchRelationOptions] = useState([]);
|
|
372
461
|
const [searchRelationOptionsLoading, setSearchRelationOptionsLoading] = useState(false);
|
|
373
462
|
const [exportLimit, setExportLimit] = useState(0);
|
|
@@ -487,53 +576,78 @@ function CsvManagerTab() {
|
|
|
487
576
|
setFilterOperator("none");
|
|
488
577
|
setFilterQuery("");
|
|
489
578
|
setEntrySearch("");
|
|
579
|
+
appliedFilterRef.current = EMPTY_SEARCH_FILTER;
|
|
580
|
+
setAppliedFilter(EMPTY_SEARCH_FILTER);
|
|
490
581
|
setMatchingCount(null);
|
|
491
582
|
setCountLoading(Boolean(newUid));
|
|
492
583
|
};
|
|
493
|
-
|
|
494
|
-
if (!
|
|
584
|
+
const executeMatchingCountSearch = async (targetUid, filterToApply) => {
|
|
585
|
+
if (!targetUid) {
|
|
495
586
|
setMatchingCount(null);
|
|
496
587
|
setCountLoading(false);
|
|
497
588
|
return;
|
|
498
589
|
}
|
|
590
|
+
if (countAbortControllerRef.current) {
|
|
591
|
+
countAbortControllerRef.current.abort();
|
|
592
|
+
}
|
|
593
|
+
const controller = new AbortController();
|
|
594
|
+
countAbortControllerRef.current = controller;
|
|
499
595
|
setCountLoading(true);
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
596
|
+
try {
|
|
597
|
+
const params = buildEntriesQueryParams({
|
|
598
|
+
page: 1,
|
|
599
|
+
pageSize: 1,
|
|
600
|
+
filter: filterToApply,
|
|
601
|
+
includeAttributeEvenIfSame: true
|
|
602
|
+
});
|
|
603
|
+
const res = await get(`/bulk-updater/collections/${targetUid}/entries?${params.toString()}`, {
|
|
604
|
+
signal: controller.signal
|
|
605
|
+
});
|
|
606
|
+
if (countAbortControllerRef.current !== controller) return;
|
|
607
|
+
if (res.data) {
|
|
608
|
+
const total = res.data.pagination?.total ?? (Array.isArray(res.data.entries) ? res.data.entries.length : 0);
|
|
609
|
+
setMatchingCount(total);
|
|
503
610
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
page: "1",
|
|
509
|
-
pageSize: "1"
|
|
510
|
-
});
|
|
511
|
-
if (searchAttribute) {
|
|
512
|
-
params.set("attribute", searchAttribute);
|
|
513
|
-
params.set("searchAttribute", searchAttribute);
|
|
514
|
-
}
|
|
515
|
-
if (filterOperator && filterOperator !== "none") {
|
|
516
|
-
params.set("filterOperator", filterOperator);
|
|
517
|
-
if (filterQuery) params.set("filterQuery", filterQuery);
|
|
518
|
-
}
|
|
519
|
-
if (entrySearch && entrySearch.trim()) {
|
|
520
|
-
params.set("search", entrySearch.trim());
|
|
521
|
-
}
|
|
522
|
-
const res = await get(`/bulk-updater/collections/${selectedUid}/entries?${params.toString()}`, {
|
|
523
|
-
signal: controller.signal
|
|
524
|
-
});
|
|
525
|
-
if (res.data) {
|
|
526
|
-
const total = res.data.pagination?.total ?? (Array.isArray(res.data.entries) ? res.data.entries.length : 0);
|
|
527
|
-
setMatchingCount(total);
|
|
528
|
-
}
|
|
529
|
-
} catch (err) {
|
|
530
|
-
if (!isAbortError(err)) ;
|
|
531
|
-
} finally {
|
|
611
|
+
} catch (err) {
|
|
612
|
+
if (!isAbortError(err)) ;
|
|
613
|
+
} finally {
|
|
614
|
+
if (countAbortControllerRef.current === controller) {
|
|
532
615
|
setCountLoading(false);
|
|
533
616
|
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
useEffect(() => {
|
|
620
|
+
if (!selectedUid) {
|
|
621
|
+
setMatchingCount(null);
|
|
622
|
+
setCountLoading(false);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
executeMatchingCountSearch(selectedUid, appliedFilterRef.current);
|
|
626
|
+
}, [selectedUid]);
|
|
627
|
+
const handleApplySearch = () => {
|
|
628
|
+
const nextApplied = {
|
|
629
|
+
searchAttribute,
|
|
630
|
+
filterOperator,
|
|
631
|
+
filterQuery,
|
|
632
|
+
entrySearch
|
|
633
|
+
};
|
|
634
|
+
appliedFilterRef.current = nextApplied;
|
|
635
|
+
setAppliedFilter(nextApplied);
|
|
636
|
+
if (selectedUid) {
|
|
637
|
+
executeMatchingCountSearch(selectedUid, nextApplied);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
const handleClearFilters = () => {
|
|
641
|
+
setSearchAttribute("");
|
|
642
|
+
setFilterOperator("none");
|
|
643
|
+
setFilterQuery("");
|
|
644
|
+
setEntrySearch("");
|
|
645
|
+
appliedFilterRef.current = EMPTY_SEARCH_FILTER;
|
|
646
|
+
setAppliedFilter(EMPTY_SEARCH_FILTER);
|
|
647
|
+
if (selectedUid) {
|
|
648
|
+
executeMatchingCountSearch(selectedUid, EMPTY_SEARCH_FILTER);
|
|
649
|
+
}
|
|
650
|
+
};
|
|
537
651
|
const fetchAndEnrichEntries = async (colUid, cols = collections, batches = pendingBatches) => {
|
|
538
652
|
if (!colUid) return [];
|
|
539
653
|
try {
|
|
@@ -616,16 +730,10 @@ function CsvManagerTab() {
|
|
|
616
730
|
if (!selectedUid || exportingCollection) return;
|
|
617
731
|
try {
|
|
618
732
|
setExportingCollection(true);
|
|
619
|
-
const queryParams =
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
queryParams.set("filterOperator", filterOperator);
|
|
624
|
-
if (filterQuery) queryParams.set("filterQuery", filterQuery);
|
|
625
|
-
}
|
|
626
|
-
if (entrySearch && entrySearch.trim()) {
|
|
627
|
-
queryParams.set("search", entrySearch.trim());
|
|
628
|
-
}
|
|
733
|
+
const queryParams = buildCsvExportQueryParams({
|
|
734
|
+
limit: exportLimit,
|
|
735
|
+
filter: appliedFilterRef.current
|
|
736
|
+
});
|
|
629
737
|
const res = await get(`/bulk-updater/csv/export/${selectedUid}?${queryParams.toString()}`);
|
|
630
738
|
const csvStr = res.data?.csvContent || (typeof res.data === "string" ? res.data : "");
|
|
631
739
|
const filename = res.data?.filename || `${selectedUid.split(".").pop()}_export.csv`;
|
|
@@ -1095,20 +1203,8 @@ function CsvManagerTab() {
|
|
|
1095
1203
|
]
|
|
1096
1204
|
}
|
|
1097
1205
|
) : null,
|
|
1098
|
-
(
|
|
1099
|
-
|
|
1100
|
-
{
|
|
1101
|
-
variant: "ghost",
|
|
1102
|
-
size: "S",
|
|
1103
|
-
onClick: () => {
|
|
1104
|
-
setSearchAttribute("");
|
|
1105
|
-
setFilterOperator("none");
|
|
1106
|
-
setFilterQuery("");
|
|
1107
|
-
setEntrySearch("");
|
|
1108
|
-
},
|
|
1109
|
-
children: "Clear Filters"
|
|
1110
|
-
}
|
|
1111
|
-
)
|
|
1206
|
+
hasPendingFilterChanges && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", size: "S", children: "Filters modified — click Search to apply" }),
|
|
1207
|
+
(searchAttribute || filterOperator !== "none" || entrySearch.trim() || hasPendingFilterChanges) && /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "S", onClick: handleClearFilters, children: "Clear Filters" })
|
|
1112
1208
|
] })
|
|
1113
1209
|
] }),
|
|
1114
1210
|
/* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
|
|
@@ -1194,7 +1290,13 @@ function CsvManagerTab() {
|
|
|
1194
1290
|
{
|
|
1195
1291
|
placeholder: "Type value to match...",
|
|
1196
1292
|
value: filterQuery,
|
|
1197
|
-
onChange: (e) => setFilterQuery(e.target.value)
|
|
1293
|
+
onChange: (e) => setFilterQuery(e.target.value),
|
|
1294
|
+
onKeyDown: (e) => {
|
|
1295
|
+
if (e.key === "Enter") {
|
|
1296
|
+
e.preventDefault();
|
|
1297
|
+
handleApplySearch();
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1198
1300
|
}
|
|
1199
1301
|
)
|
|
1200
1302
|
] }),
|
|
@@ -1205,10 +1307,27 @@ function CsvManagerTab() {
|
|
|
1205
1307
|
{
|
|
1206
1308
|
placeholder: "Search title, name, or text across records...",
|
|
1207
1309
|
value: entrySearch,
|
|
1208
|
-
onChange: (e) => setEntrySearch(e.target.value)
|
|
1310
|
+
onChange: (e) => setEntrySearch(e.target.value),
|
|
1311
|
+
onKeyDown: (e) => {
|
|
1312
|
+
if (e.key === "Enter") {
|
|
1313
|
+
e.preventDefault();
|
|
1314
|
+
handleApplySearch();
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1209
1317
|
}
|
|
1210
1318
|
)
|
|
1211
|
-
] })
|
|
1319
|
+
] }),
|
|
1320
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
1321
|
+
Button,
|
|
1322
|
+
{
|
|
1323
|
+
variant: hasPendingFilterChanges ? "default" : "secondary",
|
|
1324
|
+
startIcon: /* @__PURE__ */ jsx(Search, {}),
|
|
1325
|
+
onClick: handleApplySearch,
|
|
1326
|
+
loading: countLoading,
|
|
1327
|
+
disabled: !selectedUid || countLoading,
|
|
1328
|
+
children: "Search"
|
|
1329
|
+
}
|
|
1330
|
+
) })
|
|
1212
1331
|
] })
|
|
1213
1332
|
] }) : /* @__PURE__ */ jsx(Box, { padding: 4, background: "neutral0", hasRadius: true, marginBottom: 4, style: { border: "1px solid #eaeaef", textAlign: "center" }, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: "Please select a Target Collection Type above to configure search filters and export data." }) }),
|
|
1214
1333
|
/* @__PURE__ */ jsxs(Flex, { gap: 4, wrap: "wrap", alignItems: "flex-end", marginTop: 3, children: [
|
|
@@ -2743,6 +2862,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
2743
2862
|
previewData,
|
|
2744
2863
|
attribute,
|
|
2745
2864
|
targetValueDisplay,
|
|
2865
|
+
editMode = "common",
|
|
2746
2866
|
publishOnApproval = true,
|
|
2747
2867
|
lifecycleStats
|
|
2748
2868
|
}) => {
|
|
@@ -2757,12 +2877,14 @@ const BulkUpdatePreviewModal = ({
|
|
|
2757
2877
|
if (searchQuery.trim()) {
|
|
2758
2878
|
const q = searchQuery.toLowerCase().trim();
|
|
2759
2879
|
items = items.filter(
|
|
2760
|
-
(d) => d.label.toLowerCase().includes(q) || d.documentId.toLowerCase().includes(q) || d.collectionName.toLowerCase().includes(q) || String(d.oldDisplay || "").toLowerCase().includes(q) || String(d.newDisplay || "").toLowerCase().includes(q)
|
|
2880
|
+
(d) => d.label.toLowerCase().includes(q) || d.documentId.toLowerCase().includes(q) || d.collectionName.toLowerCase().includes(q) || String(d.attribute || "").toLowerCase().includes(q) || String(d.oldDisplay || "").toLowerCase().includes(q) || String(d.newDisplay || "").toLowerCase().includes(q)
|
|
2761
2881
|
);
|
|
2762
2882
|
}
|
|
2763
2883
|
return items;
|
|
2764
2884
|
}, [previewData, filterTab, searchQuery]);
|
|
2765
2885
|
if (!isOpen) return null;
|
|
2886
|
+
const isGridMode = editMode === "grid" || previewData?.editMode === "grid";
|
|
2887
|
+
const willErrorCount = previewData?.summary?.willError || 0;
|
|
2766
2888
|
return /* @__PURE__ */ jsx(
|
|
2767
2889
|
"div",
|
|
2768
2890
|
{
|
|
@@ -2786,7 +2908,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
2786
2908
|
hasRadius: true,
|
|
2787
2909
|
shadow: "popupShadow",
|
|
2788
2910
|
style: {
|
|
2789
|
-
maxWidth:
|
|
2911
|
+
maxWidth: 1120,
|
|
2790
2912
|
width: "95%",
|
|
2791
2913
|
maxHeight: "calc(100vh - 48px)",
|
|
2792
2914
|
display: "flex",
|
|
@@ -2813,13 +2935,16 @@ const BulkUpdatePreviewModal = ({
|
|
|
2813
2935
|
/* @__PURE__ */ jsxs(Badge, { backgroundColor: "primary100", textColor: "primary700", children: [
|
|
2814
2936
|
"Target: ",
|
|
2815
2937
|
attribute
|
|
2816
|
-
] })
|
|
2938
|
+
] }),
|
|
2939
|
+
isGridMode && /* @__PURE__ */ jsx(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: "GRID EDITING MODE" })
|
|
2817
2940
|
] }),
|
|
2818
2941
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Inspect exact before & after values across target records before applying changes to the database." })
|
|
2819
2942
|
] }),
|
|
2820
2943
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
|
|
2821
|
-
/* @__PURE__ */
|
|
2822
|
-
|
|
2944
|
+
!isGridMode ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2945
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "New Value:" }),
|
|
2946
|
+
/* @__PURE__ */ jsx(Badge, { backgroundColor: "success100", textColor: "success700", children: targetValueDisplay || "(empty)" })
|
|
2947
|
+
] }) : /* @__PURE__ */ jsx(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: targetValueDisplay || "Per-Record & Component Grid Edits" }),
|
|
2823
2948
|
/* @__PURE__ */ jsx(
|
|
2824
2949
|
Badge,
|
|
2825
2950
|
{
|
|
@@ -2847,6 +2972,13 @@ const BulkUpdatePreviewModal = ({
|
|
|
2847
2972
|
/* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "semiBold", children: "Inspecting Target Records..." }),
|
|
2848
2973
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Computing proposed diffs and verifying against database schema." })
|
|
2849
2974
|
] }) }) : !previewData ? /* @__PURE__ */ jsx(Box, { padding: 6, style: { textAlign: "center" }, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: "No preview data available." }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2975
|
+
willErrorCount > 0 && /* @__PURE__ */ jsx(Box, { marginBottom: 4, padding: 3, background: "danger100", hasRadius: true, style: { border: "1px solid #f5c0b8" }, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
2976
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "danger700", children: "⚠️ Validation / Quota Violation Detected:" }),
|
|
2977
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "danger700", children: [
|
|
2978
|
+
willErrorCount,
|
|
2979
|
+
' 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.'
|
|
2980
|
+
] })
|
|
2981
|
+
] }) }),
|
|
2850
2982
|
publishOnApproval && lifecycleStats && lifecycleStats.unreviewedCount > 0 && /* @__PURE__ */ jsx(Box, { marginBottom: 4, padding: 3, background: "warning100", hasRadius: true, style: { border: "1px solid #f5c0b8" }, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
2851
2983
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "warning700", children: "⚠️ Safe Publishing Active:" }),
|
|
2852
2984
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "warning700", children: [
|
|
@@ -2912,7 +3044,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
2912
3044
|
variant: "sigma",
|
|
2913
3045
|
textColor: previewData.summary.skipped > 0 ? "warning700" : "neutral600",
|
|
2914
3046
|
display: "block",
|
|
2915
|
-
children: "WILL SKIP
|
|
3047
|
+
children: "WILL SKIP"
|
|
2916
3048
|
}
|
|
2917
3049
|
),
|
|
2918
3050
|
/* @__PURE__ */ jsx(
|
|
@@ -2926,6 +3058,19 @@ const BulkUpdatePreviewModal = ({
|
|
|
2926
3058
|
)
|
|
2927
3059
|
]
|
|
2928
3060
|
}
|
|
3061
|
+
),
|
|
3062
|
+
willErrorCount > 0 && /* @__PURE__ */ jsxs(
|
|
3063
|
+
Box,
|
|
3064
|
+
{
|
|
3065
|
+
padding: 3,
|
|
3066
|
+
background: "danger100",
|
|
3067
|
+
hasRadius: true,
|
|
3068
|
+
style: { flex: 1, minWidth: 140, border: "1px solid #ffa39e" },
|
|
3069
|
+
children: [
|
|
3070
|
+
/* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "danger700", display: "block", children: "VALIDATION ERRORS" }),
|
|
3071
|
+
/* @__PURE__ */ jsx(Typography, { variant: "beta", fontWeight: "bold", textColor: "danger700", children: willErrorCount })
|
|
3072
|
+
]
|
|
3073
|
+
}
|
|
2929
3074
|
)
|
|
2930
3075
|
] }),
|
|
2931
3076
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 3, wrap: "wrap", gap: 3, children: [
|
|
@@ -2938,7 +3083,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
2938
3083
|
onClick: () => setFilterTab("all"),
|
|
2939
3084
|
children: [
|
|
2940
3085
|
"All (",
|
|
2941
|
-
previewData.summary.total,
|
|
3086
|
+
isGridMode ? previewData.diffs.length : previewData.summary.total,
|
|
2942
3087
|
")"
|
|
2943
3088
|
]
|
|
2944
3089
|
}
|
|
@@ -2981,6 +3126,19 @@ const BulkUpdatePreviewModal = ({
|
|
|
2981
3126
|
")"
|
|
2982
3127
|
]
|
|
2983
3128
|
}
|
|
3129
|
+
),
|
|
3130
|
+
willErrorCount > 0 && /* @__PURE__ */ jsxs(
|
|
3131
|
+
Button,
|
|
3132
|
+
{
|
|
3133
|
+
variant: filterTab === "will_error" ? "default" : "tertiary",
|
|
3134
|
+
size: "S",
|
|
3135
|
+
onClick: () => setFilterTab("will_error"),
|
|
3136
|
+
children: [
|
|
3137
|
+
"Errors (",
|
|
3138
|
+
willErrorCount,
|
|
3139
|
+
")"
|
|
3140
|
+
]
|
|
3141
|
+
}
|
|
2984
3142
|
)
|
|
2985
3143
|
] }),
|
|
2986
3144
|
/* @__PURE__ */ jsx(Box, { style: { width: 260 }, children: /* @__PURE__ */ jsx(
|
|
@@ -3003,20 +3161,22 @@ const BulkUpdatePreviewModal = ({
|
|
|
3003
3161
|
overflowY: "auto",
|
|
3004
3162
|
overflowX: "auto"
|
|
3005
3163
|
},
|
|
3006
|
-
children: /* @__PURE__ */ jsxs(Table, { colCount:
|
|
3164
|
+
children: /* @__PURE__ */ jsxs(Table, { colCount: 6, rowCount: filteredDiffs.length + 1, style: { width: "100%", minWidth: 880 }, children: [
|
|
3007
3165
|
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
3008
|
-
/* @__PURE__ */ jsx(Th, { style: { width:
|
|
3009
|
-
/* @__PURE__ */ jsx(Th, { style: { minWidth:
|
|
3010
|
-
/* @__PURE__ */ jsx(Th, { style: { minWidth:
|
|
3011
|
-
/* @__PURE__ */ jsx(Th, { style: { minWidth:
|
|
3012
|
-
/* @__PURE__ */ jsx(Th, { style: {
|
|
3166
|
+
/* @__PURE__ */ jsx(Th, { style: { width: 140 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "COLLECTION" }) }),
|
|
3167
|
+
/* @__PURE__ */ jsx(Th, { style: { minWidth: 185 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "RECORD IDENTIFIER" }) }),
|
|
3168
|
+
/* @__PURE__ */ jsx(Th, { style: { minWidth: 165 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "ATTRIBUTE / BLOCK" }) }),
|
|
3169
|
+
/* @__PURE__ */ jsx(Th, { style: { minWidth: 170 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "CURRENT VALUE (BEFORE)" }) }),
|
|
3170
|
+
/* @__PURE__ */ jsx(Th, { style: { minWidth: 170 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "NEW VALUE (AFTER)" }) }),
|
|
3171
|
+
/* @__PURE__ */ jsx(Th, { style: { width: 150, textAlign: "right" }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: "IMPACT" }) })
|
|
3013
3172
|
] }) }),
|
|
3014
|
-
/* @__PURE__ */ jsx(Tbody, { children: filteredDiffs.length === 0 ? /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan:
|
|
3173
|
+
/* @__PURE__ */ jsx(Tbody, { children: filteredDiffs.length === 0 ? /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: 6, style: { textAlign: "center", padding: "24px" }, children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: "No records match the current filter or search criteria." }) }) }) : filteredDiffs.map((diff, idx) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
3015
3174
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral700", children: diff.collectionName }) }),
|
|
3016
3175
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
3017
3176
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", display: "block", children: diff.label }),
|
|
3018
3177
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: /* @__PURE__ */ jsx("code", { children: diff.documentId }) })
|
|
3019
3178
|
] }) }),
|
|
3179
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "semiBold", textColor: "primary700", children: diff.attribute || attribute }) }),
|
|
3020
3180
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
3021
3181
|
Typography,
|
|
3022
3182
|
{
|
|
@@ -3029,13 +3189,14 @@ const BulkUpdatePreviewModal = ({
|
|
|
3029
3189
|
children: diff.oldDisplay || "(empty)"
|
|
3030
3190
|
}
|
|
3031
3191
|
) }),
|
|
3032
|
-
/* @__PURE__ */ jsx(Td, { children: diff.status === "will_skip" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", children: "— Skipped (field absent) —" }) : diff.hasChange ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(already matching)" }) }),
|
|
3192
|
+
/* @__PURE__ */ jsx(Td, { children: diff.status === "will_error" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: diff.validationError || diff.message }) : diff.status === "will_skip" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", children: "— Skipped (field absent) —" }) : diff.hasChange ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(already matching)" }) }),
|
|
3033
3193
|
/* @__PURE__ */ jsxs(Td, { style: { textAlign: "right" }, children: [
|
|
3034
3194
|
diff.status === "will_update" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "success100", textColor: "success700", children: "✓ Will Update" }),
|
|
3035
3195
|
diff.status === "unchanged" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral600", children: "= Unchanged" }),
|
|
3036
|
-
diff.status === "will_skip" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "⚠ Will Skip" })
|
|
3196
|
+
diff.status === "will_skip" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "⚠ Will Skip" }),
|
|
3197
|
+
diff.status === "will_error" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "danger100", textColor: "danger700", children: "✕ Error" })
|
|
3037
3198
|
] })
|
|
3038
|
-
] }, `${diff.uid}-${diff.documentId}`)) })
|
|
3199
|
+
] }, `${diff.uid}-${diff.documentId}-${diff.attribute || "root"}-${idx}`)) })
|
|
3039
3200
|
] })
|
|
3040
3201
|
}
|
|
3041
3202
|
)
|
|
@@ -3063,7 +3224,7 @@ const BulkUpdatePreviewModal = ({
|
|
|
3063
3224
|
onClose();
|
|
3064
3225
|
onProceed();
|
|
3065
3226
|
},
|
|
3066
|
-
disabled: loading || !previewData || previewData.summary.total === 0,
|
|
3227
|
+
disabled: loading || !previewData || previewData.summary.total === 0 || isGridMode && previewData.summary.willUpdate === 0,
|
|
3067
3228
|
children: [
|
|
3068
3229
|
"Proceed to Execute (",
|
|
3069
3230
|
previewData?.summary.willUpdate || 0,
|
|
@@ -3502,12 +3663,13 @@ const CheckerReviewModal = ({
|
|
|
3502
3663
|
children: diff.oldDisplay || "(empty)"
|
|
3503
3664
|
}
|
|
3504
3665
|
) }),
|
|
3505
|
-
/* @__PURE__ */ jsx(Td, { children: diff.status === "will_create" ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(new value)" }) : diff.status === "will_skip" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", children: "— Skipped —" }) : diff.hasChange ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(matching)" }) }),
|
|
3666
|
+
/* @__PURE__ */ jsx(Td, { children: diff.status === "will_create" ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(new value)" }) : diff.status === "will_error" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: diff.validationError || diff.message || "Validation error" }) : diff.status === "will_skip" ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", children: "— Skipped —" }) : diff.hasChange ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "success700", style: { wordBreak: "break-all" }, children: diff.newDisplay || "(empty)" }) : /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: diff.newDisplay || "(matching)" }) }),
|
|
3506
3667
|
/* @__PURE__ */ jsxs(Td, { style: { textAlign: "right" }, children: [
|
|
3507
3668
|
diff.status === "will_create" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "success100", textColor: "success700", children: "+ Will Create" }),
|
|
3508
3669
|
diff.status === "will_update" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "✎ Will Update" }),
|
|
3509
3670
|
diff.status === "unchanged" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral600", children: "= Unchanged" }),
|
|
3510
|
-
diff.status === "will_skip" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "
|
|
3671
|
+
diff.status === "will_skip" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "⚠ Will Skip" }),
|
|
3672
|
+
diff.status === "will_error" && /* @__PURE__ */ jsx(Badge, { backgroundColor: "danger100", textColor: "danger700", children: "✕ Validation Error" })
|
|
3511
3673
|
] })
|
|
3512
3674
|
] }, `${diff.uid}-${diff.documentId}-${diff.attribute}-${idx}`)) })
|
|
3513
3675
|
] })
|
|
@@ -3585,14 +3747,19 @@ const CheckerReviewModal = ({
|
|
|
3585
3747
|
}
|
|
3586
3748
|
);
|
|
3587
3749
|
};
|
|
3588
|
-
function
|
|
3750
|
+
function formatComponentNameFriendly(compUid) {
|
|
3751
|
+
if (!compUid) return "Component";
|
|
3752
|
+
const name = compUid.includes(".") ? compUid.split(".")[1] : compUid;
|
|
3753
|
+
return name.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
3754
|
+
}
|
|
3755
|
+
function parseAttrPathClient(path) {
|
|
3589
3756
|
if (!path) return { cleanPath: "", rootKey: "", subPath: "" };
|
|
3590
|
-
const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\]
|
|
3757
|
+
const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\](?:\.(.+))?$/);
|
|
3591
3758
|
if (bracketMatch) {
|
|
3592
3759
|
const rootKey = bracketMatch[1];
|
|
3593
|
-
const selector = bracketMatch[2];
|
|
3594
|
-
const subPath = bracketMatch[3];
|
|
3595
|
-
const cleanPath = `${rootKey}.${subPath}
|
|
3760
|
+
const selector = bracketMatch[2].trim();
|
|
3761
|
+
const subPath = bracketMatch[3] || "";
|
|
3762
|
+
const cleanPath = subPath ? `${rootKey}.${subPath}` : rootKey;
|
|
3596
3763
|
if (/^\d+$/.test(selector)) {
|
|
3597
3764
|
return { cleanPath, rootKey, subPath, targetIndex: parseInt(selector, 10) };
|
|
3598
3765
|
}
|
|
@@ -3605,124 +3772,1408 @@ function parseDynamicZonePath(path) {
|
|
|
3605
3772
|
subPath: parts.slice(1).join(".")
|
|
3606
3773
|
};
|
|
3607
3774
|
}
|
|
3608
|
-
function
|
|
3609
|
-
if (!
|
|
3610
|
-
|
|
3611
|
-
|
|
3775
|
+
function buildOccurrenceKey(segments) {
|
|
3776
|
+
if (!segments || segments.length === 0) return "__scalar__";
|
|
3777
|
+
return segments.map((seg) => {
|
|
3778
|
+
if (seg.index !== void 0) {
|
|
3779
|
+
return seg.componentId !== void 0 && seg.componentId !== null ? `${seg.key}[${seg.index}#${seg.componentId}]` : `${seg.key}[${seg.index}]`;
|
|
3780
|
+
}
|
|
3781
|
+
return seg.key;
|
|
3782
|
+
}).join(".");
|
|
3612
3783
|
}
|
|
3613
|
-
function
|
|
3614
|
-
if (!
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3784
|
+
function buildReadablePath(segments) {
|
|
3785
|
+
if (!segments || segments.length === 0) return "";
|
|
3786
|
+
return segments.map((seg) => {
|
|
3787
|
+
if (seg.index !== void 0) {
|
|
3788
|
+
const label = seg.componentUid ? ` ${formatComponentNameFriendly(seg.componentUid)}` : "";
|
|
3789
|
+
return `${seg.key}[#${seg.index}${label}]`;
|
|
3790
|
+
}
|
|
3791
|
+
return seg.key;
|
|
3792
|
+
}).join(".");
|
|
3793
|
+
}
|
|
3794
|
+
function getDirectProp(obj, key) {
|
|
3795
|
+
if (!obj || typeof obj !== "object") return void 0;
|
|
3796
|
+
if (obj[key] !== void 0) return obj[key];
|
|
3797
|
+
const camel = key.replace(/_([a-z0-9])/g, (_, l) => l.toUpperCase());
|
|
3798
|
+
if (obj[camel] !== void 0) return obj[camel];
|
|
3799
|
+
const snake = key.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
3800
|
+
if (obj[snake] !== void 0) return obj[snake];
|
|
3801
|
+
return void 0;
|
|
3802
|
+
}
|
|
3803
|
+
function resolveTailExistsOrValue(obj, parts) {
|
|
3804
|
+
let cur = obj;
|
|
3805
|
+
for (const p of parts) {
|
|
3806
|
+
if (cur === null || cur === void 0) return void 0;
|
|
3807
|
+
if (Array.isArray(cur)) {
|
|
3808
|
+
for (const item of cur) {
|
|
3809
|
+
const found = resolveTailExistsOrValue(item, parts.slice(parts.indexOf(p)));
|
|
3810
|
+
if (found !== void 0) return found;
|
|
3637
3811
|
}
|
|
3638
|
-
|
|
3639
|
-
|
|
3812
|
+
return void 0;
|
|
3813
|
+
}
|
|
3814
|
+
cur = getDirectProp(cur, p);
|
|
3640
3815
|
}
|
|
3641
|
-
|
|
3642
|
-
|
|
3816
|
+
return cur;
|
|
3817
|
+
}
|
|
3818
|
+
function enumerateClientOccurrences(entry, attrPath, availableAttributes, attrMeta) {
|
|
3819
|
+
if (!entry || !attrPath) return [];
|
|
3820
|
+
const parsed = parseAttrPathClient(attrPath);
|
|
3821
|
+
const parts = parsed.cleanPath.split(".").filter(Boolean);
|
|
3822
|
+
if (parts.length === 0) return [];
|
|
3823
|
+
if (parts.length === 1 && !parsed.targetComponentUid && parsed.targetIndex === void 0) {
|
|
3824
|
+
const val = getDirectProp(entry, parts[0]);
|
|
3643
3825
|
return [
|
|
3644
3826
|
{
|
|
3827
|
+
occurrenceKey: "__scalar__",
|
|
3828
|
+
displayPath: parts[0],
|
|
3829
|
+
segments: [{ key: parts[0] }],
|
|
3830
|
+
value: val !== void 0 ? val : null,
|
|
3645
3831
|
index: 0,
|
|
3646
|
-
|
|
3647
|
-
path: parsed.cleanPath
|
|
3832
|
+
isMissingIntermediate: false
|
|
3648
3833
|
}
|
|
3649
3834
|
];
|
|
3650
3835
|
}
|
|
3651
|
-
|
|
3836
|
+
const results = [];
|
|
3837
|
+
function walk(currentVal, remainingParts, segments, missingIntermediate, firstArrayIndex, resolvedCompUid, resolvedCompId, isRootLevel) {
|
|
3838
|
+
if (remainingParts.length === 0) return;
|
|
3839
|
+
const [head, ...tail] = remainingParts;
|
|
3840
|
+
if (tail.length === 0) {
|
|
3841
|
+
const val = currentVal && typeof currentVal === "object" ? getDirectProp(currentVal, head) : void 0;
|
|
3842
|
+
const nextSegs = [...segments, { key: head }];
|
|
3843
|
+
results.push({
|
|
3844
|
+
occurrenceKey: buildOccurrenceKey(nextSegs),
|
|
3845
|
+
displayPath: buildReadablePath(nextSegs),
|
|
3846
|
+
segments: nextSegs,
|
|
3847
|
+
value: val !== void 0 ? val : null,
|
|
3848
|
+
componentUid: resolvedCompUid,
|
|
3849
|
+
componentName: resolvedCompUid ? formatComponentNameFriendly(resolvedCompUid) : void 0,
|
|
3850
|
+
componentId: resolvedCompId,
|
|
3851
|
+
index: firstArrayIndex ?? 0,
|
|
3852
|
+
isMissingIntermediate: missingIntermediate
|
|
3853
|
+
});
|
|
3854
|
+
return;
|
|
3855
|
+
}
|
|
3856
|
+
const nextVal = currentVal && typeof currentVal === "object" ? getDirectProp(currentVal, head) : void 0;
|
|
3857
|
+
const isExpectingRootArray = isRootLevel && (attrMeta?.rootType === "dynamiczone" || attrMeta?.rootRepeatable);
|
|
3858
|
+
if (Array.isArray(nextVal)) {
|
|
3859
|
+
const subPath = tail.join(".");
|
|
3860
|
+
nextVal.forEach((item, idx) => {
|
|
3861
|
+
if (!item || typeof item !== "object") return;
|
|
3862
|
+
if (isRootLevel && parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
|
|
3863
|
+
if (isRootLevel && parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
|
|
3864
|
+
if (item.__component && isRootLevel) {
|
|
3865
|
+
const scopedAttr = `${head}[${item.__component}].${subPath}`;
|
|
3866
|
+
const supportedBySchema = Array.isArray(availableAttributes) && availableAttributes.includes(scopedAttr);
|
|
3867
|
+
const presentInData = resolveTailExistsOrValue(item, tail) !== void 0;
|
|
3868
|
+
if (!supportedBySchema && !presentInData) {
|
|
3869
|
+
return;
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
const seg2 = {
|
|
3873
|
+
key: head,
|
|
3874
|
+
index: idx,
|
|
3875
|
+
componentId: item.id,
|
|
3876
|
+
componentUid: item.__component || (isRootLevel ? attrMeta?.component : void 0)
|
|
3877
|
+
};
|
|
3878
|
+
walk(
|
|
3879
|
+
item,
|
|
3880
|
+
tail,
|
|
3881
|
+
[...segments, seg2],
|
|
3882
|
+
missingIntermediate,
|
|
3883
|
+
firstArrayIndex ?? idx,
|
|
3884
|
+
item.__component || resolvedCompUid,
|
|
3885
|
+
resolvedCompId ?? item.id,
|
|
3886
|
+
false
|
|
3887
|
+
);
|
|
3888
|
+
});
|
|
3889
|
+
return;
|
|
3890
|
+
}
|
|
3891
|
+
if (isExpectingRootArray) {
|
|
3892
|
+
return;
|
|
3893
|
+
}
|
|
3894
|
+
const isMissing = !nextVal || typeof nextVal !== "object";
|
|
3895
|
+
const seg = {
|
|
3896
|
+
key: head,
|
|
3897
|
+
componentId: !isMissing ? nextVal.id : void 0,
|
|
3898
|
+
componentUid: !isMissing && nextVal.__component ? nextVal.__component : void 0
|
|
3899
|
+
};
|
|
3900
|
+
walk(
|
|
3901
|
+
isMissing ? void 0 : nextVal,
|
|
3902
|
+
tail,
|
|
3903
|
+
[...segments, seg],
|
|
3904
|
+
missingIntermediate || isMissing,
|
|
3905
|
+
firstArrayIndex,
|
|
3906
|
+
resolvedCompUid,
|
|
3907
|
+
resolvedCompId,
|
|
3908
|
+
false
|
|
3909
|
+
);
|
|
3910
|
+
}
|
|
3911
|
+
walk(entry, parts, [], false, void 0, void 0, void 0, true);
|
|
3912
|
+
return results;
|
|
3652
3913
|
}
|
|
3653
|
-
function
|
|
3654
|
-
if (
|
|
3655
|
-
if (
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
const
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3914
|
+
function normalizeDisplayCompareValue(v) {
|
|
3915
|
+
if (v === void 0 || v === null) return null;
|
|
3916
|
+
if (typeof v === "object" && v.isRelation) return v;
|
|
3917
|
+
return v;
|
|
3918
|
+
}
|
|
3919
|
+
function areClientValuesEqual(a, b) {
|
|
3920
|
+
const na = normalizeDisplayCompareValue(a);
|
|
3921
|
+
const nb = normalizeDisplayCompareValue(b);
|
|
3922
|
+
if (na === nb) return true;
|
|
3923
|
+
if (na === null || nb === null) return na === nb;
|
|
3924
|
+
if (typeof na === "object" || typeof nb === "object") {
|
|
3925
|
+
try {
|
|
3926
|
+
return JSON.stringify(na) === JSON.stringify(nb);
|
|
3927
|
+
} catch {
|
|
3928
|
+
return false;
|
|
3929
|
+
}
|
|
3668
3930
|
}
|
|
3669
|
-
|
|
3670
|
-
if (camelKey in target) return target[camelKey];
|
|
3671
|
-
if (snakeKey in target) return target[snakeKey];
|
|
3672
|
-
return void 0;
|
|
3931
|
+
return String(na) === String(nb);
|
|
3673
3932
|
}
|
|
3674
|
-
function
|
|
3675
|
-
if (
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3933
|
+
function extractRelationEditCommand(rawVal, currentDisplayVal, isMulti = false) {
|
|
3934
|
+
if (rawVal && typeof rawVal === "object" && !Array.isArray(rawVal) && rawVal.mode) {
|
|
3935
|
+
return {
|
|
3936
|
+
mode: rawVal.mode,
|
|
3937
|
+
documentIds: Array.isArray(rawVal.documentIds) ? rawVal.documentIds : rawVal.documentId ? [rawVal.documentId] : [],
|
|
3938
|
+
label: rawVal.label || ""
|
|
3939
|
+
};
|
|
3940
|
+
}
|
|
3941
|
+
if (Array.isArray(rawVal)) {
|
|
3942
|
+
return {
|
|
3943
|
+
mode: "set",
|
|
3944
|
+
documentIds: rawVal.map((r) => r?.documentId).filter(Boolean),
|
|
3945
|
+
label: rawVal.map((r) => r?.name || r?.title || r?.email || r?.documentId).filter(Boolean).join(", ")
|
|
3946
|
+
};
|
|
3947
|
+
}
|
|
3948
|
+
if (rawVal && typeof rawVal === "object" && rawVal.documentId) {
|
|
3949
|
+
return {
|
|
3950
|
+
mode: "set",
|
|
3951
|
+
documentIds: [rawVal.documentId],
|
|
3952
|
+
label: rawVal.name || rawVal.title || rawVal.email || rawVal.documentId
|
|
3953
|
+
};
|
|
3954
|
+
}
|
|
3955
|
+
if (typeof rawVal === "string") {
|
|
3956
|
+
try {
|
|
3957
|
+
const parsed = JSON.parse(rawVal);
|
|
3958
|
+
if (parsed && typeof parsed === "object" && parsed.mode) {
|
|
3959
|
+
return {
|
|
3960
|
+
mode: parsed.mode,
|
|
3961
|
+
documentIds: Array.isArray(parsed.documentIds) ? parsed.documentIds : [],
|
|
3962
|
+
label: parsed.label || ""
|
|
3963
|
+
};
|
|
3692
3964
|
}
|
|
3693
|
-
|
|
3965
|
+
} catch {
|
|
3694
3966
|
}
|
|
3695
|
-
return extract(getPropertyValue(current, head), tail);
|
|
3696
3967
|
}
|
|
3697
|
-
|
|
3968
|
+
if (currentDisplayVal) {
|
|
3969
|
+
return extractRelationEditCommand(currentDisplayVal, void 0, isMulti);
|
|
3970
|
+
}
|
|
3971
|
+
return { mode: "clear", documentIds: [], label: "" };
|
|
3698
3972
|
}
|
|
3699
|
-
function
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3973
|
+
function validateClientFieldValue(value, attrMeta) {
|
|
3974
|
+
if (!attrMeta) return null;
|
|
3975
|
+
const type = String(attrMeta.type || "").toLowerCase();
|
|
3976
|
+
const isEmpty = value === null || value === void 0 || value === "";
|
|
3977
|
+
if (attrMeta.required && isEmpty && type !== "boolean") {
|
|
3978
|
+
return "Required field";
|
|
3979
|
+
}
|
|
3980
|
+
if (attrMeta.required && type === "boolean" && (value === null || value === void 0 || value === "")) {
|
|
3981
|
+
return "Required boolean";
|
|
3982
|
+
}
|
|
3983
|
+
if (isEmpty) return null;
|
|
3984
|
+
switch (type) {
|
|
3985
|
+
case "integer":
|
|
3986
|
+
case "biginteger": {
|
|
3987
|
+
const s = String(value).trim();
|
|
3988
|
+
if (!/^-?\d+$/.test(s)) return "Must be a valid integer";
|
|
3989
|
+
if (type === "integer") {
|
|
3990
|
+
const n = Number(s);
|
|
3991
|
+
if (!Number.isSafeInteger(n)) return "Integer out of range";
|
|
3992
|
+
if (typeof attrMeta.min === "number" && n < attrMeta.min) return `Min ${attrMeta.min}`;
|
|
3993
|
+
if (typeof attrMeta.max === "number" && n > attrMeta.max) return `Max ${attrMeta.max}`;
|
|
3994
|
+
}
|
|
3995
|
+
return null;
|
|
3712
3996
|
}
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3997
|
+
case "float":
|
|
3998
|
+
case "decimal": {
|
|
3999
|
+
const s = String(value).trim();
|
|
4000
|
+
if (!/^-?\d+(\.\d+)?$/.test(s)) return "Must be a valid number";
|
|
4001
|
+
const n = Number(s);
|
|
4002
|
+
if (typeof attrMeta.min === "number" && n < attrMeta.min) return `Min ${attrMeta.min}`;
|
|
4003
|
+
if (typeof attrMeta.max === "number" && n > attrMeta.max) return `Max ${attrMeta.max}`;
|
|
4004
|
+
return null;
|
|
3718
4005
|
}
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
}
|
|
3725
|
-
|
|
4006
|
+
case "boolean": {
|
|
4007
|
+
if (typeof value === "boolean") return null;
|
|
4008
|
+
const lower = String(value).trim().toLowerCase();
|
|
4009
|
+
if (!["true", "false", "1", "0"].includes(lower)) return "Must be true or false";
|
|
4010
|
+
return null;
|
|
4011
|
+
}
|
|
4012
|
+
case "enumeration": {
|
|
4013
|
+
if (Array.isArray(attrMeta.enumOptions) && !attrMeta.enumOptions.includes(String(value))) {
|
|
4014
|
+
return `Must be one of: ${attrMeta.enumOptions.join(", ")}`;
|
|
4015
|
+
}
|
|
4016
|
+
return null;
|
|
4017
|
+
}
|
|
4018
|
+
case "email": {
|
|
4019
|
+
const s = String(value).trim();
|
|
4020
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)) return "Invalid email";
|
|
4021
|
+
return null;
|
|
4022
|
+
}
|
|
4023
|
+
case "uid": {
|
|
4024
|
+
const s = String(value).trim();
|
|
4025
|
+
if (!/^[A-Za-z0-9\-_.~]*$/.test(s)) return "Invalid UID format";
|
|
4026
|
+
return null;
|
|
4027
|
+
}
|
|
4028
|
+
case "json":
|
|
4029
|
+
case "blocks": {
|
|
4030
|
+
if (typeof value === "string") {
|
|
4031
|
+
try {
|
|
4032
|
+
const parsed = JSON.parse(value);
|
|
4033
|
+
if (type === "blocks" && parsed !== null && !Array.isArray(parsed)) {
|
|
4034
|
+
return "Blocks must be a JSON array";
|
|
4035
|
+
}
|
|
4036
|
+
} catch (err) {
|
|
4037
|
+
return `Invalid JSON: ${err.message}`;
|
|
4038
|
+
}
|
|
4039
|
+
} else if (type === "blocks" && !Array.isArray(value)) {
|
|
4040
|
+
return "Blocks must be an array";
|
|
4041
|
+
}
|
|
4042
|
+
return null;
|
|
4043
|
+
}
|
|
4044
|
+
case "date":
|
|
4045
|
+
case "datetime": {
|
|
4046
|
+
const d = new Date(String(value).trim());
|
|
4047
|
+
if (isNaN(d.getTime())) return "Invalid date/datetime";
|
|
4048
|
+
return null;
|
|
4049
|
+
}
|
|
4050
|
+
case "time": {
|
|
4051
|
+
if (!/^\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/.test(String(value).trim())) {
|
|
4052
|
+
return "Invalid time (HH:mm or HH:mm:ss)";
|
|
4053
|
+
}
|
|
4054
|
+
return null;
|
|
4055
|
+
}
|
|
4056
|
+
default: {
|
|
4057
|
+
const str = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
4058
|
+
if (typeof attrMeta.minLength === "number" && str.length < attrMeta.minLength) {
|
|
4059
|
+
return `Min length ${attrMeta.minLength}`;
|
|
4060
|
+
}
|
|
4061
|
+
if (typeof attrMeta.maxLength === "number" && str.length > attrMeta.maxLength) {
|
|
4062
|
+
return `Max length ${attrMeta.maxLength}`;
|
|
4063
|
+
}
|
|
4064
|
+
if (attrMeta.regex) {
|
|
4065
|
+
try {
|
|
4066
|
+
if (!new RegExp(attrMeta.regex).test(str)) return `Must match /${attrMeta.regex}/`;
|
|
4067
|
+
} catch {
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
return null;
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
function cleanRuleKey(str) {
|
|
4075
|
+
return (str || "").replace(/[-_]/g, "").toLowerCase().trim();
|
|
4076
|
+
}
|
|
4077
|
+
function matchesFieldRulePath(attrPath, targetField) {
|
|
4078
|
+
if (!attrPath || !targetField) return false;
|
|
4079
|
+
const cleanAttr = parseAttrPathClient(attrPath).cleanPath;
|
|
4080
|
+
const parts = cleanAttr.split(".").map(cleanRuleKey).filter(Boolean);
|
|
4081
|
+
const leaf = parts[parts.length - 1] || "";
|
|
4082
|
+
const targetClean = cleanRuleKey(targetField.replace(/^api::/i, ""));
|
|
4083
|
+
if (leaf === targetClean || cleanRuleKey(cleanAttr) === targetClean) return true;
|
|
4084
|
+
const tSegs = targetField.replace(/^api::/i, "").split(".").map(cleanRuleKey).filter(Boolean);
|
|
4085
|
+
if (tSegs.length === 1) return leaf === tSegs[0];
|
|
4086
|
+
return tSegs.every((t) => t === "*" || parts.includes(t));
|
|
4087
|
+
}
|
|
4088
|
+
function computeRecordQuotaUsage(entry, attrPath, excludeOccurrenceKey, recordEdits, colAttributes, attrMeta, validationRules) {
|
|
4089
|
+
const occs = enumerateClientOccurrences(entry, attrPath, colAttributes, attrMeta);
|
|
4090
|
+
const usageCounts = {};
|
|
4091
|
+
for (const occ of occs) {
|
|
4092
|
+
if (occ.occurrenceKey === excludeOccurrenceKey) continue;
|
|
4093
|
+
const edited = recordEdits?.occurrences?.[occ.occurrenceKey];
|
|
4094
|
+
const effectiveVal = edited ? edited.value : occ.value;
|
|
4095
|
+
if (effectiveVal !== void 0 && effectiveVal !== null && String(effectiveVal).trim() !== "") {
|
|
4096
|
+
const k = String(effectiveVal).toLowerCase().trim();
|
|
4097
|
+
usageCounts[k] = (usageCounts[k] || 0) + 1;
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
const quotas = {};
|
|
4101
|
+
if (attrMeta?.options?.items) {
|
|
4102
|
+
for (const item of attrMeta.options.items) {
|
|
4103
|
+
if (typeof item.maxAllowed === "number" && item.maxAllowed > 0) {
|
|
4104
|
+
quotas[item.value.toLowerCase().trim()] = item.maxAllowed;
|
|
4105
|
+
}
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
if (attrMeta?.options?.quotas) {
|
|
4109
|
+
for (const [k, v] of Object.entries(attrMeta.options.quotas)) {
|
|
4110
|
+
if (typeof v === "number" && v > 0) quotas[k.toLowerCase().trim()] = v;
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
for (const rule of validationRules || []) {
|
|
4114
|
+
if (!rule.enabled) continue;
|
|
4115
|
+
if (rule.targetField && !matchesFieldRulePath(attrPath, rule.targetField)) continue;
|
|
4116
|
+
for (const [k, v] of Object.entries(rule.quotas || {})) {
|
|
4117
|
+
if (typeof v === "number" && v > 0) quotas[k.toLowerCase().trim()] = v;
|
|
4118
|
+
}
|
|
4119
|
+
}
|
|
4120
|
+
return { usageCounts, quotas };
|
|
4121
|
+
}
|
|
4122
|
+
function serializeGridTargets(gridEdits, selectedEntries, collectionPages = {}, attrMeta) {
|
|
4123
|
+
const targets = [];
|
|
4124
|
+
let totalEditCount = 0;
|
|
4125
|
+
let hasValidationErrors = false;
|
|
4126
|
+
for (const [key, rec] of Object.entries(gridEdits)) {
|
|
4127
|
+
if (!selectedEntries[key]) continue;
|
|
4128
|
+
const occEntries = Object.values(rec.occurrences || {});
|
|
4129
|
+
if (occEntries.length === 0) continue;
|
|
4130
|
+
for (const occ of occEntries) {
|
|
4131
|
+
if (occ.validationError) {
|
|
4132
|
+
hasValidationErrors = true;
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
const colPage = collectionPages[rec.uid];
|
|
4136
|
+
const cachedEntry = colPage?.entries?.find((e) => e.documentId === rec.documentId);
|
|
4137
|
+
const targetObj = {
|
|
4138
|
+
uid: rec.uid,
|
|
4139
|
+
documentId: rec.documentId,
|
|
4140
|
+
status: cachedEntry?.status ?? rec.status,
|
|
4141
|
+
publishedAt: cachedEntry?.publishedAt ?? rec.publishedAt,
|
|
4142
|
+
locale: cachedEntry?.locale ?? rec.locale
|
|
4143
|
+
};
|
|
4144
|
+
const isScalarOnly = occEntries.length === 1 && occEntries[0].occurrenceKey === "__scalar__" && !attrMeta?.rootType;
|
|
4145
|
+
if (isScalarOnly) {
|
|
4146
|
+
targetObj.overrideValue = occEntries[0].value;
|
|
4147
|
+
totalEditCount += 1;
|
|
4148
|
+
} else {
|
|
4149
|
+
targetObj.occurrenceUpdates = occEntries.map((occ) => ({
|
|
4150
|
+
occurrenceKey: occ.occurrenceKey,
|
|
4151
|
+
segments: occ.segments,
|
|
4152
|
+
dynamicZoneIndex: occ.segments?.[0]?.index,
|
|
4153
|
+
componentId: occ.segments?.find((s) => s.componentId !== void 0)?.componentId,
|
|
4154
|
+
componentUid: occ.segments?.find((s) => s.componentUid)?.componentUid,
|
|
4155
|
+
value: occ.value
|
|
4156
|
+
}));
|
|
4157
|
+
totalEditCount += occEntries.length;
|
|
4158
|
+
}
|
|
4159
|
+
targets.push(targetObj);
|
|
4160
|
+
}
|
|
4161
|
+
return { targets, totalEditCount, hasValidationErrors };
|
|
4162
|
+
}
|
|
4163
|
+
const DEFAULT_HEADING_ITEMS = [
|
|
4164
|
+
{ value: "h1", label: "H1 - Main Page Title", maxAllowed: 1 },
|
|
4165
|
+
{ value: "h2", label: "H2 - Primary Section Heading", maxAllowed: 3 },
|
|
4166
|
+
{ value: "h3", label: "H3 - Sub-section Heading", maxAllowed: null },
|
|
4167
|
+
{ value: "h4", label: "H4 - Component Title", maxAllowed: null },
|
|
4168
|
+
{ value: "h5", label: "H5 - Card / Item Heading", maxAllowed: null },
|
|
4169
|
+
{ value: "h6", label: "H6 - Minor Heading", maxAllowed: null }
|
|
4170
|
+
];
|
|
4171
|
+
function toTextInputString(val, type) {
|
|
4172
|
+
if (val === null || val === void 0) return "";
|
|
4173
|
+
if (type === "date" && typeof val === "string") {
|
|
4174
|
+
return val.slice(0, 10);
|
|
4175
|
+
}
|
|
4176
|
+
if (type === "datetime" && typeof val === "string") {
|
|
4177
|
+
const d = new Date(val);
|
|
4178
|
+
if (!isNaN(d.getTime())) {
|
|
4179
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
4180
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
4181
|
+
}
|
|
4182
|
+
return val.slice(0, 16);
|
|
4183
|
+
}
|
|
4184
|
+
if (type === "time" && typeof val === "string") {
|
|
4185
|
+
return val.slice(0, 8);
|
|
4186
|
+
}
|
|
4187
|
+
if (typeof val === "object") {
|
|
4188
|
+
try {
|
|
4189
|
+
return JSON.stringify(val);
|
|
4190
|
+
} catch {
|
|
4191
|
+
return String(val);
|
|
4192
|
+
}
|
|
4193
|
+
}
|
|
4194
|
+
return String(val);
|
|
4195
|
+
}
|
|
4196
|
+
const GridCellEditor = React__default.memo(
|
|
4197
|
+
({
|
|
4198
|
+
entry,
|
|
4199
|
+
attribute,
|
|
4200
|
+
occurrence,
|
|
4201
|
+
attrMeta,
|
|
4202
|
+
editedValue,
|
|
4203
|
+
isDirty,
|
|
4204
|
+
validationError,
|
|
4205
|
+
relationOptions = [],
|
|
4206
|
+
relationOptionsLoading = false,
|
|
4207
|
+
relationIsMulti = false,
|
|
4208
|
+
validationRules = [],
|
|
4209
|
+
recordEdits,
|
|
4210
|
+
colAttributes,
|
|
4211
|
+
compact = false,
|
|
4212
|
+
onCommit,
|
|
4213
|
+
onReset
|
|
4214
|
+
}) => {
|
|
4215
|
+
const { get } = useFetchClient();
|
|
4216
|
+
const fieldType = String(attrMeta?.type || "").toLowerCase();
|
|
4217
|
+
const isScopedSelect = attrMeta?.customField === "plugin::bulk-updater.scoped-select" || attrMeta?.customField === "global::scoped-select";
|
|
4218
|
+
const isRelation = Boolean(attrMeta?.isRelation || fieldType === "relation");
|
|
4219
|
+
const isMultiRelation = isRelation && Boolean(relationIsMulti || ["oneToMany", "manyToMany"].includes(attrMeta?.relationType || ""));
|
|
4220
|
+
const effectiveValue = isDirty ? editedValue : occurrence.value;
|
|
4221
|
+
const [localText, setLocalText] = useState(() => toTextInputString(effectiveValue, fieldType));
|
|
4222
|
+
const [showRichModal, setShowRichModal] = useState(false);
|
|
4223
|
+
const [richDraft, setRichDraft] = useState("");
|
|
4224
|
+
const [richError, setRichError] = useState(null);
|
|
4225
|
+
const [showMultiRelModal, setShowMultiRelModal] = useState(false);
|
|
4226
|
+
const [multiRelSelected, setMultiRelSelected] = useState([]);
|
|
4227
|
+
const [multiRelMode, setMultiRelMode] = useState("set");
|
|
4228
|
+
const [multiRelSearch, setMultiRelSearch] = useState("");
|
|
4229
|
+
const [showMediaModal, setShowMediaModal] = useState(false);
|
|
4230
|
+
const [mediaOptions, setMediaOptions] = useState([]);
|
|
4231
|
+
const [mediaSearch, setMediaSearch] = useState("");
|
|
4232
|
+
const [mediaLoading, setMediaLoading] = useState(false);
|
|
4233
|
+
const [selectedMediaIds, setSelectedMediaIds] = useState([]);
|
|
4234
|
+
useEffect(() => {
|
|
4235
|
+
setLocalText(toTextInputString(effectiveValue, fieldType));
|
|
4236
|
+
}, [effectiveValue, fieldType, occurrence.occurrenceKey]);
|
|
4237
|
+
const commitTypedValue = (rawVal) => {
|
|
4238
|
+
if (areClientValuesEqual(rawVal, occurrence.value)) {
|
|
4239
|
+
onReset(occurrence.occurrenceKey);
|
|
4240
|
+
return;
|
|
4241
|
+
}
|
|
4242
|
+
const err = validateClientFieldValue(rawVal, attrMeta);
|
|
4243
|
+
onCommit(occurrence, rawVal, err);
|
|
4244
|
+
};
|
|
4245
|
+
const loadMediaLibrary = async (query = "") => {
|
|
4246
|
+
try {
|
|
4247
|
+
setMediaLoading(true);
|
|
4248
|
+
const res = await get(`/bulk-updater/media-options?search=${encodeURIComponent(query)}`);
|
|
4249
|
+
if (res.data?.success && Array.isArray(res.data.options)) {
|
|
4250
|
+
setMediaOptions(res.data.options);
|
|
4251
|
+
}
|
|
4252
|
+
} catch {
|
|
4253
|
+
setMediaOptions([]);
|
|
4254
|
+
} finally {
|
|
4255
|
+
setMediaLoading(false);
|
|
4256
|
+
}
|
|
4257
|
+
};
|
|
4258
|
+
const quotaContext = useMemo(() => {
|
|
4259
|
+
if (!isScopedSelect) return null;
|
|
4260
|
+
return computeRecordQuotaUsage(
|
|
4261
|
+
entry,
|
|
4262
|
+
attribute,
|
|
4263
|
+
occurrence.occurrenceKey,
|
|
4264
|
+
recordEdits,
|
|
4265
|
+
colAttributes,
|
|
4266
|
+
attrMeta,
|
|
4267
|
+
validationRules
|
|
4268
|
+
);
|
|
4269
|
+
}, [isScopedSelect, entry, attribute, occurrence.occurrenceKey, recordEdits, colAttributes, attrMeta, validationRules]);
|
|
4270
|
+
const scopedItems = useMemo(() => {
|
|
4271
|
+
if (!isScopedSelect) return [];
|
|
4272
|
+
const base = attrMeta?.options?.items && attrMeta.options.items.length > 0 ? attrMeta.options.items : DEFAULT_HEADING_ITEMS;
|
|
4273
|
+
const quotas = quotaContext?.quotas || {};
|
|
4274
|
+
return base.map((it) => {
|
|
4275
|
+
const key = it.value.toLowerCase().trim();
|
|
4276
|
+
const maxAllowed = typeof quotas[key] === "number" ? quotas[key] : it.maxAllowed;
|
|
4277
|
+
const usedBySiblings = quotaContext?.usageCounts?.[key] || 0;
|
|
4278
|
+
return {
|
|
4279
|
+
...it,
|
|
4280
|
+
maxAllowed,
|
|
4281
|
+
usedBySiblings,
|
|
4282
|
+
atLimit: typeof maxAllowed === "number" && maxAllowed > 0 && usedBySiblings >= maxAllowed
|
|
4283
|
+
};
|
|
4284
|
+
});
|
|
4285
|
+
}, [isScopedSelect, attrMeta, quotaContext]);
|
|
4286
|
+
const wrapperStyle = {
|
|
4287
|
+
borderLeft: isDirty ? "3px solid #4945ff" : "3px solid transparent",
|
|
4288
|
+
paddingLeft: 6,
|
|
4289
|
+
backgroundColor: validationError ? "rgba(208, 43, 32, 0.06)" : isDirty ? "rgba(73, 69, 255, 0.05)" : "transparent",
|
|
4290
|
+
borderRadius: 4,
|
|
4291
|
+
minWidth: compact ? 180 : 210,
|
|
4292
|
+
maxWidth: 320
|
|
4293
|
+
};
|
|
4294
|
+
const renderResetBtn = () => isDirty ? /* @__PURE__ */ jsx(
|
|
4295
|
+
Button,
|
|
4296
|
+
{
|
|
4297
|
+
variant: "ghost",
|
|
4298
|
+
size: "S",
|
|
4299
|
+
onClick: () => onReset(occurrence.occurrenceKey),
|
|
4300
|
+
title: "Revert this cell back to original database value",
|
|
4301
|
+
style: { padding: "4px 6px", minWidth: 28, height: 28 },
|
|
4302
|
+
children: /* @__PURE__ */ jsx(ArrowClockwise, {})
|
|
4303
|
+
}
|
|
4304
|
+
) : null;
|
|
4305
|
+
if (isScopedSelect) {
|
|
4306
|
+
const currentValStr = effectiveValue !== null && effectiveValue !== void 0 ? String(effectiveValue) : "__clear__";
|
|
4307
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4308
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4309
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 145 }, children: /* @__PURE__ */ jsxs(
|
|
4310
|
+
SingleSelect,
|
|
4311
|
+
{
|
|
4312
|
+
size: "S",
|
|
4313
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4314
|
+
value: currentValStr,
|
|
4315
|
+
onChange: (val) => {
|
|
4316
|
+
const s = String(val);
|
|
4317
|
+
commitTypedValue(s === "__clear__" ? null : s);
|
|
4318
|
+
},
|
|
4319
|
+
children: [
|
|
4320
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "__clear__", children: "-- Unset --" }),
|
|
4321
|
+
scopedItems.map((it) => {
|
|
4322
|
+
const isCurrentlySelected = currentValStr.toLowerCase() === it.value.toLowerCase();
|
|
4323
|
+
const quotaNote = typeof it.maxAllowed === "number" && it.maxAllowed > 0 ? ` (${it.usedBySiblings + (isCurrentlySelected ? 1 : 0)}/${it.maxAllowed})` : "";
|
|
4324
|
+
return /* @__PURE__ */ jsxs(SingleSelectOption, { value: it.value, children: [
|
|
4325
|
+
it.label,
|
|
4326
|
+
quotaNote,
|
|
4327
|
+
it.atLimit && !isCurrentlySelected ? " [QUOTA FULL]" : ""
|
|
4328
|
+
] }, it.value);
|
|
4329
|
+
})
|
|
4330
|
+
]
|
|
4331
|
+
}
|
|
4332
|
+
) }),
|
|
4333
|
+
renderResetBtn()
|
|
4334
|
+
] }),
|
|
4335
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem", marginTop: 2 }, children: validationError })
|
|
4336
|
+
] });
|
|
4337
|
+
}
|
|
4338
|
+
if (fieldType === "enumeration" && Array.isArray(attrMeta?.enumOptions)) {
|
|
4339
|
+
const currentValStr = effectiveValue !== null && effectiveValue !== void 0 && effectiveValue !== "" ? String(effectiveValue) : "__clear__";
|
|
4340
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4341
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4342
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 145 }, children: /* @__PURE__ */ jsxs(
|
|
4343
|
+
SingleSelect,
|
|
4344
|
+
{
|
|
4345
|
+
size: "S",
|
|
4346
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4347
|
+
value: currentValStr,
|
|
4348
|
+
onChange: (val) => {
|
|
4349
|
+
const s = String(val);
|
|
4350
|
+
commitTypedValue(s === "__clear__" ? null : s);
|
|
4351
|
+
},
|
|
4352
|
+
children: [
|
|
4353
|
+
!attrMeta.required && /* @__PURE__ */ jsx(SingleSelectOption, { value: "__clear__", children: "-- Clear (null) --" }),
|
|
4354
|
+
attrMeta.enumOptions.map((opt) => /* @__PURE__ */ jsx(SingleSelectOption, { value: opt, children: opt }, opt))
|
|
4355
|
+
]
|
|
4356
|
+
}
|
|
4357
|
+
) }),
|
|
4358
|
+
renderResetBtn()
|
|
4359
|
+
] }),
|
|
4360
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
|
|
4361
|
+
] });
|
|
4362
|
+
}
|
|
4363
|
+
if (fieldType === "boolean") {
|
|
4364
|
+
const strVal = effectiveValue === true ? "true" : effectiveValue === false ? "false" : "__unset__";
|
|
4365
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4366
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4367
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 120 }, children: /* @__PURE__ */ jsxs(
|
|
4368
|
+
SingleSelect,
|
|
4369
|
+
{
|
|
4370
|
+
size: "S",
|
|
4371
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4372
|
+
value: strVal,
|
|
4373
|
+
onChange: (val) => {
|
|
4374
|
+
const s = String(val);
|
|
4375
|
+
commitTypedValue(s === "true" ? true : s === "false" ? false : null);
|
|
4376
|
+
},
|
|
4377
|
+
children: [
|
|
4378
|
+
!attrMeta?.required && /* @__PURE__ */ jsx(SingleSelectOption, { value: "__unset__", children: "-- Unset --" }),
|
|
4379
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "true", children: "true" }),
|
|
4380
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "false", children: "false" })
|
|
4381
|
+
]
|
|
4382
|
+
}
|
|
4383
|
+
) }),
|
|
4384
|
+
renderResetBtn()
|
|
4385
|
+
] }),
|
|
4386
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
|
|
4387
|
+
] });
|
|
4388
|
+
}
|
|
4389
|
+
if (isRelation) {
|
|
4390
|
+
const cmd = extractRelationEditCommand(effectiveValue, occurrence.value, isMultiRelation);
|
|
4391
|
+
if (!isMultiRelation) {
|
|
4392
|
+
const selectedDocId = cmd.mode === "clear" ? "__clear__" : cmd.documentIds[0] || "__clear__";
|
|
4393
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4394
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4395
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 165 }, children: /* @__PURE__ */ jsxs(
|
|
4396
|
+
Combobox,
|
|
4397
|
+
{
|
|
4398
|
+
autocomplete: { type: "list", filter: "contains" },
|
|
4399
|
+
placeholder: relationOptionsLoading ? "Loading..." : "Pick relation...",
|
|
4400
|
+
value: selectedDocId,
|
|
4401
|
+
onChange: (val) => {
|
|
4402
|
+
const docId = val ? String(val) : "__clear__";
|
|
4403
|
+
if (docId === "__clear__") {
|
|
4404
|
+
commitTypedValue({ mode: "clear", documentIds: [], label: "(cleared / unlinked)" });
|
|
4405
|
+
} else {
|
|
4406
|
+
const opt = relationOptions.find((o) => o.documentId === docId);
|
|
4407
|
+
commitTypedValue({ mode: "set", documentIds: [docId], label: opt?.label || docId });
|
|
4408
|
+
}
|
|
4409
|
+
},
|
|
4410
|
+
children: [
|
|
4411
|
+
/* @__PURE__ */ jsx(ComboboxOption, { value: "__clear__", textValue: "Clear / Unlink Relation", children: "-- Clear / Unlink --" }),
|
|
4412
|
+
relationOptions.map((opt) => /* @__PURE__ */ jsx(ComboboxOption, { value: opt.documentId, textValue: opt.label, children: opt.label }, opt.documentId))
|
|
4413
|
+
]
|
|
4414
|
+
}
|
|
4415
|
+
) }),
|
|
4416
|
+
renderResetBtn()
|
|
4417
|
+
] }),
|
|
4418
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
|
|
4419
|
+
] });
|
|
4420
|
+
}
|
|
4421
|
+
const displaySummary = cmd.mode === "clear" ? "(cleared / empty)" : cmd.label || (cmd.documentIds.length > 0 ? `${cmd.documentIds.length} linked (${cmd.mode})` : "(unlinked)");
|
|
4422
|
+
const filteredRelOpts = relationOptions.filter(
|
|
4423
|
+
(o) => !multiRelSearch.trim() || o.label.toLowerCase().includes(multiRelSearch.toLowerCase())
|
|
4424
|
+
);
|
|
4425
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4426
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4427
|
+
/* @__PURE__ */ jsx(
|
|
4428
|
+
Button,
|
|
4429
|
+
{
|
|
4430
|
+
variant: "tertiary",
|
|
4431
|
+
size: "S",
|
|
4432
|
+
onClick: () => {
|
|
4433
|
+
setMultiRelSelected(cmd.documentIds || []);
|
|
4434
|
+
setMultiRelMode(cmd.mode === "clear" && (cmd.documentIds || []).length === 0 ? "set" : cmd.mode);
|
|
4435
|
+
setMultiRelSearch("");
|
|
4436
|
+
setShowMultiRelModal(true);
|
|
4437
|
+
},
|
|
4438
|
+
style: { maxWidth: 230, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
4439
|
+
children: displaySummary
|
|
4440
|
+
}
|
|
4441
|
+
),
|
|
4442
|
+
renderResetBtn()
|
|
4443
|
+
] }),
|
|
4444
|
+
showMultiRelModal && /* @__PURE__ */ jsx(
|
|
4445
|
+
"div",
|
|
4446
|
+
{
|
|
4447
|
+
style: {
|
|
4448
|
+
position: "fixed",
|
|
4449
|
+
inset: 0,
|
|
4450
|
+
backgroundColor: "rgba(20, 20, 30, 0.55)",
|
|
4451
|
+
zIndex: 9999,
|
|
4452
|
+
display: "flex",
|
|
4453
|
+
alignItems: "center",
|
|
4454
|
+
justifyContent: "center",
|
|
4455
|
+
padding: 16
|
|
4456
|
+
},
|
|
4457
|
+
onClick: () => setShowMultiRelModal(false),
|
|
4458
|
+
children: /* @__PURE__ */ jsxs(
|
|
4459
|
+
Box,
|
|
4460
|
+
{
|
|
4461
|
+
padding: 5,
|
|
4462
|
+
background: "neutral0",
|
|
4463
|
+
hasRadius: true,
|
|
4464
|
+
shadow: "popupShadow",
|
|
4465
|
+
style: { width: "92%", maxWidth: 520, maxHeight: "80vh", display: "flex", flexDirection: "column" },
|
|
4466
|
+
onClick: (e) => e.stopPropagation(),
|
|
4467
|
+
children: [
|
|
4468
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "delta", fontWeight: "bold", marginBottom: 2, children: [
|
|
4469
|
+
"Edit Multi-Relation: ",
|
|
4470
|
+
occurrence.displayPath
|
|
4471
|
+
] }),
|
|
4472
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, marginBottom: 3, alignItems: "center", children: [
|
|
4473
|
+
/* @__PURE__ */ jsx(Box, { style: { width: 180 }, children: /* @__PURE__ */ jsxs(
|
|
4474
|
+
SingleSelect,
|
|
4475
|
+
{
|
|
4476
|
+
label: "Operation",
|
|
4477
|
+
value: multiRelMode,
|
|
4478
|
+
onChange: (v) => setMultiRelMode(String(v)),
|
|
4479
|
+
children: [
|
|
4480
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "set", children: "Set / Replace All" }),
|
|
4481
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "connect", children: "Add / Connect" }),
|
|
4482
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "disconnect", children: "Remove / Disconnect" }),
|
|
4483
|
+
/* @__PURE__ */ jsx(SingleSelectOption, { value: "clear", children: "Clear All" })
|
|
4484
|
+
]
|
|
4485
|
+
}
|
|
4486
|
+
) }),
|
|
4487
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
|
|
4488
|
+
TextInput,
|
|
4489
|
+
{
|
|
4490
|
+
label: "Filter items",
|
|
4491
|
+
placeholder: "Search relations...",
|
|
4492
|
+
value: multiRelSearch,
|
|
4493
|
+
onChange: (e) => setMultiRelSearch(e.target.value)
|
|
4494
|
+
}
|
|
4495
|
+
) })
|
|
4496
|
+
] }),
|
|
4497
|
+
multiRelMode !== "clear" && /* @__PURE__ */ jsx(
|
|
4498
|
+
Box,
|
|
4499
|
+
{
|
|
4500
|
+
padding: 2,
|
|
4501
|
+
hasRadius: true,
|
|
4502
|
+
style: { border: "1px solid #eaeaef", overflowY: "auto", maxHeight: 280, marginBottom: 16 },
|
|
4503
|
+
children: filteredRelOpts.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "No target entities found." }) : filteredRelOpts.map((opt) => {
|
|
4504
|
+
const checked = multiRelSelected.includes(opt.documentId);
|
|
4505
|
+
return /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(
|
|
4506
|
+
Checkbox,
|
|
4507
|
+
{
|
|
4508
|
+
checked,
|
|
4509
|
+
onCheckedChange: (isChecked) => {
|
|
4510
|
+
setMultiRelSelected(
|
|
4511
|
+
(prev) => isChecked ? [...prev, opt.documentId] : prev.filter((id) => id !== opt.documentId)
|
|
4512
|
+
);
|
|
4513
|
+
},
|
|
4514
|
+
children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: opt.label })
|
|
4515
|
+
}
|
|
4516
|
+
) }, opt.documentId);
|
|
4517
|
+
})
|
|
4518
|
+
}
|
|
4519
|
+
),
|
|
4520
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "flex-end", gap: 2, children: [
|
|
4521
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: () => setShowMultiRelModal(false), children: "Cancel" }),
|
|
4522
|
+
/* @__PURE__ */ jsx(
|
|
4523
|
+
Button,
|
|
4524
|
+
{
|
|
4525
|
+
variant: "default",
|
|
4526
|
+
startIcon: /* @__PURE__ */ jsx(Check, {}),
|
|
4527
|
+
onClick: () => {
|
|
4528
|
+
if (multiRelMode === "clear") {
|
|
4529
|
+
commitTypedValue({ mode: "clear", documentIds: [], label: "(cleared / unlinked)" });
|
|
4530
|
+
} else {
|
|
4531
|
+
const labels = relationOptions.filter((o) => multiRelSelected.includes(o.documentId)).map((o) => o.label).join(", ");
|
|
4532
|
+
commitTypedValue({
|
|
4533
|
+
mode: multiRelMode,
|
|
4534
|
+
documentIds: multiRelSelected,
|
|
4535
|
+
label: labels || `${multiRelSelected.length} selected`
|
|
4536
|
+
});
|
|
4537
|
+
}
|
|
4538
|
+
setShowMultiRelModal(false);
|
|
4539
|
+
},
|
|
4540
|
+
children: "Apply Relation Edit"
|
|
4541
|
+
}
|
|
4542
|
+
)
|
|
4543
|
+
] })
|
|
4544
|
+
]
|
|
4545
|
+
}
|
|
4546
|
+
)
|
|
4547
|
+
}
|
|
4548
|
+
)
|
|
4549
|
+
] });
|
|
4550
|
+
}
|
|
4551
|
+
if (fieldType === "media") {
|
|
4552
|
+
const isMultiMedia = Boolean(attrMeta?.multiple);
|
|
4553
|
+
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] : [];
|
|
4554
|
+
const mediaSummary = currentIds.length === 0 ? "(no media — pick)" : Array.isArray(effectiveValue) ? `${currentIds.length} asset(s)` : effectiveValue?.name ? `${effectiveValue.name} (#${currentIds[0]})` : `Media #${currentIds[0]}`;
|
|
4555
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4556
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4557
|
+
/* @__PURE__ */ jsx(
|
|
4558
|
+
Button,
|
|
4559
|
+
{
|
|
4560
|
+
variant: "tertiary",
|
|
4561
|
+
size: "S",
|
|
4562
|
+
onClick: () => {
|
|
4563
|
+
setSelectedMediaIds(currentIds);
|
|
4564
|
+
setMediaSearch("");
|
|
4565
|
+
setShowMediaModal(true);
|
|
4566
|
+
loadMediaLibrary("");
|
|
4567
|
+
},
|
|
4568
|
+
style: { maxWidth: 220, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
4569
|
+
children: mediaSummary
|
|
4570
|
+
}
|
|
4571
|
+
),
|
|
4572
|
+
renderResetBtn()
|
|
4573
|
+
] }),
|
|
4574
|
+
showMediaModal && /* @__PURE__ */ jsx(
|
|
4575
|
+
"div",
|
|
4576
|
+
{
|
|
4577
|
+
style: {
|
|
4578
|
+
position: "fixed",
|
|
4579
|
+
inset: 0,
|
|
4580
|
+
backgroundColor: "rgba(20, 20, 30, 0.55)",
|
|
4581
|
+
zIndex: 9999,
|
|
4582
|
+
display: "flex",
|
|
4583
|
+
alignItems: "center",
|
|
4584
|
+
justifyContent: "center",
|
|
4585
|
+
padding: 16
|
|
4586
|
+
},
|
|
4587
|
+
onClick: () => setShowMediaModal(false),
|
|
4588
|
+
children: /* @__PURE__ */ jsxs(
|
|
4589
|
+
Box,
|
|
4590
|
+
{
|
|
4591
|
+
padding: 5,
|
|
4592
|
+
background: "neutral0",
|
|
4593
|
+
hasRadius: true,
|
|
4594
|
+
shadow: "popupShadow",
|
|
4595
|
+
style: { width: "92%", maxWidth: 620, maxHeight: "82vh", display: "flex", flexDirection: "column" },
|
|
4596
|
+
onClick: (e) => e.stopPropagation(),
|
|
4597
|
+
children: [
|
|
4598
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "delta", fontWeight: "bold", marginBottom: 3, children: [
|
|
4599
|
+
"Select Media Asset",
|
|
4600
|
+
isMultiMedia ? "s" : "",
|
|
4601
|
+
": ",
|
|
4602
|
+
occurrence.displayPath
|
|
4603
|
+
] }),
|
|
4604
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, marginBottom: 3, children: [
|
|
4605
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
|
|
4606
|
+
TextInput,
|
|
4607
|
+
{
|
|
4608
|
+
placeholder: "Search media filename or MIME...",
|
|
4609
|
+
value: mediaSearch,
|
|
4610
|
+
onChange: (e) => setMediaSearch(e.target.value)
|
|
4611
|
+
}
|
|
4612
|
+
) }),
|
|
4613
|
+
/* @__PURE__ */ jsx(
|
|
4614
|
+
Button,
|
|
4615
|
+
{
|
|
4616
|
+
variant: "secondary",
|
|
4617
|
+
startIcon: /* @__PURE__ */ jsx(Search, {}),
|
|
4618
|
+
onClick: () => loadMediaLibrary(mediaSearch),
|
|
4619
|
+
loading: mediaLoading,
|
|
4620
|
+
children: "Search"
|
|
4621
|
+
}
|
|
4622
|
+
)
|
|
4623
|
+
] }),
|
|
4624
|
+
/* @__PURE__ */ jsx(
|
|
4625
|
+
Box,
|
|
4626
|
+
{
|
|
4627
|
+
padding: 2,
|
|
4628
|
+
hasRadius: true,
|
|
4629
|
+
style: { border: "1px solid #eaeaef", overflowY: "auto", maxHeight: 320, marginBottom: 16 },
|
|
4630
|
+
children: mediaLoading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Loader, { small: true, children: "Loading Media Library..." }) }) : mediaOptions.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "No media files matched." }) : mediaOptions.map((file) => {
|
|
4631
|
+
const isChecked = selectedMediaIds.includes(file.id);
|
|
4632
|
+
return /* @__PURE__ */ jsx(Box, { padding: 2, style: { borderBottom: "1px solid #f0f0f5" }, children: /* @__PURE__ */ jsx(
|
|
4633
|
+
Checkbox,
|
|
4634
|
+
{
|
|
4635
|
+
checked: isChecked,
|
|
4636
|
+
onCheckedChange: (checked) => {
|
|
4637
|
+
if (isMultiMedia) {
|
|
4638
|
+
setSelectedMediaIds(
|
|
4639
|
+
(prev) => checked ? [...prev, file.id] : prev.filter((id) => id !== file.id)
|
|
4640
|
+
);
|
|
4641
|
+
} else {
|
|
4642
|
+
setSelectedMediaIds(checked ? [file.id] : []);
|
|
4643
|
+
}
|
|
4644
|
+
},
|
|
4645
|
+
children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
4646
|
+
/* @__PURE__ */ jsxs(Badge, { backgroundColor: "neutral150", textColor: "neutral700", size: "S", children: [
|
|
4647
|
+
"#",
|
|
4648
|
+
file.id
|
|
4649
|
+
] }),
|
|
4650
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", children: file.name }),
|
|
4651
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", children: [
|
|
4652
|
+
"(",
|
|
4653
|
+
file.mime,
|
|
4654
|
+
")"
|
|
4655
|
+
] })
|
|
4656
|
+
] })
|
|
4657
|
+
}
|
|
4658
|
+
) }, file.id);
|
|
4659
|
+
})
|
|
4660
|
+
}
|
|
4661
|
+
),
|
|
4662
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 2, children: [
|
|
4663
|
+
/* @__PURE__ */ jsx(
|
|
4664
|
+
Button,
|
|
4665
|
+
{
|
|
4666
|
+
variant: "danger-light",
|
|
4667
|
+
onClick: () => {
|
|
4668
|
+
commitTypedValue(isMultiMedia ? [] : null);
|
|
4669
|
+
setShowMediaModal(false);
|
|
4670
|
+
},
|
|
4671
|
+
children: "Clear Media"
|
|
4672
|
+
}
|
|
4673
|
+
),
|
|
4674
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
4675
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: () => setShowMediaModal(false), children: "Cancel" }),
|
|
4676
|
+
/* @__PURE__ */ jsx(
|
|
4677
|
+
Button,
|
|
4678
|
+
{
|
|
4679
|
+
variant: "default",
|
|
4680
|
+
startIcon: /* @__PURE__ */ jsx(Check, {}),
|
|
4681
|
+
onClick: () => {
|
|
4682
|
+
commitTypedValue(isMultiMedia ? selectedMediaIds : selectedMediaIds[0] ?? null);
|
|
4683
|
+
setShowMediaModal(false);
|
|
4684
|
+
},
|
|
4685
|
+
children: "Apply Selection"
|
|
4686
|
+
}
|
|
4687
|
+
)
|
|
4688
|
+
] })
|
|
4689
|
+
] })
|
|
4690
|
+
]
|
|
4691
|
+
}
|
|
4692
|
+
)
|
|
4693
|
+
}
|
|
4694
|
+
)
|
|
4695
|
+
] });
|
|
4696
|
+
}
|
|
4697
|
+
if (fieldType === "richtext" || fieldType === "blocks" || fieldType === "json") {
|
|
4698
|
+
const isJsonOrBlocks = fieldType === "blocks" || fieldType === "json";
|
|
4699
|
+
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 ? "…" : "");
|
|
4700
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4701
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4702
|
+
/* @__PURE__ */ jsx(
|
|
4703
|
+
Button,
|
|
4704
|
+
{
|
|
4705
|
+
variant: "tertiary",
|
|
4706
|
+
size: "S",
|
|
4707
|
+
onClick: () => {
|
|
4708
|
+
const formatted = effectiveValue === null || effectiveValue === void 0 ? "" : typeof effectiveValue === "object" ? JSON.stringify(effectiveValue, null, 2) : String(effectiveValue);
|
|
4709
|
+
setRichDraft(formatted);
|
|
4710
|
+
setRichError(null);
|
|
4711
|
+
setShowRichModal(true);
|
|
4712
|
+
},
|
|
4713
|
+
style: { maxWidth: 230, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
4714
|
+
children: displayLabel
|
|
4715
|
+
}
|
|
4716
|
+
),
|
|
4717
|
+
renderResetBtn()
|
|
4718
|
+
] }),
|
|
4719
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError }),
|
|
4720
|
+
showRichModal && /* @__PURE__ */ jsx(
|
|
4721
|
+
"div",
|
|
4722
|
+
{
|
|
4723
|
+
style: {
|
|
4724
|
+
position: "fixed",
|
|
4725
|
+
inset: 0,
|
|
4726
|
+
backgroundColor: "rgba(20, 20, 30, 0.55)",
|
|
4727
|
+
zIndex: 9999,
|
|
4728
|
+
display: "flex",
|
|
4729
|
+
alignItems: "center",
|
|
4730
|
+
justifyContent: "center",
|
|
4731
|
+
padding: 16
|
|
4732
|
+
},
|
|
4733
|
+
onClick: () => setShowRichModal(false),
|
|
4734
|
+
children: /* @__PURE__ */ jsxs(
|
|
4735
|
+
Box,
|
|
4736
|
+
{
|
|
4737
|
+
padding: 5,
|
|
4738
|
+
background: "neutral0",
|
|
4739
|
+
hasRadius: true,
|
|
4740
|
+
shadow: "popupShadow",
|
|
4741
|
+
style: { width: "92%", maxWidth: 640, display: "flex", flexDirection: "column", gap: 12 },
|
|
4742
|
+
onClick: (e) => e.stopPropagation(),
|
|
4743
|
+
children: [
|
|
4744
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "delta", fontWeight: "bold", children: [
|
|
4745
|
+
"Edit ",
|
|
4746
|
+
fieldType.toUpperCase(),
|
|
4747
|
+
": ",
|
|
4748
|
+
occurrence.displayPath
|
|
4749
|
+
] }),
|
|
4750
|
+
/* @__PURE__ */ jsx(
|
|
4751
|
+
Textarea,
|
|
4752
|
+
{
|
|
4753
|
+
name: "richDraft",
|
|
4754
|
+
"aria-label": "Rich content editor",
|
|
4755
|
+
value: richDraft,
|
|
4756
|
+
onChange: (e) => {
|
|
4757
|
+
setRichDraft(e.target.value);
|
|
4758
|
+
if (isJsonOrBlocks && e.target.value.trim()) {
|
|
4759
|
+
try {
|
|
4760
|
+
const parsed = JSON.parse(e.target.value);
|
|
4761
|
+
if (fieldType === "blocks" && !Array.isArray(parsed)) {
|
|
4762
|
+
setRichError("Strapi Blocks value must be a JSON array.");
|
|
4763
|
+
} else {
|
|
4764
|
+
setRichError(null);
|
|
4765
|
+
}
|
|
4766
|
+
} catch (err) {
|
|
4767
|
+
setRichError(`Invalid JSON: ${err.message}`);
|
|
4768
|
+
}
|
|
4769
|
+
} else {
|
|
4770
|
+
setRichError(null);
|
|
4771
|
+
}
|
|
4772
|
+
},
|
|
4773
|
+
style: { minHeight: 220, fontFamily: isJsonOrBlocks ? "monospace" : "inherit" }
|
|
4774
|
+
}
|
|
4775
|
+
),
|
|
4776
|
+
richError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: richError }),
|
|
4777
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 2, children: [
|
|
4778
|
+
/* @__PURE__ */ jsx(
|
|
4779
|
+
Button,
|
|
4780
|
+
{
|
|
4781
|
+
variant: "danger-light",
|
|
4782
|
+
onClick: () => {
|
|
4783
|
+
commitTypedValue(isJsonOrBlocks ? null : "");
|
|
4784
|
+
setShowRichModal(false);
|
|
4785
|
+
},
|
|
4786
|
+
children: "Clear Value"
|
|
4787
|
+
}
|
|
4788
|
+
),
|
|
4789
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
4790
|
+
/* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: () => setShowRichModal(false), children: "Cancel" }),
|
|
4791
|
+
/* @__PURE__ */ jsx(
|
|
4792
|
+
Button,
|
|
4793
|
+
{
|
|
4794
|
+
variant: "default",
|
|
4795
|
+
disabled: Boolean(richError),
|
|
4796
|
+
startIcon: /* @__PURE__ */ jsx(Check, {}),
|
|
4797
|
+
onClick: () => {
|
|
4798
|
+
if (isJsonOrBlocks) {
|
|
4799
|
+
if (!richDraft.trim()) {
|
|
4800
|
+
commitTypedValue(null);
|
|
4801
|
+
} else {
|
|
4802
|
+
commitTypedValue(JSON.parse(richDraft));
|
|
4803
|
+
}
|
|
4804
|
+
} else {
|
|
4805
|
+
commitTypedValue(richDraft);
|
|
4806
|
+
}
|
|
4807
|
+
setShowRichModal(false);
|
|
4808
|
+
},
|
|
4809
|
+
children: "Apply Edit"
|
|
4810
|
+
}
|
|
4811
|
+
)
|
|
4812
|
+
] })
|
|
4813
|
+
] })
|
|
4814
|
+
]
|
|
4815
|
+
}
|
|
4816
|
+
)
|
|
4817
|
+
}
|
|
4818
|
+
)
|
|
4819
|
+
] });
|
|
4820
|
+
}
|
|
4821
|
+
if (fieldType === "date" || fieldType === "time" || fieldType === "datetime") {
|
|
4822
|
+
const inputType = fieldType === "datetime" ? "datetime-local" : fieldType;
|
|
4823
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4824
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4825
|
+
/* @__PURE__ */ jsx(
|
|
4826
|
+
"input",
|
|
4827
|
+
{
|
|
4828
|
+
type: inputType,
|
|
4829
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4830
|
+
value: localText,
|
|
4831
|
+
step: fieldType === "time" ? 1 : void 0,
|
|
4832
|
+
onChange: (e) => {
|
|
4833
|
+
const v = e.target.value;
|
|
4834
|
+
setLocalText(v);
|
|
4835
|
+
commitTypedValue(v === "" ? null : v);
|
|
4836
|
+
},
|
|
4837
|
+
style: {
|
|
4838
|
+
padding: "6px 8px",
|
|
4839
|
+
borderRadius: 4,
|
|
4840
|
+
border: "1px solid #dcdce4",
|
|
4841
|
+
fontSize: "0.85rem",
|
|
4842
|
+
minWidth: 165
|
|
4843
|
+
}
|
|
4844
|
+
}
|
|
4845
|
+
),
|
|
4846
|
+
renderResetBtn()
|
|
4847
|
+
] }),
|
|
4848
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem" }, children: validationError })
|
|
4849
|
+
] });
|
|
4850
|
+
}
|
|
4851
|
+
const isNumeric = ["integer", "biginteger", "float", "decimal", "number"].includes(fieldType);
|
|
4852
|
+
const inputStep = fieldType === "integer" || fieldType === "biginteger" ? "1" : isNumeric ? "any" : void 0;
|
|
4853
|
+
return /* @__PURE__ */ jsxs(Box, { style: wrapperStyle, children: [
|
|
4854
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
|
|
4855
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 150 }, children: /* @__PURE__ */ jsx(
|
|
4856
|
+
TextInput,
|
|
4857
|
+
{
|
|
4858
|
+
size: "S",
|
|
4859
|
+
type: isNumeric && fieldType !== "biginteger" ? "number" : "text",
|
|
4860
|
+
step: inputStep,
|
|
4861
|
+
"aria-label": `Edit ${occurrence.displayPath}`,
|
|
4862
|
+
placeholder: occurrence.isMissingIntermediate ? "Click to initialize..." : "(empty)",
|
|
4863
|
+
value: localText,
|
|
4864
|
+
onChange: (e) => {
|
|
4865
|
+
const next = e.target.value;
|
|
4866
|
+
setLocalText(next);
|
|
4867
|
+
commitTypedValue(isNumeric && next === "" ? null : next);
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
) }),
|
|
4871
|
+
renderResetBtn()
|
|
4872
|
+
] }),
|
|
4873
|
+
validationError && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", display: "block", style: { fontSize: "0.7rem", marginTop: 2 }, children: validationError })
|
|
4874
|
+
] });
|
|
4875
|
+
}
|
|
4876
|
+
);
|
|
4877
|
+
const ComponentOccurrencesDrawer = React__default.memo(
|
|
4878
|
+
({
|
|
4879
|
+
colUid,
|
|
4880
|
+
rootKey,
|
|
4881
|
+
entry,
|
|
4882
|
+
selectedAttribute,
|
|
4883
|
+
attrMeta,
|
|
4884
|
+
colAttributes,
|
|
4885
|
+
gridEditMode,
|
|
4886
|
+
isSelected,
|
|
4887
|
+
selectedDzBlocks,
|
|
4888
|
+
occurrences,
|
|
4889
|
+
recordEdits,
|
|
4890
|
+
relationOptions,
|
|
4891
|
+
relationOptionsLoading,
|
|
4892
|
+
relationIsMulti,
|
|
4893
|
+
validationRules,
|
|
4894
|
+
onToggleDzBlock,
|
|
4895
|
+
onCommitEdit,
|
|
4896
|
+
onResetEdit
|
|
4897
|
+
}) => {
|
|
4898
|
+
const cleanRootKey = rootKey || (selectedAttribute || "").split("[")[0].split(".")[0];
|
|
4899
|
+
const selectedRootKey = selectedAttribute ? selectedAttribute.split("[")[0].split(".")[0] : "";
|
|
4900
|
+
const targetsThisRoot = Boolean(selectedAttribute && selectedRootKey === cleanRootKey);
|
|
4901
|
+
const blocks = Array.isArray(entry?.[cleanRootKey]) ? entry[cleanRootKey] : [];
|
|
4902
|
+
const isDynamicZone = blocks.some((b) => Boolean(b?.__component));
|
|
4903
|
+
if (blocks.length === 0) return null;
|
|
4904
|
+
const occByRootIndex = /* @__PURE__ */ new Map();
|
|
4905
|
+
occurrences.forEach((occ) => {
|
|
4906
|
+
if (occ.segments?.[0]?.key !== cleanRootKey || occ.segments?.[0]?.index === void 0) return;
|
|
4907
|
+
const rootIdx = occ.segments[0].index;
|
|
4908
|
+
const list = occByRootIndex.get(rootIdx) || [];
|
|
4909
|
+
list.push(occ);
|
|
4910
|
+
occByRootIndex.set(rootIdx, list);
|
|
4911
|
+
});
|
|
4912
|
+
const allApplicableIndexes = blocks.map((_, bIdx) => bIdx).filter((bIdx) => targetsThisRoot ? (occByRootIndex.get(bIdx) || []).length > 0 : true);
|
|
4913
|
+
return /* @__PURE__ */ jsxs(
|
|
4914
|
+
Box,
|
|
4915
|
+
{
|
|
4916
|
+
padding: 3,
|
|
4917
|
+
background: "neutral0",
|
|
4918
|
+
hasRadius: true,
|
|
4919
|
+
style: { border: "1px solid rgba(73, 69, 255, 0.25)", boxShadow: "0 2px 8px rgba(0,0,0,0.05)" },
|
|
4920
|
+
children: [
|
|
4921
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 2, children: [
|
|
4922
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
4923
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "sigma", textColor: "primary700", children: [
|
|
4924
|
+
isDynamicZone ? "DYNAMIC ZONE" : "REPEATABLE COMPONENT",
|
|
4925
|
+
': "',
|
|
4926
|
+
cleanRootKey,
|
|
4927
|
+
'" (',
|
|
4928
|
+
blocks.length,
|
|
4929
|
+
" ",
|
|
4930
|
+
blocks.length === 1 ? "item" : "items",
|
|
4931
|
+
")"
|
|
4932
|
+
] }),
|
|
4933
|
+
/* @__PURE__ */ jsx(Badge, { backgroundColor: "primary100", textColor: "primary700", children: gridEditMode ? "Inline Per-Block Grid Editing" : "Selective Block Targeting" })
|
|
4934
|
+
] }),
|
|
4935
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: gridEditMode ? "Edit each occurrence independently — component IDs & sibling blocks stay intact" : "Selectively choose which blocks to update for this entry" })
|
|
4936
|
+
] }),
|
|
4937
|
+
/* @__PURE__ */ jsxs(Table, { colCount: gridEditMode ? 4 : 5, rowCount: blocks.length + 1, style: { width: "100%", background: "#fff" }, children: [
|
|
4938
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
4939
|
+
!gridEditMode && /* @__PURE__ */ jsx(Th, { style: { width: 64 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Update?" }) }),
|
|
4940
|
+
/* @__PURE__ */ jsx(Th, { style: { width: 85 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Pos / ID" }) }),
|
|
4941
|
+
/* @__PURE__ */ jsx(Th, { style: { width: 210 }, children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Component" }) }),
|
|
4942
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsxs(Typography, { variant: "sigma", children: [
|
|
4943
|
+
"Target Field Value (",
|
|
4944
|
+
selectedAttribute || "selected",
|
|
4945
|
+
")"
|
|
4946
|
+
] }) }),
|
|
4947
|
+
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Block Summary" }) })
|
|
4948
|
+
] }) }),
|
|
4949
|
+
/* @__PURE__ */ jsx(Tbody, { children: blocks.map((block, bIdx) => {
|
|
4950
|
+
const compUid = block?.__component || attrMeta?.component;
|
|
4951
|
+
const compLabel = formatComponentNameFriendly(compUid);
|
|
4952
|
+
const blockOccs = occByRootIndex.get(bIdx) || [];
|
|
4953
|
+
const hasTargetAttr = blockOccs.length > 0;
|
|
4954
|
+
const isBlockSelectable = targetsThisRoot ? hasTargetAttr : true;
|
|
4955
|
+
const isBlockChecked = !gridEditMode && isBlockSelectable && isSelected && (selectedDzBlocks !== void 0 ? selectedDzBlocks.includes(bIdx) : true);
|
|
4956
|
+
const hasDirtyOcc = blockOccs.some((o) => Boolean(recordEdits?.occurrences?.[o.occurrenceKey]));
|
|
4957
|
+
const blockSummaryText = block?.title || block?.name || block?.heading || block?.body || Object.keys(block || {}).filter((k) => !k.startsWith("_") && k !== "id").slice(0, 3).map((k) => {
|
|
4958
|
+
const v = block[k];
|
|
4959
|
+
if (v === null || v === void 0) return null;
|
|
4960
|
+
return `${k}: ${typeof v === "object" ? JSON.stringify(v).slice(0, 24) : String(v).slice(0, 24)}`;
|
|
4961
|
+
}).filter(Boolean).join(", ") || "-";
|
|
4962
|
+
return /* @__PURE__ */ jsxs(
|
|
4963
|
+
Tr,
|
|
4964
|
+
{
|
|
4965
|
+
style: {
|
|
4966
|
+
backgroundColor: hasDirtyOcc || isBlockChecked ? "rgba(73, 69, 255, 0.07)" : void 0
|
|
4967
|
+
},
|
|
4968
|
+
children: [
|
|
4969
|
+
!gridEditMode && /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
4970
|
+
Checkbox,
|
|
4971
|
+
{
|
|
4972
|
+
checked: isBlockChecked,
|
|
4973
|
+
disabled: !isBlockSelectable,
|
|
4974
|
+
onCheckedChange: () => {
|
|
4975
|
+
onToggleDzBlock(colUid, entry.documentId, bIdx, allApplicableIndexes);
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
) }),
|
|
4979
|
+
/* @__PURE__ */ jsxs(Td, { children: [
|
|
4980
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", display: "block", children: [
|
|
4981
|
+
"#",
|
|
4982
|
+
bIdx
|
|
4983
|
+
] }),
|
|
4984
|
+
block?.id !== void 0 && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
|
|
4985
|
+
"id:",
|
|
4986
|
+
block.id
|
|
4987
|
+
] })
|
|
4988
|
+
] }),
|
|
4989
|
+
/* @__PURE__ */ jsxs(Td, { children: [
|
|
4990
|
+
/* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: compLabel }),
|
|
4991
|
+
compUid && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", display: "block", style: { fontSize: "0.68rem", marginTop: 2 }, children: compUid })
|
|
4992
|
+
] }),
|
|
4993
|
+
/* @__PURE__ */ jsx(Td, { children: !targetsThisRoot ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: selectedAttribute ? `(targets "${selectedAttribute}")` : "(select attribute to inspect)" }) : !hasTargetAttr ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral100", textColor: "neutral500", children: "Does not contain attribute" }) : gridEditMode ? /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: blockOccs.map((occ) => {
|
|
4994
|
+
const editObj = recordEdits?.occurrences?.[occ.occurrenceKey];
|
|
4995
|
+
return /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
|
|
4996
|
+
blockOccs.length > 1 && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", display: "block", style: { fontSize: "0.7rem", marginBottom: 2 }, children: occ.displayPath }),
|
|
4997
|
+
/* @__PURE__ */ jsx(
|
|
4998
|
+
GridCellEditor,
|
|
4999
|
+
{
|
|
5000
|
+
entry,
|
|
5001
|
+
attribute: selectedAttribute,
|
|
5002
|
+
occurrence: occ,
|
|
5003
|
+
attrMeta,
|
|
5004
|
+
editedValue: editObj?.value,
|
|
5005
|
+
isDirty: Boolean(editObj),
|
|
5006
|
+
validationError: editObj?.validationError,
|
|
5007
|
+
relationOptions,
|
|
5008
|
+
relationOptionsLoading,
|
|
5009
|
+
relationIsMulti,
|
|
5010
|
+
validationRules,
|
|
5011
|
+
recordEdits,
|
|
5012
|
+
colAttributes,
|
|
5013
|
+
onCommit: (o, val, err) => onCommitEdit(entry, colUid, o, val, err),
|
|
5014
|
+
onReset: (k) => onResetEdit(colUid, entry.documentId, k)
|
|
5015
|
+
}
|
|
5016
|
+
)
|
|
5017
|
+
] }, occ.occurrenceKey);
|
|
5018
|
+
}) }) : /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: blockOccs.map((occ) => /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "primary700", children: occ.value !== null && occ.value !== void 0 && occ.value !== "" ? typeof occ.value === "object" ? JSON.stringify(occ.value) : String(occ.value) : "(empty / not set)" }, occ.occurrenceKey)) }) }),
|
|
5019
|
+
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
5020
|
+
Typography,
|
|
5021
|
+
{
|
|
5022
|
+
variant: "pi",
|
|
5023
|
+
textColor: "neutral600",
|
|
5024
|
+
style: { maxWidth: 280, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
5025
|
+
children: blockSummaryText
|
|
5026
|
+
}
|
|
5027
|
+
) })
|
|
5028
|
+
]
|
|
5029
|
+
},
|
|
5030
|
+
block?.id ? `id_${block.id}_idx_${bIdx}` : `idx_${bIdx}`
|
|
5031
|
+
);
|
|
5032
|
+
}) })
|
|
5033
|
+
] })
|
|
5034
|
+
]
|
|
5035
|
+
}
|
|
5036
|
+
);
|
|
5037
|
+
}
|
|
5038
|
+
);
|
|
5039
|
+
function parseDynamicZonePath(path) {
|
|
5040
|
+
if (!path) return { cleanPath: "", rootKey: "", subPath: "" };
|
|
5041
|
+
const bracketMatch = path.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
|
|
5042
|
+
if (bracketMatch) {
|
|
5043
|
+
const rootKey = bracketMatch[1];
|
|
5044
|
+
const selector = bracketMatch[2];
|
|
5045
|
+
const subPath = bracketMatch[3];
|
|
5046
|
+
const cleanPath = `${rootKey}.${subPath}`;
|
|
5047
|
+
if (/^\d+$/.test(selector)) {
|
|
5048
|
+
return { cleanPath, rootKey, subPath, targetIndex: parseInt(selector, 10) };
|
|
5049
|
+
}
|
|
5050
|
+
return { cleanPath, rootKey, subPath, targetComponentUid: selector };
|
|
5051
|
+
}
|
|
5052
|
+
const parts = path.split(".");
|
|
5053
|
+
return {
|
|
5054
|
+
cleanPath: path,
|
|
5055
|
+
rootKey: parts[0] || "",
|
|
5056
|
+
subPath: parts.slice(1).join(".")
|
|
5057
|
+
};
|
|
5058
|
+
}
|
|
5059
|
+
function formatComponentName(compUid) {
|
|
5060
|
+
if (!compUid) return "Component";
|
|
5061
|
+
const name = compUid.includes(".") ? compUid.split(".")[1] : compUid;
|
|
5062
|
+
return name.split(/[-_]/).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
5063
|
+
}
|
|
5064
|
+
function getAllNestedValues(obj, path, availableAttributes) {
|
|
5065
|
+
if (!obj || !path) return [];
|
|
5066
|
+
const parsed = parseDynamicZonePath(path);
|
|
5067
|
+
const parts = parsed.cleanPath.split(".");
|
|
5068
|
+
const [head, ...tail] = parts;
|
|
5069
|
+
const rootTarget = getPropertyValue(obj, head);
|
|
5070
|
+
if (Array.isArray(rootTarget)) {
|
|
5071
|
+
const results = [];
|
|
5072
|
+
rootTarget.forEach((item, idx) => {
|
|
5073
|
+
if (!item || typeof item !== "object") return;
|
|
5074
|
+
if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) return;
|
|
5075
|
+
if (parsed.targetComponentUid && item.__component !== parsed.targetComponentUid) return;
|
|
5076
|
+
const subPath = tail.join(".");
|
|
5077
|
+
const scopedPath = item.__component ? `${head}[${item.__component}].${subPath}` : "";
|
|
5078
|
+
const isSupported = availableAttributes ? availableAttributes.includes(scopedPath) : false;
|
|
5079
|
+
const subVal = tail.length > 0 ? getNestedValue(item, subPath) : item;
|
|
5080
|
+
if (subVal !== void 0 || isSupported) {
|
|
5081
|
+
results.push({
|
|
5082
|
+
index: idx,
|
|
5083
|
+
componentUid: item.__component,
|
|
5084
|
+
componentName: formatComponentName(item.__component),
|
|
5085
|
+
value: subVal !== void 0 ? subVal : null,
|
|
5086
|
+
path: `${head}[#${idx}${item.__component ? ` ${formatComponentName(item.__component)}` : ""}].${subPath}`
|
|
5087
|
+
});
|
|
5088
|
+
}
|
|
5089
|
+
});
|
|
5090
|
+
return results;
|
|
5091
|
+
}
|
|
5092
|
+
const singleVal = getNestedValue(obj, parsed.cleanPath);
|
|
5093
|
+
if (singleVal !== void 0) {
|
|
5094
|
+
return [
|
|
5095
|
+
{
|
|
5096
|
+
index: 0,
|
|
5097
|
+
value: singleVal,
|
|
5098
|
+
path: parsed.cleanPath
|
|
5099
|
+
}
|
|
5100
|
+
];
|
|
5101
|
+
}
|
|
5102
|
+
return [];
|
|
5103
|
+
}
|
|
5104
|
+
function getPropertyValue(target, key) {
|
|
5105
|
+
if (!target || typeof target !== "object" || !key) return void 0;
|
|
5106
|
+
if (target[key] !== void 0 && target[key] !== null) return target[key];
|
|
5107
|
+
const camelKey = key.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase());
|
|
5108
|
+
if (target[camelKey] !== void 0 && target[camelKey] !== null) return target[camelKey];
|
|
5109
|
+
const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
5110
|
+
if (target[snakeKey] !== void 0 && target[snakeKey] !== null) return target[snakeKey];
|
|
5111
|
+
const lowerKey = key.toLowerCase();
|
|
5112
|
+
const lowerNoUnderscore = lowerKey.replace(/_/g, "");
|
|
5113
|
+
const matchedKey = Object.keys(target).find((k) => {
|
|
5114
|
+
const kLower = k.toLowerCase();
|
|
5115
|
+
return kLower === lowerKey || kLower.replace(/_/g, "") === lowerNoUnderscore;
|
|
5116
|
+
});
|
|
5117
|
+
if (matchedKey && target[matchedKey] !== void 0 && target[matchedKey] !== null) {
|
|
5118
|
+
return target[matchedKey];
|
|
5119
|
+
}
|
|
5120
|
+
if (key in target) return target[key];
|
|
5121
|
+
if (camelKey in target) return target[camelKey];
|
|
5122
|
+
if (snakeKey in target) return target[snakeKey];
|
|
5123
|
+
return void 0;
|
|
5124
|
+
}
|
|
5125
|
+
function getNestedValue(obj, path) {
|
|
5126
|
+
if (!obj || !path) return void 0;
|
|
5127
|
+
const parsed = parseDynamicZonePath(path);
|
|
5128
|
+
const parts = parsed.cleanPath.split(".");
|
|
5129
|
+
function extract(current, remainingParts) {
|
|
5130
|
+
if (current === void 0 || current === null) return void 0;
|
|
5131
|
+
if (remainingParts.length === 0) return current;
|
|
5132
|
+
const [head, ...tail] = remainingParts;
|
|
5133
|
+
if (Array.isArray(current)) {
|
|
5134
|
+
if (/^\d+$/.test(head)) {
|
|
5135
|
+
return extract(current[parseInt(head, 10)], tail);
|
|
5136
|
+
}
|
|
5137
|
+
for (let idx = 0; idx < current.length; idx++) {
|
|
5138
|
+
const item = current[idx];
|
|
5139
|
+
if (parsed.targetIndex !== void 0 && idx !== parsed.targetIndex) continue;
|
|
5140
|
+
if (parsed.targetComponentUid && item?.__component !== parsed.targetComponentUid) continue;
|
|
5141
|
+
const found = extract(getPropertyValue(item, head), tail);
|
|
5142
|
+
if (found !== void 0 && found !== null) return found;
|
|
5143
|
+
}
|
|
5144
|
+
return void 0;
|
|
5145
|
+
}
|
|
5146
|
+
return extract(getPropertyValue(current, head), tail);
|
|
5147
|
+
}
|
|
5148
|
+
return extract(obj, parts);
|
|
5149
|
+
}
|
|
5150
|
+
function getAvailableColumnsForCollection(col, selectedAttribute, searchAttribute) {
|
|
5151
|
+
const cols = [
|
|
5152
|
+
{
|
|
5153
|
+
key: "select",
|
|
5154
|
+
label: "Select",
|
|
5155
|
+
isPermanent: true,
|
|
5156
|
+
defaultVisible: true
|
|
5157
|
+
},
|
|
5158
|
+
{
|
|
5159
|
+
key: "identifier",
|
|
5160
|
+
label: "Identifier",
|
|
5161
|
+
sortable: !col.isSingleType,
|
|
5162
|
+
defaultVisible: true
|
|
5163
|
+
}
|
|
5164
|
+
];
|
|
5165
|
+
const candidateAttrs = col.attributes || [];
|
|
5166
|
+
candidateAttrs.forEach((attr) => {
|
|
5167
|
+
if (attr === "name" || attr === "title" || attr === selectedAttribute || searchAttribute && attr === searchAttribute) {
|
|
5168
|
+
return;
|
|
5169
|
+
}
|
|
5170
|
+
let formattedLabel = attr;
|
|
5171
|
+
if (attr === "updated_at" || attr === "updatedAt") {
|
|
5172
|
+
formattedLabel = "Updated At";
|
|
5173
|
+
} else if (attr === "created_at" || attr === "createdAt") {
|
|
5174
|
+
formattedLabel = "Created At";
|
|
5175
|
+
} else if (attr === "published_at" || attr === "publishedAt") {
|
|
5176
|
+
formattedLabel = "Published At";
|
|
3726
5177
|
} else {
|
|
3727
5178
|
const bracketMatch = attr.match(/^([^.[]+)\[([^\]]+)\]\.(.+)$/);
|
|
3728
5179
|
if (bracketMatch) {
|
|
@@ -3997,7 +5448,7 @@ function formatDisplayValue(val) {
|
|
|
3997
5448
|
}
|
|
3998
5449
|
return String(val);
|
|
3999
5450
|
}
|
|
4000
|
-
function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribute, isMatch, hasAttr, isSelected, onToggleSelect, pendingBatches = [], isDzExpanded = false, onToggleExpandDz, filterQuery = "") {
|
|
5451
|
+
function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribute, isMatch, hasAttr, isSelected, onToggleSelect, pendingBatches = [], isDzExpanded = false, onToggleExpandDz, filterQuery = "", gridCtx) {
|
|
4001
5452
|
switch (colDef.key) {
|
|
4002
5453
|
case "select":
|
|
4003
5454
|
return /* @__PURE__ */ jsx(
|
|
@@ -4012,7 +5463,10 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
|
|
|
4012
5463
|
const dzField = Object.keys(entry).find(
|
|
4013
5464
|
(k) => Array.isArray(entry[k]) && entry[k].length > 0 && entry[k].some((item) => item && item.__component)
|
|
4014
5465
|
);
|
|
4015
|
-
const
|
|
5466
|
+
const selectedRootKey = selectedAttribute ? selectedAttribute.split("[")[0].split(".")[0] : "";
|
|
5467
|
+
const repeatableRoot = !dzField && gridCtx?.gridEditMode && selectedRootKey && gridCtx?.selectedAttrMeta?.rootRepeatable && Array.isArray(entry[selectedRootKey]) && entry[selectedRootKey].length > 0 ? selectedRootKey : void 0;
|
|
5468
|
+
const expandField = dzField || repeatableRoot;
|
|
5469
|
+
const dzItemsCount = expandField ? entry[expandField].length : 0;
|
|
4016
5470
|
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
4017
5471
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: mainText }),
|
|
4018
5472
|
entry.email && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", display: "block", children: entry.email }),
|
|
@@ -4030,7 +5484,7 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
|
|
|
4030
5484
|
backgroundColor: isDzExpanded ? "rgba(73, 69, 255, 0.08)" : "rgba(0, 0, 0, 0.04)",
|
|
4031
5485
|
borderRadius: 4
|
|
4032
5486
|
},
|
|
4033
|
-
children: isDzExpanded ? `▲ Hide ${
|
|
5487
|
+
children: isDzExpanded ? `▲ Hide ${expandField} (${dzItemsCount} ${dzField ? "blocks" : "items"})` : `▼ ${gridCtx?.gridEditMode ? "Edit" : "View"} ${expandField} (${dzItemsCount} ${dzField ? "blocks" : "items"})`
|
|
4034
5488
|
}
|
|
4035
5489
|
) })
|
|
4036
5490
|
] });
|
|
@@ -4104,6 +5558,88 @@ function renderCellContent(colDef, entry, col, selectedAttribute, searchAttribut
|
|
|
4104
5558
|
}) });
|
|
4105
5559
|
}
|
|
4106
5560
|
case "target_attr": {
|
|
5561
|
+
if (gridCtx?.gridEditMode) {
|
|
5562
|
+
if (selectedAttribute && !hasAttr) {
|
|
5563
|
+
return /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral200", textColor: "neutral600", children: "Ignored (absent in schema)" });
|
|
5564
|
+
}
|
|
5565
|
+
const occs = enumerateClientOccurrences(
|
|
5566
|
+
entry,
|
|
5567
|
+
selectedAttribute,
|
|
5568
|
+
col?.attributes,
|
|
5569
|
+
gridCtx.selectedAttrMeta
|
|
5570
|
+
);
|
|
5571
|
+
if (occs.length === 0) {
|
|
5572
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", style: { fontStyle: "italic" }, children: "(no applicable block / item)" });
|
|
5573
|
+
}
|
|
5574
|
+
if (occs.length === 1 && !occs[0].segments.some((s) => s.index !== void 0)) {
|
|
5575
|
+
const occ = occs[0];
|
|
5576
|
+
const editObj = gridCtx.recordEdits?.occurrences?.[occ.occurrenceKey];
|
|
5577
|
+
return /* @__PURE__ */ jsx(
|
|
5578
|
+
GridCellEditor,
|
|
5579
|
+
{
|
|
5580
|
+
entry,
|
|
5581
|
+
attribute: selectedAttribute,
|
|
5582
|
+
occurrence: occ,
|
|
5583
|
+
attrMeta: gridCtx.selectedAttrMeta,
|
|
5584
|
+
editedValue: editObj?.value,
|
|
5585
|
+
isDirty: Boolean(editObj),
|
|
5586
|
+
validationError: editObj?.validationError,
|
|
5587
|
+
relationOptions: gridCtx.relationOptions,
|
|
5588
|
+
relationOptionsLoading: gridCtx.relationOptionsLoading,
|
|
5589
|
+
relationIsMulti: gridCtx.relationIsMulti,
|
|
5590
|
+
validationRules: gridCtx.validationRules,
|
|
5591
|
+
recordEdits: gridCtx.recordEdits,
|
|
5592
|
+
colAttributes: col?.attributes,
|
|
5593
|
+
onCommit: (o, val, err) => gridCtx.onCommitEdit(entry, col.uid, o, val, err),
|
|
5594
|
+
onReset: (k) => gridCtx.onResetEdit(col.uid, entry.documentId, k)
|
|
5595
|
+
}
|
|
5596
|
+
);
|
|
5597
|
+
}
|
|
5598
|
+
const maxInline = 3;
|
|
5599
|
+
const visibleOccs = occs.slice(0, maxInline);
|
|
5600
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: [
|
|
5601
|
+
visibleOccs.map((occ) => {
|
|
5602
|
+
const editObj = gridCtx.recordEdits?.occurrences?.[occ.occurrenceKey];
|
|
5603
|
+
return /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
|
|
5604
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", marginBottom: 1, children: [
|
|
5605
|
+
/* @__PURE__ */ jsxs(Badge, { size: "S", backgroundColor: editObj ? "primary100" : "neutral200", textColor: editObj ? "primary700" : "neutral800", children: [
|
|
5606
|
+
"#",
|
|
5607
|
+
occ.index,
|
|
5608
|
+
" ",
|
|
5609
|
+
occ.componentName || "Item"
|
|
5610
|
+
] }),
|
|
5611
|
+
occ.componentId !== void 0 && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral500", style: { fontSize: "0.68rem" }, children: [
|
|
5612
|
+
"id:",
|
|
5613
|
+
occ.componentId
|
|
5614
|
+
] }),
|
|
5615
|
+
editObj && /* @__PURE__ */ jsx(Badge, { size: "S", backgroundColor: "secondary100", textColor: "secondary700", children: "Edited" })
|
|
5616
|
+
] }),
|
|
5617
|
+
/* @__PURE__ */ jsx(
|
|
5618
|
+
GridCellEditor,
|
|
5619
|
+
{
|
|
5620
|
+
compact: true,
|
|
5621
|
+
entry,
|
|
5622
|
+
attribute: selectedAttribute,
|
|
5623
|
+
occurrence: occ,
|
|
5624
|
+
attrMeta: gridCtx.selectedAttrMeta,
|
|
5625
|
+
editedValue: editObj?.value,
|
|
5626
|
+
isDirty: Boolean(editObj),
|
|
5627
|
+
validationError: editObj?.validationError,
|
|
5628
|
+
relationOptions: gridCtx.relationOptions,
|
|
5629
|
+
relationOptionsLoading: gridCtx.relationOptionsLoading,
|
|
5630
|
+
relationIsMulti: gridCtx.relationIsMulti,
|
|
5631
|
+
validationRules: gridCtx.validationRules,
|
|
5632
|
+
recordEdits: gridCtx.recordEdits,
|
|
5633
|
+
colAttributes: col?.attributes,
|
|
5634
|
+
onCommit: (o, val, err) => gridCtx.onCommitEdit(entry, col.uid, o, val, err),
|
|
5635
|
+
onReset: (k) => gridCtx.onResetEdit(col.uid, entry.documentId, k)
|
|
5636
|
+
}
|
|
5637
|
+
)
|
|
5638
|
+
] }, occ.occurrenceKey);
|
|
5639
|
+
}),
|
|
5640
|
+
occs.length > maxInline && onToggleExpandDz && /* @__PURE__ */ jsx(Button, { variant: "tertiary", size: "S", onClick: onToggleExpandDz, children: isDzExpanded ? `▲ Collapse drawer` : `▼ Edit all ${occs.length} occurrences in drawer` })
|
|
5641
|
+
] });
|
|
5642
|
+
}
|
|
4107
5643
|
const matches = getAllNestedValues(entry, selectedAttribute, col?.attributes);
|
|
4108
5644
|
if (matches.length === 0) {
|
|
4109
5645
|
return /* @__PURE__ */ jsx(Typography, { textColor: "neutral500", style: { fontStyle: "italic" }, children: "(empty / not set)" });
|
|
@@ -4310,6 +5846,10 @@ const BulkUpdater = () => {
|
|
|
4310
5846
|
const [searchAttribute, setSearchAttribute] = useState("");
|
|
4311
5847
|
const [searchAttributeInput, setSearchAttributeInput] = useState("");
|
|
4312
5848
|
const [attributesMeta, setAttributesMeta] = useState({});
|
|
5849
|
+
const [gridEditMode, setGridEditMode] = useState(false);
|
|
5850
|
+
const [gridEdits, setGridEdits] = useState({});
|
|
5851
|
+
const [gridFilterModifiedOnly, setGridFilterModifiedOnly] = useState(false);
|
|
5852
|
+
const [validationRules, setValidationRules] = useState([]);
|
|
4313
5853
|
const effectiveSearchAttribute = searchAttribute || selectedAttribute;
|
|
4314
5854
|
useEffect(() => {
|
|
4315
5855
|
if (effectiveSearchAttribute && relationsMeta[effectiveSearchAttribute]) {
|
|
@@ -4323,7 +5863,27 @@ const BulkUpdater = () => {
|
|
|
4323
5863
|
const [entrySearch, setEntrySearch] = useState("");
|
|
4324
5864
|
const abortControllersRef = useRef({});
|
|
4325
5865
|
const [statusFilter, setStatusFilter] = useState("all");
|
|
4326
|
-
const
|
|
5866
|
+
const [appliedSearchFilter, setAppliedSearchFilter] = useState(EMPTY_SEARCH_FILTER);
|
|
5867
|
+
const appliedSearchFilterRef = useRef(EMPTY_SEARCH_FILTER);
|
|
5868
|
+
const draftSearchFilter = useMemo(
|
|
5869
|
+
() => ({
|
|
5870
|
+
searchAttribute,
|
|
5871
|
+
filterOperator,
|
|
5872
|
+
filterQuery,
|
|
5873
|
+
entrySearch,
|
|
5874
|
+
statusFilter,
|
|
5875
|
+
useRegex,
|
|
5876
|
+
regexPattern
|
|
5877
|
+
}),
|
|
5878
|
+
[searchAttribute, filterOperator, filterQuery, entrySearch, statusFilter, useRegex, regexPattern]
|
|
5879
|
+
);
|
|
5880
|
+
const hasPendingFilterChanges = useMemo(
|
|
5881
|
+
() => !areSearchFiltersEqual(draftSearchFilter, appliedSearchFilter, {
|
|
5882
|
+
includeWorkspaceExtras: true
|
|
5883
|
+
}),
|
|
5884
|
+
[draftSearchFilter, appliedSearchFilter]
|
|
5885
|
+
);
|
|
5886
|
+
const isFilterActive = isSearchFilterActive(appliedSearchFilter, selectedAttribute);
|
|
4327
5887
|
const [lastResults, setLastResults] = useState(null);
|
|
4328
5888
|
const [updateSummary, setUpdateSummary] = useState(null);
|
|
4329
5889
|
const [collectionPages, setCollectionPages] = useState({});
|
|
@@ -4490,10 +6050,11 @@ const BulkUpdater = () => {
|
|
|
4490
6050
|
const currentSort = collectionSorts[colUid] || { field: "createdAt", order: "desc" };
|
|
4491
6051
|
const sortField = customSortField !== void 0 ? customSortField : currentSort.field;
|
|
4492
6052
|
const sortOrder = customSortOrder !== void 0 ? customSortOrder : currentSort.order;
|
|
4493
|
-
const
|
|
4494
|
-
const
|
|
4495
|
-
const
|
|
4496
|
-
const
|
|
6053
|
+
const appliedSnapshot = appliedSearchFilterRef.current;
|
|
6054
|
+
const op = overrideFilterOp !== void 0 ? overrideFilterOp : appliedSnapshot.filterOperator;
|
|
6055
|
+
const q = overrideFilterQuery !== void 0 ? overrideFilterQuery : appliedSnapshot.filterQuery;
|
|
6056
|
+
const s = overrideEntrySearch !== void 0 ? overrideEntrySearch : appliedSnapshot.entrySearch;
|
|
6057
|
+
const searchAttr = overrideSearchAttr !== void 0 ? overrideSearchAttr : appliedSnapshot.searchAttribute;
|
|
4497
6058
|
setCollectionPages((prev) => ({
|
|
4498
6059
|
...prev,
|
|
4499
6060
|
[colUid]: {
|
|
@@ -4501,34 +6062,30 @@ const BulkUpdater = () => {
|
|
|
4501
6062
|
loading: true
|
|
4502
6063
|
}
|
|
4503
6064
|
}));
|
|
6065
|
+
let controller = null;
|
|
4504
6066
|
try {
|
|
4505
|
-
const params =
|
|
4506
|
-
page:
|
|
4507
|
-
pageSize:
|
|
6067
|
+
const params = buildEntriesQueryParams({
|
|
6068
|
+
page: targetPage,
|
|
6069
|
+
pageSize: size,
|
|
6070
|
+
filter: {
|
|
6071
|
+
searchAttribute: searchAttr,
|
|
6072
|
+
filterOperator: op,
|
|
6073
|
+
filterQuery: q,
|
|
6074
|
+
entrySearch: s
|
|
6075
|
+
},
|
|
6076
|
+
selectedAttribute,
|
|
6077
|
+
sortField,
|
|
6078
|
+
sortOrder
|
|
4508
6079
|
});
|
|
4509
|
-
if (selectedAttribute) params.set("attribute", selectedAttribute);
|
|
4510
|
-
if (searchAttr && searchAttr !== selectedAttribute) {
|
|
4511
|
-
params.set("searchAttribute", searchAttr);
|
|
4512
|
-
}
|
|
4513
|
-
if (op && op !== "none") {
|
|
4514
|
-
params.set("filterOperator", op);
|
|
4515
|
-
if (q) params.set("filterQuery", q);
|
|
4516
|
-
}
|
|
4517
|
-
if (s && s.trim()) {
|
|
4518
|
-
params.set("search", s.trim());
|
|
4519
|
-
}
|
|
4520
|
-
if (sortField) {
|
|
4521
|
-
params.set("sortField", sortField);
|
|
4522
|
-
params.set("sortOrder", sortOrder);
|
|
4523
|
-
}
|
|
4524
6080
|
if (abortControllersRef.current[colUid]) {
|
|
4525
6081
|
abortControllersRef.current[colUid].abort();
|
|
4526
6082
|
}
|
|
4527
|
-
|
|
6083
|
+
controller = new AbortController();
|
|
4528
6084
|
abortControllersRef.current[colUid] = controller;
|
|
4529
6085
|
const res = await get(`/bulk-updater/collections/${colUid}/entries?${params.toString()}`, {
|
|
4530
6086
|
signal: controller.signal
|
|
4531
6087
|
});
|
|
6088
|
+
if (abortControllersRef.current[colUid] !== controller) return;
|
|
4532
6089
|
if (res.data && (res.data.success || res.data.entries !== void 0)) {
|
|
4533
6090
|
const fetchedEntries = res.data.entries || [];
|
|
4534
6091
|
const pageNum = res.data.pagination?.page ?? targetPage ?? 1;
|
|
@@ -4576,13 +6133,15 @@ const BulkUpdater = () => {
|
|
|
4576
6133
|
message: `Failed to load entries for ${colUid}: ${err?.message || "Network error"}`
|
|
4577
6134
|
});
|
|
4578
6135
|
}
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
6136
|
+
if (abortControllersRef.current[colUid] === controller) {
|
|
6137
|
+
setCollectionPages((prev) => ({
|
|
6138
|
+
...prev,
|
|
6139
|
+
[colUid]: {
|
|
6140
|
+
...prev[colUid] || {},
|
|
6141
|
+
loading: false
|
|
6142
|
+
}
|
|
6143
|
+
}));
|
|
6144
|
+
}
|
|
4586
6145
|
}
|
|
4587
6146
|
};
|
|
4588
6147
|
const fetchAuditHistory = async () => {
|
|
@@ -4624,56 +6183,197 @@ const BulkUpdater = () => {
|
|
|
4624
6183
|
setPendingBatchesLoading(false);
|
|
4625
6184
|
}
|
|
4626
6185
|
};
|
|
6186
|
+
const fetchValidationRules = async () => {
|
|
6187
|
+
try {
|
|
6188
|
+
const res = await get("/bulk-updater/validation-rules");
|
|
6189
|
+
if (res.data?.success && Array.isArray(res.data.rules)) {
|
|
6190
|
+
setValidationRules(res.data.rules);
|
|
6191
|
+
}
|
|
6192
|
+
} catch {
|
|
6193
|
+
}
|
|
6194
|
+
};
|
|
4627
6195
|
useEffect(() => {
|
|
4628
6196
|
fetchModels();
|
|
4629
6197
|
fetchAuditHistory();
|
|
4630
6198
|
fetchPendingBatches();
|
|
6199
|
+
fetchValidationRules();
|
|
4631
6200
|
}, []);
|
|
4632
6201
|
useEffect(() => {
|
|
4633
6202
|
if (activeTab === "audit") {
|
|
4634
6203
|
fetchAuditHistory();
|
|
4635
6204
|
fetchPendingBatches();
|
|
4636
|
-
}
|
|
4637
|
-
}, [activeTab]);
|
|
4638
|
-
const
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
6205
|
+
}
|
|
6206
|
+
}, [activeTab]);
|
|
6207
|
+
const handleApplySearch = () => {
|
|
6208
|
+
const nextApplied = {
|
|
6209
|
+
searchAttribute,
|
|
6210
|
+
filterOperator,
|
|
6211
|
+
filterQuery,
|
|
6212
|
+
entrySearch,
|
|
6213
|
+
statusFilter,
|
|
6214
|
+
useRegex,
|
|
6215
|
+
regexPattern
|
|
6216
|
+
};
|
|
6217
|
+
appliedSearchFilterRef.current = nextApplied;
|
|
6218
|
+
setAppliedSearchFilter(nextApplied);
|
|
6219
|
+
if (!selectedCollectionUid) return;
|
|
6220
|
+
const isFilterActiveNow = isSearchFilterActive(nextApplied, selectedAttribute);
|
|
6221
|
+
if (isFilterActiveNow) {
|
|
6222
|
+
if (gridEditMode) {
|
|
6223
|
+
setSelectedEntries((prev) => {
|
|
6224
|
+
const retained = {};
|
|
6225
|
+
Object.keys(gridEdits).forEach((k) => {
|
|
6226
|
+
if (prev[k]) retained[k] = true;
|
|
6227
|
+
});
|
|
6228
|
+
return retained;
|
|
6229
|
+
});
|
|
6230
|
+
} else {
|
|
6231
|
+
setSelectedEntries({});
|
|
4662
6232
|
}
|
|
4663
|
-
}
|
|
4664
|
-
|
|
4665
|
-
|
|
6233
|
+
}
|
|
6234
|
+
loadCollectionPage(
|
|
6235
|
+
selectedCollectionUid,
|
|
6236
|
+
1,
|
|
6237
|
+
void 0,
|
|
6238
|
+
void 0,
|
|
6239
|
+
void 0,
|
|
6240
|
+
nextApplied.filterOperator,
|
|
6241
|
+
nextApplied.filterQuery,
|
|
6242
|
+
nextApplied.entrySearch,
|
|
6243
|
+
true,
|
|
6244
|
+
nextApplied.searchAttribute
|
|
6245
|
+
);
|
|
6246
|
+
};
|
|
4666
6247
|
const KEY_SEP = "@@@";
|
|
4667
6248
|
const selectedCol = useMemo(() => {
|
|
4668
6249
|
if (!collections.length || !selectedCollectionUid) return null;
|
|
4669
6250
|
return collections.find((c) => c.uid === selectedCollectionUid) || null;
|
|
4670
6251
|
}, [collections, selectedCollectionUid]);
|
|
6252
|
+
const activeAttrMeta = useMemo(() => {
|
|
6253
|
+
if (!selectedAttribute) return void 0;
|
|
6254
|
+
const base = selectedCol?.attributesMeta?.[selectedAttribute] || attributesMeta[selectedAttribute];
|
|
6255
|
+
const relMeta = selectedCol?.relations?.[selectedAttribute] || relationsMeta[selectedAttribute];
|
|
6256
|
+
if (!base && !relMeta) return void 0;
|
|
6257
|
+
if (relMeta && (!base || !base.isRelation)) {
|
|
6258
|
+
return {
|
|
6259
|
+
...base || { depth: 0, type: "relation" },
|
|
6260
|
+
isRelation: true,
|
|
6261
|
+
relationType: relMeta.relationType,
|
|
6262
|
+
target: relMeta.targetUid
|
|
6263
|
+
};
|
|
6264
|
+
}
|
|
6265
|
+
return base;
|
|
6266
|
+
}, [selectedAttribute, selectedCol, attributesMeta, relationsMeta]);
|
|
6267
|
+
const totalDirtyRecordsCount = useMemo(() => Object.keys(gridEdits).length, [gridEdits]);
|
|
6268
|
+
const totalDirtyCellsCount = useMemo(
|
|
6269
|
+
() => Object.values(gridEdits).reduce(
|
|
6270
|
+
(sum, rec) => sum + Object.keys(rec.occurrences || {}).length,
|
|
6271
|
+
0
|
|
6272
|
+
),
|
|
6273
|
+
[gridEdits]
|
|
6274
|
+
);
|
|
6275
|
+
const gridSerialized = useMemo(
|
|
6276
|
+
() => serializeGridTargets(gridEdits, selectedEntries, collectionPages, activeAttrMeta),
|
|
6277
|
+
[gridEdits, selectedEntries, collectionPages, activeAttrMeta]
|
|
6278
|
+
);
|
|
6279
|
+
const handleGridCellCommit = React__default.useCallback(
|
|
6280
|
+
(entry, colUid, occ, newValue, validationError) => {
|
|
6281
|
+
const key = `${colUid}${KEY_SEP}${entry.documentId}`;
|
|
6282
|
+
const recordLabel = entry.name || entry.title || entry.email || `Entry #${entry.id || entry.documentId}`;
|
|
6283
|
+
setGridEdits((prev) => {
|
|
6284
|
+
const existingRec = prev[key] || {
|
|
6285
|
+
uid: colUid,
|
|
6286
|
+
documentId: entry.documentId,
|
|
6287
|
+
locale: entry.locale,
|
|
6288
|
+
status: entry.status,
|
|
6289
|
+
publishedAt: entry.publishedAt,
|
|
6290
|
+
recordLabel,
|
|
6291
|
+
occurrences: {}
|
|
6292
|
+
};
|
|
6293
|
+
return {
|
|
6294
|
+
...prev,
|
|
6295
|
+
[key]: {
|
|
6296
|
+
...existingRec,
|
|
6297
|
+
occurrences: {
|
|
6298
|
+
...existingRec.occurrences,
|
|
6299
|
+
[occ.occurrenceKey]: {
|
|
6300
|
+
occurrenceKey: occ.occurrenceKey,
|
|
6301
|
+
displayPath: occ.displayPath,
|
|
6302
|
+
segments: occ.segments,
|
|
6303
|
+
originalValue: occ.value,
|
|
6304
|
+
value: newValue,
|
|
6305
|
+
fieldType: activeAttrMeta?.type || "string",
|
|
6306
|
+
validationError,
|
|
6307
|
+
touchedAt: Date.now()
|
|
6308
|
+
}
|
|
6309
|
+
}
|
|
6310
|
+
}
|
|
6311
|
+
};
|
|
6312
|
+
});
|
|
6313
|
+
setSelectedEntries((prev) => prev[key] ? prev : { ...prev, [key]: true });
|
|
6314
|
+
},
|
|
6315
|
+
[activeAttrMeta?.type]
|
|
6316
|
+
);
|
|
6317
|
+
const handleGridCellReset = React__default.useCallback((colUid, documentId, occKey) => {
|
|
6318
|
+
const key = `${colUid}${KEY_SEP}${documentId}`;
|
|
6319
|
+
setGridEdits((prev) => {
|
|
6320
|
+
const existingRec = prev[key];
|
|
6321
|
+
if (!existingRec) return prev;
|
|
6322
|
+
const nextOccs = { ...existingRec.occurrences };
|
|
6323
|
+
delete nextOccs[occKey];
|
|
6324
|
+
if (Object.keys(nextOccs).length === 0) {
|
|
6325
|
+
const next = { ...prev };
|
|
6326
|
+
delete next[key];
|
|
6327
|
+
return next;
|
|
6328
|
+
}
|
|
6329
|
+
return {
|
|
6330
|
+
...prev,
|
|
6331
|
+
[key]: {
|
|
6332
|
+
...existingRec,
|
|
6333
|
+
occurrences: nextOccs
|
|
6334
|
+
}
|
|
6335
|
+
};
|
|
6336
|
+
});
|
|
6337
|
+
}, []);
|
|
6338
|
+
const handleToggleGridEditMode = (checked) => {
|
|
6339
|
+
if (!checked && totalDirtyCellsCount > 0) {
|
|
6340
|
+
if (!window.confirm(`Disable Grid Editing Mode and discard ${totalDirtyCellsCount} unsaved edit(s)?`)) {
|
|
6341
|
+
return;
|
|
6342
|
+
}
|
|
6343
|
+
setGridEdits({});
|
|
6344
|
+
}
|
|
6345
|
+
setGridEditMode(checked);
|
|
6346
|
+
setGridFilterModifiedOnly(false);
|
|
6347
|
+
if (checked) {
|
|
6348
|
+
if (useRegex) setUseRegex(false);
|
|
6349
|
+
setRegexPattern("");
|
|
6350
|
+
if (selectedCollectionUid) {
|
|
6351
|
+
setCollectionColumnVisibility((prev) => {
|
|
6352
|
+
const existing = prev[selectedCollectionUid];
|
|
6353
|
+
if (existing && !existing.includes("target_attr")) {
|
|
6354
|
+
return { ...prev, [selectedCollectionUid]: [...existing, "target_attr"] };
|
|
6355
|
+
}
|
|
6356
|
+
return prev;
|
|
6357
|
+
});
|
|
6358
|
+
}
|
|
6359
|
+
}
|
|
6360
|
+
};
|
|
4671
6361
|
const handleCollectionChange = (newUid) => {
|
|
4672
6362
|
if (newUid === selectedCollectionUid) return;
|
|
6363
|
+
if (totalDirtyCellsCount > 0) {
|
|
6364
|
+
if (!window.confirm(
|
|
6365
|
+
`You have ${totalDirtyCellsCount} unsaved Grid Edit(s) in the current collection. Switching collections will discard them. Continue?`
|
|
6366
|
+
)) {
|
|
6367
|
+
return;
|
|
6368
|
+
}
|
|
6369
|
+
}
|
|
4673
6370
|
if (abortControllersRef.current) {
|
|
4674
|
-
Object.values(abortControllersRef.current).forEach((ctrl) => ctrl
|
|
6371
|
+
Object.values(abortControllersRef.current).forEach((ctrl) => ctrl?.abort());
|
|
4675
6372
|
}
|
|
4676
6373
|
setSelectedCollectionUid(newUid);
|
|
6374
|
+
setGridEdits({});
|
|
6375
|
+
setSelectedDzBlocks({});
|
|
6376
|
+
setExpandedDzEntries({});
|
|
4677
6377
|
try {
|
|
4678
6378
|
if (newUid) {
|
|
4679
6379
|
localStorage.setItem(LAST_COLLECTION_KEY, newUid);
|
|
@@ -4684,6 +6384,12 @@ const BulkUpdater = () => {
|
|
|
4684
6384
|
}
|
|
4685
6385
|
setSelectedEntries({});
|
|
4686
6386
|
setSearchAttribute("");
|
|
6387
|
+
const nextAppliedOnColSwitch = {
|
|
6388
|
+
...appliedSearchFilterRef.current,
|
|
6389
|
+
searchAttribute: ""
|
|
6390
|
+
};
|
|
6391
|
+
appliedSearchFilterRef.current = nextAppliedOnColSwitch;
|
|
6392
|
+
setAppliedSearchFilter(nextAppliedOnColSwitch);
|
|
4687
6393
|
if (!newUid || !newUid.trim()) {
|
|
4688
6394
|
setAttributes([]);
|
|
4689
6395
|
setSelectedAttribute("");
|
|
@@ -4703,10 +6409,29 @@ const BulkUpdater = () => {
|
|
|
4703
6409
|
setSelectedRelationDocId("");
|
|
4704
6410
|
setAttributeValue("");
|
|
4705
6411
|
}
|
|
4706
|
-
loadCollectionPage(
|
|
6412
|
+
loadCollectionPage(
|
|
6413
|
+
newUid,
|
|
6414
|
+
1,
|
|
6415
|
+
void 0,
|
|
6416
|
+
void 0,
|
|
6417
|
+
void 0,
|
|
6418
|
+
nextAppliedOnColSwitch.filterOperator,
|
|
6419
|
+
nextAppliedOnColSwitch.filterQuery,
|
|
6420
|
+
nextAppliedOnColSwitch.entrySearch,
|
|
6421
|
+
true,
|
|
6422
|
+
""
|
|
6423
|
+
);
|
|
4707
6424
|
};
|
|
4708
6425
|
const handleAttributeChange = (newAttr) => {
|
|
4709
6426
|
if (newAttr !== selectedAttribute) {
|
|
6427
|
+
if (totalDirtyCellsCount > 0) {
|
|
6428
|
+
if (!window.confirm(
|
|
6429
|
+
`You have ${totalDirtyCellsCount} unsaved Grid Edit(s) for "${selectedAttribute}". Switching Target Attribute will discard them. Continue?`
|
|
6430
|
+
)) {
|
|
6431
|
+
return;
|
|
6432
|
+
}
|
|
6433
|
+
}
|
|
6434
|
+
setGridEdits({});
|
|
4710
6435
|
setSelectedAttribute(newAttr);
|
|
4711
6436
|
try {
|
|
4712
6437
|
if (newAttr) {
|
|
@@ -4728,13 +6453,13 @@ const BulkUpdater = () => {
|
|
|
4728
6453
|
const filteredCollections = useMemo(() => {
|
|
4729
6454
|
return selectedCol ? [selectedCol] : [];
|
|
4730
6455
|
}, [selectedCol]);
|
|
4731
|
-
const getAttrDepth = (attr) => attributesMeta[attr]?.depth ?? (attr.includes(".") ? attr.split(".").length - 1 : 0);
|
|
6456
|
+
const getAttrDepth = (attr) => selectedCol?.attributesMeta?.[attr]?.depth ?? attributesMeta[attr]?.depth ?? (attr.includes(".") ? attr.split(".").length - 1 : 0);
|
|
4732
6457
|
const availableColAttributes = useMemo(() => {
|
|
4733
6458
|
return selectedCol?.attributes || attributes || [];
|
|
4734
6459
|
}, [selectedCol, attributes]);
|
|
4735
6460
|
const depthFilteredAttributes = useMemo(() => {
|
|
4736
6461
|
return availableColAttributes.filter((attr) => getAttrDepth(attr) <= componentDepth);
|
|
4737
|
-
}, [availableColAttributes, componentDepth, attributesMeta]);
|
|
6462
|
+
}, [availableColAttributes, componentDepth, attributesMeta, selectedCol]);
|
|
4738
6463
|
const memoizedComboboxOptions = useMemo(() => {
|
|
4739
6464
|
if (depthFilteredAttributes.length === 0) {
|
|
4740
6465
|
return /* @__PURE__ */ jsx(ComboboxOption, { value: "__none__", disabled: true, textValue: "No attributes available", children: /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
@@ -4783,20 +6508,6 @@ const BulkUpdater = () => {
|
|
|
4783
6508
|
const handleSearchAttributeChange = (newAttr) => {
|
|
4784
6509
|
const finalAttr = newAttr === "__default__" ? "" : newAttr;
|
|
4785
6510
|
setSearchAttribute(finalAttr);
|
|
4786
|
-
if (selectedCollectionUid) {
|
|
4787
|
-
loadCollectionPage(
|
|
4788
|
-
selectedCollectionUid,
|
|
4789
|
-
1,
|
|
4790
|
-
void 0,
|
|
4791
|
-
void 0,
|
|
4792
|
-
void 0,
|
|
4793
|
-
filterOperator,
|
|
4794
|
-
filterQuery,
|
|
4795
|
-
entrySearch,
|
|
4796
|
-
true,
|
|
4797
|
-
finalAttr
|
|
4798
|
-
);
|
|
4799
|
-
}
|
|
4800
6511
|
};
|
|
4801
6512
|
const handleCollectionPageSizeChange = (colUid, newSize) => {
|
|
4802
6513
|
const capped = Math.min(500, Math.max(1, newSize));
|
|
@@ -4852,9 +6563,13 @@ const BulkUpdater = () => {
|
|
|
4852
6563
|
};
|
|
4853
6564
|
const entryMatchesFilter = (entry, attr) => {
|
|
4854
6565
|
const matches = getAllNestedValues(entry, attr);
|
|
4855
|
-
|
|
6566
|
+
const activeOp = appliedSearchFilter.filterOperator;
|
|
6567
|
+
const activeQuery = appliedSearchFilter.filterQuery || "";
|
|
6568
|
+
const activeUseRegex = Boolean(appliedSearchFilter.useRegex);
|
|
6569
|
+
const activeRegexPattern = appliedSearchFilter.regexPattern || "";
|
|
6570
|
+
if (activeUseRegex && activeRegexPattern.trim()) {
|
|
4856
6571
|
try {
|
|
4857
|
-
const regex = new RegExp(
|
|
6572
|
+
const regex = new RegExp(activeRegexPattern, "i");
|
|
4858
6573
|
const anyRegexMatch = matches.some((m) => regex.test(formatDisplayValue(m.value)));
|
|
4859
6574
|
if (!anyRegexMatch) {
|
|
4860
6575
|
return false;
|
|
@@ -4862,22 +6577,22 @@ const BulkUpdater = () => {
|
|
|
4862
6577
|
} catch {
|
|
4863
6578
|
}
|
|
4864
6579
|
}
|
|
4865
|
-
if (
|
|
6580
|
+
if (activeOp === "none") return true;
|
|
4866
6581
|
if (matches.length === 0) {
|
|
4867
|
-
return
|
|
6582
|
+
return activeOp === "empty";
|
|
4868
6583
|
}
|
|
4869
6584
|
const checkMatch = (val) => {
|
|
4870
6585
|
const displayStr = formatDisplayValue(val);
|
|
4871
6586
|
const isValEmpty = val === void 0 || val === null || Array.isArray(val) && val.length === 0 || displayStr.trim() === "" || displayStr.trim().toLowerCase() === "(not set)" || displayStr.trim().toLowerCase() === "(empty / not set)" || displayStr.trim().toLowerCase() === "(empty / unlinked)";
|
|
4872
|
-
if (
|
|
4873
|
-
if (
|
|
6587
|
+
if (activeOp === "empty") return isValEmpty;
|
|
6588
|
+
if (activeOp === "not_empty") return !isValEmpty;
|
|
4874
6589
|
if (isValEmpty) return false;
|
|
4875
|
-
const q =
|
|
6590
|
+
const q = activeQuery.trim().toLowerCase();
|
|
4876
6591
|
if (!q) return true;
|
|
4877
6592
|
const testString = (str) => {
|
|
4878
6593
|
if (str === void 0 || str === null) return false;
|
|
4879
6594
|
const s = String(str).trim().toLowerCase();
|
|
4880
|
-
switch (
|
|
6595
|
+
switch (activeOp) {
|
|
4881
6596
|
case "equals":
|
|
4882
6597
|
return s === q;
|
|
4883
6598
|
case "contains":
|
|
@@ -4908,18 +6623,22 @@ const BulkUpdater = () => {
|
|
|
4908
6623
|
}
|
|
4909
6624
|
return testString(displayStr);
|
|
4910
6625
|
};
|
|
4911
|
-
if (
|
|
6626
|
+
if (activeOp === "empty") {
|
|
4912
6627
|
return matches.every((m) => checkMatch(m.value));
|
|
4913
6628
|
}
|
|
4914
6629
|
return matches.some((m) => checkMatch(m.value));
|
|
4915
6630
|
};
|
|
4916
6631
|
const getVisibleEntries = (col) => {
|
|
4917
6632
|
const pageState = collectionPages[col.uid];
|
|
4918
|
-
|
|
4919
|
-
if (
|
|
6633
|
+
let raw = pageState ? pageState.entries : col.entries || [];
|
|
6634
|
+
if (gridEditMode && gridFilterModifiedOnly) {
|
|
6635
|
+
raw = raw.filter((entry) => Boolean(gridEdits[`${col.uid}${KEY_SEP}${entry.documentId}`]));
|
|
6636
|
+
}
|
|
6637
|
+
const activeStatus = appliedSearchFilter.statusFilter || "all";
|
|
6638
|
+
if (activeStatus === "all") return raw;
|
|
4920
6639
|
return raw.filter((entry) => {
|
|
4921
6640
|
const lifecycle = getEntryLifecycleStatus(entry, col, pendingBatches);
|
|
4922
|
-
return lifecycle.status ===
|
|
6641
|
+
return lifecycle.status === activeStatus;
|
|
4923
6642
|
});
|
|
4924
6643
|
};
|
|
4925
6644
|
const matchingEntriesCount = React__default.useMemo(() => {
|
|
@@ -4929,7 +6648,7 @@ const BulkUpdater = () => {
|
|
|
4929
6648
|
count += getVisibleEntries(col).length;
|
|
4930
6649
|
});
|
|
4931
6650
|
return count;
|
|
4932
|
-
}, [filteredCollections, collectionPages, isFilterActive,
|
|
6651
|
+
}, [filteredCollections, collectionPages, isFilterActive, appliedSearchFilter, pendingBatches, gridEditMode, gridFilterModifiedOnly, gridEdits]);
|
|
4933
6652
|
const selectAllMatching = () => {
|
|
4934
6653
|
const updated = { ...selectedEntries };
|
|
4935
6654
|
filteredCollections.forEach((col) => {
|
|
@@ -4957,7 +6676,19 @@ const BulkUpdater = () => {
|
|
|
4957
6676
|
setEntrySearch("");
|
|
4958
6677
|
setStatusFilter("all");
|
|
4959
6678
|
setRegexPattern("");
|
|
4960
|
-
|
|
6679
|
+
appliedSearchFilterRef.current = EMPTY_SEARCH_FILTER;
|
|
6680
|
+
setAppliedSearchFilter(EMPTY_SEARCH_FILTER);
|
|
6681
|
+
if (gridEditMode) {
|
|
6682
|
+
setSelectedEntries((prev) => {
|
|
6683
|
+
const retained = {};
|
|
6684
|
+
Object.keys(gridEdits).forEach((k) => {
|
|
6685
|
+
if (prev[k]) retained[k] = true;
|
|
6686
|
+
});
|
|
6687
|
+
return retained;
|
|
6688
|
+
});
|
|
6689
|
+
} else {
|
|
6690
|
+
setSelectedEntries({});
|
|
6691
|
+
}
|
|
4961
6692
|
collections.forEach((col) => {
|
|
4962
6693
|
loadCollectionPage(col.uid, 1, void 0, void 0, void 0, "none", "", "", false, "");
|
|
4963
6694
|
});
|
|
@@ -5002,58 +6733,71 @@ const BulkUpdater = () => {
|
|
|
5002
6733
|
const deselectAll = () => {
|
|
5003
6734
|
setSelectedEntries({});
|
|
5004
6735
|
};
|
|
5005
|
-
const getSelectedBreakdown = () => {
|
|
6736
|
+
const getSelectedBreakdown = (onlyKeys) => {
|
|
5006
6737
|
const breakdown = {};
|
|
5007
|
-
Object.keys(selectedEntries).
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
}
|
|
6738
|
+
const keysToCount = onlyKeys || Object.keys(selectedEntries).filter((k) => selectedEntries[k]);
|
|
6739
|
+
keysToCount.forEach((key) => {
|
|
6740
|
+
const parts = key.split(KEY_SEP);
|
|
6741
|
+
if (parts.length === 2) {
|
|
6742
|
+
const uid = parts[0];
|
|
6743
|
+
const col = collections.find((c) => c.uid === uid);
|
|
6744
|
+
const name = col?.displayName || uid;
|
|
6745
|
+
breakdown[name] = (breakdown[name] || 0) + 1;
|
|
5016
6746
|
}
|
|
5017
6747
|
});
|
|
5018
6748
|
return breakdown;
|
|
5019
6749
|
};
|
|
5020
|
-
const
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
6750
|
+
const computeLifecycleStatsForKeys = React__default.useCallback(
|
|
6751
|
+
(keys) => {
|
|
6752
|
+
let published = 0;
|
|
6753
|
+
let modified = 0;
|
|
6754
|
+
let draft = 0;
|
|
6755
|
+
let pendingReview = 0;
|
|
6756
|
+
let unknown = 0;
|
|
6757
|
+
keys.forEach((key) => {
|
|
6758
|
+
const parts = key.split(KEY_SEP);
|
|
6759
|
+
if (parts.length !== 2) return;
|
|
6760
|
+
const [uid, docId] = parts;
|
|
6761
|
+
const col = collections.find((c) => c.uid === uid) || null;
|
|
6762
|
+
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);
|
|
6763
|
+
if (col && col.draftAndPublish === false) {
|
|
6764
|
+
published++;
|
|
6765
|
+
} else if (entry) {
|
|
6766
|
+
const { status } = getEntryLifecycleStatus(entry, col, pendingBatches);
|
|
6767
|
+
if (status === "published") published++;
|
|
6768
|
+
else if (status === "modified") modified++;
|
|
6769
|
+
else if (status === "draft") draft++;
|
|
6770
|
+
else if (status === "pending_review") pendingReview++;
|
|
6771
|
+
else unknown++;
|
|
6772
|
+
} else {
|
|
6773
|
+
draft++;
|
|
6774
|
+
}
|
|
6775
|
+
});
|
|
6776
|
+
const unreviewedCount = draft + modified + pendingReview + unknown;
|
|
6777
|
+
return {
|
|
6778
|
+
published,
|
|
6779
|
+
modified,
|
|
6780
|
+
draft,
|
|
6781
|
+
pendingReview,
|
|
6782
|
+
unknown,
|
|
6783
|
+
unreviewedCount,
|
|
6784
|
+
total: published + modified + draft + pendingReview + unknown
|
|
6785
|
+
};
|
|
6786
|
+
},
|
|
6787
|
+
[collections, collectionPages, pendingBatches]
|
|
6788
|
+
);
|
|
6789
|
+
const selectedLifecycleStats = useMemo(
|
|
6790
|
+
() => computeLifecycleStatsForKeys(Object.keys(selectedEntries).filter((k) => selectedEntries[k])),
|
|
6791
|
+
[selectedEntries, computeLifecycleStatsForKeys]
|
|
6792
|
+
);
|
|
6793
|
+
const gridTargetKeys = useMemo(
|
|
6794
|
+
() => gridSerialized.targets.map((t) => `${t.uid}${KEY_SEP}${t.documentId}`),
|
|
6795
|
+
[gridSerialized]
|
|
6796
|
+
);
|
|
6797
|
+
const updateModalLifecycleStats = useMemo(
|
|
6798
|
+
() => gridEditMode ? computeLifecycleStatsForKeys(gridTargetKeys) : selectedLifecycleStats,
|
|
6799
|
+
[gridEditMode, gridTargetKeys, computeLifecycleStatsForKeys, selectedLifecycleStats]
|
|
6800
|
+
);
|
|
5057
6801
|
const handleOpenConfirmModal = () => {
|
|
5058
6802
|
if (!selectedAttribute) {
|
|
5059
6803
|
toggleNotification({
|
|
@@ -5062,13 +6806,30 @@ const BulkUpdater = () => {
|
|
|
5062
6806
|
});
|
|
5063
6807
|
return;
|
|
5064
6808
|
}
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
6809
|
+
if (gridEditMode) {
|
|
6810
|
+
if (gridSerialized.targets.length === 0) {
|
|
6811
|
+
toggleNotification({
|
|
6812
|
+
type: "warning",
|
|
6813
|
+
message: "Please edit at least one selected cell or block in the grid before updating"
|
|
6814
|
+
});
|
|
6815
|
+
return;
|
|
6816
|
+
}
|
|
6817
|
+
if (gridSerialized.hasValidationErrors) {
|
|
6818
|
+
toggleNotification({
|
|
6819
|
+
type: "danger",
|
|
6820
|
+
message: "Please resolve inline validation errors highlighted in red before updating"
|
|
6821
|
+
});
|
|
6822
|
+
return;
|
|
6823
|
+
}
|
|
6824
|
+
} else {
|
|
6825
|
+
const totalSelected = Object.values(selectedEntries).filter(Boolean).length;
|
|
6826
|
+
if (totalSelected === 0) {
|
|
6827
|
+
toggleNotification({
|
|
6828
|
+
type: "warning",
|
|
6829
|
+
message: "Please select at least one collection type or entry to update"
|
|
6830
|
+
});
|
|
6831
|
+
return;
|
|
6832
|
+
}
|
|
5072
6833
|
}
|
|
5073
6834
|
setPublishStrategy("safe");
|
|
5074
6835
|
setUnreviewedConsent(false);
|
|
@@ -5082,44 +6843,63 @@ const BulkUpdater = () => {
|
|
|
5082
6843
|
});
|
|
5083
6844
|
return;
|
|
5084
6845
|
}
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
if (
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
6846
|
+
let targets = [];
|
|
6847
|
+
if (gridEditMode) {
|
|
6848
|
+
if (gridSerialized.hasValidationErrors) {
|
|
6849
|
+
toggleNotification({
|
|
6850
|
+
type: "danger",
|
|
6851
|
+
message: "Please fix inline validation errors before previewing changes"
|
|
6852
|
+
});
|
|
6853
|
+
return;
|
|
6854
|
+
}
|
|
6855
|
+
targets = gridSerialized.targets;
|
|
6856
|
+
if (targets.length === 0) {
|
|
6857
|
+
toggleNotification({
|
|
6858
|
+
type: "warning",
|
|
6859
|
+
message: "Please modify and select at least one grid cell or block to preview"
|
|
6860
|
+
});
|
|
6861
|
+
return;
|
|
6862
|
+
}
|
|
6863
|
+
} else {
|
|
6864
|
+
Object.keys(selectedEntries).forEach((key) => {
|
|
6865
|
+
if (selectedEntries[key]) {
|
|
6866
|
+
const parts = key.split(KEY_SEP);
|
|
6867
|
+
if (parts.length === 2) {
|
|
6868
|
+
const colUid = parts[0];
|
|
6869
|
+
const docId = parts[1];
|
|
6870
|
+
const targetObj = { uid: colUid, documentId: docId };
|
|
6871
|
+
if (selectedDzBlocks[key] && selectedDzBlocks[key].length > 0) {
|
|
6872
|
+
targetObj.dynamicZoneIndexes = selectedDzBlocks[key];
|
|
6873
|
+
}
|
|
6874
|
+
const colPage = collectionPages[colUid];
|
|
6875
|
+
const cachedEntry = colPage?.entries?.find((e) => e.documentId === docId);
|
|
6876
|
+
if (cachedEntry) {
|
|
6877
|
+
if (cachedEntry.status) targetObj.status = cachedEntry.status;
|
|
6878
|
+
if (cachedEntry.publishedAt) targetObj.publishedAt = cachedEntry.publishedAt;
|
|
6879
|
+
if (cachedEntry.locale) targetObj.locale = cachedEntry.locale;
|
|
6880
|
+
}
|
|
6881
|
+
targets.push(targetObj);
|
|
5102
6882
|
}
|
|
5103
|
-
targets.push(targetObj);
|
|
5104
6883
|
}
|
|
5105
|
-
}
|
|
5106
|
-
});
|
|
5107
|
-
if (targets.length === 0) {
|
|
5108
|
-
toggleNotification({
|
|
5109
|
-
type: "warning",
|
|
5110
|
-
message: "Please select at least one collection type or entry to preview"
|
|
5111
6884
|
});
|
|
5112
|
-
|
|
6885
|
+
if (targets.length === 0) {
|
|
6886
|
+
toggleNotification({
|
|
6887
|
+
type: "warning",
|
|
6888
|
+
message: "Please select at least one collection type or entry to preview"
|
|
6889
|
+
});
|
|
6890
|
+
return;
|
|
6891
|
+
}
|
|
5113
6892
|
}
|
|
5114
6893
|
setShowPreviewModal(true);
|
|
5115
6894
|
setPreviewLoading(true);
|
|
5116
6895
|
try {
|
|
5117
6896
|
const res = await post("/bulk-updater/preview", {
|
|
5118
6897
|
attribute: selectedAttribute,
|
|
5119
|
-
value: attributeValue,
|
|
6898
|
+
value: gridEditMode ? "" : attributeValue,
|
|
6899
|
+
editMode: gridEditMode ? "grid" : "common",
|
|
5120
6900
|
selectedEntries: targets,
|
|
5121
|
-
isRegex: useRegex,
|
|
5122
|
-
regexPattern,
|
|
6901
|
+
isRegex: gridEditMode ? false : useRegex,
|
|
6902
|
+
regexPattern: gridEditMode ? "" : regexPattern,
|
|
5123
6903
|
publishOnApproval
|
|
5124
6904
|
});
|
|
5125
6905
|
if (res.data && res.data.success) {
|
|
@@ -5140,28 +6920,33 @@ const BulkUpdater = () => {
|
|
|
5140
6920
|
}
|
|
5141
6921
|
};
|
|
5142
6922
|
const executeBatchWithMode = async (executionMode, forceImmediate = false) => {
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
const
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
if (cachedEntry
|
|
6923
|
+
let targets = [];
|
|
6924
|
+
if (gridEditMode) {
|
|
6925
|
+
targets = gridSerialized.targets;
|
|
6926
|
+
} else {
|
|
6927
|
+
Object.keys(selectedEntries).forEach((key) => {
|
|
6928
|
+
if (selectedEntries[key]) {
|
|
6929
|
+
const parts = key.split(KEY_SEP);
|
|
6930
|
+
if (parts.length === 2) {
|
|
6931
|
+
const colUid = parts[0];
|
|
6932
|
+
const docId = parts[1];
|
|
6933
|
+
const targetObj = { uid: colUid, documentId: docId };
|
|
6934
|
+
if (selectedDzBlocks[key] && selectedDzBlocks[key].length > 0) {
|
|
6935
|
+
targetObj.dynamicZoneIndexes = selectedDzBlocks[key];
|
|
6936
|
+
}
|
|
6937
|
+
const colPage = collectionPages[colUid];
|
|
6938
|
+
const cachedEntry = colPage?.entries?.find((e) => e.documentId === docId);
|
|
6939
|
+
if (cachedEntry) {
|
|
6940
|
+
if (cachedEntry.status) targetObj.status = cachedEntry.status;
|
|
6941
|
+
if (cachedEntry.publishedAt) targetObj.publishedAt = cachedEntry.publishedAt;
|
|
6942
|
+
if (cachedEntry.locale) targetObj.locale = cachedEntry.locale;
|
|
6943
|
+
}
|
|
6944
|
+
targets.push(targetObj);
|
|
5160
6945
|
}
|
|
5161
|
-
targets.push(targetObj);
|
|
5162
6946
|
}
|
|
5163
|
-
}
|
|
5164
|
-
}
|
|
6947
|
+
});
|
|
6948
|
+
}
|
|
6949
|
+
const displaySummaryVal = gridEditMode ? `Grid Editing (${gridSerialized.totalEditCount} edits across ${targets.length} records)` : attributeValue;
|
|
5165
6950
|
try {
|
|
5166
6951
|
setUpdating(true);
|
|
5167
6952
|
setShowConfirmModal(false);
|
|
@@ -5176,7 +6961,7 @@ const BulkUpdater = () => {
|
|
|
5176
6961
|
status: "processing",
|
|
5177
6962
|
executionMode,
|
|
5178
6963
|
attribute: selectedAttribute,
|
|
5179
|
-
value:
|
|
6964
|
+
value: displaySummaryVal,
|
|
5180
6965
|
totalTargets: targets.length,
|
|
5181
6966
|
processedCount: 0,
|
|
5182
6967
|
updatedCount: 0,
|
|
@@ -5191,10 +6976,11 @@ const BulkUpdater = () => {
|
|
|
5191
6976
|
});
|
|
5192
6977
|
const payload = {
|
|
5193
6978
|
attribute: selectedAttribute,
|
|
5194
|
-
value: attributeValue,
|
|
6979
|
+
value: gridEditMode ? "" : attributeValue,
|
|
6980
|
+
editMode: gridEditMode ? "grid" : "common",
|
|
5195
6981
|
selectedEntries: targets,
|
|
5196
|
-
isRegex: useRegex,
|
|
5197
|
-
regexPattern,
|
|
6982
|
+
isRegex: gridEditMode ? false : useRegex,
|
|
6983
|
+
regexPattern: gridEditMode ? "" : regexPattern,
|
|
5198
6984
|
executionMode,
|
|
5199
6985
|
makerNotes: makerNotesInput,
|
|
5200
6986
|
forceImmediate,
|
|
@@ -5206,11 +6992,12 @@ const BulkUpdater = () => {
|
|
|
5206
6992
|
const res = await post("/bulk-updater/batch-update", payload);
|
|
5207
6993
|
setIsSubmittingBatch(false);
|
|
5208
6994
|
if (res.data && res.data.success) {
|
|
5209
|
-
setSelectedEntries({});
|
|
5210
|
-
setSelectedDzBlocks({});
|
|
5211
6995
|
const finalBatchId = res.data.batchId;
|
|
5212
6996
|
setDashboardBatchId(finalBatchId);
|
|
5213
6997
|
if (res.data.pending) {
|
|
6998
|
+
setSelectedEntries({});
|
|
6999
|
+
setSelectedDzBlocks({});
|
|
7000
|
+
if (gridEditMode) setGridEdits({});
|
|
5214
7001
|
setDashboardJob({
|
|
5215
7002
|
id: finalBatchId,
|
|
5216
7003
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -5218,7 +7005,7 @@ const BulkUpdater = () => {
|
|
|
5218
7005
|
executionMode,
|
|
5219
7006
|
scheduledFor: res.data.scheduledFor,
|
|
5220
7007
|
attribute: selectedAttribute,
|
|
5221
|
-
value:
|
|
7008
|
+
value: displaySummaryVal,
|
|
5222
7009
|
totalTargets: targets.length,
|
|
5223
7010
|
processedCount: 0,
|
|
5224
7011
|
updatedCount: 0,
|
|
@@ -5236,7 +7023,31 @@ const BulkUpdater = () => {
|
|
|
5236
7023
|
});
|
|
5237
7024
|
await fetchPendingBatches();
|
|
5238
7025
|
} else {
|
|
5239
|
-
|
|
7026
|
+
const resultList = res.data.results || [];
|
|
7027
|
+
if (gridEditMode) {
|
|
7028
|
+
const failedKeys = new Set(
|
|
7029
|
+
resultList.filter((r) => r.status === "error" && r.uid && r.documentId).map((r) => `${r.uid}${KEY_SEP}${r.documentId}`)
|
|
7030
|
+
);
|
|
7031
|
+
setGridEdits((prev) => {
|
|
7032
|
+
const next = {};
|
|
7033
|
+
for (const k of Object.keys(prev)) {
|
|
7034
|
+
if (failedKeys.has(k)) next[k] = prev[k];
|
|
7035
|
+
}
|
|
7036
|
+
return next;
|
|
7037
|
+
});
|
|
7038
|
+
setSelectedEntries((prev) => {
|
|
7039
|
+
const next = {};
|
|
7040
|
+
for (const k of Object.keys(prev)) {
|
|
7041
|
+
if (failedKeys.has(k) && prev[k]) next[k] = true;
|
|
7042
|
+
}
|
|
7043
|
+
return next;
|
|
7044
|
+
});
|
|
7045
|
+
setSelectedDzBlocks({});
|
|
7046
|
+
} else {
|
|
7047
|
+
setSelectedEntries({});
|
|
7048
|
+
setSelectedDzBlocks({});
|
|
7049
|
+
}
|
|
7050
|
+
setLastResults(resultList);
|
|
5240
7051
|
setUpdateSummary({
|
|
5241
7052
|
updatedCount: res.data.updatedCount || 0,
|
|
5242
7053
|
skippedCount: res.data.skippedCount || 0,
|
|
@@ -5249,15 +7060,15 @@ const BulkUpdater = () => {
|
|
|
5249
7060
|
status: res.data.status || "successful",
|
|
5250
7061
|
executionMode: "immediate",
|
|
5251
7062
|
attribute: selectedAttribute,
|
|
5252
|
-
value:
|
|
7063
|
+
value: res.data.value || displaySummaryVal,
|
|
5253
7064
|
totalTargets: res.data.totalTargets || targets.length,
|
|
5254
|
-
processedCount:
|
|
7065
|
+
processedCount: resultList.length || targets.length,
|
|
5255
7066
|
updatedCount: res.data.updatedCount || 0,
|
|
5256
7067
|
skippedCount: res.data.skippedCount || 0,
|
|
5257
7068
|
failedCount: res.data.failedCount || 0,
|
|
5258
7069
|
isLive: res.data.isLive !== false && res.data.updatedCount > 0,
|
|
5259
7070
|
publishOnApproval,
|
|
5260
|
-
results:
|
|
7071
|
+
results: resultList
|
|
5261
7072
|
});
|
|
5262
7073
|
toggleNotification({
|
|
5263
7074
|
type: "success",
|
|
@@ -5266,17 +7077,18 @@ const BulkUpdater = () => {
|
|
|
5266
7077
|
await fetchModels();
|
|
5267
7078
|
await fetchAuditHistory();
|
|
5268
7079
|
if (selectedCollectionUid) {
|
|
7080
|
+
const appliedNow = appliedSearchFilterRef.current;
|
|
5269
7081
|
loadCollectionPage(
|
|
5270
7082
|
selectedCollectionUid,
|
|
5271
7083
|
collectionPages[selectedCollectionUid]?.page || 1,
|
|
5272
7084
|
void 0,
|
|
5273
7085
|
void 0,
|
|
5274
7086
|
void 0,
|
|
5275
|
-
filterOperator,
|
|
5276
|
-
filterQuery,
|
|
5277
|
-
entrySearch,
|
|
7087
|
+
appliedNow.filterOperator,
|
|
7088
|
+
appliedNow.filterQuery,
|
|
7089
|
+
appliedNow.entrySearch,
|
|
5278
7090
|
false,
|
|
5279
|
-
searchAttribute
|
|
7091
|
+
appliedNow.searchAttribute
|
|
5280
7092
|
);
|
|
5281
7093
|
}
|
|
5282
7094
|
}
|
|
@@ -5976,14 +7788,15 @@ const BulkUpdater = () => {
|
|
|
5976
7788
|
matchingEntriesCount === 1 ? "entry" : "entries",
|
|
5977
7789
|
" found in database"
|
|
5978
7790
|
] }),
|
|
5979
|
-
searchAttribute && searchAttribute !== selectedAttribute && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
|
|
7791
|
+
appliedSearchFilter.searchAttribute && appliedSearchFilter.searchAttribute !== selectedAttribute && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
|
|
5980
7792
|
"Searching by: ",
|
|
5981
|
-
searchAttribute,
|
|
7793
|
+
appliedSearchFilter.searchAttribute,
|
|
5982
7794
|
" → Target to update: ",
|
|
5983
7795
|
selectedAttribute
|
|
5984
|
-
] })
|
|
7796
|
+
] }),
|
|
7797
|
+
hasPendingFilterChanges && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "Filters modified — click Search to apply" })
|
|
5985
7798
|
] }),
|
|
5986
|
-
isFilterActive && /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "S", onClick: clearFilter, children: "Clear Search & Filter" })
|
|
7799
|
+
(isFilterActive || hasPendingFilterChanges || Boolean(searchAttribute) || filterOperator !== "none" || Boolean(entrySearch.trim()) || statusFilter !== "all" || Boolean(useRegex && regexPattern.trim())) && /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "S", onClick: clearFilter, children: "Clear Search & Filter" })
|
|
5987
7800
|
] }),
|
|
5988
7801
|
/* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
|
|
5989
7802
|
/* @__PURE__ */ jsx(Box, { style: { width: 280, minWidth: 230 }, children: /* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
@@ -6052,7 +7865,13 @@ const BulkUpdater = () => {
|
|
|
6052
7865
|
label: effectiveSearchAttribute ? `Value for "${effectiveSearchAttribute}"` : "Value to match",
|
|
6053
7866
|
placeholder: "Type value to match...",
|
|
6054
7867
|
value: filterQuery,
|
|
6055
|
-
onChange: (e) => setFilterQuery(e.target.value)
|
|
7868
|
+
onChange: (e) => setFilterQuery(e.target.value),
|
|
7869
|
+
onKeyDown: (e) => {
|
|
7870
|
+
if (e.key === "Enter") {
|
|
7871
|
+
e.preventDefault();
|
|
7872
|
+
handleApplySearch();
|
|
7873
|
+
}
|
|
7874
|
+
}
|
|
6056
7875
|
}
|
|
6057
7876
|
) }),
|
|
6058
7877
|
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 180 }, children: /* @__PURE__ */ jsx(
|
|
@@ -6061,7 +7880,13 @@ const BulkUpdater = () => {
|
|
|
6061
7880
|
label: "Full-text Entry Search",
|
|
6062
7881
|
placeholder: "Search title, name, or text across records...",
|
|
6063
7882
|
value: entrySearch,
|
|
6064
|
-
onChange: (e) => setEntrySearch(e.target.value)
|
|
7883
|
+
onChange: (e) => setEntrySearch(e.target.value),
|
|
7884
|
+
onKeyDown: (e) => {
|
|
7885
|
+
if (e.key === "Enter") {
|
|
7886
|
+
e.preventDefault();
|
|
7887
|
+
handleApplySearch();
|
|
7888
|
+
}
|
|
7889
|
+
}
|
|
6065
7890
|
}
|
|
6066
7891
|
) }),
|
|
6067
7892
|
/* @__PURE__ */ jsx(Box, { style: { width: 190, minWidth: 160 }, children: /* @__PURE__ */ jsxs(
|
|
@@ -6080,6 +7905,17 @@ const BulkUpdater = () => {
|
|
|
6080
7905
|
]
|
|
6081
7906
|
}
|
|
6082
7907
|
) }),
|
|
7908
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
7909
|
+
Button,
|
|
7910
|
+
{
|
|
7911
|
+
variant: hasPendingFilterChanges ? "default" : "secondary",
|
|
7912
|
+
startIcon: /* @__PURE__ */ jsx(Search, {}),
|
|
7913
|
+
onClick: handleApplySearch,
|
|
7914
|
+
loading: Boolean(selectedCollectionUid && collectionPages[selectedCollectionUid]?.loading),
|
|
7915
|
+
disabled: !selectedCollectionUid || Boolean(selectedCollectionUid && collectionPages[selectedCollectionUid]?.loading),
|
|
7916
|
+
children: "Search"
|
|
7917
|
+
}
|
|
7918
|
+
) }),
|
|
6083
7919
|
isFilterActive && /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
6084
7920
|
/* @__PURE__ */ jsx(
|
|
6085
7921
|
Button,
|
|
@@ -6110,6 +7946,7 @@ const BulkUpdater = () => {
|
|
|
6110
7946
|
Checkbox,
|
|
6111
7947
|
{
|
|
6112
7948
|
checked: useRegex,
|
|
7949
|
+
disabled: gridEditMode,
|
|
6113
7950
|
onCheckedChange: (checked) => setUseRegex(Boolean(checked)),
|
|
6114
7951
|
children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: "Enable Regex Search & Replace" })
|
|
6115
7952
|
}
|
|
@@ -6117,10 +7954,10 @@ const BulkUpdater = () => {
|
|
|
6117
7954
|
/* @__PURE__ */ jsx(
|
|
6118
7955
|
Badge,
|
|
6119
7956
|
{
|
|
6120
|
-
backgroundColor: useRegex ? "secondary100" : "neutral200",
|
|
6121
|
-
textColor: useRegex ? "secondary700" : "neutral600",
|
|
7957
|
+
backgroundColor: gridEditMode ? "neutral200" : useRegex ? "secondary100" : "neutral200",
|
|
7958
|
+
textColor: gridEditMode ? "neutral600" : useRegex ? "secondary700" : "neutral600",
|
|
6122
7959
|
size: "S",
|
|
6123
|
-
children: useRegex ? "REGEX SEARCH ACTIVE" : "REGEX OFF"
|
|
7960
|
+
children: gridEditMode ? "DISABLED IN GRID EDIT" : useRegex ? "REGEX SEARCH ACTIVE" : "REGEX OFF"
|
|
6124
7961
|
}
|
|
6125
7962
|
)
|
|
6126
7963
|
] }),
|
|
@@ -6545,6 +8382,72 @@ const BulkUpdater = () => {
|
|
|
6545
8382
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: col.isSingleType ? "1 single entry" : isFilterActive ? `${totalEntries} matching entries in DB` : `${totalEntries} entries` })
|
|
6546
8383
|
] })
|
|
6547
8384
|
] }),
|
|
8385
|
+
gridEditMode && /* @__PURE__ */ jsx(
|
|
8386
|
+
Box,
|
|
8387
|
+
{
|
|
8388
|
+
padding: 3,
|
|
8389
|
+
marginBottom: 3,
|
|
8390
|
+
background: "primary100",
|
|
8391
|
+
hasRadius: true,
|
|
8392
|
+
style: { border: "1px solid #d9d8ff" },
|
|
8393
|
+
children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", wrap: "wrap", gap: 2, children: [
|
|
8394
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
|
|
8395
|
+
/* @__PURE__ */ jsx(Badge, { backgroundColor: "primary600", textColor: "neutral0", children: "GRID EDITING MODE" }),
|
|
8396
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "primary700", children: selectedAttribute ? `Editing "${selectedAttribute}" directly per record & component block` : 'Select an "Attribute to Update" below to enable inline cell editors' }),
|
|
8397
|
+
/* @__PURE__ */ jsxs(Badge, { backgroundColor: "neutral0", textColor: "primary700", children: [
|
|
8398
|
+
totalDirtyCellsCount,
|
|
8399
|
+
" edit",
|
|
8400
|
+
totalDirtyCellsCount === 1 ? "" : "s",
|
|
8401
|
+
" across ",
|
|
8402
|
+
totalDirtyRecordsCount,
|
|
8403
|
+
" record",
|
|
8404
|
+
totalDirtyRecordsCount === 1 ? "" : "s"
|
|
8405
|
+
] })
|
|
8406
|
+
] }),
|
|
8407
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
|
|
8408
|
+
(activeAttrMeta?.rootType === "dynamiczone" || activeAttrMeta?.rootRepeatable) && visibleEntries.length > 0 && /* @__PURE__ */ jsx(
|
|
8409
|
+
Button,
|
|
8410
|
+
{
|
|
8411
|
+
variant: "secondary",
|
|
8412
|
+
size: "S",
|
|
8413
|
+
onClick: () => {
|
|
8414
|
+
const allVisibleKeys = visibleEntries.map((e) => `${col.uid}${KEY_SEP}${e.documentId}`);
|
|
8415
|
+
const anyCollapsed = allVisibleKeys.some((k) => !expandedDzEntries[k]);
|
|
8416
|
+
setExpandedDzEntries((prev) => {
|
|
8417
|
+
const next = { ...prev };
|
|
8418
|
+
allVisibleKeys.forEach((k) => {
|
|
8419
|
+
next[k] = anyCollapsed;
|
|
8420
|
+
});
|
|
8421
|
+
return next;
|
|
8422
|
+
});
|
|
8423
|
+
},
|
|
8424
|
+
children: visibleEntries.some((e) => !expandedDzEntries[`${col.uid}${KEY_SEP}${e.documentId}`]) ? "Expand All Blocks" : "Collapse All Blocks"
|
|
8425
|
+
}
|
|
8426
|
+
),
|
|
8427
|
+
/* @__PURE__ */ jsx(
|
|
8428
|
+
Button,
|
|
8429
|
+
{
|
|
8430
|
+
variant: gridFilterModifiedOnly ? "default" : "tertiary",
|
|
8431
|
+
size: "S",
|
|
8432
|
+
onClick: () => setGridFilterModifiedOnly((v) => !v),
|
|
8433
|
+
disabled: totalDirtyRecordsCount === 0 && !gridFilterModifiedOnly,
|
|
8434
|
+
children: gridFilterModifiedOnly ? "Showing Modified Only" : "Filter: Modified Only"
|
|
8435
|
+
}
|
|
8436
|
+
),
|
|
8437
|
+
/* @__PURE__ */ jsx(
|
|
8438
|
+
Button,
|
|
8439
|
+
{
|
|
8440
|
+
variant: "danger-light",
|
|
8441
|
+
size: "S",
|
|
8442
|
+
disabled: totalDirtyCellsCount === 0,
|
|
8443
|
+
onClick: () => setGridEdits({}),
|
|
8444
|
+
children: "Discard All Edits"
|
|
8445
|
+
}
|
|
8446
|
+
)
|
|
8447
|
+
] })
|
|
8448
|
+
] })
|
|
8449
|
+
}
|
|
8450
|
+
),
|
|
6548
8451
|
/* @__PURE__ */ jsx(Box, { className: "bulk-updater-table-container", style: { width: "100%", maxWidth: "100%", minWidth: 0, overflowX: "auto" }, children: /* @__PURE__ */ jsxs(Table, { colCount: activeColumns.length, rowCount: visibleEntries.length + 1, style: { width: "100%" }, children: [
|
|
6549
8452
|
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsx(Tr, { children: activeColumns.map(
|
|
6550
8453
|
(colDef) => renderHeaderCell(colDef, col, currentSort, selectedAttribute, searchAttribute, handleHeaderSortClick)
|
|
@@ -6561,12 +8464,27 @@ const BulkUpdater = () => {
|
|
|
6561
8464
|
const dzFields = Object.keys(entry).filter(
|
|
6562
8465
|
(k) => Array.isArray(entry[k]) && entry[k].length > 0 && entry[k].some((item) => item && item.__component)
|
|
6563
8466
|
);
|
|
8467
|
+
const selectedRootKey = selectedAttribute ? selectedAttribute.split("[")[0].split(".")[0] : "";
|
|
8468
|
+
const expandableArrayFields = gridEditMode && selectedRootKey && activeAttrMeta?.rootRepeatable && !dzFields.includes(selectedRootKey) && Array.isArray(entry[selectedRootKey]) && entry[selectedRootKey].length > 0 ? [...dzFields, selectedRootKey] : dzFields;
|
|
8469
|
+
const recordEdits = gridEdits[key];
|
|
8470
|
+
const gridCtx = gridEditMode ? {
|
|
8471
|
+
gridEditMode: true,
|
|
8472
|
+
selectedAttrMeta: activeAttrMeta,
|
|
8473
|
+
recordEdits,
|
|
8474
|
+
relationOptions,
|
|
8475
|
+
relationOptionsLoading,
|
|
8476
|
+
relationIsMulti: Boolean(relationsMeta[selectedAttribute]?.isMulti),
|
|
8477
|
+
validationRules,
|
|
8478
|
+
onCommitEdit: handleGridCellCommit,
|
|
8479
|
+
onResetEdit: handleGridCellReset
|
|
8480
|
+
} : void 0;
|
|
8481
|
+
const rowOccs = gridEditMode && isDzExpanded && selectedAttribute ? enumerateClientOccurrences(entry, selectedAttribute, col?.attributes, activeAttrMeta) : [];
|
|
6564
8482
|
return /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
|
|
6565
8483
|
/* @__PURE__ */ jsx(
|
|
6566
8484
|
Tr,
|
|
6567
8485
|
{
|
|
6568
8486
|
style: {
|
|
6569
|
-
backgroundColor: isSelected ? "rgba(73, 69, 255, 0.14)" : isMatch ? "rgba(46, 213, 115, 0.08)" : void 0,
|
|
8487
|
+
backgroundColor: recordEdits ? "rgba(73, 69, 255, 0.10)" : isSelected ? "rgba(73, 69, 255, 0.14)" : isMatch ? "rgba(46, 213, 115, 0.08)" : void 0,
|
|
6570
8488
|
boxShadow: isSelected ? "inset 3px 0 0 0 #4945ff" : isMatch ? "inset 3px 0 0 0 #2ed573" : void 0
|
|
6571
8489
|
},
|
|
6572
8490
|
children: activeColumns.map((colDef) => /* @__PURE__ */ jsx(Td, { children: renderCellContent(
|
|
@@ -6582,97 +8500,47 @@ const BulkUpdater = () => {
|
|
|
6582
8500
|
pendingBatches,
|
|
6583
8501
|
isDzExpanded,
|
|
6584
8502
|
onToggleExpandDz,
|
|
6585
|
-
filterQuery
|
|
8503
|
+
filterQuery,
|
|
8504
|
+
gridCtx
|
|
6586
8505
|
) }, colDef.key))
|
|
6587
8506
|
}
|
|
6588
8507
|
),
|
|
6589
|
-
isDzExpanded &&
|
|
6590
|
-
const
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
if (!targetParsed.subPath) return true;
|
|
6594
|
-
const scopedPath = `${dzKey}[${blockItem?.__component}].${targetParsed.subPath}`;
|
|
6595
|
-
const componentSupports = (col?.attributes || attributes || []).includes(scopedPath);
|
|
6596
|
-
return componentSupports || getNestedValue(blockItem, targetParsed.subPath) !== void 0;
|
|
6597
|
-
};
|
|
6598
|
-
const allApplicableIndexes = blocks.map((_, i) => i).filter((i) => isBlockApplicable(blocks[i]));
|
|
6599
|
-
return /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: activeColumns.length, style: { padding: "12px 16px", backgroundColor: "rgba(73, 69, 255, 0.02)", borderBottom: "2px solid rgba(73, 69, 255, 0.15)" }, children: /* @__PURE__ */ jsxs(
|
|
6600
|
-
Box,
|
|
8508
|
+
isDzExpanded && expandableArrayFields.map((dzKey) => {
|
|
8509
|
+
const drawerOccurrences = gridEditMode && selectedAttribute ? rowOccs : enumerateClientOccurrences(entry, selectedAttribute, col?.attributes, activeAttrMeta);
|
|
8510
|
+
return /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(
|
|
8511
|
+
Td,
|
|
6601
8512
|
{
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
] }) }),
|
|
6632
|
-
/* @__PURE__ */ jsx(Tbody, { children: blocks.map((block, bIdx) => {
|
|
6633
|
-
const compUid = block.__component;
|
|
6634
|
-
const compLabel = formatComponentName(compUid);
|
|
6635
|
-
const scopedPath = `${dzKey}[${compUid}].${targetParsed.subPath}`;
|
|
6636
|
-
const componentSupports = (col?.attributes || attributes || []).includes(scopedPath);
|
|
6637
|
-
const blockVal = targetParsed.subPath ? getNestedValue(block, targetParsed.subPath) : void 0;
|
|
6638
|
-
const hasTargetAttr = componentSupports || blockVal !== void 0;
|
|
6639
|
-
const isBlockChecked = hasTargetAttr && isSelected && (selectedDzBlocks[key] !== void 0 ? selectedDzBlocks[key].includes(bIdx) : true);
|
|
6640
|
-
return /* @__PURE__ */ jsxs(
|
|
6641
|
-
Tr,
|
|
6642
|
-
{
|
|
6643
|
-
style: {
|
|
6644
|
-
backgroundColor: isBlockChecked ? "rgba(73, 69, 255, 0.08)" : void 0
|
|
6645
|
-
},
|
|
6646
|
-
children: [
|
|
6647
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
6648
|
-
Checkbox,
|
|
6649
|
-
{
|
|
6650
|
-
checked: isBlockChecked,
|
|
6651
|
-
disabled: !hasTargetAttr,
|
|
6652
|
-
onCheckedChange: () => {
|
|
6653
|
-
toggleDzBlock(col.uid, entry.documentId, bIdx, allApplicableIndexes);
|
|
6654
|
-
}
|
|
6655
|
-
}
|
|
6656
|
-
) }),
|
|
6657
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", children: [
|
|
6658
|
-
"#",
|
|
6659
|
-
bIdx
|
|
6660
|
-
] }) }),
|
|
6661
|
-
/* @__PURE__ */ jsxs(Td, { children: [
|
|
6662
|
-
/* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: compLabel }),
|
|
6663
|
-
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", display: "block", style: { fontSize: "0.68rem", marginTop: 2 }, children: compUid })
|
|
6664
|
-
] }),
|
|
6665
|
-
/* @__PURE__ */ jsx(Td, { children: hasTargetAttr ? /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "primary700", children: formatDisplayValue(blockVal) }) : /* @__PURE__ */ jsx(Badge, { backgroundColor: "neutral100", textColor: "neutral500", children: "Does not contain attribute" }) }),
|
|
6666
|
-
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { maxWidth: 300, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: block.title || block.name || block.heading || block.body || Object.keys(block).filter((k) => !k.startsWith("_") && k !== "id").slice(0, 3).map((k) => `${k}: ${formatDisplayValue(block[k])}`).join(", ") || "-" }) })
|
|
6667
|
-
]
|
|
6668
|
-
},
|
|
6669
|
-
bIdx
|
|
6670
|
-
);
|
|
6671
|
-
}) })
|
|
6672
|
-
] })
|
|
6673
|
-
]
|
|
8513
|
+
colSpan: activeColumns.length,
|
|
8514
|
+
style: {
|
|
8515
|
+
padding: "12px 16px",
|
|
8516
|
+
backgroundColor: "rgba(73, 69, 255, 0.02)",
|
|
8517
|
+
borderBottom: "2px solid rgba(73, 69, 255, 0.15)"
|
|
8518
|
+
},
|
|
8519
|
+
children: /* @__PURE__ */ jsx(
|
|
8520
|
+
ComponentOccurrencesDrawer,
|
|
8521
|
+
{
|
|
8522
|
+
colUid: col.uid,
|
|
8523
|
+
rootKey: dzKey,
|
|
8524
|
+
entry,
|
|
8525
|
+
selectedAttribute,
|
|
8526
|
+
attrMeta: activeAttrMeta,
|
|
8527
|
+
colAttributes: col?.attributes || attributes || [],
|
|
8528
|
+
gridEditMode,
|
|
8529
|
+
isSelected,
|
|
8530
|
+
selectedDzBlocks: selectedDzBlocks[key],
|
|
8531
|
+
occurrences: drawerOccurrences,
|
|
8532
|
+
recordEdits,
|
|
8533
|
+
relationOptions,
|
|
8534
|
+
relationOptionsLoading,
|
|
8535
|
+
relationIsMulti: Boolean(relationsMeta[selectedAttribute]?.isMulti),
|
|
8536
|
+
validationRules,
|
|
8537
|
+
onToggleDzBlock: toggleDzBlock,
|
|
8538
|
+
onCommitEdit: handleGridCellCommit,
|
|
8539
|
+
onResetEdit: handleGridCellReset
|
|
8540
|
+
}
|
|
8541
|
+
)
|
|
6674
8542
|
}
|
|
6675
|
-
) }
|
|
8543
|
+
) }, `${key}-dz-${dzKey}`);
|
|
6676
8544
|
})
|
|
6677
8545
|
] }, key);
|
|
6678
8546
|
}) })
|
|
@@ -6771,10 +8639,38 @@ const BulkUpdater = () => {
|
|
|
6771
8639
|
marginBottom: 6,
|
|
6772
8640
|
style: { width: "100%", maxWidth: "100%", minWidth: 0, boxSizing: "border-box" },
|
|
6773
8641
|
children: [
|
|
6774
|
-
/* @__PURE__ */
|
|
6775
|
-
/* @__PURE__ */
|
|
6776
|
-
|
|
6777
|
-
|
|
8642
|
+
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 4, wrap: "wrap", gap: 3, children: [
|
|
8643
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
8644
|
+
/* @__PURE__ */ jsx(Typography, { variant: "delta", tag: "h2", fontWeight: "semiBold", children: "2. Configure Attribute Update" }),
|
|
8645
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Select the target attribute to update and either apply a common value or enable inline Grid Editing." })
|
|
8646
|
+
] }),
|
|
8647
|
+
/* @__PURE__ */ jsx(Flex, { gap: 3, alignItems: "center", wrap: "wrap", children: /* @__PURE__ */ jsx(
|
|
8648
|
+
Box,
|
|
8649
|
+
{
|
|
8650
|
+
padding: 2,
|
|
8651
|
+
paddingLeft: 3,
|
|
8652
|
+
paddingRight: 3,
|
|
8653
|
+
background: gridEditMode ? "primary100" : "neutral100",
|
|
8654
|
+
hasRadius: true,
|
|
8655
|
+
style: { border: gridEditMode ? "1px solid #4945ff" : "1px solid #eaeaef" },
|
|
8656
|
+
children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
8657
|
+
/* @__PURE__ */ jsx(
|
|
8658
|
+
Checkbox,
|
|
8659
|
+
{
|
|
8660
|
+
checked: gridEditMode,
|
|
8661
|
+
onCheckedChange: (checked) => handleToggleGridEditMode(Boolean(checked)),
|
|
8662
|
+
children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: gridEditMode ? "primary700" : "neutral800", children: "Edit Values in Grid" })
|
|
8663
|
+
}
|
|
8664
|
+
),
|
|
8665
|
+
gridEditMode && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "primary600", textColor: "neutral0", size: "S", children: [
|
|
8666
|
+
"ON (",
|
|
8667
|
+
gridSerialized.totalEditCount,
|
|
8668
|
+
" edits)"
|
|
8669
|
+
] })
|
|
8670
|
+
] })
|
|
8671
|
+
}
|
|
8672
|
+
) })
|
|
8673
|
+
] }),
|
|
6778
8674
|
/* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
|
|
6779
8675
|
/* @__PURE__ */ jsx(Box, { style: { width: 280, minWidth: 230 }, children: /* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
6780
8676
|
/* @__PURE__ */ jsx(Field.Label, { children: "Attribute to Update" }),
|
|
@@ -6801,7 +8697,35 @@ const BulkUpdater = () => {
|
|
|
6801
8697
|
`update-attr-${selectedCollectionUid}`
|
|
6802
8698
|
)
|
|
6803
8699
|
] }) }),
|
|
6804
|
-
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 340 }, children:
|
|
8700
|
+
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 340 }, children: gridEditMode ? /* @__PURE__ */ jsx(
|
|
8701
|
+
Box,
|
|
8702
|
+
{
|
|
8703
|
+
padding: 3,
|
|
8704
|
+
background: "primary100",
|
|
8705
|
+
hasRadius: true,
|
|
8706
|
+
style: { border: "1px solid #d9d8ff" },
|
|
8707
|
+
children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", wrap: "wrap", gap: 2, children: [
|
|
8708
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
8709
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "primary700", display: "block", children: "Common value input hidden — Grid Editing Mode active" }),
|
|
8710
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral700", children: gridSerialized.targets.length > 0 ? `Ready: ${gridSerialized.totalEditCount} edited field/block value(s) across ${gridSerialized.targets.length} selected record(s).` : "Edit cell values directly in the table above (or expand component blocks) to queue heterogeneous updates." }),
|
|
8711
|
+
gridSerialized.hasValidationErrors && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", display: "block", children: "⚠️ Resolve inline red validation errors before previewing or updating." })
|
|
8712
|
+
] }),
|
|
8713
|
+
totalDirtyCellsCount > 0 && /* @__PURE__ */ jsxs(
|
|
8714
|
+
Button,
|
|
8715
|
+
{
|
|
8716
|
+
variant: "danger-light",
|
|
8717
|
+
size: "S",
|
|
8718
|
+
onClick: () => setGridEdits({}),
|
|
8719
|
+
children: [
|
|
8720
|
+
"Discard Edits (",
|
|
8721
|
+
totalDirtyCellsCount,
|
|
8722
|
+
")"
|
|
8723
|
+
]
|
|
8724
|
+
}
|
|
8725
|
+
)
|
|
8726
|
+
] })
|
|
8727
|
+
}
|
|
8728
|
+
) : relationsMeta[selectedAttribute] ? /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, style: { width: "100%" }, children: [
|
|
6805
8729
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", wrap: "wrap", children: [
|
|
6806
8730
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral700", children: [
|
|
6807
8731
|
"Target ",
|
|
@@ -6886,10 +8810,10 @@ const BulkUpdater = () => {
|
|
|
6886
8810
|
size: "L",
|
|
6887
8811
|
onClick: handleOpenPreviewModal,
|
|
6888
8812
|
loading: previewLoading,
|
|
6889
|
-
disabled: loading ||
|
|
8813
|
+
disabled: loading || !selectedAttribute || !selectedAttribute.trim() || (gridEditMode ? gridSerialized.targets.length === 0 || gridSerialized.hasValidationErrors : totalSelectedCount === 0),
|
|
6890
8814
|
children: [
|
|
6891
8815
|
"Preview Changes (",
|
|
6892
|
-
totalSelectedCount,
|
|
8816
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
6893
8817
|
")"
|
|
6894
8818
|
]
|
|
6895
8819
|
}
|
|
@@ -6902,10 +8826,10 @@ const BulkUpdater = () => {
|
|
|
6902
8826
|
size: "L",
|
|
6903
8827
|
onClick: handleOpenConfirmModal,
|
|
6904
8828
|
loading: updating,
|
|
6905
|
-
disabled: loading ||
|
|
8829
|
+
disabled: loading || !selectedAttribute || !selectedAttribute.trim() || (gridEditMode ? gridSerialized.targets.length === 0 || gridSerialized.hasValidationErrors : totalSelectedCount === 0),
|
|
6906
8830
|
children: [
|
|
6907
8831
|
"Update Selected (",
|
|
6908
|
-
totalSelectedCount,
|
|
8832
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
6909
8833
|
")"
|
|
6910
8834
|
]
|
|
6911
8835
|
}
|
|
@@ -6992,11 +8916,11 @@ const BulkUpdater = () => {
|
|
|
6992
8916
|
"Attribute: ",
|
|
6993
8917
|
selectedAttribute,
|
|
6994
8918
|
" ",
|
|
6995
|
-
|
|
8919
|
+
activeAttrMeta?.type ? `(${activeAttrMeta.type})` : ""
|
|
6996
8920
|
] }),
|
|
6997
|
-
|
|
8921
|
+
activeAttrMeta?.depth ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: "neutral200", textColor: "neutral700", children: [
|
|
6998
8922
|
"Nesting Level: L",
|
|
6999
|
-
|
|
8923
|
+
activeAttrMeta.depth
|
|
7000
8924
|
] }) : null,
|
|
7001
8925
|
selectedCol.draftAndPublish ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "success100", textColor: "success700", children: "Draft & Publish Enabled" }) : /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "Direct Publish Only" })
|
|
7002
8926
|
] }) }) })
|
|
@@ -7434,7 +9358,15 @@ const BulkUpdater = () => {
|
|
|
7434
9358
|
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Previous Value" }) }),
|
|
7435
9359
|
/* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Applied Value" }) })
|
|
7436
9360
|
] }) }),
|
|
7437
|
-
/* @__PURE__ */ jsx(Tbody, { children: rec.diffs.
|
|
9361
|
+
/* @__PURE__ */ jsx(Tbody, { children: rec.diffs.flatMap(
|
|
9362
|
+
(d) => Array.isArray(d.dynamicZoneDiffs) && d.dynamicZoneDiffs.length > 0 ? d.dynamicZoneDiffs.map((dz) => ({
|
|
9363
|
+
collectionName: d.collectionName,
|
|
9364
|
+
label: `${d.label}${dz.componentName ? ` [${dz.componentName}]` : ""}`,
|
|
9365
|
+
attribute: dz.attribute || d.attribute,
|
|
9366
|
+
oldValue: dz.oldValue,
|
|
9367
|
+
newValue: dz.newValue
|
|
9368
|
+
})) : [d]
|
|
9369
|
+
).map((d, dIdx) => /* @__PURE__ */ jsxs(Tr, { children: [
|
|
7438
9370
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: d.collectionName }) }),
|
|
7439
9371
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { children: d.label }) }),
|
|
7440
9372
|
/* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: d.attribute || "field" }) }),
|
|
@@ -7523,7 +9455,13 @@ const BulkUpdater = () => {
|
|
|
7523
9455
|
] }),
|
|
7524
9456
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
|
|
7525
9457
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: "Target Value:" }),
|
|
7526
|
-
/* @__PURE__ */ jsx(Typography, { variant: "omega", style: { wordBreak: "break-all", maxWidth: 360 }, children:
|
|
9458
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", style: { wordBreak: "break-all", maxWidth: 360 }, children: gridEditMode ? /* @__PURE__ */ jsxs(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
|
|
9459
|
+
"Grid Editing (",
|
|
9460
|
+
gridSerialized.totalEditCount,
|
|
9461
|
+
" heterogeneous edits across ",
|
|
9462
|
+
gridSerialized.targets.length,
|
|
9463
|
+
" records)"
|
|
9464
|
+
] }) : relationsMeta[selectedAttribute] ? /* @__PURE__ */ jsx("span", { children: selectedRelationDocId === "__clear__" ? /* @__PURE__ */ jsx(Badge, { backgroundColor: "danger100", textColor: "danger700", children: "Clear / Unlink Relation" }) : /* @__PURE__ */ jsxs(Badge, { backgroundColor: "secondary100", textColor: "secondary700", children: [
|
|
7527
9465
|
relationsMeta[selectedAttribute].isMulti ? `[${relationMode.toUpperCase()}] ` : "",
|
|
7528
9466
|
relationOptions.find((o) => o.documentId === selectedRelationDocId)?.label || selectedRelationDocId || "(none selected)"
|
|
7529
9467
|
] }) }) : useRegex ? /* @__PURE__ */ jsxs("span", { children: [
|
|
@@ -7548,7 +9486,7 @@ const BulkUpdater = () => {
|
|
|
7548
9486
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
|
|
7549
9487
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", children: "Total Selected Records:" }),
|
|
7550
9488
|
/* @__PURE__ */ jsxs(Typography, { fontWeight: "bold", textColor: "primary600", children: [
|
|
7551
|
-
totalSelectedCount,
|
|
9489
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
7552
9490
|
" records"
|
|
7553
9491
|
] })
|
|
7554
9492
|
] }),
|
|
@@ -7584,31 +9522,31 @@ const BulkUpdater = () => {
|
|
|
7584
9522
|
/* @__PURE__ */ jsxs(Box, { marginBottom: 4, padding: 3, background: "neutral100", hasRadius: true, style: { border: "1px solid rgba(120, 120, 150, 0.15)" }, children: [
|
|
7585
9523
|
/* @__PURE__ */ jsxs(Typography, { variant: "sigma", textColor: "neutral600", marginBottom: 2, display: "block", children: [
|
|
7586
9524
|
"LIFECYCLE STATUS BREAKDOWN (",
|
|
7587
|
-
totalSelectedCount,
|
|
9525
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
7588
9526
|
" Selected)"
|
|
7589
9527
|
] }),
|
|
7590
9528
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", children: [
|
|
7591
9529
|
/* @__PURE__ */ jsxs(Badge, { backgroundColor: "success100", textColor: "success700", children: [
|
|
7592
9530
|
"✓ Published / Approved: ",
|
|
7593
|
-
|
|
9531
|
+
updateModalLifecycleStats.published
|
|
7594
9532
|
] }),
|
|
7595
|
-
|
|
9533
|
+
updateModalLifecycleStats.modified > 0 && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "primary100", textColor: "primary700", children: [
|
|
7596
9534
|
"📝 Modified (Unreviewed Revisions): ",
|
|
7597
|
-
|
|
9535
|
+
updateModalLifecycleStats.modified
|
|
7598
9536
|
] }),
|
|
7599
|
-
|
|
9537
|
+
updateModalLifecycleStats.draft > 0 && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "neutral200", textColor: "neutral800", children: [
|
|
7600
9538
|
"📄 Draft (Never Published): ",
|
|
7601
|
-
|
|
9539
|
+
updateModalLifecycleStats.draft
|
|
7602
9540
|
] }),
|
|
7603
|
-
|
|
9541
|
+
updateModalLifecycleStats.pendingReview > 0 && /* @__PURE__ */ jsxs(Badge, { backgroundColor: "warning100", textColor: "warning700", children: [
|
|
7604
9542
|
"⏳ Pending Review: ",
|
|
7605
|
-
|
|
9543
|
+
updateModalLifecycleStats.pendingReview
|
|
7606
9544
|
] })
|
|
7607
9545
|
] })
|
|
7608
9546
|
] }),
|
|
7609
9547
|
/* @__PURE__ */ jsxs(Box, { marginBottom: 4, children: [
|
|
7610
9548
|
/* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", marginBottom: 2, display: "block", children: "COLLECTION BREAKDOWN" }),
|
|
7611
|
-
/* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, children: Object.entries(getSelectedBreakdown()).map(([name, count]) => /* @__PURE__ */ jsxs(
|
|
9549
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", gap: 1, children: Object.entries(getSelectedBreakdown(gridEditMode ? gridTargetKeys : void 0)).map(([name, count]) => /* @__PURE__ */ jsxs(
|
|
7612
9550
|
Flex,
|
|
7613
9551
|
{
|
|
7614
9552
|
justifyContent: "space-between",
|
|
@@ -7656,7 +9594,7 @@ const BulkUpdater = () => {
|
|
|
7656
9594
|
] })
|
|
7657
9595
|
}
|
|
7658
9596
|
),
|
|
7659
|
-
publishOnApproval &&
|
|
9597
|
+
publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && /* @__PURE__ */ jsxs(
|
|
7660
9598
|
Box,
|
|
7661
9599
|
{
|
|
7662
9600
|
padding: 4,
|
|
@@ -7700,11 +9638,11 @@ const BulkUpdater = () => {
|
|
|
7700
9638
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", display: "block", children: "🛡️ Safe Publishing (Recommended)" }),
|
|
7701
9639
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
7702
9640
|
"Only publish records that are already approved & live (",
|
|
7703
|
-
|
|
9641
|
+
updateModalLifecycleStats.published,
|
|
7704
9642
|
" record",
|
|
7705
|
-
|
|
9643
|
+
updateModalLifecycleStats.published === 1 ? "" : "s",
|
|
7706
9644
|
"). The ",
|
|
7707
|
-
|
|
9645
|
+
updateModalLifecycleStats.unreviewedCount,
|
|
7708
9646
|
" unreviewed or draft record(s) will receive the bulk update in Draft mode without publishing unreviewed draft revisions to visitors."
|
|
7709
9647
|
] })
|
|
7710
9648
|
] })
|
|
@@ -7738,9 +9676,9 @@ const BulkUpdater = () => {
|
|
|
7738
9676
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "danger700", display: "block", children: "⚠️ Publish All Selected Records (Includes Unreviewed Drafts)" }),
|
|
7739
9677
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
7740
9678
|
"Publish all ",
|
|
7741
|
-
totalSelectedCount,
|
|
9679
|
+
gridEditMode ? gridSerialized.targets.length : totalSelectedCount,
|
|
7742
9680
|
" records live to production immediately, pushing all pending unreviewed draft edits in the ",
|
|
7743
|
-
|
|
9681
|
+
updateModalLifecycleStats.unreviewedCount,
|
|
7744
9682
|
" draft/modified record(s) live."
|
|
7745
9683
|
] })
|
|
7746
9684
|
] })
|
|
@@ -7767,7 +9705,7 @@ const BulkUpdater = () => {
|
|
|
7767
9705
|
/* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "danger700", display: "block", children: "Mandatory Risk Consent Required" }),
|
|
7768
9706
|
/* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "danger700", children: [
|
|
7769
9707
|
"I understand and explicitly consent that ",
|
|
7770
|
-
|
|
9708
|
+
updateModalLifecycleStats.unreviewedCount,
|
|
7771
9709
|
" record(s) with unreviewed draft revisions or saved draft states will be published live to production visitors."
|
|
7772
9710
|
] })
|
|
7773
9711
|
] })
|
|
@@ -7805,7 +9743,7 @@ const BulkUpdater = () => {
|
|
|
7805
9743
|
boxShadow: "0 -4px 16px rgba(0, 0, 0, 0.08)"
|
|
7806
9744
|
},
|
|
7807
9745
|
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, style: { width: "100%" }, children: [
|
|
7808
|
-
publishOnApproval &&
|
|
9746
|
+
publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger700", fontWeight: "bold", children: "⚠️ Explicit consent is required before publishing records with unreviewed draft revisions." }),
|
|
7809
9747
|
/* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", gap: 3, style: { width: "100%" }, children: [
|
|
7810
9748
|
/* @__PURE__ */ jsx(Button, { variant: "tertiary", size: "M", onClick: () => setShowConfirmModal(false), children: "Cancel" }),
|
|
7811
9749
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", justifyContent: "flex-end", alignItems: "center", children: [
|
|
@@ -7816,7 +9754,7 @@ const BulkUpdater = () => {
|
|
|
7816
9754
|
size: "M",
|
|
7817
9755
|
onClick: () => executeBatchWithMode("maker_checker"),
|
|
7818
9756
|
loading: updating,
|
|
7819
|
-
disabled: updating || publishOnApproval &&
|
|
9757
|
+
disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
|
|
7820
9758
|
children: "Submit for Checker Approval"
|
|
7821
9759
|
}
|
|
7822
9760
|
),
|
|
@@ -7828,7 +9766,7 @@ const BulkUpdater = () => {
|
|
|
7828
9766
|
size: "M",
|
|
7829
9767
|
onClick: () => executeBatchWithMode("queue_offpeak"),
|
|
7830
9768
|
loading: updating,
|
|
7831
|
-
disabled: updating || publishOnApproval &&
|
|
9769
|
+
disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
|
|
7832
9770
|
children: [
|
|
7833
9771
|
"Queue for Off-Peak (",
|
|
7834
9772
|
executionWindow?.offPeakStartTime || "18:00",
|
|
@@ -7843,7 +9781,7 @@ const BulkUpdater = () => {
|
|
|
7843
9781
|
size: "S",
|
|
7844
9782
|
onClick: () => executeBatchWithMode("immediate", true),
|
|
7845
9783
|
loading: updating,
|
|
7846
|
-
disabled: updating || publishOnApproval &&
|
|
9784
|
+
disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
|
|
7847
9785
|
children: "Force Run Now"
|
|
7848
9786
|
}
|
|
7849
9787
|
)
|
|
@@ -7854,7 +9792,7 @@ const BulkUpdater = () => {
|
|
|
7854
9792
|
size: "M",
|
|
7855
9793
|
onClick: () => executeBatchWithMode("immediate"),
|
|
7856
9794
|
loading: updating,
|
|
7857
|
-
disabled: updating || publishOnApproval &&
|
|
9795
|
+
disabled: updating || publishOnApproval && updateModalLifecycleStats.unreviewedCount > 0 && publishStrategy === "all" && !unreviewedConsent,
|
|
7858
9796
|
children: "Confirm & Execute Now"
|
|
7859
9797
|
}
|
|
7860
9798
|
)
|
|
@@ -8143,9 +10081,10 @@ const BulkUpdater = () => {
|
|
|
8143
10081
|
loading: previewLoading,
|
|
8144
10082
|
previewData,
|
|
8145
10083
|
attribute: selectedAttribute,
|
|
10084
|
+
editMode: gridEditMode ? "grid" : "common",
|
|
8146
10085
|
publishOnApproval,
|
|
8147
10086
|
lifecycleStats: selectedLifecycleStats,
|
|
8148
|
-
targetValueDisplay: relationsMeta[selectedAttribute] ? selectedRelationDocId === "__clear__" ? "Clear / Unlink Relation" : relationOptions.find((o) => o.documentId === selectedRelationDocId)?.label || selectedRelationDocId || "(none)" : useRegex ? `Replace /${regexPattern}/g with "${attributeValue}"` : attributeValue
|
|
10087
|
+
targetValueDisplay: gridEditMode ? `Grid Editing (${gridSerialized.totalEditCount} edits across ${gridSerialized.targets.length} records)` : relationsMeta[selectedAttribute] ? selectedRelationDocId === "__clear__" ? "Clear / Unlink Relation" : relationOptions.find((o) => o.documentId === selectedRelationDocId)?.label || selectedRelationDocId || "(none)" : useRegex ? `Replace /${regexPattern}/g with "${attributeValue}"` : attributeValue
|
|
8149
10088
|
}
|
|
8150
10089
|
),
|
|
8151
10090
|
/* @__PURE__ */ jsx(
|
|
@@ -8187,4 +10126,4 @@ export {
|
|
|
8187
10126
|
getSortOptionsForCollection,
|
|
8188
10127
|
parseDynamicZonePath
|
|
8189
10128
|
};
|
|
8190
|
-
//# sourceMappingURL=BulkUpdater-
|
|
10129
|
+
//# sourceMappingURL=BulkUpdater-xj4wH_iI.mjs.map
|