@procore/saved-views 1.0.1-estimatingFork.3 → 1.1.0-alpha.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/legacy/index.d.mts +11 -30
- package/dist/legacy/index.d.ts +11 -30
- package/dist/legacy/index.js +334 -396
- package/dist/legacy/index.mjs +281 -343
- package/dist/modern/index.d.mts +11 -30
- package/dist/modern/index.d.ts +11 -30
- package/dist/modern/index.js +334 -395
- package/dist/modern/index.mjs +281 -342
- package/package.json +1 -1
package/dist/modern/index.js
CHANGED
|
@@ -3976,7 +3976,7 @@ var require_lodash = __commonJS({
|
|
|
3976
3976
|
if (typeof func != "function") {
|
|
3977
3977
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
3978
3978
|
}
|
|
3979
|
-
return
|
|
3979
|
+
return setTimeout(function() {
|
|
3980
3980
|
func.apply(undefined2, args);
|
|
3981
3981
|
}, wait);
|
|
3982
3982
|
}
|
|
@@ -5807,7 +5807,7 @@ var require_lodash = __commonJS({
|
|
|
5807
5807
|
return object2[key];
|
|
5808
5808
|
}
|
|
5809
5809
|
var setData = shortOut(baseSetData);
|
|
5810
|
-
var
|
|
5810
|
+
var setTimeout = ctxSetTimeout || function(func, wait) {
|
|
5811
5811
|
return root.setTimeout(func, wait);
|
|
5812
5812
|
};
|
|
5813
5813
|
var setToString = shortOut(baseSetToString);
|
|
@@ -6599,7 +6599,7 @@ var require_lodash = __commonJS({
|
|
|
6599
6599
|
}
|
|
6600
6600
|
function leadingEdge(time) {
|
|
6601
6601
|
lastInvokeTime = time;
|
|
6602
|
-
timerId =
|
|
6602
|
+
timerId = setTimeout(timerExpired, wait);
|
|
6603
6603
|
return leading ? invokeFunc(time) : result2;
|
|
6604
6604
|
}
|
|
6605
6605
|
function remainingWait(time) {
|
|
@@ -6615,7 +6615,7 @@ var require_lodash = __commonJS({
|
|
|
6615
6615
|
if (shouldInvoke(time)) {
|
|
6616
6616
|
return trailingEdge(time);
|
|
6617
6617
|
}
|
|
6618
|
-
timerId =
|
|
6618
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
6619
6619
|
}
|
|
6620
6620
|
function trailingEdge(time) {
|
|
6621
6621
|
timerId = undefined2;
|
|
@@ -6646,12 +6646,12 @@ var require_lodash = __commonJS({
|
|
|
6646
6646
|
}
|
|
6647
6647
|
if (maxing) {
|
|
6648
6648
|
clearTimeout(timerId);
|
|
6649
|
-
timerId =
|
|
6649
|
+
timerId = setTimeout(timerExpired, wait);
|
|
6650
6650
|
return invokeFunc(lastCallTime);
|
|
6651
6651
|
}
|
|
6652
6652
|
}
|
|
6653
6653
|
if (timerId === undefined2) {
|
|
6654
|
-
timerId =
|
|
6654
|
+
timerId = setTimeout(timerExpired, wait);
|
|
6655
6655
|
}
|
|
6656
6656
|
return result2;
|
|
6657
6657
|
}
|
|
@@ -11389,7 +11389,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11389
11389
|
loading: props.isUpdateProcessing
|
|
11390
11390
|
},
|
|
11391
11391
|
i18n.t("savedViews.actions.update")
|
|
11392
|
-
)),
|
|
11392
|
+
)), props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
|
|
11393
11393
|
import_core_react3.Button,
|
|
11394
11394
|
{
|
|
11395
11395
|
onClick: copyShareLink,
|
|
@@ -11437,12 +11437,191 @@ var ExpandedPanel = styled_components_esm_default(import_core_react4.Panel)`
|
|
|
11437
11437
|
`;
|
|
11438
11438
|
|
|
11439
11439
|
// src/components/panels/PanelContent.tsx
|
|
11440
|
-
var
|
|
11440
|
+
var import_core_react8 = require("@procore/core-react");
|
|
11441
11441
|
var import_toast_alert2 = require("@procore/toast-alert");
|
|
11442
11442
|
var import_react9 = __toESM(require("react"));
|
|
11443
11443
|
|
|
11444
|
+
// node_modules/@procore/core-http/dist/modern/index.js
|
|
11445
|
+
function getCSRFToken() {
|
|
11446
|
+
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
11447
|
+
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
11448
|
+
}
|
|
11449
|
+
function getCSRFHeader() {
|
|
11450
|
+
const csrfToken = getCSRFToken();
|
|
11451
|
+
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
11452
|
+
}
|
|
11453
|
+
function removeLeadingSlash(url) {
|
|
11454
|
+
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
11455
|
+
}
|
|
11456
|
+
function removeTrailingSlash(url) {
|
|
11457
|
+
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
11458
|
+
}
|
|
11459
|
+
function applyBaseUrl(url, baseUrl) {
|
|
11460
|
+
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
11461
|
+
}
|
|
11462
|
+
function getOptions({ headers, ...options }) {
|
|
11463
|
+
const opts = {
|
|
11464
|
+
credentials: "same-origin",
|
|
11465
|
+
headers: {
|
|
11466
|
+
...getCSRFHeader(),
|
|
11467
|
+
...headers
|
|
11468
|
+
},
|
|
11469
|
+
mode: "same-origin",
|
|
11470
|
+
...options
|
|
11471
|
+
};
|
|
11472
|
+
return opts;
|
|
11473
|
+
}
|
|
11474
|
+
function getUrl(url, baseUrl) {
|
|
11475
|
+
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
11476
|
+
}
|
|
11477
|
+
function request(url, { baseUrl, ...options } = {}) {
|
|
11478
|
+
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
11479
|
+
}
|
|
11480
|
+
function requestJSON(url, requestParams = {}) {
|
|
11481
|
+
return request(url, requestParams).then(
|
|
11482
|
+
(response) => response.json()
|
|
11483
|
+
);
|
|
11484
|
+
}
|
|
11485
|
+
|
|
11486
|
+
// src/utils/api/queries.ts
|
|
11487
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
11488
|
+
|
|
11489
|
+
// src/utils/api/queriesHandler.ts
|
|
11490
|
+
var import_react_query = require("@tanstack/react-query");
|
|
11491
|
+
var import_core_react5 = require("@procore/core-react");
|
|
11492
|
+
var getBasePath = (companyId, projectId) => {
|
|
11493
|
+
if (projectId) {
|
|
11494
|
+
return `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views`;
|
|
11495
|
+
}
|
|
11496
|
+
return `/rest/v2.0/companies/${companyId}/saved_views`;
|
|
11497
|
+
};
|
|
11498
|
+
var useApiRequest = (props, method, mutationKey) => {
|
|
11499
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
11500
|
+
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
11501
|
+
const { locale: locale2 } = (0, import_core_react5.useI18nContext)();
|
|
11502
|
+
const basePath = getBasePath(companyId, projectId);
|
|
11503
|
+
const queryKey = ["savedViews", domain, tableName, companyId, projectId];
|
|
11504
|
+
return (0, import_react_query.useMutation)({
|
|
11505
|
+
mutationKey,
|
|
11506
|
+
mutationFn: async (savedView) => {
|
|
11507
|
+
let url = "";
|
|
11508
|
+
if (method === "DELETE" || method === "PUT") {
|
|
11509
|
+
url = `${basePath}/${savedView.share_token}?permissions_domain=${domain}`;
|
|
11510
|
+
} else {
|
|
11511
|
+
url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11512
|
+
}
|
|
11513
|
+
const response = await requestJSON(url, {
|
|
11514
|
+
method,
|
|
11515
|
+
body: JSON.stringify(savedView),
|
|
11516
|
+
headers: {
|
|
11517
|
+
"Content-Type": "application/json",
|
|
11518
|
+
"Accept-Language": locale2
|
|
11519
|
+
}
|
|
11520
|
+
});
|
|
11521
|
+
if (response.error) {
|
|
11522
|
+
throw response.error;
|
|
11523
|
+
}
|
|
11524
|
+
return response.data;
|
|
11525
|
+
},
|
|
11526
|
+
onSuccess: (savedView) => {
|
|
11527
|
+
if (method === "DELETE" || method === "POST") {
|
|
11528
|
+
queryClient2.invalidateQueries({
|
|
11529
|
+
queryKey
|
|
11530
|
+
});
|
|
11531
|
+
return;
|
|
11532
|
+
} else {
|
|
11533
|
+
const oldData = queryClient2.getQueryData(queryKey);
|
|
11534
|
+
const oldView = oldData?.find(
|
|
11535
|
+
(item) => item.share_token === savedView.share_token
|
|
11536
|
+
);
|
|
11537
|
+
if (oldView?.name !== savedView.name) {
|
|
11538
|
+
queryClient2.invalidateQueries({
|
|
11539
|
+
queryKey
|
|
11540
|
+
});
|
|
11541
|
+
return;
|
|
11542
|
+
}
|
|
11543
|
+
}
|
|
11544
|
+
queryClient2.setQueryData(queryKey, (oldData) => {
|
|
11545
|
+
if (!oldData)
|
|
11546
|
+
return [savedView];
|
|
11547
|
+
return oldData.map(
|
|
11548
|
+
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
11549
|
+
);
|
|
11550
|
+
});
|
|
11551
|
+
}
|
|
11552
|
+
});
|
|
11553
|
+
};
|
|
11554
|
+
|
|
11444
11555
|
// src/utils/constants/viewLevels.ts
|
|
11445
|
-
var
|
|
11556
|
+
var PROJECT_LEVEL_TOOL_VIEW_LEVELS = [
|
|
11557
|
+
"company",
|
|
11558
|
+
"project",
|
|
11559
|
+
"personal"
|
|
11560
|
+
];
|
|
11561
|
+
var COMPANY_LEVEL_TOOL_VIEW_LEVELS = ["company", "personal"];
|
|
11562
|
+
var getViewLevels = (isProjectLevelTool) => isProjectLevelTool ? PROJECT_LEVEL_TOOL_VIEW_LEVELS : COMPANY_LEVEL_TOOL_VIEW_LEVELS;
|
|
11563
|
+
|
|
11564
|
+
// src/utils/api/queries.ts
|
|
11565
|
+
var PAGE_SIZE = 50 * PROJECT_LEVEL_TOOL_VIEW_LEVELS.length;
|
|
11566
|
+
var getBasePath2 = (companyId, projectId) => {
|
|
11567
|
+
if (projectId) {
|
|
11568
|
+
return `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views`;
|
|
11569
|
+
}
|
|
11570
|
+
return `/rest/v2.0/companies/${companyId}/saved_views`;
|
|
11571
|
+
};
|
|
11572
|
+
var useSavedViewsQuery = (props) => {
|
|
11573
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
11574
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11575
|
+
const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11576
|
+
return (0, import_react_query2.useQuery)({
|
|
11577
|
+
queryKey: ["savedViews", domain, tableName, companyId, projectId],
|
|
11578
|
+
queryFn: async () => {
|
|
11579
|
+
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
11580
|
+
const response = await requestJSON(getUrl2);
|
|
11581
|
+
return response.data;
|
|
11582
|
+
}
|
|
11583
|
+
});
|
|
11584
|
+
};
|
|
11585
|
+
var useSavedViewsPermissions = (props) => {
|
|
11586
|
+
const { projectId, companyId, domain } = props;
|
|
11587
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11588
|
+
const url = `${basePath}/permissions?permissions_domain=${domain}`;
|
|
11589
|
+
return (0, import_react_query2.useQuery)({
|
|
11590
|
+
queryKey: ["savedViewsConfig", domain, companyId, projectId],
|
|
11591
|
+
queryFn: async () => {
|
|
11592
|
+
const response = await requestJSON(url);
|
|
11593
|
+
return response.data;
|
|
11594
|
+
}
|
|
11595
|
+
});
|
|
11596
|
+
};
|
|
11597
|
+
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
11598
|
+
"createSavedView",
|
|
11599
|
+
props.domain,
|
|
11600
|
+
props.tableName
|
|
11601
|
+
]);
|
|
11602
|
+
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
11603
|
+
"updateSavedView",
|
|
11604
|
+
props.domain,
|
|
11605
|
+
props.tableName
|
|
11606
|
+
]);
|
|
11607
|
+
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
11608
|
+
"deleteSavedView",
|
|
11609
|
+
props.domain,
|
|
11610
|
+
props.tableName
|
|
11611
|
+
]);
|
|
11612
|
+
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
11613
|
+
const { projectId, companyId, domain } = queryInput;
|
|
11614
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11615
|
+
return (0, import_react_query2.useQuery)({
|
|
11616
|
+
enabled: enabled && Boolean(savedViewToken),
|
|
11617
|
+
queryKey: ["savedView", savedViewToken, companyId, projectId],
|
|
11618
|
+
queryFn: async () => {
|
|
11619
|
+
const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
|
|
11620
|
+
const response = await requestJSON(url);
|
|
11621
|
+
return response.data;
|
|
11622
|
+
}
|
|
11623
|
+
});
|
|
11624
|
+
};
|
|
11446
11625
|
|
|
11447
11626
|
// src/components/panels/PanelContentUtils.ts
|
|
11448
11627
|
var import_lodash = __toESM(require_lodash());
|
|
@@ -11517,12 +11696,10 @@ var getColumnIdentifier = (col) => {
|
|
|
11517
11696
|
};
|
|
11518
11697
|
var updateTableConfig = (view, tableApi, provider) => {
|
|
11519
11698
|
if (provider === "smart-grid") {
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
);
|
|
11525
|
-
}, 0);
|
|
11699
|
+
setSmartGridConfig(
|
|
11700
|
+
tableApi,
|
|
11701
|
+
view.table_config
|
|
11702
|
+
);
|
|
11526
11703
|
} else {
|
|
11527
11704
|
const dataTableApi = tableApi;
|
|
11528
11705
|
const tableConfig = view.table_config;
|
|
@@ -11594,20 +11771,13 @@ var cleanObject = (table_config, provider) => {
|
|
|
11594
11771
|
var normalizeForComparison = (config) => {
|
|
11595
11772
|
if (!config?.columnState)
|
|
11596
11773
|
return config;
|
|
11597
|
-
const filteredColumnState = config.columnState.filter(
|
|
11598
|
-
(col) => {
|
|
11599
|
-
const colId = getColumnIdentifier(col);
|
|
11600
|
-
return colId !== "drag_handle" && colId !== "ag-Grid-AutoColumn";
|
|
11601
|
-
}
|
|
11602
|
-
);
|
|
11603
11774
|
return {
|
|
11604
|
-
...
|
|
11605
|
-
columnState:
|
|
11606
|
-
const res = import_lodash.default.omit(col, ["aggFunc"]);
|
|
11775
|
+
...config,
|
|
11776
|
+
columnState: config.columnState.map((col) => {
|
|
11607
11777
|
if (col.flex) {
|
|
11608
|
-
return import_lodash.default.omit(
|
|
11778
|
+
return import_lodash.default.omit(col, ["width", "flex"]);
|
|
11609
11779
|
}
|
|
11610
|
-
return
|
|
11780
|
+
return col;
|
|
11611
11781
|
})
|
|
11612
11782
|
};
|
|
11613
11783
|
};
|
|
@@ -11620,17 +11790,10 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
|
|
|
11620
11790
|
);
|
|
11621
11791
|
const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
|
|
11622
11792
|
const normalizedCurrentConfig = normalizeForComparison(tableConfig);
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
console.log(
|
|
11628
|
-
"[SavedViews]: Showing update button - view config, current config",
|
|
11629
|
-
cleanedViewConfig,
|
|
11630
|
-
cleanedCurrentConfig
|
|
11631
|
-
);
|
|
11632
|
-
}
|
|
11633
|
-
return isEqual2;
|
|
11793
|
+
return import_lodash.default.isEqual(
|
|
11794
|
+
cleanObject(normalizedViewConfig, provider),
|
|
11795
|
+
cleanObject(normalizedCurrentConfig, provider)
|
|
11796
|
+
);
|
|
11634
11797
|
};
|
|
11635
11798
|
var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
11636
11799
|
switch (viewLevel) {
|
|
@@ -11647,9 +11810,10 @@ var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
|
11647
11810
|
|
|
11648
11811
|
// src/components/panels/useGroups.ts
|
|
11649
11812
|
var import_react6 = require("react");
|
|
11650
|
-
var useGroups = () => {
|
|
11813
|
+
var useGroups = (isProjectLevelTool) => {
|
|
11814
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11651
11815
|
const [groups, setGroups] = (0, import_react6.useState)(
|
|
11652
|
-
Object.fromEntries(
|
|
11816
|
+
Object.fromEntries(viewLevels.map((level) => [level, true]))
|
|
11653
11817
|
);
|
|
11654
11818
|
const toggleGroup = (group) => {
|
|
11655
11819
|
setGroups((groups2) => ({ ...groups2, [group]: !groups2[group] }));
|
|
@@ -11658,7 +11822,7 @@ var useGroups = () => {
|
|
|
11658
11822
|
};
|
|
11659
11823
|
|
|
11660
11824
|
// src/components/panels/ViewLevelHeader.tsx
|
|
11661
|
-
var
|
|
11825
|
+
var import_core_react6 = require("@procore/core-react");
|
|
11662
11826
|
var import_react7 = __toESM(require("react"));
|
|
11663
11827
|
var groupIcon = (group) => {
|
|
11664
11828
|
switch (group) {
|
|
@@ -11670,26 +11834,26 @@ var groupIcon = (group) => {
|
|
|
11670
11834
|
return /* @__PURE__ */ import_react7.default.createElement(Building_default, null);
|
|
11671
11835
|
}
|
|
11672
11836
|
};
|
|
11673
|
-
var Header = styled_components_esm_default(
|
|
11837
|
+
var Header = styled_components_esm_default(import_core_react6.Flex)`
|
|
11674
11838
|
width: 100%;
|
|
11675
11839
|
&:hover {
|
|
11676
|
-
background-color: ${
|
|
11840
|
+
background-color: ${import_core_react6.colors.gray98};
|
|
11677
11841
|
}
|
|
11678
11842
|
`;
|
|
11679
11843
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
11680
|
-
const I18n = (0,
|
|
11844
|
+
const I18n = (0, import_core_react6.useI18nContext)();
|
|
11681
11845
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
11682
11846
|
Header,
|
|
11683
11847
|
{
|
|
11684
11848
|
alignItems: "center",
|
|
11685
|
-
padding: `${
|
|
11686
|
-
gap: `${
|
|
11849
|
+
padding: `${import_core_react6.spacing.sm}px`,
|
|
11850
|
+
gap: `${import_core_react6.spacing.sm}px`,
|
|
11687
11851
|
style: { cursor: "pointer" },
|
|
11688
11852
|
onClick: () => toggleGroup(group)
|
|
11689
11853
|
},
|
|
11690
11854
|
expanded ? /* @__PURE__ */ import_react7.default.createElement(ChevronDown_default, { size: "sm" }) : /* @__PURE__ */ import_react7.default.createElement(ChevronRight_default, { size: "sm" }),
|
|
11691
11855
|
groupIcon(group),
|
|
11692
|
-
/* @__PURE__ */ import_react7.default.createElement(
|
|
11856
|
+
/* @__PURE__ */ import_react7.default.createElement(import_core_react6.Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
|
|
11693
11857
|
);
|
|
11694
11858
|
};
|
|
11695
11859
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
@@ -11707,21 +11871,21 @@ var useScrollToRef = (dependency) => {
|
|
|
11707
11871
|
};
|
|
11708
11872
|
|
|
11709
11873
|
// src/components/panels/PanelContent.styles.ts
|
|
11710
|
-
var
|
|
11711
|
-
var Row = styled_components_esm_default(
|
|
11874
|
+
var import_core_react7 = require("@procore/core-react");
|
|
11875
|
+
var Row = styled_components_esm_default(import_core_react7.UNSAFE_Menu.Item)`
|
|
11712
11876
|
width: 100%;
|
|
11713
11877
|
padding-left: 35px;
|
|
11714
11878
|
padding-right: 4px;
|
|
11715
|
-
background-color: ${({ selected }) => selected ?
|
|
11879
|
+
background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : "transparent"};
|
|
11716
11880
|
|
|
11717
11881
|
&:hover {
|
|
11718
|
-
background-color: ${({ selected }) => selected ?
|
|
11882
|
+
background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : import_core_react7.colors.gray98};
|
|
11719
11883
|
}
|
|
11720
11884
|
`;
|
|
11721
|
-
var Panel2 = styled_components_esm_default(
|
|
11885
|
+
var Panel2 = styled_components_esm_default(import_core_react7.DetailPage.Card)`
|
|
11722
11886
|
margin: 0;
|
|
11723
11887
|
height: 100%;
|
|
11724
|
-
padding-top: ${
|
|
11888
|
+
padding-top: ${import_core_react7.spacing.sm}px;
|
|
11725
11889
|
box-shadow: none;
|
|
11726
11890
|
`;
|
|
11727
11891
|
|
|
@@ -11729,9 +11893,9 @@ var Panel2 = styled_components_esm_default(import_core_react6.DetailPage.Card)`
|
|
|
11729
11893
|
var PanelContent = (props) => {
|
|
11730
11894
|
const { queryInput, selectedSavedView, tableConfig } = props;
|
|
11731
11895
|
const { showToast } = (0, import_toast_alert2.useToastAlertContext)();
|
|
11732
|
-
const I18n = (0,
|
|
11733
|
-
const { data: savedViewsFromQuery, error: savedViewsError } =
|
|
11734
|
-
const updateMutation =
|
|
11896
|
+
const I18n = (0, import_core_react8.useI18nContext)();
|
|
11897
|
+
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
11898
|
+
const updateMutation = useUpdateSavedView(queryInput);
|
|
11735
11899
|
const { mutate: updateSavedView } = updateMutation;
|
|
11736
11900
|
const isUpdateLoading = "isPending" in updateMutation ? updateMutation.isPending : updateMutation.isLoading ?? false;
|
|
11737
11901
|
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
@@ -11742,14 +11906,14 @@ var PanelContent = (props) => {
|
|
|
11742
11906
|
errorToastRef.current = savedViewsError;
|
|
11743
11907
|
}
|
|
11744
11908
|
}, [savedViewsError, showToast, I18n]);
|
|
11745
|
-
const { data: permissions } = props.
|
|
11746
|
-
props.queryInput
|
|
11747
|
-
);
|
|
11909
|
+
const { data: permissions } = useSavedViewsPermissions(props.queryInput);
|
|
11748
11910
|
const selectedRowRef = useScrollToRef(savedViews);
|
|
11749
|
-
const { groups, toggleGroup } = useGroups();
|
|
11750
11911
|
const isTemporarySelected = selectedSavedView?.id === "temporary";
|
|
11751
11912
|
const temporaryView = savedViews?.find((view) => view.id === "temporary");
|
|
11752
11913
|
const presetViews = props.presetViews || [props.defaultView];
|
|
11914
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
11915
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11916
|
+
const { groups, toggleGroup } = useGroups(isProjectLevelTool);
|
|
11753
11917
|
const onUpdate = (data) => {
|
|
11754
11918
|
const newSavedView = {
|
|
11755
11919
|
...data,
|
|
@@ -11766,7 +11930,7 @@ var PanelContent = (props) => {
|
|
|
11766
11930
|
}
|
|
11767
11931
|
});
|
|
11768
11932
|
};
|
|
11769
|
-
return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(
|
|
11933
|
+
return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(import_core_react8.Flex, { direction: "column", style: { height: "100%", width: "100%" } }, temporaryView && /* @__PURE__ */ import_react9.default.createElement(
|
|
11770
11934
|
Row,
|
|
11771
11935
|
{
|
|
11772
11936
|
selected: isTemporarySelected,
|
|
@@ -11778,8 +11942,7 @@ var PanelContent = (props) => {
|
|
|
11778
11942
|
{
|
|
11779
11943
|
item: temporaryView,
|
|
11780
11944
|
selected: isTemporarySelected,
|
|
11781
|
-
onClearTemporary: props.onClearTemporary
|
|
11782
|
-
enableSharingViews: false
|
|
11945
|
+
onClearTemporary: props.onClearTemporary
|
|
11783
11946
|
}
|
|
11784
11947
|
)
|
|
11785
11948
|
), presetViews.map((presetView) => {
|
|
@@ -11796,12 +11959,11 @@ var PanelContent = (props) => {
|
|
|
11796
11959
|
SavedViewCollectionMenuItem,
|
|
11797
11960
|
{
|
|
11798
11961
|
item: presetView,
|
|
11799
|
-
selected: isSelected
|
|
11800
|
-
enableSharingViews: false
|
|
11962
|
+
selected: isSelected
|
|
11801
11963
|
}
|
|
11802
11964
|
)
|
|
11803
11965
|
);
|
|
11804
|
-
}),
|
|
11966
|
+
}), viewLevels.map((level) => {
|
|
11805
11967
|
const isExpanded = groups[level];
|
|
11806
11968
|
const views = isExpanded && savedViews ? savedViews.filter(
|
|
11807
11969
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
@@ -11845,8 +12007,7 @@ var PanelContent = (props) => {
|
|
|
11845
12007
|
isUpdateProcessing: isUpdateLoading,
|
|
11846
12008
|
onEdit: () => props.openModal("update" /* UPDATE */),
|
|
11847
12009
|
onDelete: props.onDelete,
|
|
11848
|
-
permissions
|
|
11849
|
-
enableSharingViews: false
|
|
12010
|
+
permissions
|
|
11850
12011
|
}
|
|
11851
12012
|
)
|
|
11852
12013
|
);
|
|
@@ -11861,16 +12022,16 @@ var import_react_query3 = require("@tanstack/react-query");
|
|
|
11861
12022
|
var import_toast_alert3 = require("@procore/toast-alert");
|
|
11862
12023
|
|
|
11863
12024
|
// src/components/modals/DeleteConfirmationModal.tsx
|
|
11864
|
-
var
|
|
12025
|
+
var import_core_react9 = require("@procore/core-react");
|
|
11865
12026
|
var import_react10 = __toESM(require("react"));
|
|
11866
12027
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
11867
12028
|
onCancel,
|
|
11868
12029
|
onDelete,
|
|
11869
12030
|
open
|
|
11870
12031
|
}) => {
|
|
11871
|
-
const i18n = (0,
|
|
12032
|
+
const i18n = (0, import_core_react9.useI18nContext)();
|
|
11872
12033
|
return /* @__PURE__ */ import_react10.default.createElement(
|
|
11873
|
-
|
|
12034
|
+
import_core_react9.ConfirmModal,
|
|
11874
12035
|
{
|
|
11875
12036
|
"data-testid": "delete-confirmation-modal",
|
|
11876
12037
|
open,
|
|
@@ -11879,8 +12040,8 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11879
12040
|
onClose: onCancel,
|
|
11880
12041
|
style: { overflowWrap: "anywhere" }
|
|
11881
12042
|
},
|
|
11882
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
11883
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
12043
|
+
/* @__PURE__ */ import_react10.default.createElement(import_core_react9.Modal.Body, null, /* @__PURE__ */ import_react10.default.createElement(import_core_react9.P, null, i18n.t("savedViews.modal.delete.description"))),
|
|
12044
|
+
/* @__PURE__ */ import_react10.default.createElement(import_core_react9.Modal.Footer, null, /* @__PURE__ */ import_react10.default.createElement(import_core_react9.Modal.FooterButtons, null, /* @__PURE__ */ import_react10.default.createElement(import_core_react9.Button, { variant: "secondary", onClick: onCancel }, i18n.t("savedViews.actions.cancel")), /* @__PURE__ */ import_react10.default.createElement(import_core_react9.Button, { variant: "primary", onClick: onDelete }, i18n.t("savedViews.actions.delete"))))
|
|
11884
12045
|
);
|
|
11885
12046
|
};
|
|
11886
12047
|
|
|
@@ -11888,7 +12049,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11888
12049
|
var import_react11 = __toESM(require("react"));
|
|
11889
12050
|
|
|
11890
12051
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
11891
|
-
var
|
|
12052
|
+
var import_core_react10 = require("@procore/core-react");
|
|
11892
12053
|
var React19 = __toESM(require("react"));
|
|
11893
12054
|
|
|
11894
12055
|
// ../../node_modules/yup/index.esm.js
|
|
@@ -14184,10 +14345,11 @@ var TupleSchema = class extends Schema {
|
|
|
14184
14345
|
create$1.prototype = TupleSchema.prototype;
|
|
14185
14346
|
|
|
14186
14347
|
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
14187
|
-
var getViewLevelOptions = (permissions, i18n) => {
|
|
14348
|
+
var getViewLevelOptions = (permissions, i18n, isProjectLevelTool = true) => {
|
|
14188
14349
|
const options = ["personal"];
|
|
14189
|
-
if (permissions?.can_create_project_saved_views)
|
|
14350
|
+
if (isProjectLevelTool && permissions?.can_create_project_saved_views) {
|
|
14190
14351
|
options.push("project");
|
|
14352
|
+
}
|
|
14191
14353
|
if (permissions?.can_create_company_saved_views)
|
|
14192
14354
|
options.push("company");
|
|
14193
14355
|
return options.map((option) => ({
|
|
@@ -14217,7 +14379,6 @@ function extractMessage(error, I18n) {
|
|
|
14217
14379
|
}
|
|
14218
14380
|
|
|
14219
14381
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14220
|
-
var { useEffect: useEffect2, useRef: useRef2 } = React19;
|
|
14221
14382
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14222
14383
|
overflow: auto;
|
|
14223
14384
|
`;
|
|
@@ -14234,38 +14395,22 @@ var FormModalBase = ({
|
|
|
14234
14395
|
defaultView,
|
|
14235
14396
|
selectedSavedView,
|
|
14236
14397
|
setOpenEditCreateModal,
|
|
14237
|
-
onSelect
|
|
14238
|
-
backend
|
|
14398
|
+
onSelect
|
|
14239
14399
|
}) => {
|
|
14240
|
-
const I18n = (0,
|
|
14400
|
+
const I18n = (0, import_core_react10.useI18nContext)();
|
|
14241
14401
|
const NAME_MAX_LENGTH = 150;
|
|
14242
|
-
const originalBodyWidth = useRef2("");
|
|
14243
|
-
useEffect2(() => {
|
|
14244
|
-
if (open) {
|
|
14245
|
-
originalBodyWidth.current = document.body.style.width || "";
|
|
14246
|
-
document.body.style.width = "100%";
|
|
14247
|
-
} else {
|
|
14248
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14249
|
-
}
|
|
14250
|
-
return () => {
|
|
14251
|
-
if (originalBodyWidth.current !== void 0) {
|
|
14252
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14253
|
-
}
|
|
14254
|
-
};
|
|
14255
|
-
}, [open]);
|
|
14256
|
-
const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
|
|
14257
14402
|
const {
|
|
14258
14403
|
mutate: createSavedView,
|
|
14259
14404
|
isPending: isCreating,
|
|
14260
14405
|
error: createError,
|
|
14261
14406
|
reset: resetCreateMutation
|
|
14262
|
-
} =
|
|
14407
|
+
} = useCreateSavedView(queryInput);
|
|
14263
14408
|
const {
|
|
14264
14409
|
mutate: updateSavedView,
|
|
14265
14410
|
isPending: isUpdating,
|
|
14266
14411
|
error: updateError,
|
|
14267
14412
|
reset: resetUpdateMutation
|
|
14268
|
-
} =
|
|
14413
|
+
} = useUpdateSavedView(queryInput);
|
|
14269
14414
|
const resetMutations = () => {
|
|
14270
14415
|
resetCreateMutation();
|
|
14271
14416
|
resetUpdateMutation();
|
|
@@ -14274,7 +14419,7 @@ var FormModalBase = ({
|
|
|
14274
14419
|
resetMutations();
|
|
14275
14420
|
onCancel();
|
|
14276
14421
|
};
|
|
14277
|
-
const { data: permissions } =
|
|
14422
|
+
const { data: permissions } = useSavedViewsPermissions(queryInput);
|
|
14278
14423
|
const isLoading = isCreating || isUpdating;
|
|
14279
14424
|
const errors = extractMessage(createError || updateError, I18n);
|
|
14280
14425
|
const handleOnSubmit = (data) => {
|
|
@@ -14305,9 +14450,14 @@ var FormModalBase = ({
|
|
|
14305
14450
|
});
|
|
14306
14451
|
}
|
|
14307
14452
|
};
|
|
14308
|
-
const
|
|
14453
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
14454
|
+
const viewLevelOptions = getViewLevelOptions(
|
|
14455
|
+
permissions,
|
|
14456
|
+
I18n,
|
|
14457
|
+
isProjectLevelTool
|
|
14458
|
+
);
|
|
14309
14459
|
return /* @__PURE__ */ React19.createElement(
|
|
14310
|
-
|
|
14460
|
+
import_core_react10.Modal,
|
|
14311
14461
|
{
|
|
14312
14462
|
"aria-label": I18n.t("savedViews.ariaLabels.modal"),
|
|
14313
14463
|
onClickOverlay: onClose,
|
|
@@ -14316,14 +14466,14 @@ var FormModalBase = ({
|
|
|
14316
14466
|
"data-testid": "create-update-modal"
|
|
14317
14467
|
},
|
|
14318
14468
|
/* @__PURE__ */ React19.createElement(ScrollContainer, null, /* @__PURE__ */ React19.createElement(
|
|
14319
|
-
|
|
14469
|
+
import_core_react10.Modal.Header,
|
|
14320
14470
|
{
|
|
14321
14471
|
onClose,
|
|
14322
|
-
style: { borderBottom: `1px solid ${
|
|
14472
|
+
style: { borderBottom: `1px solid ${import_core_react10.colors.gray85}` }
|
|
14323
14473
|
},
|
|
14324
|
-
/* @__PURE__ */ React19.createElement(
|
|
14474
|
+
/* @__PURE__ */ React19.createElement(import_core_react10.H2, null, header)
|
|
14325
14475
|
), /* @__PURE__ */ React19.createElement(
|
|
14326
|
-
|
|
14476
|
+
import_core_react10.Form,
|
|
14327
14477
|
{
|
|
14328
14478
|
initialValues: {
|
|
14329
14479
|
name: initialName,
|
|
@@ -14348,14 +14498,14 @@ var FormModalBase = ({
|
|
|
14348
14498
|
onReset: onCancel,
|
|
14349
14499
|
validateOnChange: true
|
|
14350
14500
|
},
|
|
14351
|
-
/* @__PURE__ */ React19.createElement(
|
|
14352
|
-
|
|
14501
|
+
/* @__PURE__ */ React19.createElement(import_core_react10.Form.Form, { name: header }, /* @__PURE__ */ React19.createElement(
|
|
14502
|
+
import_core_react10.Modal.Body,
|
|
14353
14503
|
{
|
|
14354
|
-
style: { paddingTop: 0, paddingBottom: 0, marginTop:
|
|
14504
|
+
style: { paddingTop: 0, paddingBottom: 0, marginTop: import_core_react10.spacing.lg }
|
|
14355
14505
|
},
|
|
14356
|
-
errors && /* @__PURE__ */ React19.createElement(
|
|
14357
|
-
/* @__PURE__ */ React19.createElement(
|
|
14358
|
-
|
|
14506
|
+
errors && /* @__PURE__ */ React19.createElement(import_core_react10.ErrorBanner, { style: { marginBottom: import_core_react10.spacing.xl } }, /* @__PURE__ */ React19.createElement(import_core_react10.Banner.Content, null, /* @__PURE__ */ React19.createElement(import_core_react10.Banner.Title, null, I18n.t("savedViews.modal.errors.title", { mode })), /* @__PURE__ */ React19.createElement(import_core_react10.Banner.Body, null, errors?.form || I18n.t(`savedViews.modal.errors.description.${mode}`)))),
|
|
14507
|
+
/* @__PURE__ */ React19.createElement(import_core_react10.Form.Row, null, /* @__PURE__ */ React19.createElement(
|
|
14508
|
+
import_core_react10.Form.Text,
|
|
14359
14509
|
{
|
|
14360
14510
|
name: "name",
|
|
14361
14511
|
error: errors?.name,
|
|
@@ -14366,12 +14516,12 @@ var FormModalBase = ({
|
|
|
14366
14516
|
}
|
|
14367
14517
|
)),
|
|
14368
14518
|
/* @__PURE__ */ React19.createElement(
|
|
14369
|
-
|
|
14519
|
+
import_core_react10.Form.Row,
|
|
14370
14520
|
{
|
|
14371
|
-
style: { marginTop: errors?.name ?
|
|
14521
|
+
style: { marginTop: errors?.name ? import_core_react10.spacing.xl : import_core_react10.spacing.none }
|
|
14372
14522
|
},
|
|
14373
14523
|
/* @__PURE__ */ React19.createElement(
|
|
14374
|
-
|
|
14524
|
+
import_core_react10.Form.TextArea,
|
|
14375
14525
|
{
|
|
14376
14526
|
name: "description",
|
|
14377
14527
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14381,11 +14531,10 @@ var FormModalBase = ({
|
|
|
14381
14531
|
}
|
|
14382
14532
|
)
|
|
14383
14533
|
),
|
|
14384
|
-
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(
|
|
14385
|
-
|
|
14534
|
+
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(import_core_react10.Form.Row, null, /* @__PURE__ */ React19.createElement(
|
|
14535
|
+
import_core_react10.Form.Select,
|
|
14386
14536
|
{
|
|
14387
14537
|
name: "view_level",
|
|
14388
|
-
qa: { label: "view-level" },
|
|
14389
14538
|
options: viewLevelOptions,
|
|
14390
14539
|
label: I18n.t("savedViews.modal.fields.viewLevel"),
|
|
14391
14540
|
colWidth: 12,
|
|
@@ -14393,8 +14542,8 @@ var FormModalBase = ({
|
|
|
14393
14542
|
onClear: false
|
|
14394
14543
|
}
|
|
14395
14544
|
)) : /* @__PURE__ */ React19.createElement(React19.Fragment, null)
|
|
14396
|
-
), /* @__PURE__ */ React19.createElement(
|
|
14397
|
-
|
|
14545
|
+
), /* @__PURE__ */ React19.createElement(import_core_react10.Modal.Footer, { style: { borderTop: `1px solid ${import_core_react10.colors.gray85}` } }, /* @__PURE__ */ React19.createElement(import_core_react10.Flex, { grow: "1", justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React19.createElement(import_core_react10.Typography, { color: "gray45", italic: true }, /* @__PURE__ */ React19.createElement(import_core_react10.Typography, { color: "red45" }, "*"), " ", I18n.t("savedViews.modal.info.required_fields")), /* @__PURE__ */ React19.createElement(import_core_react10.Modal.FooterButtons, null, /* @__PURE__ */ React19.createElement(import_core_react10.Button, { type: "reset", variant: "tertiary", disabled: isLoading }, I18n.t("savedViews.actions.cancel")), /* @__PURE__ */ React19.createElement(
|
|
14546
|
+
import_core_react10.Button,
|
|
14398
14547
|
{
|
|
14399
14548
|
"data-testid": "create-update-modal-button",
|
|
14400
14549
|
type: "submit",
|
|
@@ -14409,7 +14558,7 @@ var FormModalBase = ({
|
|
|
14409
14558
|
};
|
|
14410
14559
|
|
|
14411
14560
|
// src/components/modals/form-modal/FormModal.tsx
|
|
14412
|
-
var
|
|
14561
|
+
var import_core_react11 = require("@procore/core-react");
|
|
14413
14562
|
var FormModal = ({
|
|
14414
14563
|
open,
|
|
14415
14564
|
mode,
|
|
@@ -14420,10 +14569,9 @@ var FormModal = ({
|
|
|
14420
14569
|
selectedSavedView,
|
|
14421
14570
|
setOpenEditCreateModal,
|
|
14422
14571
|
onSelect,
|
|
14423
|
-
defaultView
|
|
14424
|
-
backend
|
|
14572
|
+
defaultView
|
|
14425
14573
|
}) => {
|
|
14426
|
-
const i18n = (0,
|
|
14574
|
+
const i18n = (0, import_core_react11.useI18nContext)();
|
|
14427
14575
|
return /* @__PURE__ */ import_react11.default.createElement(
|
|
14428
14576
|
FormModalBase,
|
|
14429
14577
|
{
|
|
@@ -14439,14 +14587,13 @@ var FormModal = ({
|
|
|
14439
14587
|
selectedSavedView,
|
|
14440
14588
|
setOpenEditCreateModal,
|
|
14441
14589
|
onSelect,
|
|
14442
|
-
defaultView
|
|
14443
|
-
backend
|
|
14590
|
+
defaultView
|
|
14444
14591
|
}
|
|
14445
14592
|
);
|
|
14446
14593
|
};
|
|
14447
14594
|
|
|
14448
14595
|
// src/components/modals/form-modal/SharedViewFormModal.tsx
|
|
14449
|
-
var
|
|
14596
|
+
var import_core_react12 = require("@procore/core-react");
|
|
14450
14597
|
var React21 = __toESM(require("react"));
|
|
14451
14598
|
var SharedViewFormModal = ({
|
|
14452
14599
|
open,
|
|
@@ -14458,7 +14605,7 @@ var SharedViewFormModal = ({
|
|
|
14458
14605
|
isCreating,
|
|
14459
14606
|
resetCreateError
|
|
14460
14607
|
}) => {
|
|
14461
|
-
const I18n = (0,
|
|
14608
|
+
const I18n = (0, import_core_react12.useI18nContext)();
|
|
14462
14609
|
const NAME_MAX_LENGTH = 150;
|
|
14463
14610
|
const errors = extractMessage(createError, I18n);
|
|
14464
14611
|
const handleNameChange = () => {
|
|
@@ -14470,7 +14617,7 @@ var SharedViewFormModal = ({
|
|
|
14470
14617
|
onCreateView(data.name, data.description);
|
|
14471
14618
|
};
|
|
14472
14619
|
return /* @__PURE__ */ React21.createElement(
|
|
14473
|
-
|
|
14620
|
+
import_core_react12.Modal,
|
|
14474
14621
|
{
|
|
14475
14622
|
"data-testid": "shared-view-form-modal",
|
|
14476
14623
|
open,
|
|
@@ -14478,35 +14625,35 @@ var SharedViewFormModal = ({
|
|
|
14478
14625
|
style: { width: "540px" }
|
|
14479
14626
|
},
|
|
14480
14627
|
/* @__PURE__ */ React21.createElement(
|
|
14481
|
-
|
|
14628
|
+
import_core_react12.Modal.Header,
|
|
14482
14629
|
{
|
|
14483
14630
|
onClose,
|
|
14484
14631
|
style: {
|
|
14485
|
-
paddingTop:
|
|
14486
|
-
paddingBottom:
|
|
14487
|
-
paddingLeft:
|
|
14488
|
-
paddingRight:
|
|
14632
|
+
paddingTop: import_core_react12.spacing.lg,
|
|
14633
|
+
paddingBottom: import_core_react12.spacing.xs,
|
|
14634
|
+
paddingLeft: import_core_react12.spacing.xl,
|
|
14635
|
+
paddingRight: import_core_react12.spacing.xl
|
|
14489
14636
|
}
|
|
14490
14637
|
},
|
|
14491
14638
|
I18n.t("savedViews.modal.create.title")
|
|
14492
14639
|
),
|
|
14493
14640
|
/* @__PURE__ */ React21.createElement(
|
|
14494
|
-
|
|
14641
|
+
import_core_react12.P,
|
|
14495
14642
|
{
|
|
14496
14643
|
style: {
|
|
14497
|
-
paddingLeft:
|
|
14498
|
-
paddingRight:
|
|
14499
|
-
paddingBottom:
|
|
14500
|
-
paddingTop:
|
|
14644
|
+
paddingLeft: import_core_react12.spacing.xl,
|
|
14645
|
+
paddingRight: import_core_react12.spacing.xl,
|
|
14646
|
+
paddingBottom: import_core_react12.spacing.lg,
|
|
14647
|
+
paddingTop: import_core_react12.spacing.none,
|
|
14501
14648
|
margin: 0,
|
|
14502
|
-
color:
|
|
14649
|
+
color: import_core_react12.colors.gray45,
|
|
14503
14650
|
whiteSpace: "pre-line"
|
|
14504
14651
|
}
|
|
14505
14652
|
},
|
|
14506
14653
|
I18n.t("savedViews.modal.copyConfirmation.description")
|
|
14507
14654
|
),
|
|
14508
14655
|
/* @__PURE__ */ React21.createElement(
|
|
14509
|
-
|
|
14656
|
+
import_core_react12.Form,
|
|
14510
14657
|
{
|
|
14511
14658
|
initialValues: {
|
|
14512
14659
|
name: fetchedView.name,
|
|
@@ -14524,20 +14671,20 @@ var SharedViewFormModal = ({
|
|
|
14524
14671
|
onSubmit: handleOnSubmit,
|
|
14525
14672
|
validateOnChange: true
|
|
14526
14673
|
},
|
|
14527
|
-
/* @__PURE__ */ React21.createElement(
|
|
14528
|
-
|
|
14674
|
+
/* @__PURE__ */ React21.createElement(import_core_react12.Form.Form, { name: "share-view-form" }, /* @__PURE__ */ React21.createElement(
|
|
14675
|
+
import_core_react12.Modal.Body,
|
|
14529
14676
|
{
|
|
14530
14677
|
style: {
|
|
14531
|
-
paddingTop:
|
|
14678
|
+
paddingTop: import_core_react12.spacing.lg,
|
|
14532
14679
|
paddingBottom: 0,
|
|
14533
|
-
borderTop: `1px solid ${
|
|
14680
|
+
borderTop: `1px solid ${import_core_react12.colors.gray85}`
|
|
14534
14681
|
}
|
|
14535
14682
|
},
|
|
14536
|
-
errors && /* @__PURE__ */ React21.createElement(
|
|
14683
|
+
errors && /* @__PURE__ */ React21.createElement(import_core_react12.ErrorBanner, { style: { marginBottom: import_core_react12.spacing.xl } }, /* @__PURE__ */ React21.createElement(import_core_react12.Banner.Content, null, /* @__PURE__ */ React21.createElement(import_core_react12.Banner.Title, null, I18n.t("savedViews.modal.errors.title", {
|
|
14537
14684
|
mode: "create"
|
|
14538
|
-
})), /* @__PURE__ */ React21.createElement(
|
|
14539
|
-
/* @__PURE__ */ React21.createElement(
|
|
14540
|
-
|
|
14685
|
+
})), /* @__PURE__ */ React21.createElement(import_core_react12.Banner.Body, null, errors?.form || I18n.t("savedViews.modal.errors.description.create")))),
|
|
14686
|
+
/* @__PURE__ */ React21.createElement(import_core_react12.Form.Row, null, /* @__PURE__ */ React21.createElement(
|
|
14687
|
+
import_core_react12.Form.Text,
|
|
14541
14688
|
{
|
|
14542
14689
|
name: "name",
|
|
14543
14690
|
error: errors?.name,
|
|
@@ -14548,12 +14695,12 @@ var SharedViewFormModal = ({
|
|
|
14548
14695
|
}
|
|
14549
14696
|
)),
|
|
14550
14697
|
/* @__PURE__ */ React21.createElement(
|
|
14551
|
-
|
|
14698
|
+
import_core_react12.Form.Row,
|
|
14552
14699
|
{
|
|
14553
|
-
style: { marginTop: errors?.name ?
|
|
14700
|
+
style: { marginTop: errors?.name ? import_core_react12.spacing.xl : import_core_react12.spacing.none }
|
|
14554
14701
|
},
|
|
14555
14702
|
/* @__PURE__ */ React21.createElement(
|
|
14556
|
-
|
|
14703
|
+
import_core_react12.Form.TextArea,
|
|
14557
14704
|
{
|
|
14558
14705
|
name: "description",
|
|
14559
14706
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14563,8 +14710,8 @@ var SharedViewFormModal = ({
|
|
|
14563
14710
|
}
|
|
14564
14711
|
)
|
|
14565
14712
|
)
|
|
14566
|
-
), /* @__PURE__ */ React21.createElement(
|
|
14567
|
-
|
|
14713
|
+
), /* @__PURE__ */ React21.createElement(import_core_react12.Modal.Footer, { style: { borderTop: `1px solid ${import_core_react12.colors.gray85}` } }, /* @__PURE__ */ React21.createElement(import_core_react12.Flex, { grow: "1", justifyContent: "space-between", alignItems: "center" }, /* @__PURE__ */ React21.createElement(import_core_react12.Typography, { color: "gray45", italic: true }, /* @__PURE__ */ React21.createElement(import_core_react12.Typography, { color: "red45" }, "*"), " ", I18n.t("savedViews.modal.info.required_fields")), /* @__PURE__ */ React21.createElement(import_core_react12.Modal.FooterButtons, null, /* @__PURE__ */ React21.createElement(
|
|
14714
|
+
import_core_react12.Button,
|
|
14568
14715
|
{
|
|
14569
14716
|
variant: "secondary",
|
|
14570
14717
|
onClick: onCreateTemporaryView,
|
|
@@ -14573,7 +14720,7 @@ var SharedViewFormModal = ({
|
|
|
14573
14720
|
},
|
|
14574
14721
|
I18n.t("savedViews.actions.viewTemporarily")
|
|
14575
14722
|
), /* @__PURE__ */ React21.createElement(
|
|
14576
|
-
|
|
14723
|
+
import_core_react12.Button,
|
|
14577
14724
|
{
|
|
14578
14725
|
type: "submit",
|
|
14579
14726
|
variant: "primary",
|
|
@@ -14590,7 +14737,7 @@ var SharedViewFormModal = ({
|
|
|
14590
14737
|
// src/utils/hooks/useViewSelection.ts
|
|
14591
14738
|
var import_react12 = require("react");
|
|
14592
14739
|
var import_react_router_dom = require("react-router-dom");
|
|
14593
|
-
var
|
|
14740
|
+
var import_core_react13 = require("@procore/core-react");
|
|
14594
14741
|
|
|
14595
14742
|
// src/utils/viewStorage.ts
|
|
14596
14743
|
var ViewStorage = {
|
|
@@ -14653,8 +14800,9 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
14653
14800
|
}
|
|
14654
14801
|
};
|
|
14655
14802
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
14656
|
-
const I18n = (0,
|
|
14657
|
-
const
|
|
14803
|
+
const I18n = (0, import_core_react13.useI18nContext)();
|
|
14804
|
+
const projectIdSegment = config.projectId ?? "company";
|
|
14805
|
+
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
14658
14806
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14659
14807
|
const [searchParams, setSearchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
14660
14808
|
const previousSavedViewParamRef = (0, import_react12.useRef)(null);
|
|
@@ -14752,177 +14900,6 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14752
14900
|
};
|
|
14753
14901
|
};
|
|
14754
14902
|
|
|
14755
|
-
// node_modules/@procore/core-http/dist/modern/index.js
|
|
14756
|
-
function getCSRFToken() {
|
|
14757
|
-
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
14758
|
-
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
14759
|
-
}
|
|
14760
|
-
function getCSRFHeader() {
|
|
14761
|
-
const csrfToken = getCSRFToken();
|
|
14762
|
-
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
14763
|
-
}
|
|
14764
|
-
function removeLeadingSlash(url) {
|
|
14765
|
-
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
14766
|
-
}
|
|
14767
|
-
function removeTrailingSlash(url) {
|
|
14768
|
-
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
14769
|
-
}
|
|
14770
|
-
function applyBaseUrl(url, baseUrl) {
|
|
14771
|
-
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
14772
|
-
}
|
|
14773
|
-
function getOptions({ headers, ...options }) {
|
|
14774
|
-
const opts = {
|
|
14775
|
-
credentials: "same-origin",
|
|
14776
|
-
headers: {
|
|
14777
|
-
...getCSRFHeader(),
|
|
14778
|
-
...headers
|
|
14779
|
-
},
|
|
14780
|
-
mode: "same-origin",
|
|
14781
|
-
...options
|
|
14782
|
-
};
|
|
14783
|
-
return opts;
|
|
14784
|
-
}
|
|
14785
|
-
function getUrl(url, baseUrl) {
|
|
14786
|
-
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
14787
|
-
}
|
|
14788
|
-
function request(url, { baseUrl, ...options } = {}) {
|
|
14789
|
-
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
14790
|
-
}
|
|
14791
|
-
function requestJSON(url, requestParams = {}) {
|
|
14792
|
-
return request(url, requestParams).then(
|
|
14793
|
-
(response) => response.json()
|
|
14794
|
-
);
|
|
14795
|
-
}
|
|
14796
|
-
|
|
14797
|
-
// src/utils/api/queries.ts
|
|
14798
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
14799
|
-
|
|
14800
|
-
// src/utils/api/queriesHandler.ts
|
|
14801
|
-
var import_react_query = require("@tanstack/react-query");
|
|
14802
|
-
var import_core_react13 = require("@procore/core-react");
|
|
14803
|
-
var useApiRequest = (props, method, mutationKey) => {
|
|
14804
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14805
|
-
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
14806
|
-
const { locale: locale2 } = (0, import_core_react13.useI18nContext)();
|
|
14807
|
-
return (0, import_react_query.useMutation)({
|
|
14808
|
-
mutationKey,
|
|
14809
|
-
mutationFn: async (savedView) => {
|
|
14810
|
-
let url = "";
|
|
14811
|
-
if (method === "DELETE" || method === "PUT") {
|
|
14812
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.share_token}?permissions_domain=${domain}`;
|
|
14813
|
-
} else {
|
|
14814
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14815
|
-
}
|
|
14816
|
-
const response = await requestJSON(url, {
|
|
14817
|
-
method,
|
|
14818
|
-
body: JSON.stringify(savedView),
|
|
14819
|
-
headers: {
|
|
14820
|
-
"Content-Type": "application/json",
|
|
14821
|
-
"Accept-Language": locale2
|
|
14822
|
-
}
|
|
14823
|
-
});
|
|
14824
|
-
if (response.error) {
|
|
14825
|
-
throw response.error;
|
|
14826
|
-
}
|
|
14827
|
-
return response.data;
|
|
14828
|
-
},
|
|
14829
|
-
onSuccess: (savedView) => {
|
|
14830
|
-
if (method === "DELETE" || method === "POST") {
|
|
14831
|
-
queryClient2.invalidateQueries({
|
|
14832
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14833
|
-
});
|
|
14834
|
-
return;
|
|
14835
|
-
} else {
|
|
14836
|
-
const oldData = queryClient2.getQueryData([
|
|
14837
|
-
"savedViews",
|
|
14838
|
-
domain,
|
|
14839
|
-
tableName
|
|
14840
|
-
]);
|
|
14841
|
-
const oldView = oldData?.find(
|
|
14842
|
-
(item) => item.share_token === savedView.share_token
|
|
14843
|
-
);
|
|
14844
|
-
if (oldView?.name !== savedView.name) {
|
|
14845
|
-
queryClient2.invalidateQueries({
|
|
14846
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14847
|
-
});
|
|
14848
|
-
return;
|
|
14849
|
-
}
|
|
14850
|
-
}
|
|
14851
|
-
queryClient2.setQueryData(
|
|
14852
|
-
["savedViews", domain, tableName],
|
|
14853
|
-
(oldData) => {
|
|
14854
|
-
if (!oldData)
|
|
14855
|
-
return [savedView];
|
|
14856
|
-
return oldData.map(
|
|
14857
|
-
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
14858
|
-
);
|
|
14859
|
-
}
|
|
14860
|
-
);
|
|
14861
|
-
}
|
|
14862
|
-
});
|
|
14863
|
-
};
|
|
14864
|
-
|
|
14865
|
-
// src/utils/api/queries.ts
|
|
14866
|
-
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
14867
|
-
var useSavedViewsQuery = (props) => {
|
|
14868
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14869
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14870
|
-
return (0, import_react_query2.useQuery)({
|
|
14871
|
-
queryKey: ["savedViews", domain, tableName],
|
|
14872
|
-
queryFn: async () => {
|
|
14873
|
-
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
14874
|
-
const response = await requestJSON(getUrl2);
|
|
14875
|
-
return response.data;
|
|
14876
|
-
}
|
|
14877
|
-
});
|
|
14878
|
-
};
|
|
14879
|
-
var useSavedViewsPermissions = (props) => {
|
|
14880
|
-
const { projectId, companyId, domain } = props;
|
|
14881
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
14882
|
-
return (0, import_react_query2.useQuery)({
|
|
14883
|
-
queryKey: ["savedViewsConfig", domain],
|
|
14884
|
-
queryFn: async () => {
|
|
14885
|
-
const response = await requestJSON(url);
|
|
14886
|
-
return response.data;
|
|
14887
|
-
}
|
|
14888
|
-
});
|
|
14889
|
-
};
|
|
14890
|
-
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
14891
|
-
"createSavedView",
|
|
14892
|
-
props.domain,
|
|
14893
|
-
props.tableName
|
|
14894
|
-
]);
|
|
14895
|
-
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
14896
|
-
"updateSavedView",
|
|
14897
|
-
props.domain,
|
|
14898
|
-
props.tableName
|
|
14899
|
-
]);
|
|
14900
|
-
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
14901
|
-
"deleteSavedView",
|
|
14902
|
-
props.domain,
|
|
14903
|
-
props.tableName
|
|
14904
|
-
]);
|
|
14905
|
-
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
14906
|
-
const { projectId, companyId } = queryInput;
|
|
14907
|
-
return (0, import_react_query2.useQuery)({
|
|
14908
|
-
enabled: enabled && Boolean(savedViewToken),
|
|
14909
|
-
queryKey: ["savedView", savedViewToken],
|
|
14910
|
-
queryFn: async () => {
|
|
14911
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedViewToken}`;
|
|
14912
|
-
const response = await requestJSON(url);
|
|
14913
|
-
return response.data;
|
|
14914
|
-
}
|
|
14915
|
-
});
|
|
14916
|
-
};
|
|
14917
|
-
var createQueries = (customBackend) => ({
|
|
14918
|
-
useSavedViewsQuery: customBackend?.useSavedViewsQuery ?? useSavedViewsQuery,
|
|
14919
|
-
useSavedViewsPermissions: customBackend?.useSavedViewsPermissions ?? useSavedViewsPermissions,
|
|
14920
|
-
useCreateSavedView: customBackend?.useCreateSavedView ?? useCreateSavedView,
|
|
14921
|
-
useUpdateSavedView: customBackend?.useUpdateSavedView ?? useUpdateSavedView,
|
|
14922
|
-
useDeleteSavedView: customBackend?.useDeleteSavedView ?? useDeleteSavedView,
|
|
14923
|
-
useFetchSavedViewById: customBackend?.useFetchSavedViewById ?? useFetchSavedViewById
|
|
14924
|
-
});
|
|
14925
|
-
|
|
14926
14903
|
// src/components/saved-views/SavedViews.tsx
|
|
14927
14904
|
var StyledPanel = styled_components_esm_default.div`
|
|
14928
14905
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
@@ -14930,15 +14907,14 @@ var StyledPanel = styled_components_esm_default.div`
|
|
|
14930
14907
|
var queryClient = new import_react_query3.QueryClient();
|
|
14931
14908
|
var SavedViewsContent = (props) => {
|
|
14932
14909
|
const { projectId, companyId } = props;
|
|
14933
|
-
const backend = createQueries(props.backend);
|
|
14934
14910
|
const queryInput = {
|
|
14935
14911
|
domain: props.domain,
|
|
14936
14912
|
tableName: props.tableName,
|
|
14937
14913
|
projectId,
|
|
14938
14914
|
companyId
|
|
14939
14915
|
};
|
|
14940
|
-
const { data: savedViews } =
|
|
14941
|
-
const { mutate: deleteSavedView } =
|
|
14916
|
+
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14917
|
+
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14942
14918
|
const { showToast } = (0, import_toast_alert3.useToastAlertContext)();
|
|
14943
14919
|
const i18n = (0, import_core_react14.useI18nContext)();
|
|
14944
14920
|
const [activeModal, setActiveModal] = (0, import_react13.useState)(null);
|
|
@@ -14975,7 +14951,7 @@ var SavedViewsContent = (props) => {
|
|
|
14975
14951
|
props.presetViews,
|
|
14976
14952
|
openSharedViewModal
|
|
14977
14953
|
);
|
|
14978
|
-
const { data: fetchedView, isError: fetchError } =
|
|
14954
|
+
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
14979
14955
|
modalData?.viewId ?? null,
|
|
14980
14956
|
queryInput,
|
|
14981
14957
|
Boolean(modalData?.viewId)
|
|
@@ -14985,7 +14961,7 @@ var SavedViewsContent = (props) => {
|
|
|
14985
14961
|
isPending: isCreating,
|
|
14986
14962
|
error: createError,
|
|
14987
14963
|
reset: resetCreateError
|
|
14988
|
-
} =
|
|
14964
|
+
} = useCreateSavedView(queryInput);
|
|
14989
14965
|
(0, import_react13.useEffect)(() => {
|
|
14990
14966
|
if (fetchError) {
|
|
14991
14967
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
@@ -15072,8 +15048,7 @@ var SavedViewsContent = (props) => {
|
|
|
15072
15048
|
savedViews: allViews,
|
|
15073
15049
|
provider: props.provider,
|
|
15074
15050
|
userId: props.userId,
|
|
15075
|
-
onClearTemporary: clearTemporaryView
|
|
15076
|
-
backend
|
|
15051
|
+
onClearTemporary: clearTemporaryView
|
|
15077
15052
|
}
|
|
15078
15053
|
))
|
|
15079
15054
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -15088,8 +15063,7 @@ var SavedViewsContent = (props) => {
|
|
|
15088
15063
|
selectedSavedView: selectedView,
|
|
15089
15064
|
onSelect: selectView,
|
|
15090
15065
|
setOpenEditCreateModal: closeModal,
|
|
15091
|
-
defaultView: props.defaultView
|
|
15092
|
-
backend
|
|
15066
|
+
defaultView: props.defaultView
|
|
15093
15067
|
}
|
|
15094
15068
|
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ import_react13.default.createElement(
|
|
15095
15069
|
SavedViewsDeleteConfirmationModalShared,
|
|
@@ -15134,37 +15108,27 @@ var DEFAULT_COLUMN_STATE = {
|
|
|
15134
15108
|
rowGroupIndex: null,
|
|
15135
15109
|
flex: null
|
|
15136
15110
|
};
|
|
15137
|
-
var
|
|
15138
|
-
return "children" in colDef && Array.isArray(colDef.children);
|
|
15139
|
-
};
|
|
15111
|
+
var flattenColumnDefs = (defs) => defs.flatMap((d) => "children" in d ? flattenColumnDefs(d.children) : [d]);
|
|
15140
15112
|
var getColumnStateFromDefs = (columnDefs) => {
|
|
15141
|
-
return columnDefs.
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
return
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
sortIndex: null,
|
|
15161
|
-
pivot: false,
|
|
15162
|
-
pivotIndex: null,
|
|
15163
|
-
aggFunc: null,
|
|
15164
|
-
rowGroup: false,
|
|
15165
|
-
rowGroupIndex: null,
|
|
15166
|
-
flex: colDef.flex ?? null
|
|
15167
|
-
};
|
|
15113
|
+
return flattenColumnDefs(columnDefs).map((colDef) => {
|
|
15114
|
+
const field = colDef.field ?? colDef.colId;
|
|
15115
|
+
if (!field)
|
|
15116
|
+
return null;
|
|
15117
|
+
return {
|
|
15118
|
+
colId: field,
|
|
15119
|
+
hide: colDef.hide ?? false,
|
|
15120
|
+
pinned: colDef.pinned ?? null,
|
|
15121
|
+
width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
|
|
15122
|
+
sort: null,
|
|
15123
|
+
sortIndex: null,
|
|
15124
|
+
pivot: false,
|
|
15125
|
+
pivotIndex: null,
|
|
15126
|
+
aggFunc: null,
|
|
15127
|
+
rowGroup: false,
|
|
15128
|
+
rowGroupIndex: null,
|
|
15129
|
+
flex: colDef.flex ?? null
|
|
15130
|
+
};
|
|
15131
|
+
}).filter((col) => col !== null);
|
|
15168
15132
|
};
|
|
15169
15133
|
var extractDefaultView = (gridApi, receivedConfig) => {
|
|
15170
15134
|
const columnDefs = gridApi.getColumnDefs() ?? [];
|
|
@@ -15210,14 +15174,10 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15210
15174
|
const [config, setConfig] = (0, import_react15.useState)(
|
|
15211
15175
|
() => getSmartGridConfig(gridApi)
|
|
15212
15176
|
);
|
|
15213
|
-
const eventListenersDisabledRef = (0, import_react15.useRef)(false);
|
|
15214
15177
|
(0, import_react15.useEffect)(() => {
|
|
15215
15178
|
if (!gridApi)
|
|
15216
15179
|
return;
|
|
15217
15180
|
const updateConfig = () => {
|
|
15218
|
-
if (eventListenersDisabledRef.current) {
|
|
15219
|
-
return;
|
|
15220
|
-
}
|
|
15221
15181
|
setConfig(getSmartGridConfig(gridApi));
|
|
15222
15182
|
};
|
|
15223
15183
|
GRID_STATE_EVENTS.forEach((event) => {
|
|
@@ -15229,24 +15189,13 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15229
15189
|
});
|
|
15230
15190
|
};
|
|
15231
15191
|
}, [gridApi]);
|
|
15232
|
-
|
|
15233
|
-
eventListenersDisabledRef.current = true;
|
|
15234
|
-
};
|
|
15235
|
-
const enableEventListeners = () => {
|
|
15236
|
-
eventListenersDisabledRef.current = false;
|
|
15237
|
-
};
|
|
15238
|
-
return { config, setConfig, disableEventListeners, enableEventListeners };
|
|
15192
|
+
return { config, setConfig };
|
|
15239
15193
|
};
|
|
15240
15194
|
|
|
15241
15195
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15242
15196
|
var SmartGridSavedViews = (props) => {
|
|
15243
15197
|
const { gridApi, userId, projectId, companyId } = props;
|
|
15244
|
-
const {
|
|
15245
|
-
config: tableConfig,
|
|
15246
|
-
setConfig: setTableConfig,
|
|
15247
|
-
disableEventListeners,
|
|
15248
|
-
enableEventListeners
|
|
15249
|
-
} = useSmartGridConfig(gridApi);
|
|
15198
|
+
const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
|
|
15250
15199
|
const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
|
|
15251
15200
|
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15252
15201
|
const onSelect = (0, import_react16.useCallback)(
|
|
@@ -15254,29 +15203,20 @@ var SmartGridSavedViews = (props) => {
|
|
|
15254
15203
|
if (!gridApi)
|
|
15255
15204
|
return item;
|
|
15256
15205
|
const isPresetView = item.view_level === "default";
|
|
15257
|
-
const newConfig = item.table_config;
|
|
15258
|
-
const transformedConfig = props.transformSettings?.(newConfig) ?? newConfig;
|
|
15259
|
-
disableEventListeners();
|
|
15260
15206
|
if (isPresetView) {
|
|
15261
15207
|
updateTableConfig(item, gridApi, "smart-grid");
|
|
15262
|
-
setTableConfig(
|
|
15263
|
-
setTimeout(() => {
|
|
15264
|
-
enableEventListeners();
|
|
15265
|
-
}, 0);
|
|
15208
|
+
setTableConfig(item.table_config);
|
|
15266
15209
|
return item;
|
|
15267
15210
|
}
|
|
15268
15211
|
const updatedView = {
|
|
15269
15212
|
...item,
|
|
15270
15213
|
table_config: customAndConfigSync(
|
|
15271
|
-
|
|
15214
|
+
item.table_config,
|
|
15272
15215
|
tableConfig
|
|
15273
15216
|
)
|
|
15274
15217
|
};
|
|
15275
15218
|
updateTableConfig(updatedView, gridApi, "smart-grid");
|
|
15276
15219
|
setTableConfig(updatedView.table_config);
|
|
15277
|
-
setTimeout(() => {
|
|
15278
|
-
enableEventListeners();
|
|
15279
|
-
}, 0);
|
|
15280
15220
|
return updatedView;
|
|
15281
15221
|
},
|
|
15282
15222
|
[gridApi, tableConfig, setTableConfig]
|
|
@@ -15293,8 +15233,7 @@ var SmartGridSavedViews = (props) => {
|
|
|
15293
15233
|
defaultView,
|
|
15294
15234
|
presetViews,
|
|
15295
15235
|
tableName: props.tableName,
|
|
15296
|
-
tableConfig
|
|
15297
|
-
backend: props.backend
|
|
15236
|
+
tableConfig
|
|
15298
15237
|
}
|
|
15299
15238
|
);
|
|
15300
15239
|
};
|