@procore/saved-views 1.0.1-estimatingFork.3 → 1.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/legacy/index.d.mts +11 -30
- package/dist/legacy/index.d.ts +11 -30
- package/dist/legacy/index.js +334 -396
- package/dist/legacy/index.mjs +281 -343
- package/dist/modern/index.d.mts +11 -30
- package/dist/modern/index.d.ts +11 -30
- package/dist/modern/index.js +334 -395
- package/dist/modern/index.mjs +281 -342
- package/package.json +1 -1
package/dist/legacy/index.mjs
CHANGED
|
@@ -3982,7 +3982,7 @@ var require_lodash = __commonJS({
|
|
|
3982
3982
|
if (typeof func != "function") {
|
|
3983
3983
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
3984
3984
|
}
|
|
3985
|
-
return
|
|
3985
|
+
return setTimeout(function() {
|
|
3986
3986
|
func.apply(undefined2, args);
|
|
3987
3987
|
}, wait);
|
|
3988
3988
|
}
|
|
@@ -5813,7 +5813,7 @@ var require_lodash = __commonJS({
|
|
|
5813
5813
|
return object2[key];
|
|
5814
5814
|
}
|
|
5815
5815
|
var setData = shortOut(baseSetData);
|
|
5816
|
-
var
|
|
5816
|
+
var setTimeout = ctxSetTimeout || function(func, wait) {
|
|
5817
5817
|
return root.setTimeout(func, wait);
|
|
5818
5818
|
};
|
|
5819
5819
|
var setToString = shortOut(baseSetToString);
|
|
@@ -6605,7 +6605,7 @@ var require_lodash = __commonJS({
|
|
|
6605
6605
|
}
|
|
6606
6606
|
function leadingEdge(time) {
|
|
6607
6607
|
lastInvokeTime = time;
|
|
6608
|
-
timerId =
|
|
6608
|
+
timerId = setTimeout(timerExpired, wait);
|
|
6609
6609
|
return leading ? invokeFunc(time) : result2;
|
|
6610
6610
|
}
|
|
6611
6611
|
function remainingWait(time) {
|
|
@@ -6621,7 +6621,7 @@ var require_lodash = __commonJS({
|
|
|
6621
6621
|
if (shouldInvoke(time)) {
|
|
6622
6622
|
return trailingEdge(time);
|
|
6623
6623
|
}
|
|
6624
|
-
timerId =
|
|
6624
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
6625
6625
|
}
|
|
6626
6626
|
function trailingEdge(time) {
|
|
6627
6627
|
timerId = undefined2;
|
|
@@ -6652,12 +6652,12 @@ var require_lodash = __commonJS({
|
|
|
6652
6652
|
}
|
|
6653
6653
|
if (maxing) {
|
|
6654
6654
|
clearTimeout(timerId);
|
|
6655
|
-
timerId =
|
|
6655
|
+
timerId = setTimeout(timerExpired, wait);
|
|
6656
6656
|
return invokeFunc(lastCallTime);
|
|
6657
6657
|
}
|
|
6658
6658
|
}
|
|
6659
6659
|
if (timerId === undefined2) {
|
|
6660
|
-
timerId =
|
|
6660
|
+
timerId = setTimeout(timerExpired, wait);
|
|
6661
6661
|
}
|
|
6662
6662
|
return result2;
|
|
6663
6663
|
}
|
|
@@ -11387,7 +11387,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11387
11387
|
loading: props.isUpdateProcessing
|
|
11388
11388
|
},
|
|
11389
11389
|
i18n.t("savedViews.actions.update")
|
|
11390
|
-
)),
|
|
11390
|
+
)), props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
|
|
11391
11391
|
Button2,
|
|
11392
11392
|
{
|
|
11393
11393
|
onClick: copyShareLink,
|
|
@@ -11436,12 +11436,191 @@ var ExpandedPanel = styled_components_esm_default(Panel)`
|
|
|
11436
11436
|
`;
|
|
11437
11437
|
|
|
11438
11438
|
// src/components/panels/PanelContent.tsx
|
|
11439
|
-
import { Flex as Flex3, useI18nContext as
|
|
11439
|
+
import { Flex as Flex3, useI18nContext as useI18nContext5 } from "@procore/core-react";
|
|
11440
11440
|
import { useToastAlertContext as useToastAlertContext2 } from "@procore/toast-alert";
|
|
11441
11441
|
import React17 from "react";
|
|
11442
11442
|
|
|
11443
|
+
// node_modules/@procore/core-http/dist/modern/index.js
|
|
11444
|
+
function getCSRFToken() {
|
|
11445
|
+
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
11446
|
+
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
11447
|
+
}
|
|
11448
|
+
function getCSRFHeader() {
|
|
11449
|
+
const csrfToken = getCSRFToken();
|
|
11450
|
+
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
11451
|
+
}
|
|
11452
|
+
function removeLeadingSlash(url) {
|
|
11453
|
+
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
11454
|
+
}
|
|
11455
|
+
function removeTrailingSlash(url) {
|
|
11456
|
+
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
11457
|
+
}
|
|
11458
|
+
function applyBaseUrl(url, baseUrl) {
|
|
11459
|
+
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
11460
|
+
}
|
|
11461
|
+
function getOptions({ headers, ...options }) {
|
|
11462
|
+
const opts = {
|
|
11463
|
+
credentials: "same-origin",
|
|
11464
|
+
headers: {
|
|
11465
|
+
...getCSRFHeader(),
|
|
11466
|
+
...headers
|
|
11467
|
+
},
|
|
11468
|
+
mode: "same-origin",
|
|
11469
|
+
...options
|
|
11470
|
+
};
|
|
11471
|
+
return opts;
|
|
11472
|
+
}
|
|
11473
|
+
function getUrl(url, baseUrl) {
|
|
11474
|
+
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
11475
|
+
}
|
|
11476
|
+
function request(url, { baseUrl, ...options } = {}) {
|
|
11477
|
+
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
11478
|
+
}
|
|
11479
|
+
function requestJSON(url, requestParams = {}) {
|
|
11480
|
+
return request(url, requestParams).then(
|
|
11481
|
+
(response) => response.json()
|
|
11482
|
+
);
|
|
11483
|
+
}
|
|
11484
|
+
|
|
11485
|
+
// src/utils/api/queries.ts
|
|
11486
|
+
import { useQuery } from "@tanstack/react-query";
|
|
11487
|
+
|
|
11488
|
+
// src/utils/api/queriesHandler.ts
|
|
11489
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
11490
|
+
import { useI18nContext as useI18nContext3 } from "@procore/core-react";
|
|
11491
|
+
var getBasePath = (companyId, projectId) => {
|
|
11492
|
+
if (projectId) {
|
|
11493
|
+
return `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views`;
|
|
11494
|
+
}
|
|
11495
|
+
return `/rest/v2.0/companies/${companyId}/saved_views`;
|
|
11496
|
+
};
|
|
11497
|
+
var useApiRequest = (props, method, mutationKey) => {
|
|
11498
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
11499
|
+
const queryClient2 = useQueryClient();
|
|
11500
|
+
const { locale: locale2 } = useI18nContext3();
|
|
11501
|
+
const basePath = getBasePath(companyId, projectId);
|
|
11502
|
+
const queryKey = ["savedViews", domain, tableName, companyId, projectId];
|
|
11503
|
+
return useMutation({
|
|
11504
|
+
mutationKey,
|
|
11505
|
+
mutationFn: async (savedView) => {
|
|
11506
|
+
let url = "";
|
|
11507
|
+
if (method === "DELETE" || method === "PUT") {
|
|
11508
|
+
url = `${basePath}/${savedView.share_token}?permissions_domain=${domain}`;
|
|
11509
|
+
} else {
|
|
11510
|
+
url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11511
|
+
}
|
|
11512
|
+
const response = await requestJSON(url, {
|
|
11513
|
+
method,
|
|
11514
|
+
body: JSON.stringify(savedView),
|
|
11515
|
+
headers: {
|
|
11516
|
+
"Content-Type": "application/json",
|
|
11517
|
+
"Accept-Language": locale2
|
|
11518
|
+
}
|
|
11519
|
+
});
|
|
11520
|
+
if (response.error) {
|
|
11521
|
+
throw response.error;
|
|
11522
|
+
}
|
|
11523
|
+
return response.data;
|
|
11524
|
+
},
|
|
11525
|
+
onSuccess: (savedView) => {
|
|
11526
|
+
if (method === "DELETE" || method === "POST") {
|
|
11527
|
+
queryClient2.invalidateQueries({
|
|
11528
|
+
queryKey
|
|
11529
|
+
});
|
|
11530
|
+
return;
|
|
11531
|
+
} else {
|
|
11532
|
+
const oldData = queryClient2.getQueryData(queryKey);
|
|
11533
|
+
const oldView = oldData == null ? void 0 : oldData.find(
|
|
11534
|
+
(item) => item.share_token === savedView.share_token
|
|
11535
|
+
);
|
|
11536
|
+
if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
|
|
11537
|
+
queryClient2.invalidateQueries({
|
|
11538
|
+
queryKey
|
|
11539
|
+
});
|
|
11540
|
+
return;
|
|
11541
|
+
}
|
|
11542
|
+
}
|
|
11543
|
+
queryClient2.setQueryData(queryKey, (oldData) => {
|
|
11544
|
+
if (!oldData)
|
|
11545
|
+
return [savedView];
|
|
11546
|
+
return oldData.map(
|
|
11547
|
+
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
11548
|
+
);
|
|
11549
|
+
});
|
|
11550
|
+
}
|
|
11551
|
+
});
|
|
11552
|
+
};
|
|
11553
|
+
|
|
11443
11554
|
// src/utils/constants/viewLevels.ts
|
|
11444
|
-
var
|
|
11555
|
+
var PROJECT_LEVEL_TOOL_VIEW_LEVELS = [
|
|
11556
|
+
"company",
|
|
11557
|
+
"project",
|
|
11558
|
+
"personal"
|
|
11559
|
+
];
|
|
11560
|
+
var COMPANY_LEVEL_TOOL_VIEW_LEVELS = ["company", "personal"];
|
|
11561
|
+
var getViewLevels = (isProjectLevelTool) => isProjectLevelTool ? PROJECT_LEVEL_TOOL_VIEW_LEVELS : COMPANY_LEVEL_TOOL_VIEW_LEVELS;
|
|
11562
|
+
|
|
11563
|
+
// src/utils/api/queries.ts
|
|
11564
|
+
var PAGE_SIZE = 50 * PROJECT_LEVEL_TOOL_VIEW_LEVELS.length;
|
|
11565
|
+
var getBasePath2 = (companyId, projectId) => {
|
|
11566
|
+
if (projectId) {
|
|
11567
|
+
return `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views`;
|
|
11568
|
+
}
|
|
11569
|
+
return `/rest/v2.0/companies/${companyId}/saved_views`;
|
|
11570
|
+
};
|
|
11571
|
+
var useSavedViewsQuery = (props) => {
|
|
11572
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
11573
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11574
|
+
const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11575
|
+
return useQuery({
|
|
11576
|
+
queryKey: ["savedViews", domain, tableName, companyId, projectId],
|
|
11577
|
+
queryFn: async () => {
|
|
11578
|
+
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
11579
|
+
const response = await requestJSON(getUrl2);
|
|
11580
|
+
return response.data;
|
|
11581
|
+
}
|
|
11582
|
+
});
|
|
11583
|
+
};
|
|
11584
|
+
var useSavedViewsPermissions = (props) => {
|
|
11585
|
+
const { projectId, companyId, domain } = props;
|
|
11586
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11587
|
+
const url = `${basePath}/permissions?permissions_domain=${domain}`;
|
|
11588
|
+
return useQuery({
|
|
11589
|
+
queryKey: ["savedViewsConfig", domain, companyId, projectId],
|
|
11590
|
+
queryFn: async () => {
|
|
11591
|
+
const response = await requestJSON(url);
|
|
11592
|
+
return response.data;
|
|
11593
|
+
}
|
|
11594
|
+
});
|
|
11595
|
+
};
|
|
11596
|
+
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
11597
|
+
"createSavedView",
|
|
11598
|
+
props.domain,
|
|
11599
|
+
props.tableName
|
|
11600
|
+
]);
|
|
11601
|
+
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
11602
|
+
"updateSavedView",
|
|
11603
|
+
props.domain,
|
|
11604
|
+
props.tableName
|
|
11605
|
+
]);
|
|
11606
|
+
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
11607
|
+
"deleteSavedView",
|
|
11608
|
+
props.domain,
|
|
11609
|
+
props.tableName
|
|
11610
|
+
]);
|
|
11611
|
+
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
11612
|
+
const { projectId, companyId, domain } = queryInput;
|
|
11613
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11614
|
+
return useQuery({
|
|
11615
|
+
enabled: enabled && Boolean(savedViewToken),
|
|
11616
|
+
queryKey: ["savedView", savedViewToken, companyId, projectId],
|
|
11617
|
+
queryFn: async () => {
|
|
11618
|
+
const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
|
|
11619
|
+
const response = await requestJSON(url);
|
|
11620
|
+
return response.data;
|
|
11621
|
+
}
|
|
11622
|
+
});
|
|
11623
|
+
};
|
|
11445
11624
|
|
|
11446
11625
|
// src/components/panels/PanelContentUtils.ts
|
|
11447
11626
|
var import_lodash = __toESM(require_lodash());
|
|
@@ -11516,12 +11695,10 @@ var getColumnIdentifier = (col) => {
|
|
|
11516
11695
|
};
|
|
11517
11696
|
var updateTableConfig = (view, tableApi, provider) => {
|
|
11518
11697
|
if (provider === "smart-grid") {
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
);
|
|
11524
|
-
}, 0);
|
|
11698
|
+
setSmartGridConfig(
|
|
11699
|
+
tableApi,
|
|
11700
|
+
view.table_config
|
|
11701
|
+
);
|
|
11525
11702
|
} else {
|
|
11526
11703
|
const dataTableApi = tableApi;
|
|
11527
11704
|
const tableConfig = view.table_config;
|
|
@@ -11593,20 +11770,13 @@ var cleanObject = (table_config, provider) => {
|
|
|
11593
11770
|
var normalizeForComparison = (config) => {
|
|
11594
11771
|
if (!(config == null ? void 0 : config.columnState))
|
|
11595
11772
|
return config;
|
|
11596
|
-
const filteredColumnState = config.columnState.filter(
|
|
11597
|
-
(col) => {
|
|
11598
|
-
const colId = getColumnIdentifier(col);
|
|
11599
|
-
return colId !== "drag_handle" && colId !== "ag-Grid-AutoColumn";
|
|
11600
|
-
}
|
|
11601
|
-
);
|
|
11602
11773
|
return {
|
|
11603
|
-
...
|
|
11604
|
-
columnState:
|
|
11605
|
-
const res = import_lodash.default.omit(col, ["aggFunc"]);
|
|
11774
|
+
...config,
|
|
11775
|
+
columnState: config.columnState.map((col) => {
|
|
11606
11776
|
if (col.flex) {
|
|
11607
|
-
return import_lodash.default.omit(
|
|
11777
|
+
return import_lodash.default.omit(col, ["width", "flex"]);
|
|
11608
11778
|
}
|
|
11609
|
-
return
|
|
11779
|
+
return col;
|
|
11610
11780
|
})
|
|
11611
11781
|
};
|
|
11612
11782
|
};
|
|
@@ -11619,17 +11789,10 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
|
|
|
11619
11789
|
);
|
|
11620
11790
|
const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
|
|
11621
11791
|
const normalizedCurrentConfig = normalizeForComparison(tableConfig);
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
console.log(
|
|
11627
|
-
"[SavedViews]: Showing update button - view config, current config",
|
|
11628
|
-
cleanedViewConfig,
|
|
11629
|
-
cleanedCurrentConfig
|
|
11630
|
-
);
|
|
11631
|
-
}
|
|
11632
|
-
return isEqual2;
|
|
11792
|
+
return import_lodash.default.isEqual(
|
|
11793
|
+
cleanObject(normalizedViewConfig, provider),
|
|
11794
|
+
cleanObject(normalizedCurrentConfig, provider)
|
|
11795
|
+
);
|
|
11633
11796
|
};
|
|
11634
11797
|
var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
11635
11798
|
switch (viewLevel) {
|
|
@@ -11646,9 +11809,10 @@ var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
|
11646
11809
|
|
|
11647
11810
|
// src/components/panels/useGroups.ts
|
|
11648
11811
|
import { useState as useState2 } from "react";
|
|
11649
|
-
var useGroups = () => {
|
|
11812
|
+
var useGroups = (isProjectLevelTool) => {
|
|
11813
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11650
11814
|
const [groups, setGroups] = useState2(
|
|
11651
|
-
Object.fromEntries(
|
|
11815
|
+
Object.fromEntries(viewLevels.map((level) => [level, true]))
|
|
11652
11816
|
);
|
|
11653
11817
|
const toggleGroup = (group) => {
|
|
11654
11818
|
setGroups((groups2) => ({ ...groups2, [group]: !groups2[group] }));
|
|
@@ -11662,7 +11826,7 @@ import {
|
|
|
11662
11826
|
Flex as Flex2,
|
|
11663
11827
|
spacing,
|
|
11664
11828
|
Typography,
|
|
11665
|
-
useI18nContext as
|
|
11829
|
+
useI18nContext as useI18nContext4
|
|
11666
11830
|
} from "@procore/core-react";
|
|
11667
11831
|
import React16 from "react";
|
|
11668
11832
|
var groupIcon = (group) => {
|
|
@@ -11682,7 +11846,7 @@ var Header = styled_components_esm_default(Flex2)`
|
|
|
11682
11846
|
}
|
|
11683
11847
|
`;
|
|
11684
11848
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
11685
|
-
const I18n =
|
|
11849
|
+
const I18n = useI18nContext4();
|
|
11686
11850
|
return /* @__PURE__ */ React16.createElement(
|
|
11687
11851
|
Header,
|
|
11688
11852
|
{
|
|
@@ -11739,9 +11903,9 @@ var Panel2 = styled_components_esm_default(DetailPage.Card)`
|
|
|
11739
11903
|
var PanelContent = (props) => {
|
|
11740
11904
|
const { queryInput, selectedSavedView, tableConfig } = props;
|
|
11741
11905
|
const { showToast } = useToastAlertContext2();
|
|
11742
|
-
const I18n =
|
|
11743
|
-
const { data: savedViewsFromQuery, error: savedViewsError } =
|
|
11744
|
-
const updateMutation =
|
|
11906
|
+
const I18n = useI18nContext5();
|
|
11907
|
+
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
11908
|
+
const updateMutation = useUpdateSavedView(queryInput);
|
|
11745
11909
|
const { mutate: updateSavedView } = updateMutation;
|
|
11746
11910
|
const isUpdateLoading = "isPending" in updateMutation ? updateMutation.isPending : updateMutation.isLoading ?? false;
|
|
11747
11911
|
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
@@ -11752,14 +11916,14 @@ var PanelContent = (props) => {
|
|
|
11752
11916
|
errorToastRef.current = savedViewsError;
|
|
11753
11917
|
}
|
|
11754
11918
|
}, [savedViewsError, showToast, I18n]);
|
|
11755
|
-
const { data: permissions } = props.
|
|
11756
|
-
props.queryInput
|
|
11757
|
-
);
|
|
11919
|
+
const { data: permissions } = useSavedViewsPermissions(props.queryInput);
|
|
11758
11920
|
const selectedRowRef = useScrollToRef(savedViews);
|
|
11759
|
-
const { groups, toggleGroup } = useGroups();
|
|
11760
11921
|
const isTemporarySelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === "temporary";
|
|
11761
11922
|
const temporaryView = savedViews == null ? void 0 : savedViews.find((view) => view.id === "temporary");
|
|
11762
11923
|
const presetViews = props.presetViews || [props.defaultView];
|
|
11924
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
11925
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11926
|
+
const { groups, toggleGroup } = useGroups(isProjectLevelTool);
|
|
11763
11927
|
const onUpdate = (data) => {
|
|
11764
11928
|
const newSavedView = {
|
|
11765
11929
|
...data,
|
|
@@ -11788,8 +11952,7 @@ var PanelContent = (props) => {
|
|
|
11788
11952
|
{
|
|
11789
11953
|
item: temporaryView,
|
|
11790
11954
|
selected: isTemporarySelected,
|
|
11791
|
-
onClearTemporary: props.onClearTemporary
|
|
11792
|
-
enableSharingViews: false
|
|
11955
|
+
onClearTemporary: props.onClearTemporary
|
|
11793
11956
|
}
|
|
11794
11957
|
)
|
|
11795
11958
|
), presetViews.map((presetView) => {
|
|
@@ -11806,12 +11969,11 @@ var PanelContent = (props) => {
|
|
|
11806
11969
|
SavedViewCollectionMenuItem,
|
|
11807
11970
|
{
|
|
11808
11971
|
item: presetView,
|
|
11809
|
-
selected: isSelected
|
|
11810
|
-
enableSharingViews: false
|
|
11972
|
+
selected: isSelected
|
|
11811
11973
|
}
|
|
11812
11974
|
)
|
|
11813
11975
|
);
|
|
11814
|
-
}),
|
|
11976
|
+
}), viewLevels.map((level) => {
|
|
11815
11977
|
const isExpanded = groups[level];
|
|
11816
11978
|
const views = isExpanded && savedViews ? savedViews.filter(
|
|
11817
11979
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
@@ -11855,8 +12017,7 @@ var PanelContent = (props) => {
|
|
|
11855
12017
|
isUpdateProcessing: isUpdateLoading,
|
|
11856
12018
|
onEdit: () => props.openModal("update" /* UPDATE */),
|
|
11857
12019
|
onDelete: props.onDelete,
|
|
11858
|
-
permissions
|
|
11859
|
-
enableSharingViews: false
|
|
12020
|
+
permissions
|
|
11860
12021
|
}
|
|
11861
12022
|
)
|
|
11862
12023
|
);
|
|
@@ -11873,7 +12034,7 @@ import {
|
|
|
11873
12034
|
Tooltip,
|
|
11874
12035
|
useI18nContext as useI18nContext11
|
|
11875
12036
|
} from "@procore/core-react";
|
|
11876
|
-
import React22, { useState as useState4, useEffect as
|
|
12037
|
+
import React22, { useState as useState4, useEffect as useEffect3, useCallback as useCallback3 } from "react";
|
|
11877
12038
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
11878
12039
|
import { useToastAlertContext as useToastAlertContext3, ToastAlertProvider } from "@procore/toast-alert";
|
|
11879
12040
|
|
|
@@ -11883,7 +12044,7 @@ import {
|
|
|
11883
12044
|
ConfirmModal,
|
|
11884
12045
|
Modal,
|
|
11885
12046
|
P as P2,
|
|
11886
|
-
useI18nContext as
|
|
12047
|
+
useI18nContext as useI18nContext6
|
|
11887
12048
|
} from "@procore/core-react";
|
|
11888
12049
|
import React18 from "react";
|
|
11889
12050
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
@@ -11891,7 +12052,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11891
12052
|
onDelete,
|
|
11892
12053
|
open
|
|
11893
12054
|
}) => {
|
|
11894
|
-
const i18n =
|
|
12055
|
+
const i18n = useI18nContext6();
|
|
11895
12056
|
return /* @__PURE__ */ React18.createElement(
|
|
11896
12057
|
ConfirmModal,
|
|
11897
12058
|
{
|
|
@@ -11922,7 +12083,7 @@ import {
|
|
|
11922
12083
|
Modal as Modal2,
|
|
11923
12084
|
spacing as spacing3,
|
|
11924
12085
|
Typography as Typography2,
|
|
11925
|
-
useI18nContext as
|
|
12086
|
+
useI18nContext as useI18nContext7
|
|
11926
12087
|
} from "@procore/core-react";
|
|
11927
12088
|
import * as React19 from "react";
|
|
11928
12089
|
|
|
@@ -14219,10 +14380,11 @@ var TupleSchema = class extends Schema {
|
|
|
14219
14380
|
create$1.prototype = TupleSchema.prototype;
|
|
14220
14381
|
|
|
14221
14382
|
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
14222
|
-
var getViewLevelOptions = (permissions, i18n) => {
|
|
14383
|
+
var getViewLevelOptions = (permissions, i18n, isProjectLevelTool = true) => {
|
|
14223
14384
|
const options = ["personal"];
|
|
14224
|
-
if (permissions == null ? void 0 : permissions.can_create_project_saved_views)
|
|
14385
|
+
if (isProjectLevelTool && (permissions == null ? void 0 : permissions.can_create_project_saved_views)) {
|
|
14225
14386
|
options.push("project");
|
|
14387
|
+
}
|
|
14226
14388
|
if (permissions == null ? void 0 : permissions.can_create_company_saved_views)
|
|
14227
14389
|
options.push("company");
|
|
14228
14390
|
return options.map((option) => ({
|
|
@@ -14252,7 +14414,6 @@ function extractMessage(error, I18n) {
|
|
|
14252
14414
|
}
|
|
14253
14415
|
|
|
14254
14416
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14255
|
-
var { useEffect: useEffect2, useRef: useRef2 } = React19;
|
|
14256
14417
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14257
14418
|
overflow: auto;
|
|
14258
14419
|
`;
|
|
@@ -14269,38 +14430,22 @@ var FormModalBase = ({
|
|
|
14269
14430
|
defaultView,
|
|
14270
14431
|
selectedSavedView,
|
|
14271
14432
|
setOpenEditCreateModal,
|
|
14272
|
-
onSelect
|
|
14273
|
-
backend
|
|
14433
|
+
onSelect
|
|
14274
14434
|
}) => {
|
|
14275
|
-
const I18n =
|
|
14435
|
+
const I18n = useI18nContext7();
|
|
14276
14436
|
const NAME_MAX_LENGTH = 150;
|
|
14277
|
-
const originalBodyWidth = useRef2("");
|
|
14278
|
-
useEffect2(() => {
|
|
14279
|
-
if (open) {
|
|
14280
|
-
originalBodyWidth.current = document.body.style.width || "";
|
|
14281
|
-
document.body.style.width = "100%";
|
|
14282
|
-
} else {
|
|
14283
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14284
|
-
}
|
|
14285
|
-
return () => {
|
|
14286
|
-
if (originalBodyWidth.current !== void 0) {
|
|
14287
|
-
document.body.style.width = originalBodyWidth.current;
|
|
14288
|
-
}
|
|
14289
|
-
};
|
|
14290
|
-
}, [open]);
|
|
14291
|
-
const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
|
|
14292
14437
|
const {
|
|
14293
14438
|
mutate: createSavedView,
|
|
14294
14439
|
isPending: isCreating,
|
|
14295
14440
|
error: createError,
|
|
14296
14441
|
reset: resetCreateMutation
|
|
14297
|
-
} =
|
|
14442
|
+
} = useCreateSavedView(queryInput);
|
|
14298
14443
|
const {
|
|
14299
14444
|
mutate: updateSavedView,
|
|
14300
14445
|
isPending: isUpdating,
|
|
14301
14446
|
error: updateError,
|
|
14302
14447
|
reset: resetUpdateMutation
|
|
14303
|
-
} =
|
|
14448
|
+
} = useUpdateSavedView(queryInput);
|
|
14304
14449
|
const resetMutations = () => {
|
|
14305
14450
|
resetCreateMutation();
|
|
14306
14451
|
resetUpdateMutation();
|
|
@@ -14309,7 +14454,7 @@ var FormModalBase = ({
|
|
|
14309
14454
|
resetMutations();
|
|
14310
14455
|
onCancel();
|
|
14311
14456
|
};
|
|
14312
|
-
const { data: permissions } =
|
|
14457
|
+
const { data: permissions } = useSavedViewsPermissions(queryInput);
|
|
14313
14458
|
const isLoading = isCreating || isUpdating;
|
|
14314
14459
|
const errors = extractMessage(createError || updateError, I18n);
|
|
14315
14460
|
const handleOnSubmit = (data) => {
|
|
@@ -14340,7 +14485,12 @@ var FormModalBase = ({
|
|
|
14340
14485
|
});
|
|
14341
14486
|
}
|
|
14342
14487
|
};
|
|
14343
|
-
const
|
|
14488
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
14489
|
+
const viewLevelOptions = getViewLevelOptions(
|
|
14490
|
+
permissions,
|
|
14491
|
+
I18n,
|
|
14492
|
+
isProjectLevelTool
|
|
14493
|
+
);
|
|
14344
14494
|
return /* @__PURE__ */ React19.createElement(
|
|
14345
14495
|
Modal2,
|
|
14346
14496
|
{
|
|
@@ -14420,7 +14570,6 @@ var FormModalBase = ({
|
|
|
14420
14570
|
Form.Select,
|
|
14421
14571
|
{
|
|
14422
14572
|
name: "view_level",
|
|
14423
|
-
qa: { label: "view-level" },
|
|
14424
14573
|
options: viewLevelOptions,
|
|
14425
14574
|
label: I18n.t("savedViews.modal.fields.viewLevel"),
|
|
14426
14575
|
colWidth: 12,
|
|
@@ -14444,7 +14593,7 @@ var FormModalBase = ({
|
|
|
14444
14593
|
};
|
|
14445
14594
|
|
|
14446
14595
|
// src/components/modals/form-modal/FormModal.tsx
|
|
14447
|
-
import { useI18nContext as
|
|
14596
|
+
import { useI18nContext as useI18nContext8 } from "@procore/core-react";
|
|
14448
14597
|
var FormModal = ({
|
|
14449
14598
|
open,
|
|
14450
14599
|
mode,
|
|
@@ -14455,10 +14604,9 @@ var FormModal = ({
|
|
|
14455
14604
|
selectedSavedView,
|
|
14456
14605
|
setOpenEditCreateModal,
|
|
14457
14606
|
onSelect,
|
|
14458
|
-
defaultView
|
|
14459
|
-
backend
|
|
14607
|
+
defaultView
|
|
14460
14608
|
}) => {
|
|
14461
|
-
const i18n =
|
|
14609
|
+
const i18n = useI18nContext8();
|
|
14462
14610
|
return /* @__PURE__ */ React20.createElement(
|
|
14463
14611
|
FormModalBase,
|
|
14464
14612
|
{
|
|
@@ -14474,8 +14622,7 @@ var FormModal = ({
|
|
|
14474
14622
|
selectedSavedView,
|
|
14475
14623
|
setOpenEditCreateModal,
|
|
14476
14624
|
onSelect,
|
|
14477
|
-
defaultView
|
|
14478
|
-
backend
|
|
14625
|
+
defaultView
|
|
14479
14626
|
}
|
|
14480
14627
|
);
|
|
14481
14628
|
};
|
|
@@ -14492,7 +14639,7 @@ import {
|
|
|
14492
14639
|
P as P3,
|
|
14493
14640
|
spacing as spacing4,
|
|
14494
14641
|
Typography as Typography3,
|
|
14495
|
-
useI18nContext as
|
|
14642
|
+
useI18nContext as useI18nContext9
|
|
14496
14643
|
} from "@procore/core-react";
|
|
14497
14644
|
import * as React21 from "react";
|
|
14498
14645
|
var SharedViewFormModal = ({
|
|
@@ -14505,7 +14652,7 @@ var SharedViewFormModal = ({
|
|
|
14505
14652
|
isCreating,
|
|
14506
14653
|
resetCreateError
|
|
14507
14654
|
}) => {
|
|
14508
|
-
const I18n =
|
|
14655
|
+
const I18n = useI18nContext9();
|
|
14509
14656
|
const NAME_MAX_LENGTH = 150;
|
|
14510
14657
|
const errors = extractMessage(createError, I18n);
|
|
14511
14658
|
const handleNameChange = () => {
|
|
@@ -14635,9 +14782,9 @@ var SharedViewFormModal = ({
|
|
|
14635
14782
|
};
|
|
14636
14783
|
|
|
14637
14784
|
// src/utils/hooks/useViewSelection.ts
|
|
14638
|
-
import { useState as useState3, useCallback as useCallback2, useEffect as
|
|
14785
|
+
import { useState as useState3, useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useMemo } from "react";
|
|
14639
14786
|
import { useSearchParams } from "react-router-dom";
|
|
14640
|
-
import { useI18nContext as
|
|
14787
|
+
import { useI18nContext as useI18nContext10 } from "@procore/core-react";
|
|
14641
14788
|
|
|
14642
14789
|
// src/utils/viewStorage.ts
|
|
14643
14790
|
var ViewStorage = {
|
|
@@ -14700,11 +14847,12 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
14700
14847
|
}
|
|
14701
14848
|
};
|
|
14702
14849
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
14703
|
-
const I18n =
|
|
14704
|
-
const
|
|
14850
|
+
const I18n = useI18nContext10();
|
|
14851
|
+
const projectIdSegment = config.projectId ?? "company";
|
|
14852
|
+
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
14705
14853
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14706
14854
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
14707
|
-
const previousSavedViewParamRef =
|
|
14855
|
+
const previousSavedViewParamRef = useRef2(null);
|
|
14708
14856
|
const [selectedSavedView, setSelectedSavedView] = useState3(() => {
|
|
14709
14857
|
const stored = ViewStorage.load(storageKey, config.defaultView);
|
|
14710
14858
|
return stored ?? config.defaultView;
|
|
@@ -14775,7 +14923,7 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14775
14923
|
},
|
|
14776
14924
|
[isViewAlreadySelected, openSharedViewModal, allViews, selectView]
|
|
14777
14925
|
);
|
|
14778
|
-
|
|
14926
|
+
useEffect2(() => {
|
|
14779
14927
|
const savedViewId = searchParams.get("saved-view");
|
|
14780
14928
|
restoreUrlParameter(
|
|
14781
14929
|
savedViewId,
|
|
@@ -14799,177 +14947,6 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14799
14947
|
};
|
|
14800
14948
|
};
|
|
14801
14949
|
|
|
14802
|
-
// node_modules/@procore/core-http/dist/modern/index.js
|
|
14803
|
-
function getCSRFToken() {
|
|
14804
|
-
const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
|
|
14805
|
-
return token ? decodeURIComponent(token.pop() || "") : "";
|
|
14806
|
-
}
|
|
14807
|
-
function getCSRFHeader() {
|
|
14808
|
-
const csrfToken = getCSRFToken();
|
|
14809
|
-
return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
|
|
14810
|
-
}
|
|
14811
|
-
function removeLeadingSlash(url) {
|
|
14812
|
-
return url.startsWith("/") ? url.substring(1, url.length) : url;
|
|
14813
|
-
}
|
|
14814
|
-
function removeTrailingSlash(url) {
|
|
14815
|
-
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
14816
|
-
}
|
|
14817
|
-
function applyBaseUrl(url, baseUrl) {
|
|
14818
|
-
return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
|
|
14819
|
-
}
|
|
14820
|
-
function getOptions({ headers, ...options }) {
|
|
14821
|
-
const opts = {
|
|
14822
|
-
credentials: "same-origin",
|
|
14823
|
-
headers: {
|
|
14824
|
-
...getCSRFHeader(),
|
|
14825
|
-
...headers
|
|
14826
|
-
},
|
|
14827
|
-
mode: "same-origin",
|
|
14828
|
-
...options
|
|
14829
|
-
};
|
|
14830
|
-
return opts;
|
|
14831
|
-
}
|
|
14832
|
-
function getUrl(url, baseUrl) {
|
|
14833
|
-
return baseUrl ? applyBaseUrl(url, baseUrl) : url;
|
|
14834
|
-
}
|
|
14835
|
-
function request(url, { baseUrl, ...options } = {}) {
|
|
14836
|
-
return fetch(getUrl(url, baseUrl), getOptions(options));
|
|
14837
|
-
}
|
|
14838
|
-
function requestJSON(url, requestParams = {}) {
|
|
14839
|
-
return request(url, requestParams).then(
|
|
14840
|
-
(response) => response.json()
|
|
14841
|
-
);
|
|
14842
|
-
}
|
|
14843
|
-
|
|
14844
|
-
// src/utils/api/queries.ts
|
|
14845
|
-
import { useQuery } from "@tanstack/react-query";
|
|
14846
|
-
|
|
14847
|
-
// src/utils/api/queriesHandler.ts
|
|
14848
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
14849
|
-
import { useI18nContext as useI18nContext10 } from "@procore/core-react";
|
|
14850
|
-
var useApiRequest = (props, method, mutationKey) => {
|
|
14851
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14852
|
-
const queryClient2 = useQueryClient();
|
|
14853
|
-
const { locale: locale2 } = useI18nContext10();
|
|
14854
|
-
return useMutation({
|
|
14855
|
-
mutationKey,
|
|
14856
|
-
mutationFn: async (savedView) => {
|
|
14857
|
-
let url = "";
|
|
14858
|
-
if (method === "DELETE" || method === "PUT") {
|
|
14859
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.share_token}?permissions_domain=${domain}`;
|
|
14860
|
-
} else {
|
|
14861
|
-
url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14862
|
-
}
|
|
14863
|
-
const response = await requestJSON(url, {
|
|
14864
|
-
method,
|
|
14865
|
-
body: JSON.stringify(savedView),
|
|
14866
|
-
headers: {
|
|
14867
|
-
"Content-Type": "application/json",
|
|
14868
|
-
"Accept-Language": locale2
|
|
14869
|
-
}
|
|
14870
|
-
});
|
|
14871
|
-
if (response.error) {
|
|
14872
|
-
throw response.error;
|
|
14873
|
-
}
|
|
14874
|
-
return response.data;
|
|
14875
|
-
},
|
|
14876
|
-
onSuccess: (savedView) => {
|
|
14877
|
-
if (method === "DELETE" || method === "POST") {
|
|
14878
|
-
queryClient2.invalidateQueries({
|
|
14879
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14880
|
-
});
|
|
14881
|
-
return;
|
|
14882
|
-
} else {
|
|
14883
|
-
const oldData = queryClient2.getQueryData([
|
|
14884
|
-
"savedViews",
|
|
14885
|
-
domain,
|
|
14886
|
-
tableName
|
|
14887
|
-
]);
|
|
14888
|
-
const oldView = oldData == null ? void 0 : oldData.find(
|
|
14889
|
-
(item) => item.share_token === savedView.share_token
|
|
14890
|
-
);
|
|
14891
|
-
if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
|
|
14892
|
-
queryClient2.invalidateQueries({
|
|
14893
|
-
queryKey: ["savedViews", domain, tableName]
|
|
14894
|
-
});
|
|
14895
|
-
return;
|
|
14896
|
-
}
|
|
14897
|
-
}
|
|
14898
|
-
queryClient2.setQueryData(
|
|
14899
|
-
["savedViews", domain, tableName],
|
|
14900
|
-
(oldData) => {
|
|
14901
|
-
if (!oldData)
|
|
14902
|
-
return [savedView];
|
|
14903
|
-
return oldData.map(
|
|
14904
|
-
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
14905
|
-
);
|
|
14906
|
-
}
|
|
14907
|
-
);
|
|
14908
|
-
}
|
|
14909
|
-
});
|
|
14910
|
-
};
|
|
14911
|
-
|
|
14912
|
-
// src/utils/api/queries.ts
|
|
14913
|
-
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
14914
|
-
var useSavedViewsQuery = (props) => {
|
|
14915
|
-
const { projectId, companyId, domain, tableName } = props;
|
|
14916
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
|
|
14917
|
-
return useQuery({
|
|
14918
|
-
queryKey: ["savedViews", domain, tableName],
|
|
14919
|
-
queryFn: async () => {
|
|
14920
|
-
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
14921
|
-
const response = await requestJSON(getUrl2);
|
|
14922
|
-
return response.data;
|
|
14923
|
-
}
|
|
14924
|
-
});
|
|
14925
|
-
};
|
|
14926
|
-
var useSavedViewsPermissions = (props) => {
|
|
14927
|
-
const { projectId, companyId, domain } = props;
|
|
14928
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
|
|
14929
|
-
return useQuery({
|
|
14930
|
-
queryKey: ["savedViewsConfig", domain],
|
|
14931
|
-
queryFn: async () => {
|
|
14932
|
-
const response = await requestJSON(url);
|
|
14933
|
-
return response.data;
|
|
14934
|
-
}
|
|
14935
|
-
});
|
|
14936
|
-
};
|
|
14937
|
-
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
14938
|
-
"createSavedView",
|
|
14939
|
-
props.domain,
|
|
14940
|
-
props.tableName
|
|
14941
|
-
]);
|
|
14942
|
-
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
14943
|
-
"updateSavedView",
|
|
14944
|
-
props.domain,
|
|
14945
|
-
props.tableName
|
|
14946
|
-
]);
|
|
14947
|
-
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
14948
|
-
"deleteSavedView",
|
|
14949
|
-
props.domain,
|
|
14950
|
-
props.tableName
|
|
14951
|
-
]);
|
|
14952
|
-
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
14953
|
-
const { projectId, companyId } = queryInput;
|
|
14954
|
-
return useQuery({
|
|
14955
|
-
enabled: enabled && Boolean(savedViewToken),
|
|
14956
|
-
queryKey: ["savedView", savedViewToken],
|
|
14957
|
-
queryFn: async () => {
|
|
14958
|
-
const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedViewToken}`;
|
|
14959
|
-
const response = await requestJSON(url);
|
|
14960
|
-
return response.data;
|
|
14961
|
-
}
|
|
14962
|
-
});
|
|
14963
|
-
};
|
|
14964
|
-
var createQueries = (customBackend) => ({
|
|
14965
|
-
useSavedViewsQuery: (customBackend == null ? void 0 : customBackend.useSavedViewsQuery) ?? useSavedViewsQuery,
|
|
14966
|
-
useSavedViewsPermissions: (customBackend == null ? void 0 : customBackend.useSavedViewsPermissions) ?? useSavedViewsPermissions,
|
|
14967
|
-
useCreateSavedView: (customBackend == null ? void 0 : customBackend.useCreateSavedView) ?? useCreateSavedView,
|
|
14968
|
-
useUpdateSavedView: (customBackend == null ? void 0 : customBackend.useUpdateSavedView) ?? useUpdateSavedView,
|
|
14969
|
-
useDeleteSavedView: (customBackend == null ? void 0 : customBackend.useDeleteSavedView) ?? useDeleteSavedView,
|
|
14970
|
-
useFetchSavedViewById: (customBackend == null ? void 0 : customBackend.useFetchSavedViewById) ?? useFetchSavedViewById
|
|
14971
|
-
});
|
|
14972
|
-
|
|
14973
14950
|
// src/components/saved-views/SavedViews.tsx
|
|
14974
14951
|
var StyledPanel = styled_components_esm_default.div`
|
|
14975
14952
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
@@ -14977,15 +14954,14 @@ var StyledPanel = styled_components_esm_default.div`
|
|
|
14977
14954
|
var queryClient = new QueryClient();
|
|
14978
14955
|
var SavedViewsContent = (props) => {
|
|
14979
14956
|
const { projectId, companyId } = props;
|
|
14980
|
-
const backend = createQueries(props.backend);
|
|
14981
14957
|
const queryInput = {
|
|
14982
14958
|
domain: props.domain,
|
|
14983
14959
|
tableName: props.tableName,
|
|
14984
14960
|
projectId,
|
|
14985
14961
|
companyId
|
|
14986
14962
|
};
|
|
14987
|
-
const { data: savedViews } =
|
|
14988
|
-
const { mutate: deleteSavedView } =
|
|
14963
|
+
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14964
|
+
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14989
14965
|
const { showToast } = useToastAlertContext3();
|
|
14990
14966
|
const i18n = useI18nContext11();
|
|
14991
14967
|
const [activeModal, setActiveModal] = useState4(null);
|
|
@@ -15022,7 +14998,7 @@ var SavedViewsContent = (props) => {
|
|
|
15022
14998
|
props.presetViews,
|
|
15023
14999
|
openSharedViewModal
|
|
15024
15000
|
);
|
|
15025
|
-
const { data: fetchedView, isError: fetchError } =
|
|
15001
|
+
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
15026
15002
|
(modalData == null ? void 0 : modalData.viewId) ?? null,
|
|
15027
15003
|
queryInput,
|
|
15028
15004
|
Boolean(modalData == null ? void 0 : modalData.viewId)
|
|
@@ -15032,8 +15008,8 @@ var SavedViewsContent = (props) => {
|
|
|
15032
15008
|
isPending: isCreating,
|
|
15033
15009
|
error: createError,
|
|
15034
15010
|
reset: resetCreateError
|
|
15035
|
-
} =
|
|
15036
|
-
|
|
15011
|
+
} = useCreateSavedView(queryInput);
|
|
15012
|
+
useEffect3(() => {
|
|
15037
15013
|
if (fetchError) {
|
|
15038
15014
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
15039
15015
|
selectView(selectedView ?? props.defaultView);
|
|
@@ -15119,8 +15095,7 @@ var SavedViewsContent = (props) => {
|
|
|
15119
15095
|
savedViews: allViews,
|
|
15120
15096
|
provider: props.provider,
|
|
15121
15097
|
userId: props.userId,
|
|
15122
|
-
onClearTemporary: clearTemporaryView
|
|
15123
|
-
backend
|
|
15098
|
+
onClearTemporary: clearTemporaryView
|
|
15124
15099
|
}
|
|
15125
15100
|
))
|
|
15126
15101
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ React22.createElement(
|
|
@@ -15135,8 +15110,7 @@ var SavedViewsContent = (props) => {
|
|
|
15135
15110
|
selectedSavedView: selectedView,
|
|
15136
15111
|
onSelect: selectView,
|
|
15137
15112
|
setOpenEditCreateModal: closeModal,
|
|
15138
|
-
defaultView: props.defaultView
|
|
15139
|
-
backend
|
|
15113
|
+
defaultView: props.defaultView
|
|
15140
15114
|
}
|
|
15141
15115
|
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ React22.createElement(
|
|
15142
15116
|
SavedViewsDeleteConfirmationModalShared,
|
|
@@ -15181,37 +15155,27 @@ var DEFAULT_COLUMN_STATE = {
|
|
|
15181
15155
|
rowGroupIndex: null,
|
|
15182
15156
|
flex: null
|
|
15183
15157
|
};
|
|
15184
|
-
var
|
|
15185
|
-
return "children" in colDef && Array.isArray(colDef.children);
|
|
15186
|
-
};
|
|
15158
|
+
var flattenColumnDefs = (defs) => defs.flatMap((d) => "children" in d ? flattenColumnDefs(d.children) : [d]);
|
|
15187
15159
|
var getColumnStateFromDefs = (columnDefs) => {
|
|
15188
|
-
return columnDefs.
|
|
15189
|
-
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
return
|
|
15193
|
-
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
sortIndex: null,
|
|
15208
|
-
pivot: false,
|
|
15209
|
-
pivotIndex: null,
|
|
15210
|
-
aggFunc: null,
|
|
15211
|
-
rowGroup: false,
|
|
15212
|
-
rowGroupIndex: null,
|
|
15213
|
-
flex: colDef.flex ?? null
|
|
15214
|
-
};
|
|
15160
|
+
return flattenColumnDefs(columnDefs).map((colDef) => {
|
|
15161
|
+
const field = colDef.field ?? colDef.colId;
|
|
15162
|
+
if (!field)
|
|
15163
|
+
return null;
|
|
15164
|
+
return {
|
|
15165
|
+
colId: field,
|
|
15166
|
+
hide: colDef.hide ?? false,
|
|
15167
|
+
pinned: colDef.pinned ?? null,
|
|
15168
|
+
width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
|
|
15169
|
+
sort: null,
|
|
15170
|
+
sortIndex: null,
|
|
15171
|
+
pivot: false,
|
|
15172
|
+
pivotIndex: null,
|
|
15173
|
+
aggFunc: null,
|
|
15174
|
+
rowGroup: false,
|
|
15175
|
+
rowGroupIndex: null,
|
|
15176
|
+
flex: colDef.flex ?? null
|
|
15177
|
+
};
|
|
15178
|
+
}).filter((col) => col !== null);
|
|
15215
15179
|
};
|
|
15216
15180
|
var extractDefaultView = (gridApi, receivedConfig) => {
|
|
15217
15181
|
var _a, _b;
|
|
@@ -15239,7 +15203,7 @@ var useNormalizedDefaultViews = (defaultViews, gridApi) => {
|
|
|
15239
15203
|
};
|
|
15240
15204
|
|
|
15241
15205
|
// src/components/adapters/smart-grid/useSmartGridConfig.ts
|
|
15242
|
-
import { useState as useState5, useEffect as
|
|
15206
|
+
import { useState as useState5, useEffect as useEffect4 } from "react";
|
|
15243
15207
|
var GRID_STATE_EVENTS = [
|
|
15244
15208
|
"sortChanged",
|
|
15245
15209
|
"filterOpened",
|
|
@@ -15258,14 +15222,10 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15258
15222
|
const [config, setConfig] = useState5(
|
|
15259
15223
|
() => getSmartGridConfig(gridApi)
|
|
15260
15224
|
);
|
|
15261
|
-
|
|
15262
|
-
useEffect5(() => {
|
|
15225
|
+
useEffect4(() => {
|
|
15263
15226
|
if (!gridApi)
|
|
15264
15227
|
return;
|
|
15265
15228
|
const updateConfig = () => {
|
|
15266
|
-
if (eventListenersDisabledRef.current) {
|
|
15267
|
-
return;
|
|
15268
|
-
}
|
|
15269
15229
|
setConfig(getSmartGridConfig(gridApi));
|
|
15270
15230
|
};
|
|
15271
15231
|
GRID_STATE_EVENTS.forEach((event) => {
|
|
@@ -15277,55 +15237,34 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15277
15237
|
});
|
|
15278
15238
|
};
|
|
15279
15239
|
}, [gridApi]);
|
|
15280
|
-
|
|
15281
|
-
eventListenersDisabledRef.current = true;
|
|
15282
|
-
};
|
|
15283
|
-
const enableEventListeners = () => {
|
|
15284
|
-
eventListenersDisabledRef.current = false;
|
|
15285
|
-
};
|
|
15286
|
-
return { config, setConfig, disableEventListeners, enableEventListeners };
|
|
15240
|
+
return { config, setConfig };
|
|
15287
15241
|
};
|
|
15288
15242
|
|
|
15289
15243
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15290
15244
|
var SmartGridSavedViews = (props) => {
|
|
15291
15245
|
const { gridApi, userId, projectId, companyId } = props;
|
|
15292
|
-
const {
|
|
15293
|
-
config: tableConfig,
|
|
15294
|
-
setConfig: setTableConfig,
|
|
15295
|
-
disableEventListeners,
|
|
15296
|
-
enableEventListeners
|
|
15297
|
-
} = useSmartGridConfig(gridApi);
|
|
15246
|
+
const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
|
|
15298
15247
|
const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
|
|
15299
15248
|
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15300
15249
|
const onSelect = useCallback4(
|
|
15301
15250
|
({ item }) => {
|
|
15302
|
-
var _a;
|
|
15303
15251
|
if (!gridApi)
|
|
15304
15252
|
return item;
|
|
15305
15253
|
const isPresetView = item.view_level === "default";
|
|
15306
|
-
const newConfig = item.table_config;
|
|
15307
|
-
const transformedConfig = ((_a = props.transformSettings) == null ? void 0 : _a.call(props, newConfig)) ?? newConfig;
|
|
15308
|
-
disableEventListeners();
|
|
15309
15254
|
if (isPresetView) {
|
|
15310
15255
|
updateTableConfig(item, gridApi, "smart-grid");
|
|
15311
|
-
setTableConfig(
|
|
15312
|
-
setTimeout(() => {
|
|
15313
|
-
enableEventListeners();
|
|
15314
|
-
}, 0);
|
|
15256
|
+
setTableConfig(item.table_config);
|
|
15315
15257
|
return item;
|
|
15316
15258
|
}
|
|
15317
15259
|
const updatedView = {
|
|
15318
15260
|
...item,
|
|
15319
15261
|
table_config: customAndConfigSync(
|
|
15320
|
-
|
|
15262
|
+
item.table_config,
|
|
15321
15263
|
tableConfig
|
|
15322
15264
|
)
|
|
15323
15265
|
};
|
|
15324
15266
|
updateTableConfig(updatedView, gridApi, "smart-grid");
|
|
15325
15267
|
setTableConfig(updatedView.table_config);
|
|
15326
|
-
setTimeout(() => {
|
|
15327
|
-
enableEventListeners();
|
|
15328
|
-
}, 0);
|
|
15329
15268
|
return updatedView;
|
|
15330
15269
|
},
|
|
15331
15270
|
[gridApi, tableConfig, setTableConfig]
|
|
@@ -15342,8 +15281,7 @@ var SmartGridSavedViews = (props) => {
|
|
|
15342
15281
|
defaultView,
|
|
15343
15282
|
presetViews,
|
|
15344
15283
|
tableName: props.tableName,
|
|
15345
|
-
tableConfig
|
|
15346
|
-
backend: props.backend
|
|
15284
|
+
tableConfig
|
|
15347
15285
|
}
|
|
15348
15286
|
);
|
|
15349
15287
|
};
|