@procore/saved-views 1.0.1-alpha.2 → 1.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/legacy/index.d.mts +11 -30
- package/dist/legacy/index.d.ts +11 -30
- package/dist/legacy/index.js +343 -377
- package/dist/legacy/index.mjs +290 -324
- package/dist/modern/index.d.mts +11 -30
- package/dist/modern/index.d.ts +11 -30
- package/dist/modern/index.js +343 -376
- package/dist/modern/index.mjs +290 -323
- 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,199 @@ 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 queryKeyContext = projectId ?? companyId;
|
|
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: ["savedViews", domain, tableName, queryKeyContext]
|
|
11530
|
+
});
|
|
11531
|
+
return;
|
|
11532
|
+
} else {
|
|
11533
|
+
const oldData = queryClient2.getQueryData([
|
|
11534
|
+
"savedViews",
|
|
11535
|
+
domain,
|
|
11536
|
+
tableName,
|
|
11537
|
+
queryKeyContext
|
|
11538
|
+
]);
|
|
11539
|
+
const oldView = oldData?.find(
|
|
11540
|
+
(item) => item.share_token === savedView.share_token
|
|
11541
|
+
);
|
|
11542
|
+
if (oldView?.name !== savedView.name) {
|
|
11543
|
+
queryClient2.invalidateQueries({
|
|
11544
|
+
queryKey: ["savedViews", domain, tableName, queryKeyContext]
|
|
11545
|
+
});
|
|
11546
|
+
return;
|
|
11547
|
+
}
|
|
11548
|
+
}
|
|
11549
|
+
queryClient2.setQueryData(
|
|
11550
|
+
["savedViews", domain, tableName, queryKeyContext],
|
|
11551
|
+
(oldData) => {
|
|
11552
|
+
if (!oldData)
|
|
11553
|
+
return [savedView];
|
|
11554
|
+
return oldData.map(
|
|
11555
|
+
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
11556
|
+
);
|
|
11557
|
+
}
|
|
11558
|
+
);
|
|
11559
|
+
}
|
|
11560
|
+
});
|
|
11561
|
+
};
|
|
11562
|
+
|
|
11444
11563
|
// src/utils/constants/viewLevels.ts
|
|
11445
|
-
var
|
|
11564
|
+
var PROJECT_LEVEL_TOOL_VIEW_LEVELS = [
|
|
11565
|
+
"company",
|
|
11566
|
+
"project",
|
|
11567
|
+
"personal"
|
|
11568
|
+
];
|
|
11569
|
+
var COMPANY_LEVEL_TOOL_VIEW_LEVELS = ["company", "personal"];
|
|
11570
|
+
var getViewLevels = (isProjectLevelTool) => isProjectLevelTool ? PROJECT_LEVEL_TOOL_VIEW_LEVELS : COMPANY_LEVEL_TOOL_VIEW_LEVELS;
|
|
11571
|
+
|
|
11572
|
+
// src/utils/api/queries.ts
|
|
11573
|
+
var PAGE_SIZE = 50 * PROJECT_LEVEL_TOOL_VIEW_LEVELS.length;
|
|
11574
|
+
var getBasePath2 = (companyId, projectId) => {
|
|
11575
|
+
if (projectId) {
|
|
11576
|
+
return `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views`;
|
|
11577
|
+
}
|
|
11578
|
+
return `/rest/v2.0/companies/${companyId}/saved_views`;
|
|
11579
|
+
};
|
|
11580
|
+
var useSavedViewsQuery = (props) => {
|
|
11581
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
11582
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11583
|
+
const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11584
|
+
return (0, import_react_query2.useQuery)({
|
|
11585
|
+
queryKey: ["savedViews", domain, tableName, projectId ?? companyId],
|
|
11586
|
+
queryFn: async () => {
|
|
11587
|
+
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
11588
|
+
const response = await requestJSON(getUrl2);
|
|
11589
|
+
return response.data;
|
|
11590
|
+
}
|
|
11591
|
+
});
|
|
11592
|
+
};
|
|
11593
|
+
var useSavedViewsPermissions = (props) => {
|
|
11594
|
+
const { projectId, companyId, domain } = props;
|
|
11595
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11596
|
+
const url = `${basePath}/permissions?permissions_domain=${domain}`;
|
|
11597
|
+
return (0, import_react_query2.useQuery)({
|
|
11598
|
+
queryKey: ["savedViewsConfig", domain, projectId ?? companyId],
|
|
11599
|
+
queryFn: async () => {
|
|
11600
|
+
const response = await requestJSON(url);
|
|
11601
|
+
return response.data;
|
|
11602
|
+
}
|
|
11603
|
+
});
|
|
11604
|
+
};
|
|
11605
|
+
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
11606
|
+
"createSavedView",
|
|
11607
|
+
props.domain,
|
|
11608
|
+
props.tableName
|
|
11609
|
+
]);
|
|
11610
|
+
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
11611
|
+
"updateSavedView",
|
|
11612
|
+
props.domain,
|
|
11613
|
+
props.tableName
|
|
11614
|
+
]);
|
|
11615
|
+
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
11616
|
+
"deleteSavedView",
|
|
11617
|
+
props.domain,
|
|
11618
|
+
props.tableName
|
|
11619
|
+
]);
|
|
11620
|
+
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
11621
|
+
const { projectId, companyId, domain } = queryInput;
|
|
11622
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11623
|
+
return (0, import_react_query2.useQuery)({
|
|
11624
|
+
enabled: enabled && Boolean(savedViewToken),
|
|
11625
|
+
queryKey: ["savedView", savedViewToken, projectId ?? companyId],
|
|
11626
|
+
queryFn: async () => {
|
|
11627
|
+
const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
|
|
11628
|
+
const response = await requestJSON(url);
|
|
11629
|
+
return response.data;
|
|
11630
|
+
}
|
|
11631
|
+
});
|
|
11632
|
+
};
|
|
11446
11633
|
|
|
11447
11634
|
// src/components/panels/PanelContentUtils.ts
|
|
11448
11635
|
var import_lodash = __toESM(require_lodash());
|
|
@@ -11517,12 +11704,10 @@ var getColumnIdentifier = (col) => {
|
|
|
11517
11704
|
};
|
|
11518
11705
|
var updateTableConfig = (view, tableApi, provider) => {
|
|
11519
11706
|
if (provider === "smart-grid") {
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
);
|
|
11525
|
-
}, 0);
|
|
11707
|
+
setSmartGridConfig(
|
|
11708
|
+
tableApi,
|
|
11709
|
+
view.table_config
|
|
11710
|
+
);
|
|
11526
11711
|
} else {
|
|
11527
11712
|
const dataTableApi = tableApi;
|
|
11528
11713
|
const tableConfig = view.table_config;
|
|
@@ -11594,20 +11779,13 @@ var cleanObject = (table_config, provider) => {
|
|
|
11594
11779
|
var normalizeForComparison = (config) => {
|
|
11595
11780
|
if (!config?.columnState)
|
|
11596
11781
|
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
11782
|
return {
|
|
11604
|
-
...
|
|
11605
|
-
columnState:
|
|
11606
|
-
const res = import_lodash.default.omit(col, ["aggFunc"]);
|
|
11783
|
+
...config,
|
|
11784
|
+
columnState: config.columnState.map((col) => {
|
|
11607
11785
|
if (col.flex) {
|
|
11608
|
-
return import_lodash.default.omit(
|
|
11786
|
+
return import_lodash.default.omit(col, ["width", "flex"]);
|
|
11609
11787
|
}
|
|
11610
|
-
return
|
|
11788
|
+
return col;
|
|
11611
11789
|
})
|
|
11612
11790
|
};
|
|
11613
11791
|
};
|
|
@@ -11620,9 +11798,10 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
|
|
|
11620
11798
|
);
|
|
11621
11799
|
const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
|
|
11622
11800
|
const normalizedCurrentConfig = normalizeForComparison(tableConfig);
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11801
|
+
return import_lodash.default.isEqual(
|
|
11802
|
+
cleanObject(normalizedViewConfig, provider),
|
|
11803
|
+
cleanObject(normalizedCurrentConfig, provider)
|
|
11804
|
+
);
|
|
11626
11805
|
};
|
|
11627
11806
|
var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
11628
11807
|
switch (viewLevel) {
|
|
@@ -11639,9 +11818,10 @@ var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
|
11639
11818
|
|
|
11640
11819
|
// src/components/panels/useGroups.ts
|
|
11641
11820
|
var import_react6 = require("react");
|
|
11642
|
-
var useGroups = () => {
|
|
11821
|
+
var useGroups = (isProjectLevelTool) => {
|
|
11822
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11643
11823
|
const [groups, setGroups] = (0, import_react6.useState)(
|
|
11644
|
-
Object.fromEntries(
|
|
11824
|
+
Object.fromEntries(viewLevels.map((level) => [level, true]))
|
|
11645
11825
|
);
|
|
11646
11826
|
const toggleGroup = (group) => {
|
|
11647
11827
|
setGroups((groups2) => ({ ...groups2, [group]: !groups2[group] }));
|
|
@@ -11650,7 +11830,7 @@ var useGroups = () => {
|
|
|
11650
11830
|
};
|
|
11651
11831
|
|
|
11652
11832
|
// src/components/panels/ViewLevelHeader.tsx
|
|
11653
|
-
var
|
|
11833
|
+
var import_core_react6 = require("@procore/core-react");
|
|
11654
11834
|
var import_react7 = __toESM(require("react"));
|
|
11655
11835
|
var groupIcon = (group) => {
|
|
11656
11836
|
switch (group) {
|
|
@@ -11662,26 +11842,26 @@ var groupIcon = (group) => {
|
|
|
11662
11842
|
return /* @__PURE__ */ import_react7.default.createElement(Building_default, null);
|
|
11663
11843
|
}
|
|
11664
11844
|
};
|
|
11665
|
-
var Header = styled_components_esm_default(
|
|
11845
|
+
var Header = styled_components_esm_default(import_core_react6.Flex)`
|
|
11666
11846
|
width: 100%;
|
|
11667
11847
|
&:hover {
|
|
11668
|
-
background-color: ${
|
|
11848
|
+
background-color: ${import_core_react6.colors.gray98};
|
|
11669
11849
|
}
|
|
11670
11850
|
`;
|
|
11671
11851
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
11672
|
-
const I18n = (0,
|
|
11852
|
+
const I18n = (0, import_core_react6.useI18nContext)();
|
|
11673
11853
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
11674
11854
|
Header,
|
|
11675
11855
|
{
|
|
11676
11856
|
alignItems: "center",
|
|
11677
|
-
padding: `${
|
|
11678
|
-
gap: `${
|
|
11857
|
+
padding: `${import_core_react6.spacing.sm}px`,
|
|
11858
|
+
gap: `${import_core_react6.spacing.sm}px`,
|
|
11679
11859
|
style: { cursor: "pointer" },
|
|
11680
11860
|
onClick: () => toggleGroup(group)
|
|
11681
11861
|
},
|
|
11682
11862
|
expanded ? /* @__PURE__ */ import_react7.default.createElement(ChevronDown_default, { size: "sm" }) : /* @__PURE__ */ import_react7.default.createElement(ChevronRight_default, { size: "sm" }),
|
|
11683
11863
|
groupIcon(group),
|
|
11684
|
-
/* @__PURE__ */ import_react7.default.createElement(
|
|
11864
|
+
/* @__PURE__ */ import_react7.default.createElement(import_core_react6.Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
|
|
11685
11865
|
);
|
|
11686
11866
|
};
|
|
11687
11867
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
@@ -11699,21 +11879,21 @@ var useScrollToRef = (dependency) => {
|
|
|
11699
11879
|
};
|
|
11700
11880
|
|
|
11701
11881
|
// src/components/panels/PanelContent.styles.ts
|
|
11702
|
-
var
|
|
11703
|
-
var Row = styled_components_esm_default(
|
|
11882
|
+
var import_core_react7 = require("@procore/core-react");
|
|
11883
|
+
var Row = styled_components_esm_default(import_core_react7.UNSAFE_Menu.Item)`
|
|
11704
11884
|
width: 100%;
|
|
11705
11885
|
padding-left: 35px;
|
|
11706
11886
|
padding-right: 4px;
|
|
11707
|
-
background-color: ${({ selected }) => selected ?
|
|
11887
|
+
background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : "transparent"};
|
|
11708
11888
|
|
|
11709
11889
|
&:hover {
|
|
11710
|
-
background-color: ${({ selected }) => selected ?
|
|
11890
|
+
background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : import_core_react7.colors.gray98};
|
|
11711
11891
|
}
|
|
11712
11892
|
`;
|
|
11713
|
-
var Panel2 = styled_components_esm_default(
|
|
11893
|
+
var Panel2 = styled_components_esm_default(import_core_react7.DetailPage.Card)`
|
|
11714
11894
|
margin: 0;
|
|
11715
11895
|
height: 100%;
|
|
11716
|
-
padding-top: ${
|
|
11896
|
+
padding-top: ${import_core_react7.spacing.sm}px;
|
|
11717
11897
|
box-shadow: none;
|
|
11718
11898
|
`;
|
|
11719
11899
|
|
|
@@ -11721,9 +11901,9 @@ var Panel2 = styled_components_esm_default(import_core_react6.DetailPage.Card)`
|
|
|
11721
11901
|
var PanelContent = (props) => {
|
|
11722
11902
|
const { queryInput, selectedSavedView, tableConfig } = props;
|
|
11723
11903
|
const { showToast } = (0, import_toast_alert2.useToastAlertContext)();
|
|
11724
|
-
const I18n = (0,
|
|
11725
|
-
const { data: savedViewsFromQuery, error: savedViewsError } =
|
|
11726
|
-
const updateMutation =
|
|
11904
|
+
const I18n = (0, import_core_react8.useI18nContext)();
|
|
11905
|
+
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
11906
|
+
const updateMutation = useUpdateSavedView(queryInput);
|
|
11727
11907
|
const { mutate: updateSavedView } = updateMutation;
|
|
11728
11908
|
const isUpdateLoading = "isPending" in updateMutation ? updateMutation.isPending : updateMutation.isLoading ?? false;
|
|
11729
11909
|
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
@@ -11734,14 +11914,14 @@ var PanelContent = (props) => {
|
|
|
11734
11914
|
errorToastRef.current = savedViewsError;
|
|
11735
11915
|
}
|
|
11736
11916
|
}, [savedViewsError, showToast, I18n]);
|
|
11737
|
-
const { data: permissions } = props.
|
|
11738
|
-
props.queryInput
|
|
11739
|
-
);
|
|
11917
|
+
const { data: permissions } = useSavedViewsPermissions(props.queryInput);
|
|
11740
11918
|
const selectedRowRef = useScrollToRef(savedViews);
|
|
11741
|
-
const { groups, toggleGroup } = useGroups();
|
|
11742
11919
|
const isTemporarySelected = selectedSavedView?.id === "temporary";
|
|
11743
11920
|
const temporaryView = savedViews?.find((view) => view.id === "temporary");
|
|
11744
11921
|
const presetViews = props.presetViews || [props.defaultView];
|
|
11922
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
11923
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11924
|
+
const { groups, toggleGroup } = useGroups(isProjectLevelTool);
|
|
11745
11925
|
const onUpdate = (data) => {
|
|
11746
11926
|
const newSavedView = {
|
|
11747
11927
|
...data,
|
|
@@ -11758,7 +11938,7 @@ var PanelContent = (props) => {
|
|
|
11758
11938
|
}
|
|
11759
11939
|
});
|
|
11760
11940
|
};
|
|
11761
|
-
return /* @__PURE__ */ import_react9.default.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ import_react9.default.createElement(
|
|
11941
|
+
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(
|
|
11762
11942
|
Row,
|
|
11763
11943
|
{
|
|
11764
11944
|
selected: isTemporarySelected,
|
|
@@ -11770,8 +11950,7 @@ var PanelContent = (props) => {
|
|
|
11770
11950
|
{
|
|
11771
11951
|
item: temporaryView,
|
|
11772
11952
|
selected: isTemporarySelected,
|
|
11773
|
-
onClearTemporary: props.onClearTemporary
|
|
11774
|
-
enableSharingViews: false
|
|
11953
|
+
onClearTemporary: props.onClearTemporary
|
|
11775
11954
|
}
|
|
11776
11955
|
)
|
|
11777
11956
|
), presetViews.map((presetView) => {
|
|
@@ -11788,12 +11967,11 @@ var PanelContent = (props) => {
|
|
|
11788
11967
|
SavedViewCollectionMenuItem,
|
|
11789
11968
|
{
|
|
11790
11969
|
item: presetView,
|
|
11791
|
-
selected: isSelected
|
|
11792
|
-
enableSharingViews: false
|
|
11970
|
+
selected: isSelected
|
|
11793
11971
|
}
|
|
11794
11972
|
)
|
|
11795
11973
|
);
|
|
11796
|
-
}),
|
|
11974
|
+
}), viewLevels.map((level) => {
|
|
11797
11975
|
const isExpanded = groups[level];
|
|
11798
11976
|
const views = isExpanded && savedViews ? savedViews.filter(
|
|
11799
11977
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
@@ -11837,8 +12015,7 @@ var PanelContent = (props) => {
|
|
|
11837
12015
|
isUpdateProcessing: isUpdateLoading,
|
|
11838
12016
|
onEdit: () => props.openModal("update" /* UPDATE */),
|
|
11839
12017
|
onDelete: props.onDelete,
|
|
11840
|
-
permissions
|
|
11841
|
-
enableSharingViews: false
|
|
12018
|
+
permissions
|
|
11842
12019
|
}
|
|
11843
12020
|
)
|
|
11844
12021
|
);
|
|
@@ -11853,16 +12030,16 @@ var import_react_query3 = require("@tanstack/react-query");
|
|
|
11853
12030
|
var import_toast_alert3 = require("@procore/toast-alert");
|
|
11854
12031
|
|
|
11855
12032
|
// src/components/modals/DeleteConfirmationModal.tsx
|
|
11856
|
-
var
|
|
12033
|
+
var import_core_react9 = require("@procore/core-react");
|
|
11857
12034
|
var import_react10 = __toESM(require("react"));
|
|
11858
12035
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
11859
12036
|
onCancel,
|
|
11860
12037
|
onDelete,
|
|
11861
12038
|
open
|
|
11862
12039
|
}) => {
|
|
11863
|
-
const i18n = (0,
|
|
12040
|
+
const i18n = (0, import_core_react9.useI18nContext)();
|
|
11864
12041
|
return /* @__PURE__ */ import_react10.default.createElement(
|
|
11865
|
-
|
|
12042
|
+
import_core_react9.ConfirmModal,
|
|
11866
12043
|
{
|
|
11867
12044
|
"data-testid": "delete-confirmation-modal",
|
|
11868
12045
|
open,
|
|
@@ -11871,8 +12048,8 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11871
12048
|
onClose: onCancel,
|
|
11872
12049
|
style: { overflowWrap: "anywhere" }
|
|
11873
12050
|
},
|
|
11874
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
11875
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
12051
|
+
/* @__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"))),
|
|
12052
|
+
/* @__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"))))
|
|
11876
12053
|
);
|
|
11877
12054
|
};
|
|
11878
12055
|
|
|
@@ -11880,7 +12057,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11880
12057
|
var import_react11 = __toESM(require("react"));
|
|
11881
12058
|
|
|
11882
12059
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
11883
|
-
var
|
|
12060
|
+
var import_core_react10 = require("@procore/core-react");
|
|
11884
12061
|
var React19 = __toESM(require("react"));
|
|
11885
12062
|
|
|
11886
12063
|
// ../../node_modules/yup/index.esm.js
|
|
@@ -14176,10 +14353,11 @@ var TupleSchema = class extends Schema {
|
|
|
14176
14353
|
create$1.prototype = TupleSchema.prototype;
|
|
14177
14354
|
|
|
14178
14355
|
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
14179
|
-
var getViewLevelOptions = (permissions, i18n) => {
|
|
14356
|
+
var getViewLevelOptions = (permissions, i18n, isProjectLevelTool = true) => {
|
|
14180
14357
|
const options = ["personal"];
|
|
14181
|
-
if (permissions?.can_create_project_saved_views)
|
|
14358
|
+
if (isProjectLevelTool && permissions?.can_create_project_saved_views) {
|
|
14182
14359
|
options.push("project");
|
|
14360
|
+
}
|
|
14183
14361
|
if (permissions?.can_create_company_saved_views)
|
|
14184
14362
|
options.push("company");
|
|
14185
14363
|
return options.map((option) => ({
|
|
@@ -14209,7 +14387,6 @@ function extractMessage(error, I18n) {
|
|
|
14209
14387
|
}
|
|
14210
14388
|
|
|
14211
14389
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14212
|
-
var { useEffect: useEffect2, useRef: useRef2 } = React19;
|
|
14213
14390
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14214
14391
|
overflow: auto;
|
|
14215
14392
|
`;
|
|
@@ -14226,38 +14403,22 @@ var FormModalBase = ({
|
|
|
14226
14403
|
defaultView,
|
|
14227
14404
|
selectedSavedView,
|
|
14228
14405
|
setOpenEditCreateModal,
|
|
14229
|
-
onSelect
|
|
14230
|
-
backend
|
|
14406
|
+
onSelect
|
|
14231
14407
|
}) => {
|
|
14232
|
-
const I18n = (0,
|
|
14408
|
+
const I18n = (0, import_core_react10.useI18nContext)();
|
|
14233
14409
|
const NAME_MAX_LENGTH = 150;
|
|
14234
|
-
const originalBodyWidth = useRef2("");
|
|
14235
|
-
useEffect2(() => {
|
|
14236
|
-
if (open) {
|
|
14237
|
-
originalBodyWidth.current = document.body.style.width || "";
|
|
14238
|
-
document.body.style.width = "100%";
|
|
14239
|
-
} else {
|
|
14240
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14241
|
-
}
|
|
14242
|
-
return () => {
|
|
14243
|
-
if (originalBodyWidth.current !== void 0) {
|
|
14244
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14245
|
-
}
|
|
14246
|
-
};
|
|
14247
|
-
}, [open]);
|
|
14248
|
-
const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
|
|
14249
14410
|
const {
|
|
14250
14411
|
mutate: createSavedView,
|
|
14251
14412
|
isPending: isCreating,
|
|
14252
14413
|
error: createError,
|
|
14253
14414
|
reset: resetCreateMutation
|
|
14254
|
-
} =
|
|
14415
|
+
} = useCreateSavedView(queryInput);
|
|
14255
14416
|
const {
|
|
14256
14417
|
mutate: updateSavedView,
|
|
14257
14418
|
isPending: isUpdating,
|
|
14258
14419
|
error: updateError,
|
|
14259
14420
|
reset: resetUpdateMutation
|
|
14260
|
-
} =
|
|
14421
|
+
} = useUpdateSavedView(queryInput);
|
|
14261
14422
|
const resetMutations = () => {
|
|
14262
14423
|
resetCreateMutation();
|
|
14263
14424
|
resetUpdateMutation();
|
|
@@ -14266,7 +14427,7 @@ var FormModalBase = ({
|
|
|
14266
14427
|
resetMutations();
|
|
14267
14428
|
onCancel();
|
|
14268
14429
|
};
|
|
14269
|
-
const { data: permissions } =
|
|
14430
|
+
const { data: permissions } = useSavedViewsPermissions(queryInput);
|
|
14270
14431
|
const isLoading = isCreating || isUpdating;
|
|
14271
14432
|
const errors = extractMessage(createError || updateError, I18n);
|
|
14272
14433
|
const handleOnSubmit = (data) => {
|
|
@@ -14297,9 +14458,14 @@ var FormModalBase = ({
|
|
|
14297
14458
|
});
|
|
14298
14459
|
}
|
|
14299
14460
|
};
|
|
14300
|
-
const
|
|
14461
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
14462
|
+
const viewLevelOptions = getViewLevelOptions(
|
|
14463
|
+
permissions,
|
|
14464
|
+
I18n,
|
|
14465
|
+
isProjectLevelTool
|
|
14466
|
+
);
|
|
14301
14467
|
return /* @__PURE__ */ React19.createElement(
|
|
14302
|
-
|
|
14468
|
+
import_core_react10.Modal,
|
|
14303
14469
|
{
|
|
14304
14470
|
"aria-label": I18n.t("savedViews.ariaLabels.modal"),
|
|
14305
14471
|
onClickOverlay: onClose,
|
|
@@ -14308,14 +14474,14 @@ var FormModalBase = ({
|
|
|
14308
14474
|
"data-testid": "create-update-modal"
|
|
14309
14475
|
},
|
|
14310
14476
|
/* @__PURE__ */ React19.createElement(ScrollContainer, null, /* @__PURE__ */ React19.createElement(
|
|
14311
|
-
|
|
14477
|
+
import_core_react10.Modal.Header,
|
|
14312
14478
|
{
|
|
14313
14479
|
onClose,
|
|
14314
|
-
style: { borderBottom: `1px solid ${
|
|
14480
|
+
style: { borderBottom: `1px solid ${import_core_react10.colors.gray85}` }
|
|
14315
14481
|
},
|
|
14316
|
-
/* @__PURE__ */ React19.createElement(
|
|
14482
|
+
/* @__PURE__ */ React19.createElement(import_core_react10.H2, null, header)
|
|
14317
14483
|
), /* @__PURE__ */ React19.createElement(
|
|
14318
|
-
|
|
14484
|
+
import_core_react10.Form,
|
|
14319
14485
|
{
|
|
14320
14486
|
initialValues: {
|
|
14321
14487
|
name: initialName,
|
|
@@ -14340,14 +14506,14 @@ var FormModalBase = ({
|
|
|
14340
14506
|
onReset: onCancel,
|
|
14341
14507
|
validateOnChange: true
|
|
14342
14508
|
},
|
|
14343
|
-
/* @__PURE__ */ React19.createElement(
|
|
14344
|
-
|
|
14509
|
+
/* @__PURE__ */ React19.createElement(import_core_react10.Form.Form, { name: header }, /* @__PURE__ */ React19.createElement(
|
|
14510
|
+
import_core_react10.Modal.Body,
|
|
14345
14511
|
{
|
|
14346
|
-
style: { paddingTop: 0, paddingBottom: 0, marginTop:
|
|
14512
|
+
style: { paddingTop: 0, paddingBottom: 0, marginTop: import_core_react10.spacing.lg }
|
|
14347
14513
|
},
|
|
14348
|
-
errors && /* @__PURE__ */ React19.createElement(
|
|
14349
|
-
/* @__PURE__ */ React19.createElement(
|
|
14350
|
-
|
|
14514
|
+
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}`)))),
|
|
14515
|
+
/* @__PURE__ */ React19.createElement(import_core_react10.Form.Row, null, /* @__PURE__ */ React19.createElement(
|
|
14516
|
+
import_core_react10.Form.Text,
|
|
14351
14517
|
{
|
|
14352
14518
|
name: "name",
|
|
14353
14519
|
error: errors?.name,
|
|
@@ -14358,12 +14524,12 @@ var FormModalBase = ({
|
|
|
14358
14524
|
}
|
|
14359
14525
|
)),
|
|
14360
14526
|
/* @__PURE__ */ React19.createElement(
|
|
14361
|
-
|
|
14527
|
+
import_core_react10.Form.Row,
|
|
14362
14528
|
{
|
|
14363
|
-
style: { marginTop: errors?.name ?
|
|
14529
|
+
style: { marginTop: errors?.name ? import_core_react10.spacing.xl : import_core_react10.spacing.none }
|
|
14364
14530
|
},
|
|
14365
14531
|
/* @__PURE__ */ React19.createElement(
|
|
14366
|
-
|
|
14532
|
+
import_core_react10.Form.TextArea,
|
|
14367
14533
|
{
|
|
14368
14534
|
name: "description",
|
|
14369
14535
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14373,11 +14539,10 @@ var FormModalBase = ({
|
|
|
14373
14539
|
}
|
|
14374
14540
|
)
|
|
14375
14541
|
),
|
|
14376
|
-
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(
|
|
14377
|
-
|
|
14542
|
+
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(import_core_react10.Form.Row, null, /* @__PURE__ */ React19.createElement(
|
|
14543
|
+
import_core_react10.Form.Select,
|
|
14378
14544
|
{
|
|
14379
14545
|
name: "view_level",
|
|
14380
|
-
qa: { label: "view-level" },
|
|
14381
14546
|
options: viewLevelOptions,
|
|
14382
14547
|
label: I18n.t("savedViews.modal.fields.viewLevel"),
|
|
14383
14548
|
colWidth: 12,
|
|
@@ -14385,8 +14550,8 @@ var FormModalBase = ({
|
|
|
14385
14550
|
onClear: false
|
|
14386
14551
|
}
|
|
14387
14552
|
)) : /* @__PURE__ */ React19.createElement(React19.Fragment, null)
|
|
14388
|
-
), /* @__PURE__ */ React19.createElement(
|
|
14389
|
-
|
|
14553
|
+
), /* @__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(
|
|
14554
|
+
import_core_react10.Button,
|
|
14390
14555
|
{
|
|
14391
14556
|
"data-testid": "create-update-modal-button",
|
|
14392
14557
|
type: "submit",
|
|
@@ -14401,7 +14566,7 @@ var FormModalBase = ({
|
|
|
14401
14566
|
};
|
|
14402
14567
|
|
|
14403
14568
|
// src/components/modals/form-modal/FormModal.tsx
|
|
14404
|
-
var
|
|
14569
|
+
var import_core_react11 = require("@procore/core-react");
|
|
14405
14570
|
var FormModal = ({
|
|
14406
14571
|
open,
|
|
14407
14572
|
mode,
|
|
@@ -14412,10 +14577,9 @@ var FormModal = ({
|
|
|
14412
14577
|
selectedSavedView,
|
|
14413
14578
|
setOpenEditCreateModal,
|
|
14414
14579
|
onSelect,
|
|
14415
|
-
defaultView
|
|
14416
|
-
backend
|
|
14580
|
+
defaultView
|
|
14417
14581
|
}) => {
|
|
14418
|
-
const i18n = (0,
|
|
14582
|
+
const i18n = (0, import_core_react11.useI18nContext)();
|
|
14419
14583
|
return /* @__PURE__ */ import_react11.default.createElement(
|
|
14420
14584
|
FormModalBase,
|
|
14421
14585
|
{
|
|
@@ -14431,14 +14595,13 @@ var FormModal = ({
|
|
|
14431
14595
|
selectedSavedView,
|
|
14432
14596
|
setOpenEditCreateModal,
|
|
14433
14597
|
onSelect,
|
|
14434
|
-
defaultView
|
|
14435
|
-
backend
|
|
14598
|
+
defaultView
|
|
14436
14599
|
}
|
|
14437
14600
|
);
|
|
14438
14601
|
};
|
|
14439
14602
|
|
|
14440
14603
|
// src/components/modals/form-modal/SharedViewFormModal.tsx
|
|
14441
|
-
var
|
|
14604
|
+
var import_core_react12 = require("@procore/core-react");
|
|
14442
14605
|
var React21 = __toESM(require("react"));
|
|
14443
14606
|
var SharedViewFormModal = ({
|
|
14444
14607
|
open,
|
|
@@ -14450,7 +14613,7 @@ var SharedViewFormModal = ({
|
|
|
14450
14613
|
isCreating,
|
|
14451
14614
|
resetCreateError
|
|
14452
14615
|
}) => {
|
|
14453
|
-
const I18n = (0,
|
|
14616
|
+
const I18n = (0, import_core_react12.useI18nContext)();
|
|
14454
14617
|
const NAME_MAX_LENGTH = 150;
|
|
14455
14618
|
const errors = extractMessage(createError, I18n);
|
|
14456
14619
|
const handleNameChange = () => {
|
|
@@ -14462,7 +14625,7 @@ var SharedViewFormModal = ({
|
|
|
14462
14625
|
onCreateView(data.name, data.description);
|
|
14463
14626
|
};
|
|
14464
14627
|
return /* @__PURE__ */ React21.createElement(
|
|
14465
|
-
|
|
14628
|
+
import_core_react12.Modal,
|
|
14466
14629
|
{
|
|
14467
14630
|
"data-testid": "shared-view-form-modal",
|
|
14468
14631
|
open,
|
|
@@ -14470,35 +14633,35 @@ var SharedViewFormModal = ({
|
|
|
14470
14633
|
style: { width: "540px" }
|
|
14471
14634
|
},
|
|
14472
14635
|
/* @__PURE__ */ React21.createElement(
|
|
14473
|
-
|
|
14636
|
+
import_core_react12.Modal.Header,
|
|
14474
14637
|
{
|
|
14475
14638
|
onClose,
|
|
14476
14639
|
style: {
|
|
14477
|
-
paddingTop:
|
|
14478
|
-
paddingBottom:
|
|
14479
|
-
paddingLeft:
|
|
14480
|
-
paddingRight:
|
|
14640
|
+
paddingTop: import_core_react12.spacing.lg,
|
|
14641
|
+
paddingBottom: import_core_react12.spacing.xs,
|
|
14642
|
+
paddingLeft: import_core_react12.spacing.xl,
|
|
14643
|
+
paddingRight: import_core_react12.spacing.xl
|
|
14481
14644
|
}
|
|
14482
14645
|
},
|
|
14483
14646
|
I18n.t("savedViews.modal.create.title")
|
|
14484
14647
|
),
|
|
14485
14648
|
/* @__PURE__ */ React21.createElement(
|
|
14486
|
-
|
|
14649
|
+
import_core_react12.P,
|
|
14487
14650
|
{
|
|
14488
14651
|
style: {
|
|
14489
|
-
paddingLeft:
|
|
14490
|
-
paddingRight:
|
|
14491
|
-
paddingBottom:
|
|
14492
|
-
paddingTop:
|
|
14652
|
+
paddingLeft: import_core_react12.spacing.xl,
|
|
14653
|
+
paddingRight: import_core_react12.spacing.xl,
|
|
14654
|
+
paddingBottom: import_core_react12.spacing.lg,
|
|
14655
|
+
paddingTop: import_core_react12.spacing.none,
|
|
14493
14656
|
margin: 0,
|
|
14494
|
-
color:
|
|
14657
|
+
color: import_core_react12.colors.gray45,
|
|
14495
14658
|
whiteSpace: "pre-line"
|
|
14496
14659
|
}
|
|
14497
14660
|
},
|
|
14498
14661
|
I18n.t("savedViews.modal.copyConfirmation.description")
|
|
14499
14662
|
),
|
|
14500
14663
|
/* @__PURE__ */ React21.createElement(
|
|
14501
|
-
|
|
14664
|
+
import_core_react12.Form,
|
|
14502
14665
|
{
|
|
14503
14666
|
initialValues: {
|
|
14504
14667
|
name: fetchedView.name,
|
|
@@ -14516,20 +14679,20 @@ var SharedViewFormModal = ({
|
|
|
14516
14679
|
onSubmit: handleOnSubmit,
|
|
14517
14680
|
validateOnChange: true
|
|
14518
14681
|
},
|
|
14519
|
-
/* @__PURE__ */ React21.createElement(
|
|
14520
|
-
|
|
14682
|
+
/* @__PURE__ */ React21.createElement(import_core_react12.Form.Form, { name: "share-view-form" }, /* @__PURE__ */ React21.createElement(
|
|
14683
|
+
import_core_react12.Modal.Body,
|
|
14521
14684
|
{
|
|
14522
14685
|
style: {
|
|
14523
|
-
paddingTop:
|
|
14686
|
+
paddingTop: import_core_react12.spacing.lg,
|
|
14524
14687
|
paddingBottom: 0,
|
|
14525
|
-
borderTop: `1px solid ${
|
|
14688
|
+
borderTop: `1px solid ${import_core_react12.colors.gray85}`
|
|
14526
14689
|
}
|
|
14527
14690
|
},
|
|
14528
|
-
errors && /* @__PURE__ */ React21.createElement(
|
|
14691
|
+
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", {
|
|
14529
14692
|
mode: "create"
|
|
14530
|
-
})), /* @__PURE__ */ React21.createElement(
|
|
14531
|
-
/* @__PURE__ */ React21.createElement(
|
|
14532
|
-
|
|
14693
|
+
})), /* @__PURE__ */ React21.createElement(import_core_react12.Banner.Body, null, errors?.form || I18n.t("savedViews.modal.errors.description.create")))),
|
|
14694
|
+
/* @__PURE__ */ React21.createElement(import_core_react12.Form.Row, null, /* @__PURE__ */ React21.createElement(
|
|
14695
|
+
import_core_react12.Form.Text,
|
|
14533
14696
|
{
|
|
14534
14697
|
name: "name",
|
|
14535
14698
|
error: errors?.name,
|
|
@@ -14540,12 +14703,12 @@ var SharedViewFormModal = ({
|
|
|
14540
14703
|
}
|
|
14541
14704
|
)),
|
|
14542
14705
|
/* @__PURE__ */ React21.createElement(
|
|
14543
|
-
|
|
14706
|
+
import_core_react12.Form.Row,
|
|
14544
14707
|
{
|
|
14545
|
-
style: { marginTop: errors?.name ?
|
|
14708
|
+
style: { marginTop: errors?.name ? import_core_react12.spacing.xl : import_core_react12.spacing.none }
|
|
14546
14709
|
},
|
|
14547
14710
|
/* @__PURE__ */ React21.createElement(
|
|
14548
|
-
|
|
14711
|
+
import_core_react12.Form.TextArea,
|
|
14549
14712
|
{
|
|
14550
14713
|
name: "description",
|
|
14551
14714
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14555,8 +14718,8 @@ var SharedViewFormModal = ({
|
|
|
14555
14718
|
}
|
|
14556
14719
|
)
|
|
14557
14720
|
)
|
|
14558
|
-
), /* @__PURE__ */ React21.createElement(
|
|
14559
|
-
|
|
14721
|
+
), /* @__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(
|
|
14722
|
+
import_core_react12.Button,
|
|
14560
14723
|
{
|
|
14561
14724
|
variant: "secondary",
|
|
14562
14725
|
onClick: onCreateTemporaryView,
|
|
@@ -14565,7 +14728,7 @@ var SharedViewFormModal = ({
|
|
|
14565
14728
|
},
|
|
14566
14729
|
I18n.t("savedViews.actions.viewTemporarily")
|
|
14567
14730
|
), /* @__PURE__ */ React21.createElement(
|
|
14568
|
-
|
|
14731
|
+
import_core_react12.Button,
|
|
14569
14732
|
{
|
|
14570
14733
|
type: "submit",
|
|
14571
14734
|
variant: "primary",
|
|
@@ -14582,7 +14745,7 @@ var SharedViewFormModal = ({
|
|
|
14582
14745
|
// src/utils/hooks/useViewSelection.ts
|
|
14583
14746
|
var import_react12 = require("react");
|
|
14584
14747
|
var import_react_router_dom = require("react-router-dom");
|
|
14585
|
-
var
|
|
14748
|
+
var import_core_react13 = require("@procore/core-react");
|
|
14586
14749
|
|
|
14587
14750
|
// src/utils/viewStorage.ts
|
|
14588
14751
|
var ViewStorage = {
|
|
@@ -14645,8 +14808,9 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
14645
14808
|
}
|
|
14646
14809
|
};
|
|
14647
14810
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
14648
|
-
const I18n = (0,
|
|
14649
|
-
const
|
|
14811
|
+
const I18n = (0, import_core_react13.useI18nContext)();
|
|
14812
|
+
const projectIdSegment = config.projectId ?? "company";
|
|
14813
|
+
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
14650
14814
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14651
14815
|
const [searchParams, setSearchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
14652
14816
|
const previousSavedViewParamRef = (0, import_react12.useRef)(null);
|
|
@@ -14744,177 +14908,6 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14744
14908
|
};
|
|
14745
14909
|
};
|
|
14746
14910
|
|
|
14747
|
-
// node_modules/@procore/core-http/dist/modern/index.js
|
|
14748
|
-
function getCSRFToken() {
|
|
14749
|
-
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
14750
|
-
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
14751
|
-
}
|
|
14752
|
-
function getCSRFHeader() {
|
|
14753
|
-
const csrfToken = getCSRFToken();
|
|
14754
|
-
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
14755
|
-
}
|
|
14756
|
-
function removeLeadingSlash(url) {
|
|
14757
|
-
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
14758
|
-
}
|
|
14759
|
-
function removeTrailingSlash(url) {
|
|
14760
|
-
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
14761
|
-
}
|
|
14762
|
-
function applyBaseUrl(url, baseUrl) {
|
|
14763
|
-
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
14764
|
-
}
|
|
14765
|
-
function getOptions({ headers, ...options }) {
|
|
14766
|
-
const opts = {
|
|
14767
|
-
credentials: "same-origin",
|
|
14768
|
-
headers: {
|
|
14769
|
-
...getCSRFHeader(),
|
|
14770
|
-
...headers
|
|
14771
|
-
},
|
|
14772
|
-
mode: "same-origin",
|
|
14773
|
-
...options
|
|
14774
|
-
};
|
|
14775
|
-
return opts;
|
|
14776
|
-
}
|
|
14777
|
-
function getUrl(url, baseUrl) {
|
|
14778
|
-
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
14779
|
-
}
|
|
14780
|
-
function request(url, { baseUrl, ...options } = {}) {
|
|
14781
|
-
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
14782
|
-
}
|
|
14783
|
-
function requestJSON(url, requestParams = {}) {
|
|
14784
|
-
return request(url, requestParams).then(
|
|
14785
|
-
(response) => response.json()
|
|
14786
|
-
);
|
|
14787
|
-
}
|
|
14788
|
-
|
|
14789
|
-
// src/utils/api/queries.ts
|
|
14790
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
14791
|
-
|
|
14792
|
-
// src/utils/api/queriesHandler.ts
|
|
14793
|
-
var import_react_query = require("@tanstack/react-query");
|
|
14794
|
-
var import_core_react13 = require("@procore/core-react");
|
|
14795
|
-
var useApiRequest = (props, method, mutationKey) => {
|
|
14796
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14797
|
-
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
14798
|
-
const { locale: locale2 } = (0, import_core_react13.useI18nContext)();
|
|
14799
|
-
return (0, import_react_query.useMutation)({
|
|
14800
|
-
mutationKey,
|
|
14801
|
-
mutationFn: async (savedView) => {
|
|
14802
|
-
let url = "";
|
|
14803
|
-
if (method === "DELETE" || method === "PUT") {
|
|
14804
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.share_token}?permissions_domain=${domain}`;
|
|
14805
|
-
} else {
|
|
14806
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14807
|
-
}
|
|
14808
|
-
const response = await requestJSON(url, {
|
|
14809
|
-
method,
|
|
14810
|
-
body: JSON.stringify(savedView),
|
|
14811
|
-
headers: {
|
|
14812
|
-
"Content-Type": "application/json",
|
|
14813
|
-
"Accept-Language": locale2
|
|
14814
|
-
}
|
|
14815
|
-
});
|
|
14816
|
-
if (response.error) {
|
|
14817
|
-
throw response.error;
|
|
14818
|
-
}
|
|
14819
|
-
return response.data;
|
|
14820
|
-
},
|
|
14821
|
-
onSuccess: (savedView) => {
|
|
14822
|
-
if (method === "DELETE" || method === "POST") {
|
|
14823
|
-
queryClient2.invalidateQueries({
|
|
14824
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14825
|
-
});
|
|
14826
|
-
return;
|
|
14827
|
-
} else {
|
|
14828
|
-
const oldData = queryClient2.getQueryData([
|
|
14829
|
-
"savedViews",
|
|
14830
|
-
domain,
|
|
14831
|
-
tableName
|
|
14832
|
-
]);
|
|
14833
|
-
const oldView = oldData?.find(
|
|
14834
|
-
(item) => item.share_token === savedView.share_token
|
|
14835
|
-
);
|
|
14836
|
-
if (oldView?.name !== savedView.name) {
|
|
14837
|
-
queryClient2.invalidateQueries({
|
|
14838
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14839
|
-
});
|
|
14840
|
-
return;
|
|
14841
|
-
}
|
|
14842
|
-
}
|
|
14843
|
-
queryClient2.setQueryData(
|
|
14844
|
-
["savedViews", domain, tableName],
|
|
14845
|
-
(oldData) => {
|
|
14846
|
-
if (!oldData)
|
|
14847
|
-
return [savedView];
|
|
14848
|
-
return oldData.map(
|
|
14849
|
-
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
14850
|
-
);
|
|
14851
|
-
}
|
|
14852
|
-
);
|
|
14853
|
-
}
|
|
14854
|
-
});
|
|
14855
|
-
};
|
|
14856
|
-
|
|
14857
|
-
// src/utils/api/queries.ts
|
|
14858
|
-
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
14859
|
-
var useSavedViewsQuery = (props) => {
|
|
14860
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14861
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14862
|
-
return (0, import_react_query2.useQuery)({
|
|
14863
|
-
queryKey: ["savedViews", domain, tableName],
|
|
14864
|
-
queryFn: async () => {
|
|
14865
|
-
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
14866
|
-
const response = await requestJSON(getUrl2);
|
|
14867
|
-
return response.data;
|
|
14868
|
-
}
|
|
14869
|
-
});
|
|
14870
|
-
};
|
|
14871
|
-
var useSavedViewsPermissions = (props) => {
|
|
14872
|
-
const { projectId, companyId, domain } = props;
|
|
14873
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
14874
|
-
return (0, import_react_query2.useQuery)({
|
|
14875
|
-
queryKey: ["savedViewsConfig", domain],
|
|
14876
|
-
queryFn: async () => {
|
|
14877
|
-
const response = await requestJSON(url);
|
|
14878
|
-
return response.data;
|
|
14879
|
-
}
|
|
14880
|
-
});
|
|
14881
|
-
};
|
|
14882
|
-
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
14883
|
-
"createSavedView",
|
|
14884
|
-
props.domain,
|
|
14885
|
-
props.tableName
|
|
14886
|
-
]);
|
|
14887
|
-
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
14888
|
-
"updateSavedView",
|
|
14889
|
-
props.domain,
|
|
14890
|
-
props.tableName
|
|
14891
|
-
]);
|
|
14892
|
-
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
14893
|
-
"deleteSavedView",
|
|
14894
|
-
props.domain,
|
|
14895
|
-
props.tableName
|
|
14896
|
-
]);
|
|
14897
|
-
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
14898
|
-
const { projectId, companyId } = queryInput;
|
|
14899
|
-
return (0, import_react_query2.useQuery)({
|
|
14900
|
-
enabled: enabled && Boolean(savedViewToken),
|
|
14901
|
-
queryKey: ["savedView", savedViewToken],
|
|
14902
|
-
queryFn: async () => {
|
|
14903
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedViewToken}`;
|
|
14904
|
-
const response = await requestJSON(url);
|
|
14905
|
-
return response.data;
|
|
14906
|
-
}
|
|
14907
|
-
});
|
|
14908
|
-
};
|
|
14909
|
-
var createQueries = (customBackend) => ({
|
|
14910
|
-
useSavedViewsQuery: customBackend?.useSavedViewsQuery ?? useSavedViewsQuery,
|
|
14911
|
-
useSavedViewsPermissions: customBackend?.useSavedViewsPermissions ?? useSavedViewsPermissions,
|
|
14912
|
-
useCreateSavedView: customBackend?.useCreateSavedView ?? useCreateSavedView,
|
|
14913
|
-
useUpdateSavedView: customBackend?.useUpdateSavedView ?? useUpdateSavedView,
|
|
14914
|
-
useDeleteSavedView: customBackend?.useDeleteSavedView ?? useDeleteSavedView,
|
|
14915
|
-
useFetchSavedViewById: customBackend?.useFetchSavedViewById ?? useFetchSavedViewById
|
|
14916
|
-
});
|
|
14917
|
-
|
|
14918
14911
|
// src/components/saved-views/SavedViews.tsx
|
|
14919
14912
|
var StyledPanel = styled_components_esm_default.div`
|
|
14920
14913
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
@@ -14922,15 +14915,14 @@ var StyledPanel = styled_components_esm_default.div`
|
|
|
14922
14915
|
var queryClient = new import_react_query3.QueryClient();
|
|
14923
14916
|
var SavedViewsContent = (props) => {
|
|
14924
14917
|
const { projectId, companyId } = props;
|
|
14925
|
-
const backend = createQueries(props.backend);
|
|
14926
14918
|
const queryInput = {
|
|
14927
14919
|
domain: props.domain,
|
|
14928
14920
|
tableName: props.tableName,
|
|
14929
|
-
projectId,
|
|
14921
|
+
projectId: projectId ?? void 0,
|
|
14930
14922
|
companyId
|
|
14931
14923
|
};
|
|
14932
|
-
const { data: savedViews } =
|
|
14933
|
-
const { mutate: deleteSavedView } =
|
|
14924
|
+
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14925
|
+
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14934
14926
|
const { showToast } = (0, import_toast_alert3.useToastAlertContext)();
|
|
14935
14927
|
const i18n = (0, import_core_react14.useI18nContext)();
|
|
14936
14928
|
const [activeModal, setActiveModal] = (0, import_react13.useState)(null);
|
|
@@ -14958,7 +14950,7 @@ var SavedViewsContent = (props) => {
|
|
|
14958
14950
|
domain: props.domain,
|
|
14959
14951
|
tableName: props.tableName,
|
|
14960
14952
|
userId: props.userId,
|
|
14961
|
-
projectId,
|
|
14953
|
+
projectId: projectId ?? void 0,
|
|
14962
14954
|
companyId,
|
|
14963
14955
|
defaultView: props.defaultView,
|
|
14964
14956
|
onSelect: props.onSelect
|
|
@@ -14967,7 +14959,7 @@ var SavedViewsContent = (props) => {
|
|
|
14967
14959
|
props.presetViews,
|
|
14968
14960
|
openSharedViewModal
|
|
14969
14961
|
);
|
|
14970
|
-
const { data: fetchedView, isError: fetchError } =
|
|
14962
|
+
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
14971
14963
|
modalData?.viewId ?? null,
|
|
14972
14964
|
queryInput,
|
|
14973
14965
|
Boolean(modalData?.viewId)
|
|
@@ -14977,7 +14969,7 @@ var SavedViewsContent = (props) => {
|
|
|
14977
14969
|
isPending: isCreating,
|
|
14978
14970
|
error: createError,
|
|
14979
14971
|
reset: resetCreateError
|
|
14980
|
-
} =
|
|
14972
|
+
} = useCreateSavedView(queryInput);
|
|
14981
14973
|
(0, import_react13.useEffect)(() => {
|
|
14982
14974
|
if (fetchError) {
|
|
14983
14975
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
@@ -15064,8 +15056,7 @@ var SavedViewsContent = (props) => {
|
|
|
15064
15056
|
savedViews: allViews,
|
|
15065
15057
|
provider: props.provider,
|
|
15066
15058
|
userId: props.userId,
|
|
15067
|
-
onClearTemporary: clearTemporaryView
|
|
15068
|
-
backend
|
|
15059
|
+
onClearTemporary: clearTemporaryView
|
|
15069
15060
|
}
|
|
15070
15061
|
))
|
|
15071
15062
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -15080,8 +15071,7 @@ var SavedViewsContent = (props) => {
|
|
|
15080
15071
|
selectedSavedView: selectedView,
|
|
15081
15072
|
onSelect: selectView,
|
|
15082
15073
|
setOpenEditCreateModal: closeModal,
|
|
15083
|
-
defaultView: props.defaultView
|
|
15084
|
-
backend
|
|
15074
|
+
defaultView: props.defaultView
|
|
15085
15075
|
}
|
|
15086
15076
|
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ import_react13.default.createElement(
|
|
15087
15077
|
SavedViewsDeleteConfirmationModalShared,
|
|
@@ -15126,37 +15116,27 @@ var DEFAULT_COLUMN_STATE = {
|
|
|
15126
15116
|
rowGroupIndex: null,
|
|
15127
15117
|
flex: null
|
|
15128
15118
|
};
|
|
15129
|
-
var
|
|
15130
|
-
return "children" in colDef && Array.isArray(colDef.children);
|
|
15131
|
-
};
|
|
15119
|
+
var flattenColumnDefs = (defs) => defs.flatMap((d) => "children" in d ? flattenColumnDefs(d.children) : [d]);
|
|
15132
15120
|
var getColumnStateFromDefs = (columnDefs) => {
|
|
15133
|
-
return columnDefs.
|
|
15134
|
-
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
return
|
|
15138
|
-
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
sortIndex: null,
|
|
15153
|
-
pivot: false,
|
|
15154
|
-
pivotIndex: null,
|
|
15155
|
-
aggFunc: null,
|
|
15156
|
-
rowGroup: false,
|
|
15157
|
-
rowGroupIndex: null,
|
|
15158
|
-
flex: colDef.flex ?? null
|
|
15159
|
-
};
|
|
15121
|
+
return flattenColumnDefs(columnDefs).map((colDef) => {
|
|
15122
|
+
const field = colDef.field ?? colDef.colId;
|
|
15123
|
+
if (!field)
|
|
15124
|
+
return null;
|
|
15125
|
+
return {
|
|
15126
|
+
colId: field,
|
|
15127
|
+
hide: colDef.hide ?? false,
|
|
15128
|
+
pinned: colDef.pinned ?? null,
|
|
15129
|
+
width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
|
|
15130
|
+
sort: null,
|
|
15131
|
+
sortIndex: null,
|
|
15132
|
+
pivot: false,
|
|
15133
|
+
pivotIndex: null,
|
|
15134
|
+
aggFunc: null,
|
|
15135
|
+
rowGroup: false,
|
|
15136
|
+
rowGroupIndex: null,
|
|
15137
|
+
flex: colDef.flex ?? null
|
|
15138
|
+
};
|
|
15139
|
+
}).filter((col) => col !== null);
|
|
15160
15140
|
};
|
|
15161
15141
|
var extractDefaultView = (gridApi, receivedConfig) => {
|
|
15162
15142
|
const columnDefs = gridApi.getColumnDefs() ?? [];
|
|
@@ -15202,14 +15182,10 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15202
15182
|
const [config, setConfig] = (0, import_react15.useState)(
|
|
15203
15183
|
() => getSmartGridConfig(gridApi)
|
|
15204
15184
|
);
|
|
15205
|
-
const eventListenersDisabledRef = (0, import_react15.useRef)(false);
|
|
15206
15185
|
(0, import_react15.useEffect)(() => {
|
|
15207
15186
|
if (!gridApi)
|
|
15208
15187
|
return;
|
|
15209
15188
|
const updateConfig = () => {
|
|
15210
|
-
if (eventListenersDisabledRef.current) {
|
|
15211
|
-
return;
|
|
15212
|
-
}
|
|
15213
15189
|
setConfig(getSmartGridConfig(gridApi));
|
|
15214
15190
|
};
|
|
15215
15191
|
GRID_STATE_EVENTS.forEach((event) => {
|
|
@@ -15221,13 +15197,7 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15221
15197
|
});
|
|
15222
15198
|
};
|
|
15223
15199
|
}, [gridApi]);
|
|
15224
|
-
|
|
15225
|
-
eventListenersDisabledRef.current = true;
|
|
15226
|
-
};
|
|
15227
|
-
const enableEventListeners = () => {
|
|
15228
|
-
eventListenersDisabledRef.current = false;
|
|
15229
|
-
};
|
|
15230
|
-
return { config, setConfig, disableEventListeners, enableEventListeners };
|
|
15200
|
+
return { config, setConfig };
|
|
15231
15201
|
};
|
|
15232
15202
|
|
|
15233
15203
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
@@ -15241,17 +15211,15 @@ var SmartGridSavedViews = (props) => {
|
|
|
15241
15211
|
if (!gridApi)
|
|
15242
15212
|
return item;
|
|
15243
15213
|
const isPresetView = item.view_level === "default";
|
|
15244
|
-
const newConfig = item.table_config;
|
|
15245
|
-
const transformedConfig = props.transformSettings?.(newConfig) ?? newConfig;
|
|
15246
15214
|
if (isPresetView) {
|
|
15247
15215
|
updateTableConfig(item, gridApi, "smart-grid");
|
|
15248
|
-
setTableConfig(
|
|
15216
|
+
setTableConfig(item.table_config);
|
|
15249
15217
|
return item;
|
|
15250
15218
|
}
|
|
15251
15219
|
const updatedView = {
|
|
15252
15220
|
...item,
|
|
15253
15221
|
table_config: customAndConfigSync(
|
|
15254
|
-
|
|
15222
|
+
item.table_config,
|
|
15255
15223
|
tableConfig
|
|
15256
15224
|
)
|
|
15257
15225
|
};
|
|
@@ -15273,8 +15241,7 @@ var SmartGridSavedViews = (props) => {
|
|
|
15273
15241
|
defaultView,
|
|
15274
15242
|
presetViews,
|
|
15275
15243
|
tableName: props.tableName,
|
|
15276
|
-
tableConfig
|
|
15277
|
-
backend: props.backend
|
|
15244
|
+
tableConfig
|
|
15278
15245
|
}
|
|
15279
15246
|
);
|
|
15280
15247
|
};
|