strapi-plugin-bulk-updater 1.6.0 → 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-D12SUhTd.js → BulkUpdater-DTJLdJJy.js} +344 -169
- package/dist/_chunks/BulkUpdater-DTJLdJJy.js.map +1 -0
- package/dist/_chunks/{BulkUpdater-CTKfvKhE.mjs → BulkUpdater-xj4wH_iI.mjs} +345 -170
- 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 +2367 -1587
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +2367 -1587
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/_chunks/BulkUpdater-CTKfvKhE.mjs.map +0 -1
- package/dist/_chunks/BulkUpdater-D12SUhTd.js.map +0 -1
|
@@ -2,7 +2,7 @@ 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
4
|
import { Box, Flex, Typography, Button, Combobox, ComboboxOption, Badge, SingleSelect, SingleSelectOption, TextInput, Checkbox, Alert, Table, Thead, Tr, Th, Tbody, Td, Loader, Textarea, Field } from "@strapi/design-system";
|
|
5
|
-
import { ArrowClockwise, Download, Upload, ChevronLeft, ChevronRight, Eye, Check,
|
|
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: [
|
|
@@ -5744,7 +5863,27 @@ const BulkUpdater = () => {
|
|
|
5744
5863
|
const [entrySearch, setEntrySearch] = useState("");
|
|
5745
5864
|
const abortControllersRef = useRef({});
|
|
5746
5865
|
const [statusFilter, setStatusFilter] = useState("all");
|
|
5747
|
-
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);
|
|
5748
5887
|
const [lastResults, setLastResults] = useState(null);
|
|
5749
5888
|
const [updateSummary, setUpdateSummary] = useState(null);
|
|
5750
5889
|
const [collectionPages, setCollectionPages] = useState({});
|
|
@@ -5911,10 +6050,11 @@ const BulkUpdater = () => {
|
|
|
5911
6050
|
const currentSort = collectionSorts[colUid] || { field: "createdAt", order: "desc" };
|
|
5912
6051
|
const sortField = customSortField !== void 0 ? customSortField : currentSort.field;
|
|
5913
6052
|
const sortOrder = customSortOrder !== void 0 ? customSortOrder : currentSort.order;
|
|
5914
|
-
const
|
|
5915
|
-
const
|
|
5916
|
-
const
|
|
5917
|
-
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;
|
|
5918
6058
|
setCollectionPages((prev) => ({
|
|
5919
6059
|
...prev,
|
|
5920
6060
|
[colUid]: {
|
|
@@ -5922,34 +6062,30 @@ const BulkUpdater = () => {
|
|
|
5922
6062
|
loading: true
|
|
5923
6063
|
}
|
|
5924
6064
|
}));
|
|
6065
|
+
let controller = null;
|
|
5925
6066
|
try {
|
|
5926
|
-
const params =
|
|
5927
|
-
page:
|
|
5928
|
-
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
|
|
5929
6079
|
});
|
|
5930
|
-
if (selectedAttribute) params.set("attribute", selectedAttribute);
|
|
5931
|
-
if (searchAttr && searchAttr !== selectedAttribute) {
|
|
5932
|
-
params.set("searchAttribute", searchAttr);
|
|
5933
|
-
}
|
|
5934
|
-
if (op && op !== "none") {
|
|
5935
|
-
params.set("filterOperator", op);
|
|
5936
|
-
if (q) params.set("filterQuery", q);
|
|
5937
|
-
}
|
|
5938
|
-
if (s && s.trim()) {
|
|
5939
|
-
params.set("search", s.trim());
|
|
5940
|
-
}
|
|
5941
|
-
if (sortField) {
|
|
5942
|
-
params.set("sortField", sortField);
|
|
5943
|
-
params.set("sortOrder", sortOrder);
|
|
5944
|
-
}
|
|
5945
6080
|
if (abortControllersRef.current[colUid]) {
|
|
5946
6081
|
abortControllersRef.current[colUid].abort();
|
|
5947
6082
|
}
|
|
5948
|
-
|
|
6083
|
+
controller = new AbortController();
|
|
5949
6084
|
abortControllersRef.current[colUid] = controller;
|
|
5950
6085
|
const res = await get(`/bulk-updater/collections/${colUid}/entries?${params.toString()}`, {
|
|
5951
6086
|
signal: controller.signal
|
|
5952
6087
|
});
|
|
6088
|
+
if (abortControllersRef.current[colUid] !== controller) return;
|
|
5953
6089
|
if (res.data && (res.data.success || res.data.entries !== void 0)) {
|
|
5954
6090
|
const fetchedEntries = res.data.entries || [];
|
|
5955
6091
|
const pageNum = res.data.pagination?.page ?? targetPage ?? 1;
|
|
@@ -5997,13 +6133,15 @@ const BulkUpdater = () => {
|
|
|
5997
6133
|
message: `Failed to load entries for ${colUid}: ${err?.message || "Network error"}`
|
|
5998
6134
|
});
|
|
5999
6135
|
}
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6136
|
+
if (abortControllersRef.current[colUid] === controller) {
|
|
6137
|
+
setCollectionPages((prev) => ({
|
|
6138
|
+
...prev,
|
|
6139
|
+
[colUid]: {
|
|
6140
|
+
...prev[colUid] || {},
|
|
6141
|
+
loading: false
|
|
6142
|
+
}
|
|
6143
|
+
}));
|
|
6144
|
+
}
|
|
6007
6145
|
}
|
|
6008
6146
|
};
|
|
6009
6147
|
const fetchAuditHistory = async () => {
|
|
@@ -6066,44 +6204,46 @@ const BulkUpdater = () => {
|
|
|
6066
6204
|
fetchPendingBatches();
|
|
6067
6205
|
}
|
|
6068
6206
|
}, [activeTab]);
|
|
6069
|
-
const
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
}
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
void 0,
|
|
6095
|
-
void 0,
|
|
6096
|
-
void 0,
|
|
6097
|
-
filterOperator,
|
|
6098
|
-
filterQuery,
|
|
6099
|
-
entrySearch,
|
|
6100
|
-
true,
|
|
6101
|
-
searchAttribute
|
|
6102
|
-
);
|
|
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({});
|
|
6103
6232
|
}
|
|
6104
|
-
}
|
|
6105
|
-
|
|
6106
|
-
|
|
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
|
+
};
|
|
6107
6247
|
const KEY_SEP = "@@@";
|
|
6108
6248
|
const selectedCol = useMemo(() => {
|
|
6109
6249
|
if (!collections.length || !selectedCollectionUid) return null;
|
|
@@ -6244,6 +6384,12 @@ const BulkUpdater = () => {
|
|
|
6244
6384
|
}
|
|
6245
6385
|
setSelectedEntries({});
|
|
6246
6386
|
setSearchAttribute("");
|
|
6387
|
+
const nextAppliedOnColSwitch = {
|
|
6388
|
+
...appliedSearchFilterRef.current,
|
|
6389
|
+
searchAttribute: ""
|
|
6390
|
+
};
|
|
6391
|
+
appliedSearchFilterRef.current = nextAppliedOnColSwitch;
|
|
6392
|
+
setAppliedSearchFilter(nextAppliedOnColSwitch);
|
|
6247
6393
|
if (!newUid || !newUid.trim()) {
|
|
6248
6394
|
setAttributes([]);
|
|
6249
6395
|
setSelectedAttribute("");
|
|
@@ -6263,7 +6409,18 @@ const BulkUpdater = () => {
|
|
|
6263
6409
|
setSelectedRelationDocId("");
|
|
6264
6410
|
setAttributeValue("");
|
|
6265
6411
|
}
|
|
6266
|
-
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
|
+
);
|
|
6267
6424
|
};
|
|
6268
6425
|
const handleAttributeChange = (newAttr) => {
|
|
6269
6426
|
if (newAttr !== selectedAttribute) {
|
|
@@ -6351,20 +6508,6 @@ const BulkUpdater = () => {
|
|
|
6351
6508
|
const handleSearchAttributeChange = (newAttr) => {
|
|
6352
6509
|
const finalAttr = newAttr === "__default__" ? "" : newAttr;
|
|
6353
6510
|
setSearchAttribute(finalAttr);
|
|
6354
|
-
if (selectedCollectionUid) {
|
|
6355
|
-
loadCollectionPage(
|
|
6356
|
-
selectedCollectionUid,
|
|
6357
|
-
1,
|
|
6358
|
-
void 0,
|
|
6359
|
-
void 0,
|
|
6360
|
-
void 0,
|
|
6361
|
-
filterOperator,
|
|
6362
|
-
filterQuery,
|
|
6363
|
-
entrySearch,
|
|
6364
|
-
true,
|
|
6365
|
-
finalAttr
|
|
6366
|
-
);
|
|
6367
|
-
}
|
|
6368
6511
|
};
|
|
6369
6512
|
const handleCollectionPageSizeChange = (colUid, newSize) => {
|
|
6370
6513
|
const capped = Math.min(500, Math.max(1, newSize));
|
|
@@ -6420,9 +6563,13 @@ const BulkUpdater = () => {
|
|
|
6420
6563
|
};
|
|
6421
6564
|
const entryMatchesFilter = (entry, attr) => {
|
|
6422
6565
|
const matches = getAllNestedValues(entry, attr);
|
|
6423
|
-
|
|
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()) {
|
|
6424
6571
|
try {
|
|
6425
|
-
const regex = new RegExp(
|
|
6572
|
+
const regex = new RegExp(activeRegexPattern, "i");
|
|
6426
6573
|
const anyRegexMatch = matches.some((m) => regex.test(formatDisplayValue(m.value)));
|
|
6427
6574
|
if (!anyRegexMatch) {
|
|
6428
6575
|
return false;
|
|
@@ -6430,22 +6577,22 @@ const BulkUpdater = () => {
|
|
|
6430
6577
|
} catch {
|
|
6431
6578
|
}
|
|
6432
6579
|
}
|
|
6433
|
-
if (
|
|
6580
|
+
if (activeOp === "none") return true;
|
|
6434
6581
|
if (matches.length === 0) {
|
|
6435
|
-
return
|
|
6582
|
+
return activeOp === "empty";
|
|
6436
6583
|
}
|
|
6437
6584
|
const checkMatch = (val) => {
|
|
6438
6585
|
const displayStr = formatDisplayValue(val);
|
|
6439
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)";
|
|
6440
|
-
if (
|
|
6441
|
-
if (
|
|
6587
|
+
if (activeOp === "empty") return isValEmpty;
|
|
6588
|
+
if (activeOp === "not_empty") return !isValEmpty;
|
|
6442
6589
|
if (isValEmpty) return false;
|
|
6443
|
-
const q =
|
|
6590
|
+
const q = activeQuery.trim().toLowerCase();
|
|
6444
6591
|
if (!q) return true;
|
|
6445
6592
|
const testString = (str) => {
|
|
6446
6593
|
if (str === void 0 || str === null) return false;
|
|
6447
6594
|
const s = String(str).trim().toLowerCase();
|
|
6448
|
-
switch (
|
|
6595
|
+
switch (activeOp) {
|
|
6449
6596
|
case "equals":
|
|
6450
6597
|
return s === q;
|
|
6451
6598
|
case "contains":
|
|
@@ -6476,7 +6623,7 @@ const BulkUpdater = () => {
|
|
|
6476
6623
|
}
|
|
6477
6624
|
return testString(displayStr);
|
|
6478
6625
|
};
|
|
6479
|
-
if (
|
|
6626
|
+
if (activeOp === "empty") {
|
|
6480
6627
|
return matches.every((m) => checkMatch(m.value));
|
|
6481
6628
|
}
|
|
6482
6629
|
return matches.some((m) => checkMatch(m.value));
|
|
@@ -6487,10 +6634,11 @@ const BulkUpdater = () => {
|
|
|
6487
6634
|
if (gridEditMode && gridFilterModifiedOnly) {
|
|
6488
6635
|
raw = raw.filter((entry) => Boolean(gridEdits[`${col.uid}${KEY_SEP}${entry.documentId}`]));
|
|
6489
6636
|
}
|
|
6490
|
-
|
|
6637
|
+
const activeStatus = appliedSearchFilter.statusFilter || "all";
|
|
6638
|
+
if (activeStatus === "all") return raw;
|
|
6491
6639
|
return raw.filter((entry) => {
|
|
6492
6640
|
const lifecycle = getEntryLifecycleStatus(entry, col, pendingBatches);
|
|
6493
|
-
return lifecycle.status ===
|
|
6641
|
+
return lifecycle.status === activeStatus;
|
|
6494
6642
|
});
|
|
6495
6643
|
};
|
|
6496
6644
|
const matchingEntriesCount = React__default.useMemo(() => {
|
|
@@ -6500,7 +6648,7 @@ const BulkUpdater = () => {
|
|
|
6500
6648
|
count += getVisibleEntries(col).length;
|
|
6501
6649
|
});
|
|
6502
6650
|
return count;
|
|
6503
|
-
}, [filteredCollections, collectionPages, isFilterActive,
|
|
6651
|
+
}, [filteredCollections, collectionPages, isFilterActive, appliedSearchFilter, pendingBatches, gridEditMode, gridFilterModifiedOnly, gridEdits]);
|
|
6504
6652
|
const selectAllMatching = () => {
|
|
6505
6653
|
const updated = { ...selectedEntries };
|
|
6506
6654
|
filteredCollections.forEach((col) => {
|
|
@@ -6528,6 +6676,8 @@ const BulkUpdater = () => {
|
|
|
6528
6676
|
setEntrySearch("");
|
|
6529
6677
|
setStatusFilter("all");
|
|
6530
6678
|
setRegexPattern("");
|
|
6679
|
+
appliedSearchFilterRef.current = EMPTY_SEARCH_FILTER;
|
|
6680
|
+
setAppliedSearchFilter(EMPTY_SEARCH_FILTER);
|
|
6531
6681
|
if (gridEditMode) {
|
|
6532
6682
|
setSelectedEntries((prev) => {
|
|
6533
6683
|
const retained = {};
|
|
@@ -6927,17 +7077,18 @@ const BulkUpdater = () => {
|
|
|
6927
7077
|
await fetchModels();
|
|
6928
7078
|
await fetchAuditHistory();
|
|
6929
7079
|
if (selectedCollectionUid) {
|
|
7080
|
+
const appliedNow = appliedSearchFilterRef.current;
|
|
6930
7081
|
loadCollectionPage(
|
|
6931
7082
|
selectedCollectionUid,
|
|
6932
7083
|
collectionPages[selectedCollectionUid]?.page || 1,
|
|
6933
7084
|
void 0,
|
|
6934
7085
|
void 0,
|
|
6935
7086
|
void 0,
|
|
6936
|
-
filterOperator,
|
|
6937
|
-
filterQuery,
|
|
6938
|
-
entrySearch,
|
|
7087
|
+
appliedNow.filterOperator,
|
|
7088
|
+
appliedNow.filterQuery,
|
|
7089
|
+
appliedNow.entrySearch,
|
|
6939
7090
|
false,
|
|
6940
|
-
searchAttribute
|
|
7091
|
+
appliedNow.searchAttribute
|
|
6941
7092
|
);
|
|
6942
7093
|
}
|
|
6943
7094
|
}
|
|
@@ -7637,14 +7788,15 @@ const BulkUpdater = () => {
|
|
|
7637
7788
|
matchingEntriesCount === 1 ? "entry" : "entries",
|
|
7638
7789
|
" found in database"
|
|
7639
7790
|
] }),
|
|
7640
|
-
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: [
|
|
7641
7792
|
"Searching by: ",
|
|
7642
|
-
searchAttribute,
|
|
7793
|
+
appliedSearchFilter.searchAttribute,
|
|
7643
7794
|
" → Target to update: ",
|
|
7644
7795
|
selectedAttribute
|
|
7645
|
-
] })
|
|
7796
|
+
] }),
|
|
7797
|
+
hasPendingFilterChanges && /* @__PURE__ */ jsx(Badge, { backgroundColor: "warning100", textColor: "warning700", children: "Filters modified — click Search to apply" })
|
|
7646
7798
|
] }),
|
|
7647
|
-
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" })
|
|
7648
7800
|
] }),
|
|
7649
7801
|
/* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-end", wrap: "wrap", children: [
|
|
7650
7802
|
/* @__PURE__ */ jsx(Box, { style: { width: 280, minWidth: 230 }, children: /* @__PURE__ */ jsxs(Field.Root, { children: [
|
|
@@ -7713,7 +7865,13 @@ const BulkUpdater = () => {
|
|
|
7713
7865
|
label: effectiveSearchAttribute ? `Value for "${effectiveSearchAttribute}"` : "Value to match",
|
|
7714
7866
|
placeholder: "Type value to match...",
|
|
7715
7867
|
value: filterQuery,
|
|
7716
|
-
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
|
+
}
|
|
7717
7875
|
}
|
|
7718
7876
|
) }),
|
|
7719
7877
|
/* @__PURE__ */ jsx(Box, { style: { flex: 1, minWidth: 180 }, children: /* @__PURE__ */ jsx(
|
|
@@ -7722,7 +7880,13 @@ const BulkUpdater = () => {
|
|
|
7722
7880
|
label: "Full-text Entry Search",
|
|
7723
7881
|
placeholder: "Search title, name, or text across records...",
|
|
7724
7882
|
value: entrySearch,
|
|
7725
|
-
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
|
+
}
|
|
7726
7890
|
}
|
|
7727
7891
|
) }),
|
|
7728
7892
|
/* @__PURE__ */ jsx(Box, { style: { width: 190, minWidth: 160 }, children: /* @__PURE__ */ jsxs(
|
|
@@ -7741,6 +7905,17 @@ const BulkUpdater = () => {
|
|
|
7741
7905
|
]
|
|
7742
7906
|
}
|
|
7743
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
|
+
) }),
|
|
7744
7919
|
isFilterActive && /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
7745
7920
|
/* @__PURE__ */ jsx(
|
|
7746
7921
|
Button,
|
|
@@ -9951,4 +10126,4 @@ export {
|
|
|
9951
10126
|
getSortOptionsForCollection,
|
|
9952
10127
|
parseDynamicZonePath
|
|
9953
10128
|
};
|
|
9954
|
-
//# sourceMappingURL=BulkUpdater-
|
|
10129
|
+
//# sourceMappingURL=BulkUpdater-xj4wH_iI.mjs.map
|