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