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