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