@procore/saved-views 1.0.1-estimatingFork.3 → 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 +344 -398
- package/dist/legacy/index.mjs +291 -345
- package/dist/modern/index.d.mts +11 -30
- package/dist/modern/index.d.ts +11 -30
- package/dist/modern/index.js +344 -397
- package/dist/modern/index.mjs +291 -344
- 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,17 +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
|
-
|
|
11629
|
-
|
|
11630
|
-
console.log(
|
|
11631
|
-
"[SavedViews]: Showing update button - view config, current config",
|
|
11632
|
-
cleanedViewConfig,
|
|
11633
|
-
cleanedCurrentConfig
|
|
11634
|
-
);
|
|
11635
|
-
}
|
|
11636
|
-
return isEqual2;
|
|
11804
|
+
return import_lodash.default.isEqual(
|
|
11805
|
+
cleanObject(normalizedViewConfig, provider),
|
|
11806
|
+
cleanObject(normalizedCurrentConfig, provider)
|
|
11807
|
+
);
|
|
11637
11808
|
};
|
|
11638
11809
|
var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
11639
11810
|
switch (viewLevel) {
|
|
@@ -11650,9 +11821,10 @@ var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
|
11650
11821
|
|
|
11651
11822
|
// src/components/panels/useGroups.ts
|
|
11652
11823
|
var import_react6 = require("react");
|
|
11653
|
-
var useGroups = () => {
|
|
11824
|
+
var useGroups = (isProjectLevelTool) => {
|
|
11825
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11654
11826
|
const [groups, setGroups] = (0, import_react6.useState)(
|
|
11655
|
-
Object.fromEntries(
|
|
11827
|
+
Object.fromEntries(viewLevels.map((level) => [level, true]))
|
|
11656
11828
|
);
|
|
11657
11829
|
const toggleGroup = (group) => {
|
|
11658
11830
|
setGroups((groups2) => ({ ...groups2, [group]: !groups2[group] }));
|
|
@@ -11661,7 +11833,7 @@ var useGroups = () => {
|
|
|
11661
11833
|
};
|
|
11662
11834
|
|
|
11663
11835
|
// src/components/panels/ViewLevelHeader.tsx
|
|
11664
|
-
var
|
|
11836
|
+
var import_core_react6 = require("@procore/core-react");
|
|
11665
11837
|
var import_react7 = __toESM(require("react"));
|
|
11666
11838
|
var groupIcon = (group) => {
|
|
11667
11839
|
switch (group) {
|
|
@@ -11673,26 +11845,26 @@ var groupIcon = (group) => {
|
|
|
11673
11845
|
return /* @__PURE__ */ import_react7.default.createElement(Building_default, null);
|
|
11674
11846
|
}
|
|
11675
11847
|
};
|
|
11676
|
-
var Header = styled_components_esm_default(
|
|
11848
|
+
var Header = styled_components_esm_default(import_core_react6.Flex)`
|
|
11677
11849
|
width: 100%;
|
|
11678
11850
|
&:hover {
|
|
11679
|
-
background-color: ${
|
|
11851
|
+
background-color: ${import_core_react6.colors.gray98};
|
|
11680
11852
|
}
|
|
11681
11853
|
`;
|
|
11682
11854
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
11683
|
-
const I18n = (0,
|
|
11855
|
+
const I18n = (0, import_core_react6.useI18nContext)();
|
|
11684
11856
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
11685
11857
|
Header,
|
|
11686
11858
|
{
|
|
11687
11859
|
alignItems: "center",
|
|
11688
|
-
padding: `${
|
|
11689
|
-
gap: `${
|
|
11860
|
+
padding: `${import_core_react6.spacing.sm}px`,
|
|
11861
|
+
gap: `${import_core_react6.spacing.sm}px`,
|
|
11690
11862
|
style: { cursor: "pointer" },
|
|
11691
11863
|
onClick: () => toggleGroup(group)
|
|
11692
11864
|
},
|
|
11693
11865
|
expanded ? /* @__PURE__ */ import_react7.default.createElement(ChevronDown_default, { size: "sm" }) : /* @__PURE__ */ import_react7.default.createElement(ChevronRight_default, { size: "sm" }),
|
|
11694
11866
|
groupIcon(group),
|
|
11695
|
-
/* @__PURE__ */ import_react7.default.createElement(
|
|
11867
|
+
/* @__PURE__ */ import_react7.default.createElement(import_core_react6.Typography, { weight: "semibold" }, I18n.t(`savedViews.viewLevel.${group}`))
|
|
11696
11868
|
);
|
|
11697
11869
|
};
|
|
11698
11870
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
@@ -11710,21 +11882,21 @@ var useScrollToRef = (dependency) => {
|
|
|
11710
11882
|
};
|
|
11711
11883
|
|
|
11712
11884
|
// src/components/panels/PanelContent.styles.ts
|
|
11713
|
-
var
|
|
11714
|
-
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)`
|
|
11715
11887
|
width: 100%;
|
|
11716
11888
|
padding-left: 35px;
|
|
11717
11889
|
padding-right: 4px;
|
|
11718
|
-
background-color: ${({ selected }) => selected ?
|
|
11890
|
+
background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : "transparent"};
|
|
11719
11891
|
|
|
11720
11892
|
&:hover {
|
|
11721
|
-
background-color: ${({ selected }) => selected ?
|
|
11893
|
+
background-color: ${({ selected }) => selected ? import_core_react7.colors.blue96 : import_core_react7.colors.gray98};
|
|
11722
11894
|
}
|
|
11723
11895
|
`;
|
|
11724
|
-
var Panel2 = styled_components_esm_default(
|
|
11896
|
+
var Panel2 = styled_components_esm_default(import_core_react7.DetailPage.Card)`
|
|
11725
11897
|
margin: 0;
|
|
11726
11898
|
height: 100%;
|
|
11727
|
-
padding-top: ${
|
|
11899
|
+
padding-top: ${import_core_react7.spacing.sm}px;
|
|
11728
11900
|
box-shadow: none;
|
|
11729
11901
|
`;
|
|
11730
11902
|
|
|
@@ -11732,9 +11904,9 @@ var Panel2 = styled_components_esm_default(import_core_react6.DetailPage.Card)`
|
|
|
11732
11904
|
var PanelContent = (props) => {
|
|
11733
11905
|
const { queryInput, selectedSavedView, tableConfig } = props;
|
|
11734
11906
|
const { showToast } = (0, import_toast_alert2.useToastAlertContext)();
|
|
11735
|
-
const I18n = (0,
|
|
11736
|
-
const { data: savedViewsFromQuery, error: savedViewsError } =
|
|
11737
|
-
const updateMutation =
|
|
11907
|
+
const I18n = (0, import_core_react8.useI18nContext)();
|
|
11908
|
+
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
11909
|
+
const updateMutation = useUpdateSavedView(queryInput);
|
|
11738
11910
|
const { mutate: updateSavedView } = updateMutation;
|
|
11739
11911
|
const isUpdateLoading = "isPending" in updateMutation ? updateMutation.isPending : updateMutation.isLoading ?? false;
|
|
11740
11912
|
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
@@ -11745,14 +11917,14 @@ var PanelContent = (props) => {
|
|
|
11745
11917
|
errorToastRef.current = savedViewsError;
|
|
11746
11918
|
}
|
|
11747
11919
|
}, [savedViewsError, showToast, I18n]);
|
|
11748
|
-
const { data: permissions } = props.
|
|
11749
|
-
props.queryInput
|
|
11750
|
-
);
|
|
11920
|
+
const { data: permissions } = useSavedViewsPermissions(props.queryInput);
|
|
11751
11921
|
const selectedRowRef = useScrollToRef(savedViews);
|
|
11752
|
-
const { groups, toggleGroup } = useGroups();
|
|
11753
11922
|
const isTemporarySelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === "temporary";
|
|
11754
11923
|
const temporaryView = savedViews == null ? void 0 : savedViews.find((view) => view.id === "temporary");
|
|
11755
11924
|
const presetViews = props.presetViews || [props.defaultView];
|
|
11925
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
11926
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11927
|
+
const { groups, toggleGroup } = useGroups(isProjectLevelTool);
|
|
11756
11928
|
const onUpdate = (data) => {
|
|
11757
11929
|
const newSavedView = {
|
|
11758
11930
|
...data,
|
|
@@ -11769,7 +11941,7 @@ var PanelContent = (props) => {
|
|
|
11769
11941
|
}
|
|
11770
11942
|
});
|
|
11771
11943
|
};
|
|
11772
|
-
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(
|
|
11773
11945
|
Row,
|
|
11774
11946
|
{
|
|
11775
11947
|
selected: isTemporarySelected,
|
|
@@ -11781,8 +11953,7 @@ var PanelContent = (props) => {
|
|
|
11781
11953
|
{
|
|
11782
11954
|
item: temporaryView,
|
|
11783
11955
|
selected: isTemporarySelected,
|
|
11784
|
-
onClearTemporary: props.onClearTemporary
|
|
11785
|
-
enableSharingViews: false
|
|
11956
|
+
onClearTemporary: props.onClearTemporary
|
|
11786
11957
|
}
|
|
11787
11958
|
)
|
|
11788
11959
|
), presetViews.map((presetView) => {
|
|
@@ -11799,12 +11970,11 @@ var PanelContent = (props) => {
|
|
|
11799
11970
|
SavedViewCollectionMenuItem,
|
|
11800
11971
|
{
|
|
11801
11972
|
item: presetView,
|
|
11802
|
-
selected: isSelected
|
|
11803
|
-
enableSharingViews: false
|
|
11973
|
+
selected: isSelected
|
|
11804
11974
|
}
|
|
11805
11975
|
)
|
|
11806
11976
|
);
|
|
11807
|
-
}),
|
|
11977
|
+
}), viewLevels.map((level) => {
|
|
11808
11978
|
const isExpanded = groups[level];
|
|
11809
11979
|
const views = isExpanded && savedViews ? savedViews.filter(
|
|
11810
11980
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
@@ -11848,8 +12018,7 @@ var PanelContent = (props) => {
|
|
|
11848
12018
|
isUpdateProcessing: isUpdateLoading,
|
|
11849
12019
|
onEdit: () => props.openModal("update" /* UPDATE */),
|
|
11850
12020
|
onDelete: props.onDelete,
|
|
11851
|
-
permissions
|
|
11852
|
-
enableSharingViews: false
|
|
12021
|
+
permissions
|
|
11853
12022
|
}
|
|
11854
12023
|
)
|
|
11855
12024
|
);
|
|
@@ -11864,16 +12033,16 @@ var import_react_query3 = require("@tanstack/react-query");
|
|
|
11864
12033
|
var import_toast_alert3 = require("@procore/toast-alert");
|
|
11865
12034
|
|
|
11866
12035
|
// src/components/modals/DeleteConfirmationModal.tsx
|
|
11867
|
-
var
|
|
12036
|
+
var import_core_react9 = require("@procore/core-react");
|
|
11868
12037
|
var import_react10 = __toESM(require("react"));
|
|
11869
12038
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
11870
12039
|
onCancel,
|
|
11871
12040
|
onDelete,
|
|
11872
12041
|
open
|
|
11873
12042
|
}) => {
|
|
11874
|
-
const i18n = (0,
|
|
12043
|
+
const i18n = (0, import_core_react9.useI18nContext)();
|
|
11875
12044
|
return /* @__PURE__ */ import_react10.default.createElement(
|
|
11876
|
-
|
|
12045
|
+
import_core_react9.ConfirmModal,
|
|
11877
12046
|
{
|
|
11878
12047
|
"data-testid": "delete-confirmation-modal",
|
|
11879
12048
|
open,
|
|
@@ -11882,8 +12051,8 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11882
12051
|
onClose: onCancel,
|
|
11883
12052
|
style: { overflowWrap: "anywhere" }
|
|
11884
12053
|
},
|
|
11885
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
11886
|
-
/* @__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"))))
|
|
11887
12056
|
);
|
|
11888
12057
|
};
|
|
11889
12058
|
|
|
@@ -11891,7 +12060,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11891
12060
|
var import_react11 = __toESM(require("react"));
|
|
11892
12061
|
|
|
11893
12062
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
11894
|
-
var
|
|
12063
|
+
var import_core_react10 = require("@procore/core-react");
|
|
11895
12064
|
var React19 = __toESM(require("react"));
|
|
11896
12065
|
|
|
11897
12066
|
// ../../node_modules/yup/index.esm.js
|
|
@@ -14187,10 +14356,11 @@ var TupleSchema = class extends Schema {
|
|
|
14187
14356
|
create$1.prototype = TupleSchema.prototype;
|
|
14188
14357
|
|
|
14189
14358
|
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
14190
|
-
var getViewLevelOptions = (permissions, i18n) => {
|
|
14359
|
+
var getViewLevelOptions = (permissions, i18n, isProjectLevelTool = true) => {
|
|
14191
14360
|
const options = ["personal"];
|
|
14192
|
-
if (permissions == null ? void 0 : permissions.can_create_project_saved_views)
|
|
14361
|
+
if (isProjectLevelTool && (permissions == null ? void 0 : permissions.can_create_project_saved_views)) {
|
|
14193
14362
|
options.push("project");
|
|
14363
|
+
}
|
|
14194
14364
|
if (permissions == null ? void 0 : permissions.can_create_company_saved_views)
|
|
14195
14365
|
options.push("company");
|
|
14196
14366
|
return options.map((option) => ({
|
|
@@ -14220,7 +14390,6 @@ function extractMessage(error, I18n) {
|
|
|
14220
14390
|
}
|
|
14221
14391
|
|
|
14222
14392
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14223
|
-
var { useEffect: useEffect2, useRef: useRef2 } = React19;
|
|
14224
14393
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14225
14394
|
overflow: auto;
|
|
14226
14395
|
`;
|
|
@@ -14237,38 +14406,22 @@ var FormModalBase = ({
|
|
|
14237
14406
|
defaultView,
|
|
14238
14407
|
selectedSavedView,
|
|
14239
14408
|
setOpenEditCreateModal,
|
|
14240
|
-
onSelect
|
|
14241
|
-
backend
|
|
14409
|
+
onSelect
|
|
14242
14410
|
}) => {
|
|
14243
|
-
const I18n = (0,
|
|
14411
|
+
const I18n = (0, import_core_react10.useI18nContext)();
|
|
14244
14412
|
const NAME_MAX_LENGTH = 150;
|
|
14245
|
-
const originalBodyWidth = useRef2("");
|
|
14246
|
-
useEffect2(() => {
|
|
14247
|
-
if (open) {
|
|
14248
|
-
originalBodyWidth.current = document.body.style.width || "";
|
|
14249
|
-
document.body.style.width = "100%";
|
|
14250
|
-
} else {
|
|
14251
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14252
|
-
}
|
|
14253
|
-
return () => {
|
|
14254
|
-
if (originalBodyWidth.current !== void 0) {
|
|
14255
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14256
|
-
}
|
|
14257
|
-
};
|
|
14258
|
-
}, [open]);
|
|
14259
|
-
const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
|
|
14260
14413
|
const {
|
|
14261
14414
|
mutate: createSavedView,
|
|
14262
14415
|
isPending: isCreating,
|
|
14263
14416
|
error: createError,
|
|
14264
14417
|
reset: resetCreateMutation
|
|
14265
|
-
} =
|
|
14418
|
+
} = useCreateSavedView(queryInput);
|
|
14266
14419
|
const {
|
|
14267
14420
|
mutate: updateSavedView,
|
|
14268
14421
|
isPending: isUpdating,
|
|
14269
14422
|
error: updateError,
|
|
14270
14423
|
reset: resetUpdateMutation
|
|
14271
|
-
} =
|
|
14424
|
+
} = useUpdateSavedView(queryInput);
|
|
14272
14425
|
const resetMutations = () => {
|
|
14273
14426
|
resetCreateMutation();
|
|
14274
14427
|
resetUpdateMutation();
|
|
@@ -14277,7 +14430,7 @@ var FormModalBase = ({
|
|
|
14277
14430
|
resetMutations();
|
|
14278
14431
|
onCancel();
|
|
14279
14432
|
};
|
|
14280
|
-
const { data: permissions } =
|
|
14433
|
+
const { data: permissions } = useSavedViewsPermissions(queryInput);
|
|
14281
14434
|
const isLoading = isCreating || isUpdating;
|
|
14282
14435
|
const errors = extractMessage(createError || updateError, I18n);
|
|
14283
14436
|
const handleOnSubmit = (data) => {
|
|
@@ -14308,9 +14461,14 @@ var FormModalBase = ({
|
|
|
14308
14461
|
});
|
|
14309
14462
|
}
|
|
14310
14463
|
};
|
|
14311
|
-
const
|
|
14464
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
14465
|
+
const viewLevelOptions = getViewLevelOptions(
|
|
14466
|
+
permissions,
|
|
14467
|
+
I18n,
|
|
14468
|
+
isProjectLevelTool
|
|
14469
|
+
);
|
|
14312
14470
|
return /* @__PURE__ */ React19.createElement(
|
|
14313
|
-
|
|
14471
|
+
import_core_react10.Modal,
|
|
14314
14472
|
{
|
|
14315
14473
|
"aria-label": I18n.t("savedViews.ariaLabels.modal"),
|
|
14316
14474
|
onClickOverlay: onClose,
|
|
@@ -14319,14 +14477,14 @@ var FormModalBase = ({
|
|
|
14319
14477
|
"data-testid": "create-update-modal"
|
|
14320
14478
|
},
|
|
14321
14479
|
/* @__PURE__ */ React19.createElement(ScrollContainer, null, /* @__PURE__ */ React19.createElement(
|
|
14322
|
-
|
|
14480
|
+
import_core_react10.Modal.Header,
|
|
14323
14481
|
{
|
|
14324
14482
|
onClose,
|
|
14325
|
-
style: { borderBottom: `1px solid ${
|
|
14483
|
+
style: { borderBottom: `1px solid ${import_core_react10.colors.gray85}` }
|
|
14326
14484
|
},
|
|
14327
|
-
/* @__PURE__ */ React19.createElement(
|
|
14485
|
+
/* @__PURE__ */ React19.createElement(import_core_react10.H2, null, header)
|
|
14328
14486
|
), /* @__PURE__ */ React19.createElement(
|
|
14329
|
-
|
|
14487
|
+
import_core_react10.Form,
|
|
14330
14488
|
{
|
|
14331
14489
|
initialValues: {
|
|
14332
14490
|
name: initialName,
|
|
@@ -14351,14 +14509,14 @@ var FormModalBase = ({
|
|
|
14351
14509
|
onReset: onCancel,
|
|
14352
14510
|
validateOnChange: true
|
|
14353
14511
|
},
|
|
14354
|
-
/* @__PURE__ */ React19.createElement(
|
|
14355
|
-
|
|
14512
|
+
/* @__PURE__ */ React19.createElement(import_core_react10.Form.Form, { name: header }, /* @__PURE__ */ React19.createElement(
|
|
14513
|
+
import_core_react10.Modal.Body,
|
|
14356
14514
|
{
|
|
14357
|
-
style: { paddingTop: 0, paddingBottom: 0, marginTop:
|
|
14515
|
+
style: { paddingTop: 0, paddingBottom: 0, marginTop: import_core_react10.spacing.lg }
|
|
14358
14516
|
},
|
|
14359
|
-
errors && /* @__PURE__ */ React19.createElement(
|
|
14360
|
-
/* @__PURE__ */ React19.createElement(
|
|
14361
|
-
|
|
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,
|
|
14362
14520
|
{
|
|
14363
14521
|
name: "name",
|
|
14364
14522
|
error: errors == null ? void 0 : errors.name,
|
|
@@ -14369,12 +14527,12 @@ var FormModalBase = ({
|
|
|
14369
14527
|
}
|
|
14370
14528
|
)),
|
|
14371
14529
|
/* @__PURE__ */ React19.createElement(
|
|
14372
|
-
|
|
14530
|
+
import_core_react10.Form.Row,
|
|
14373
14531
|
{
|
|
14374
|
-
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 }
|
|
14375
14533
|
},
|
|
14376
14534
|
/* @__PURE__ */ React19.createElement(
|
|
14377
|
-
|
|
14535
|
+
import_core_react10.Form.TextArea,
|
|
14378
14536
|
{
|
|
14379
14537
|
name: "description",
|
|
14380
14538
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14384,11 +14542,10 @@ var FormModalBase = ({
|
|
|
14384
14542
|
}
|
|
14385
14543
|
)
|
|
14386
14544
|
),
|
|
14387
|
-
viewLevelOptions.length > 1 && mode === "create" /* CREATE */ ? /* @__PURE__ */ React19.createElement(
|
|
14388
|
-
|
|
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,
|
|
14389
14547
|
{
|
|
14390
14548
|
name: "view_level",
|
|
14391
|
-
qa: { label: "view-level" },
|
|
14392
14549
|
options: viewLevelOptions,
|
|
14393
14550
|
label: I18n.t("savedViews.modal.fields.viewLevel"),
|
|
14394
14551
|
colWidth: 12,
|
|
@@ -14396,8 +14553,8 @@ var FormModalBase = ({
|
|
|
14396
14553
|
onClear: false
|
|
14397
14554
|
}
|
|
14398
14555
|
)) : /* @__PURE__ */ React19.createElement(React19.Fragment, null)
|
|
14399
|
-
), /* @__PURE__ */ React19.createElement(
|
|
14400
|
-
|
|
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,
|
|
14401
14558
|
{
|
|
14402
14559
|
"data-testid": "create-update-modal-button",
|
|
14403
14560
|
type: "submit",
|
|
@@ -14412,7 +14569,7 @@ var FormModalBase = ({
|
|
|
14412
14569
|
};
|
|
14413
14570
|
|
|
14414
14571
|
// src/components/modals/form-modal/FormModal.tsx
|
|
14415
|
-
var
|
|
14572
|
+
var import_core_react11 = require("@procore/core-react");
|
|
14416
14573
|
var FormModal = ({
|
|
14417
14574
|
open,
|
|
14418
14575
|
mode,
|
|
@@ -14423,10 +14580,9 @@ var FormModal = ({
|
|
|
14423
14580
|
selectedSavedView,
|
|
14424
14581
|
setOpenEditCreateModal,
|
|
14425
14582
|
onSelect,
|
|
14426
|
-
defaultView
|
|
14427
|
-
backend
|
|
14583
|
+
defaultView
|
|
14428
14584
|
}) => {
|
|
14429
|
-
const i18n = (0,
|
|
14585
|
+
const i18n = (0, import_core_react11.useI18nContext)();
|
|
14430
14586
|
return /* @__PURE__ */ import_react11.default.createElement(
|
|
14431
14587
|
FormModalBase,
|
|
14432
14588
|
{
|
|
@@ -14442,14 +14598,13 @@ var FormModal = ({
|
|
|
14442
14598
|
selectedSavedView,
|
|
14443
14599
|
setOpenEditCreateModal,
|
|
14444
14600
|
onSelect,
|
|
14445
|
-
defaultView
|
|
14446
|
-
backend
|
|
14601
|
+
defaultView
|
|
14447
14602
|
}
|
|
14448
14603
|
);
|
|
14449
14604
|
};
|
|
14450
14605
|
|
|
14451
14606
|
// src/components/modals/form-modal/SharedViewFormModal.tsx
|
|
14452
|
-
var
|
|
14607
|
+
var import_core_react12 = require("@procore/core-react");
|
|
14453
14608
|
var React21 = __toESM(require("react"));
|
|
14454
14609
|
var SharedViewFormModal = ({
|
|
14455
14610
|
open,
|
|
@@ -14461,7 +14616,7 @@ var SharedViewFormModal = ({
|
|
|
14461
14616
|
isCreating,
|
|
14462
14617
|
resetCreateError
|
|
14463
14618
|
}) => {
|
|
14464
|
-
const I18n = (0,
|
|
14619
|
+
const I18n = (0, import_core_react12.useI18nContext)();
|
|
14465
14620
|
const NAME_MAX_LENGTH = 150;
|
|
14466
14621
|
const errors = extractMessage(createError, I18n);
|
|
14467
14622
|
const handleNameChange = () => {
|
|
@@ -14473,7 +14628,7 @@ var SharedViewFormModal = ({
|
|
|
14473
14628
|
onCreateView(data.name, data.description);
|
|
14474
14629
|
};
|
|
14475
14630
|
return /* @__PURE__ */ React21.createElement(
|
|
14476
|
-
|
|
14631
|
+
import_core_react12.Modal,
|
|
14477
14632
|
{
|
|
14478
14633
|
"data-testid": "shared-view-form-modal",
|
|
14479
14634
|
open,
|
|
@@ -14481,35 +14636,35 @@ var SharedViewFormModal = ({
|
|
|
14481
14636
|
style: { width: "540px" }
|
|
14482
14637
|
},
|
|
14483
14638
|
/* @__PURE__ */ React21.createElement(
|
|
14484
|
-
|
|
14639
|
+
import_core_react12.Modal.Header,
|
|
14485
14640
|
{
|
|
14486
14641
|
onClose,
|
|
14487
14642
|
style: {
|
|
14488
|
-
paddingTop:
|
|
14489
|
-
paddingBottom:
|
|
14490
|
-
paddingLeft:
|
|
14491
|
-
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
|
|
14492
14647
|
}
|
|
14493
14648
|
},
|
|
14494
14649
|
I18n.t("savedViews.modal.create.title")
|
|
14495
14650
|
),
|
|
14496
14651
|
/* @__PURE__ */ React21.createElement(
|
|
14497
|
-
|
|
14652
|
+
import_core_react12.P,
|
|
14498
14653
|
{
|
|
14499
14654
|
style: {
|
|
14500
|
-
paddingLeft:
|
|
14501
|
-
paddingRight:
|
|
14502
|
-
paddingBottom:
|
|
14503
|
-
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,
|
|
14504
14659
|
margin: 0,
|
|
14505
|
-
color:
|
|
14660
|
+
color: import_core_react12.colors.gray45,
|
|
14506
14661
|
whiteSpace: "pre-line"
|
|
14507
14662
|
}
|
|
14508
14663
|
},
|
|
14509
14664
|
I18n.t("savedViews.modal.copyConfirmation.description")
|
|
14510
14665
|
),
|
|
14511
14666
|
/* @__PURE__ */ React21.createElement(
|
|
14512
|
-
|
|
14667
|
+
import_core_react12.Form,
|
|
14513
14668
|
{
|
|
14514
14669
|
initialValues: {
|
|
14515
14670
|
name: fetchedView.name,
|
|
@@ -14527,20 +14682,20 @@ var SharedViewFormModal = ({
|
|
|
14527
14682
|
onSubmit: handleOnSubmit,
|
|
14528
14683
|
validateOnChange: true
|
|
14529
14684
|
},
|
|
14530
|
-
/* @__PURE__ */ React21.createElement(
|
|
14531
|
-
|
|
14685
|
+
/* @__PURE__ */ React21.createElement(import_core_react12.Form.Form, { name: "share-view-form" }, /* @__PURE__ */ React21.createElement(
|
|
14686
|
+
import_core_react12.Modal.Body,
|
|
14532
14687
|
{
|
|
14533
14688
|
style: {
|
|
14534
|
-
paddingTop:
|
|
14689
|
+
paddingTop: import_core_react12.spacing.lg,
|
|
14535
14690
|
paddingBottom: 0,
|
|
14536
|
-
borderTop: `1px solid ${
|
|
14691
|
+
borderTop: `1px solid ${import_core_react12.colors.gray85}`
|
|
14537
14692
|
}
|
|
14538
14693
|
},
|
|
14539
|
-
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", {
|
|
14540
14695
|
mode: "create"
|
|
14541
|
-
})), /* @__PURE__ */ React21.createElement(
|
|
14542
|
-
/* @__PURE__ */ React21.createElement(
|
|
14543
|
-
|
|
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,
|
|
14544
14699
|
{
|
|
14545
14700
|
name: "name",
|
|
14546
14701
|
error: errors == null ? void 0 : errors.name,
|
|
@@ -14551,12 +14706,12 @@ var SharedViewFormModal = ({
|
|
|
14551
14706
|
}
|
|
14552
14707
|
)),
|
|
14553
14708
|
/* @__PURE__ */ React21.createElement(
|
|
14554
|
-
|
|
14709
|
+
import_core_react12.Form.Row,
|
|
14555
14710
|
{
|
|
14556
|
-
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 }
|
|
14557
14712
|
},
|
|
14558
14713
|
/* @__PURE__ */ React21.createElement(
|
|
14559
|
-
|
|
14714
|
+
import_core_react12.Form.TextArea,
|
|
14560
14715
|
{
|
|
14561
14716
|
name: "description",
|
|
14562
14717
|
placeholder: I18n.t("savedViews.modal.fields.description"),
|
|
@@ -14566,8 +14721,8 @@ var SharedViewFormModal = ({
|
|
|
14566
14721
|
}
|
|
14567
14722
|
)
|
|
14568
14723
|
)
|
|
14569
|
-
), /* @__PURE__ */ React21.createElement(
|
|
14570
|
-
|
|
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,
|
|
14571
14726
|
{
|
|
14572
14727
|
variant: "secondary",
|
|
14573
14728
|
onClick: onCreateTemporaryView,
|
|
@@ -14576,7 +14731,7 @@ var SharedViewFormModal = ({
|
|
|
14576
14731
|
},
|
|
14577
14732
|
I18n.t("savedViews.actions.viewTemporarily")
|
|
14578
14733
|
), /* @__PURE__ */ React21.createElement(
|
|
14579
|
-
|
|
14734
|
+
import_core_react12.Button,
|
|
14580
14735
|
{
|
|
14581
14736
|
type: "submit",
|
|
14582
14737
|
variant: "primary",
|
|
@@ -14593,7 +14748,7 @@ var SharedViewFormModal = ({
|
|
|
14593
14748
|
// src/utils/hooks/useViewSelection.ts
|
|
14594
14749
|
var import_react12 = require("react");
|
|
14595
14750
|
var import_react_router_dom = require("react-router-dom");
|
|
14596
|
-
var
|
|
14751
|
+
var import_core_react13 = require("@procore/core-react");
|
|
14597
14752
|
|
|
14598
14753
|
// src/utils/viewStorage.ts
|
|
14599
14754
|
var ViewStorage = {
|
|
@@ -14656,8 +14811,9 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
14656
14811
|
}
|
|
14657
14812
|
};
|
|
14658
14813
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
14659
|
-
const I18n = (0,
|
|
14660
|
-
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}`;
|
|
14661
14817
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14662
14818
|
const [searchParams, setSearchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
14663
14819
|
const previousSavedViewParamRef = (0, import_react12.useRef)(null);
|
|
@@ -14755,177 +14911,6 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14755
14911
|
};
|
|
14756
14912
|
};
|
|
14757
14913
|
|
|
14758
|
-
// node_modules/@procore/core-http/dist/modern/index.js
|
|
14759
|
-
function getCSRFToken() {
|
|
14760
|
-
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
14761
|
-
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
14762
|
-
}
|
|
14763
|
-
function getCSRFHeader() {
|
|
14764
|
-
const csrfToken = getCSRFToken();
|
|
14765
|
-
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
14766
|
-
}
|
|
14767
|
-
function removeLeadingSlash(url) {
|
|
14768
|
-
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
14769
|
-
}
|
|
14770
|
-
function removeTrailingSlash(url) {
|
|
14771
|
-
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
14772
|
-
}
|
|
14773
|
-
function applyBaseUrl(url, baseUrl) {
|
|
14774
|
-
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
14775
|
-
}
|
|
14776
|
-
function getOptions({ headers, ...options }) {
|
|
14777
|
-
const opts = {
|
|
14778
|
-
credentials: "same-origin",
|
|
14779
|
-
headers: {
|
|
14780
|
-
...getCSRFHeader(),
|
|
14781
|
-
...headers
|
|
14782
|
-
},
|
|
14783
|
-
mode: "same-origin",
|
|
14784
|
-
...options
|
|
14785
|
-
};
|
|
14786
|
-
return opts;
|
|
14787
|
-
}
|
|
14788
|
-
function getUrl(url, baseUrl) {
|
|
14789
|
-
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
14790
|
-
}
|
|
14791
|
-
function request(url, { baseUrl, ...options } = {}) {
|
|
14792
|
-
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
14793
|
-
}
|
|
14794
|
-
function requestJSON(url, requestParams = {}) {
|
|
14795
|
-
return request(url, requestParams).then(
|
|
14796
|
-
(response) => response.json()
|
|
14797
|
-
);
|
|
14798
|
-
}
|
|
14799
|
-
|
|
14800
|
-
// src/utils/api/queries.ts
|
|
14801
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
14802
|
-
|
|
14803
|
-
// src/utils/api/queriesHandler.ts
|
|
14804
|
-
var import_react_query = require("@tanstack/react-query");
|
|
14805
|
-
var import_core_react13 = require("@procore/core-react");
|
|
14806
|
-
var useApiRequest = (props, method, mutationKey) => {
|
|
14807
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14808
|
-
const queryClient2 = (0, import_react_query.useQueryClient)();
|
|
14809
|
-
const { locale: locale2 } = (0, import_core_react13.useI18nContext)();
|
|
14810
|
-
return (0, import_react_query.useMutation)({
|
|
14811
|
-
mutationKey,
|
|
14812
|
-
mutationFn: async (savedView) => {
|
|
14813
|
-
let url = "";
|
|
14814
|
-
if (method === "DELETE" || method === "PUT") {
|
|
14815
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.share_token}?permissions_domain=${domain}`;
|
|
14816
|
-
} else {
|
|
14817
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14818
|
-
}
|
|
14819
|
-
const response = await requestJSON(url, {
|
|
14820
|
-
method,
|
|
14821
|
-
body: JSON.stringify(savedView),
|
|
14822
|
-
headers: {
|
|
14823
|
-
"Content-Type": "application/json",
|
|
14824
|
-
"Accept-Language": locale2
|
|
14825
|
-
}
|
|
14826
|
-
});
|
|
14827
|
-
if (response.error) {
|
|
14828
|
-
throw response.error;
|
|
14829
|
-
}
|
|
14830
|
-
return response.data;
|
|
14831
|
-
},
|
|
14832
|
-
onSuccess: (savedView) => {
|
|
14833
|
-
if (method === "DELETE" || method === "POST") {
|
|
14834
|
-
queryClient2.invalidateQueries({
|
|
14835
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14836
|
-
});
|
|
14837
|
-
return;
|
|
14838
|
-
} else {
|
|
14839
|
-
const oldData = queryClient2.getQueryData([
|
|
14840
|
-
"savedViews",
|
|
14841
|
-
domain,
|
|
14842
|
-
tableName
|
|
14843
|
-
]);
|
|
14844
|
-
const oldView = oldData == null ? void 0 : oldData.find(
|
|
14845
|
-
(item) => item.share_token === savedView.share_token
|
|
14846
|
-
);
|
|
14847
|
-
if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
|
|
14848
|
-
queryClient2.invalidateQueries({
|
|
14849
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14850
|
-
});
|
|
14851
|
-
return;
|
|
14852
|
-
}
|
|
14853
|
-
}
|
|
14854
|
-
queryClient2.setQueryData(
|
|
14855
|
-
["savedViews", domain, tableName],
|
|
14856
|
-
(oldData) => {
|
|
14857
|
-
if (!oldData)
|
|
14858
|
-
return [savedView];
|
|
14859
|
-
return oldData.map(
|
|
14860
|
-
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
14861
|
-
);
|
|
14862
|
-
}
|
|
14863
|
-
);
|
|
14864
|
-
}
|
|
14865
|
-
});
|
|
14866
|
-
};
|
|
14867
|
-
|
|
14868
|
-
// src/utils/api/queries.ts
|
|
14869
|
-
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
14870
|
-
var useSavedViewsQuery = (props) => {
|
|
14871
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14872
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14873
|
-
return (0, import_react_query2.useQuery)({
|
|
14874
|
-
queryKey: ["savedViews", domain, tableName],
|
|
14875
|
-
queryFn: async () => {
|
|
14876
|
-
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
14877
|
-
const response = await requestJSON(getUrl2);
|
|
14878
|
-
return response.data;
|
|
14879
|
-
}
|
|
14880
|
-
});
|
|
14881
|
-
};
|
|
14882
|
-
var useSavedViewsPermissions = (props) => {
|
|
14883
|
-
const { projectId, companyId, domain } = props;
|
|
14884
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
14885
|
-
return (0, import_react_query2.useQuery)({
|
|
14886
|
-
queryKey: ["savedViewsConfig", domain],
|
|
14887
|
-
queryFn: async () => {
|
|
14888
|
-
const response = await requestJSON(url);
|
|
14889
|
-
return response.data;
|
|
14890
|
-
}
|
|
14891
|
-
});
|
|
14892
|
-
};
|
|
14893
|
-
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
14894
|
-
"createSavedView",
|
|
14895
|
-
props.domain,
|
|
14896
|
-
props.tableName
|
|
14897
|
-
]);
|
|
14898
|
-
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
14899
|
-
"updateSavedView",
|
|
14900
|
-
props.domain,
|
|
14901
|
-
props.tableName
|
|
14902
|
-
]);
|
|
14903
|
-
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
14904
|
-
"deleteSavedView",
|
|
14905
|
-
props.domain,
|
|
14906
|
-
props.tableName
|
|
14907
|
-
]);
|
|
14908
|
-
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
14909
|
-
const { projectId, companyId } = queryInput;
|
|
14910
|
-
return (0, import_react_query2.useQuery)({
|
|
14911
|
-
enabled: enabled && Boolean(savedViewToken),
|
|
14912
|
-
queryKey: ["savedView", savedViewToken],
|
|
14913
|
-
queryFn: async () => {
|
|
14914
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedViewToken}`;
|
|
14915
|
-
const response = await requestJSON(url);
|
|
14916
|
-
return response.data;
|
|
14917
|
-
}
|
|
14918
|
-
});
|
|
14919
|
-
};
|
|
14920
|
-
var createQueries = (customBackend) => ({
|
|
14921
|
-
useSavedViewsQuery: (customBackend == null ? void 0 : customBackend.useSavedViewsQuery) ?? useSavedViewsQuery,
|
|
14922
|
-
useSavedViewsPermissions: (customBackend == null ? void 0 : customBackend.useSavedViewsPermissions) ?? useSavedViewsPermissions,
|
|
14923
|
-
useCreateSavedView: (customBackend == null ? void 0 : customBackend.useCreateSavedView) ?? useCreateSavedView,
|
|
14924
|
-
useUpdateSavedView: (customBackend == null ? void 0 : customBackend.useUpdateSavedView) ?? useUpdateSavedView,
|
|
14925
|
-
useDeleteSavedView: (customBackend == null ? void 0 : customBackend.useDeleteSavedView) ?? useDeleteSavedView,
|
|
14926
|
-
useFetchSavedViewById: (customBackend == null ? void 0 : customBackend.useFetchSavedViewById) ?? useFetchSavedViewById
|
|
14927
|
-
});
|
|
14928
|
-
|
|
14929
14914
|
// src/components/saved-views/SavedViews.tsx
|
|
14930
14915
|
var StyledPanel = styled_components_esm_default.div`
|
|
14931
14916
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
@@ -14933,15 +14918,14 @@ var StyledPanel = styled_components_esm_default.div`
|
|
|
14933
14918
|
var queryClient = new import_react_query3.QueryClient();
|
|
14934
14919
|
var SavedViewsContent = (props) => {
|
|
14935
14920
|
const { projectId, companyId } = props;
|
|
14936
|
-
const backend = createQueries(props.backend);
|
|
14937
14921
|
const queryInput = {
|
|
14938
14922
|
domain: props.domain,
|
|
14939
14923
|
tableName: props.tableName,
|
|
14940
|
-
projectId,
|
|
14924
|
+
projectId: projectId ?? void 0,
|
|
14941
14925
|
companyId
|
|
14942
14926
|
};
|
|
14943
|
-
const { data: savedViews } =
|
|
14944
|
-
const { mutate: deleteSavedView } =
|
|
14927
|
+
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14928
|
+
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14945
14929
|
const { showToast } = (0, import_toast_alert3.useToastAlertContext)();
|
|
14946
14930
|
const i18n = (0, import_core_react14.useI18nContext)();
|
|
14947
14931
|
const [activeModal, setActiveModal] = (0, import_react13.useState)(null);
|
|
@@ -14969,7 +14953,7 @@ var SavedViewsContent = (props) => {
|
|
|
14969
14953
|
domain: props.domain,
|
|
14970
14954
|
tableName: props.tableName,
|
|
14971
14955
|
userId: props.userId,
|
|
14972
|
-
projectId,
|
|
14956
|
+
projectId: projectId ?? void 0,
|
|
14973
14957
|
companyId,
|
|
14974
14958
|
defaultView: props.defaultView,
|
|
14975
14959
|
onSelect: props.onSelect
|
|
@@ -14978,7 +14962,7 @@ var SavedViewsContent = (props) => {
|
|
|
14978
14962
|
props.presetViews,
|
|
14979
14963
|
openSharedViewModal
|
|
14980
14964
|
);
|
|
14981
|
-
const { data: fetchedView, isError: fetchError } =
|
|
14965
|
+
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
14982
14966
|
(modalData == null ? void 0 : modalData.viewId) ?? null,
|
|
14983
14967
|
queryInput,
|
|
14984
14968
|
Boolean(modalData == null ? void 0 : modalData.viewId)
|
|
@@ -14988,7 +14972,7 @@ var SavedViewsContent = (props) => {
|
|
|
14988
14972
|
isPending: isCreating,
|
|
14989
14973
|
error: createError,
|
|
14990
14974
|
reset: resetCreateError
|
|
14991
|
-
} =
|
|
14975
|
+
} = useCreateSavedView(queryInput);
|
|
14992
14976
|
(0, import_react13.useEffect)(() => {
|
|
14993
14977
|
if (fetchError) {
|
|
14994
14978
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
@@ -15075,8 +15059,7 @@ var SavedViewsContent = (props) => {
|
|
|
15075
15059
|
savedViews: allViews,
|
|
15076
15060
|
provider: props.provider,
|
|
15077
15061
|
userId: props.userId,
|
|
15078
|
-
onClearTemporary: clearTemporaryView
|
|
15079
|
-
backend
|
|
15062
|
+
onClearTemporary: clearTemporaryView
|
|
15080
15063
|
}
|
|
15081
15064
|
))
|
|
15082
15065
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ import_react13.default.createElement(
|
|
@@ -15091,8 +15074,7 @@ var SavedViewsContent = (props) => {
|
|
|
15091
15074
|
selectedSavedView: selectedView,
|
|
15092
15075
|
onSelect: selectView,
|
|
15093
15076
|
setOpenEditCreateModal: closeModal,
|
|
15094
|
-
defaultView: props.defaultView
|
|
15095
|
-
backend
|
|
15077
|
+
defaultView: props.defaultView
|
|
15096
15078
|
}
|
|
15097
15079
|
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ import_react13.default.createElement(
|
|
15098
15080
|
SavedViewsDeleteConfirmationModalShared,
|
|
@@ -15137,37 +15119,27 @@ var DEFAULT_COLUMN_STATE = {
|
|
|
15137
15119
|
rowGroupIndex: null,
|
|
15138
15120
|
flex: null
|
|
15139
15121
|
};
|
|
15140
|
-
var
|
|
15141
|
-
return "children" in colDef && Array.isArray(colDef.children);
|
|
15142
|
-
};
|
|
15122
|
+
var flattenColumnDefs = (defs) => defs.flatMap((d) => "children" in d ? flattenColumnDefs(d.children) : [d]);
|
|
15143
15123
|
var getColumnStateFromDefs = (columnDefs) => {
|
|
15144
|
-
return columnDefs.
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
return
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
|
|
15161
|
-
|
|
15162
|
-
|
|
15163
|
-
sortIndex: null,
|
|
15164
|
-
pivot: false,
|
|
15165
|
-
pivotIndex: null,
|
|
15166
|
-
aggFunc: null,
|
|
15167
|
-
rowGroup: false,
|
|
15168
|
-
rowGroupIndex: null,
|
|
15169
|
-
flex: colDef.flex ?? null
|
|
15170
|
-
};
|
|
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);
|
|
15171
15143
|
};
|
|
15172
15144
|
var extractDefaultView = (gridApi, receivedConfig) => {
|
|
15173
15145
|
var _a, _b;
|
|
@@ -15214,14 +15186,10 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15214
15186
|
const [config, setConfig] = (0, import_react15.useState)(
|
|
15215
15187
|
() => getSmartGridConfig(gridApi)
|
|
15216
15188
|
);
|
|
15217
|
-
const eventListenersDisabledRef = (0, import_react15.useRef)(false);
|
|
15218
15189
|
(0, import_react15.useEffect)(() => {
|
|
15219
15190
|
if (!gridApi)
|
|
15220
15191
|
return;
|
|
15221
15192
|
const updateConfig = () => {
|
|
15222
|
-
if (eventListenersDisabledRef.current) {
|
|
15223
|
-
return;
|
|
15224
|
-
}
|
|
15225
15193
|
setConfig(getSmartGridConfig(gridApi));
|
|
15226
15194
|
};
|
|
15227
15195
|
GRID_STATE_EVENTS.forEach((event) => {
|
|
@@ -15233,55 +15201,34 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15233
15201
|
});
|
|
15234
15202
|
};
|
|
15235
15203
|
}, [gridApi]);
|
|
15236
|
-
|
|
15237
|
-
eventListenersDisabledRef.current = true;
|
|
15238
|
-
};
|
|
15239
|
-
const enableEventListeners = () => {
|
|
15240
|
-
eventListenersDisabledRef.current = false;
|
|
15241
|
-
};
|
|
15242
|
-
return { config, setConfig, disableEventListeners, enableEventListeners };
|
|
15204
|
+
return { config, setConfig };
|
|
15243
15205
|
};
|
|
15244
15206
|
|
|
15245
15207
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15246
15208
|
var SmartGridSavedViews = (props) => {
|
|
15247
15209
|
const { gridApi, userId, projectId, companyId } = props;
|
|
15248
|
-
const {
|
|
15249
|
-
config: tableConfig,
|
|
15250
|
-
setConfig: setTableConfig,
|
|
15251
|
-
disableEventListeners,
|
|
15252
|
-
enableEventListeners
|
|
15253
|
-
} = useSmartGridConfig(gridApi);
|
|
15210
|
+
const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
|
|
15254
15211
|
const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
|
|
15255
15212
|
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15256
15213
|
const onSelect = (0, import_react16.useCallback)(
|
|
15257
15214
|
({ item }) => {
|
|
15258
|
-
var _a;
|
|
15259
15215
|
if (!gridApi)
|
|
15260
15216
|
return item;
|
|
15261
15217
|
const isPresetView = item.view_level === "default";
|
|
15262
|
-
const newConfig = item.table_config;
|
|
15263
|
-
const transformedConfig = ((_a = props.transformSettings) == null ? void 0 : _a.call(props, newConfig)) ?? newConfig;
|
|
15264
|
-
disableEventListeners();
|
|
15265
15218
|
if (isPresetView) {
|
|
15266
15219
|
updateTableConfig(item, gridApi, "smart-grid");
|
|
15267
|
-
setTableConfig(
|
|
15268
|
-
setTimeout(() => {
|
|
15269
|
-
enableEventListeners();
|
|
15270
|
-
}, 0);
|
|
15220
|
+
setTableConfig(item.table_config);
|
|
15271
15221
|
return item;
|
|
15272
15222
|
}
|
|
15273
15223
|
const updatedView = {
|
|
15274
15224
|
...item,
|
|
15275
15225
|
table_config: customAndConfigSync(
|
|
15276
|
-
|
|
15226
|
+
item.table_config,
|
|
15277
15227
|
tableConfig
|
|
15278
15228
|
)
|
|
15279
15229
|
};
|
|
15280
15230
|
updateTableConfig(updatedView, gridApi, "smart-grid");
|
|
15281
15231
|
setTableConfig(updatedView.table_config);
|
|
15282
|
-
setTimeout(() => {
|
|
15283
|
-
enableEventListeners();
|
|
15284
|
-
}, 0);
|
|
15285
15232
|
return updatedView;
|
|
15286
15233
|
},
|
|
15287
15234
|
[gridApi, tableConfig, setTableConfig]
|
|
@@ -15298,8 +15245,7 @@ var SmartGridSavedViews = (props) => {
|
|
|
15298
15245
|
defaultView,
|
|
15299
15246
|
presetViews,
|
|
15300
15247
|
tableName: props.tableName,
|
|
15301
|
-
tableConfig
|
|
15302
|
-
backend: props.backend
|
|
15248
|
+
tableConfig
|
|
15303
15249
|
}
|
|
15304
15250
|
);
|
|
15305
15251
|
};
|