@procore/saved-views 1.0.1-estimatingFork.3 → 1.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/legacy/index.d.mts +11 -30
- package/dist/legacy/index.d.ts +11 -30
- package/dist/legacy/index.js +344 -398
- package/dist/legacy/index.mjs +291 -345
- package/dist/modern/index.d.mts +11 -30
- package/dist/modern/index.d.ts +11 -30
- package/dist/modern/index.js +344 -397
- package/dist/modern/index.mjs +291 -344
- package/package.json +1 -1
package/dist/legacy/index.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,199 @@ 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 queryKeyContext = projectId ?? companyId;
|
|
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: ["savedViews", domain, tableName, queryKeyContext]
|
|
11529
|
+
});
|
|
11530
|
+
return;
|
|
11531
|
+
} else {
|
|
11532
|
+
const oldData = queryClient2.getQueryData([
|
|
11533
|
+
"savedViews",
|
|
11534
|
+
domain,
|
|
11535
|
+
tableName,
|
|
11536
|
+
queryKeyContext
|
|
11537
|
+
]);
|
|
11538
|
+
const oldView = oldData == null ? void 0 : oldData.find(
|
|
11539
|
+
(item) => item.share_token === savedView.share_token
|
|
11540
|
+
);
|
|
11541
|
+
if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
|
|
11542
|
+
queryClient2.invalidateQueries({
|
|
11543
|
+
queryKey: ["savedViews", domain, tableName, queryKeyContext]
|
|
11544
|
+
});
|
|
11545
|
+
return;
|
|
11546
|
+
}
|
|
11547
|
+
}
|
|
11548
|
+
queryClient2.setQueryData(
|
|
11549
|
+
["savedViews", domain, tableName, queryKeyContext],
|
|
11550
|
+
(oldData) => {
|
|
11551
|
+
if (!oldData)
|
|
11552
|
+
return [savedView];
|
|
11553
|
+
return oldData.map(
|
|
11554
|
+
(item) => item.share_token === savedView.share_token ? savedView : item
|
|
11555
|
+
);
|
|
11556
|
+
}
|
|
11557
|
+
);
|
|
11558
|
+
}
|
|
11559
|
+
});
|
|
11560
|
+
};
|
|
11561
|
+
|
|
11443
11562
|
// src/utils/constants/viewLevels.ts
|
|
11444
|
-
var
|
|
11563
|
+
var PROJECT_LEVEL_TOOL_VIEW_LEVELS = [
|
|
11564
|
+
"company",
|
|
11565
|
+
"project",
|
|
11566
|
+
"personal"
|
|
11567
|
+
];
|
|
11568
|
+
var COMPANY_LEVEL_TOOL_VIEW_LEVELS = ["company", "personal"];
|
|
11569
|
+
var getViewLevels = (isProjectLevelTool) => isProjectLevelTool ? PROJECT_LEVEL_TOOL_VIEW_LEVELS : COMPANY_LEVEL_TOOL_VIEW_LEVELS;
|
|
11570
|
+
|
|
11571
|
+
// src/utils/api/queries.ts
|
|
11572
|
+
var PAGE_SIZE = 50 * PROJECT_LEVEL_TOOL_VIEW_LEVELS.length;
|
|
11573
|
+
var getBasePath2 = (companyId, projectId) => {
|
|
11574
|
+
if (projectId) {
|
|
11575
|
+
return `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views`;
|
|
11576
|
+
}
|
|
11577
|
+
return `/rest/v2.0/companies/${companyId}/saved_views`;
|
|
11578
|
+
};
|
|
11579
|
+
var useSavedViewsQuery = (props) => {
|
|
11580
|
+
const { projectId, companyId, domain, tableName } = props;
|
|
11581
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11582
|
+
const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
|
|
11583
|
+
return useQuery({
|
|
11584
|
+
queryKey: ["savedViews", domain, tableName, projectId ?? companyId],
|
|
11585
|
+
queryFn: async () => {
|
|
11586
|
+
const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
|
|
11587
|
+
const response = await requestJSON(getUrl2);
|
|
11588
|
+
return response.data;
|
|
11589
|
+
}
|
|
11590
|
+
});
|
|
11591
|
+
};
|
|
11592
|
+
var useSavedViewsPermissions = (props) => {
|
|
11593
|
+
const { projectId, companyId, domain } = props;
|
|
11594
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11595
|
+
const url = `${basePath}/permissions?permissions_domain=${domain}`;
|
|
11596
|
+
return useQuery({
|
|
11597
|
+
queryKey: ["savedViewsConfig", domain, projectId ?? companyId],
|
|
11598
|
+
queryFn: async () => {
|
|
11599
|
+
const response = await requestJSON(url);
|
|
11600
|
+
return response.data;
|
|
11601
|
+
}
|
|
11602
|
+
});
|
|
11603
|
+
};
|
|
11604
|
+
var useCreateSavedView = (props) => useApiRequest(props, "POST", [
|
|
11605
|
+
"createSavedView",
|
|
11606
|
+
props.domain,
|
|
11607
|
+
props.tableName
|
|
11608
|
+
]);
|
|
11609
|
+
var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
|
|
11610
|
+
"updateSavedView",
|
|
11611
|
+
props.domain,
|
|
11612
|
+
props.tableName
|
|
11613
|
+
]);
|
|
11614
|
+
var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
|
|
11615
|
+
"deleteSavedView",
|
|
11616
|
+
props.domain,
|
|
11617
|
+
props.tableName
|
|
11618
|
+
]);
|
|
11619
|
+
var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
11620
|
+
const { projectId, companyId, domain } = queryInput;
|
|
11621
|
+
const basePath = getBasePath2(companyId, projectId);
|
|
11622
|
+
return useQuery({
|
|
11623
|
+
enabled: enabled && Boolean(savedViewToken),
|
|
11624
|
+
queryKey: ["savedView", savedViewToken, projectId ?? companyId],
|
|
11625
|
+
queryFn: async () => {
|
|
11626
|
+
const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
|
|
11627
|
+
const response = await requestJSON(url);
|
|
11628
|
+
return response.data;
|
|
11629
|
+
}
|
|
11630
|
+
});
|
|
11631
|
+
};
|
|
11445
11632
|
|
|
11446
11633
|
// src/components/panels/PanelContentUtils.ts
|
|
11447
11634
|
var import_lodash = __toESM(require_lodash());
|
|
@@ -11516,12 +11703,10 @@ var getColumnIdentifier = (col) => {
|
|
|
11516
11703
|
};
|
|
11517
11704
|
var updateTableConfig = (view, tableApi, provider) => {
|
|
11518
11705
|
if (provider === "smart-grid") {
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
);
|
|
11524
|
-
}, 0);
|
|
11706
|
+
setSmartGridConfig(
|
|
11707
|
+
tableApi,
|
|
11708
|
+
view.table_config
|
|
11709
|
+
);
|
|
11525
11710
|
} else {
|
|
11526
11711
|
const dataTableApi = tableApi;
|
|
11527
11712
|
const tableConfig = view.table_config;
|
|
@@ -11593,20 +11778,13 @@ var cleanObject = (table_config, provider) => {
|
|
|
11593
11778
|
var normalizeForComparison = (config) => {
|
|
11594
11779
|
if (!(config == null ? void 0 : config.columnState))
|
|
11595
11780
|
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
11781
|
return {
|
|
11603
|
-
...
|
|
11604
|
-
columnState:
|
|
11605
|
-
const res = import_lodash.default.omit(col, ["aggFunc"]);
|
|
11782
|
+
...config,
|
|
11783
|
+
columnState: config.columnState.map((col) => {
|
|
11606
11784
|
if (col.flex) {
|
|
11607
|
-
return import_lodash.default.omit(
|
|
11785
|
+
return import_lodash.default.omit(col, ["width", "flex"]);
|
|
11608
11786
|
}
|
|
11609
|
-
return
|
|
11787
|
+
return col;
|
|
11610
11788
|
})
|
|
11611
11789
|
};
|
|
11612
11790
|
};
|
|
@@ -11619,17 +11797,10 @@ var isEqual = (viewTableConfig, tableConfig, defaultViewConfig, provider) => {
|
|
|
11619
11797
|
);
|
|
11620
11798
|
const normalizedViewConfig = normalizeForComparison(syncedViewTableConfig);
|
|
11621
11799
|
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;
|
|
11800
|
+
return import_lodash.default.isEqual(
|
|
11801
|
+
cleanObject(normalizedViewConfig, provider),
|
|
11802
|
+
cleanObject(normalizedCurrentConfig, provider)
|
|
11803
|
+
);
|
|
11633
11804
|
};
|
|
11634
11805
|
var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
11635
11806
|
switch (viewLevel) {
|
|
@@ -11646,9 +11817,10 @@ var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
|
11646
11817
|
|
|
11647
11818
|
// src/components/panels/useGroups.ts
|
|
11648
11819
|
import { useState as useState2 } from "react";
|
|
11649
|
-
var useGroups = () => {
|
|
11820
|
+
var useGroups = (isProjectLevelTool) => {
|
|
11821
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11650
11822
|
const [groups, setGroups] = useState2(
|
|
11651
|
-
Object.fromEntries(
|
|
11823
|
+
Object.fromEntries(viewLevels.map((level) => [level, true]))
|
|
11652
11824
|
);
|
|
11653
11825
|
const toggleGroup = (group) => {
|
|
11654
11826
|
setGroups((groups2) => ({ ...groups2, [group]: !groups2[group] }));
|
|
@@ -11662,7 +11834,7 @@ import {
|
|
|
11662
11834
|
Flex as Flex2,
|
|
11663
11835
|
spacing,
|
|
11664
11836
|
Typography,
|
|
11665
|
-
useI18nContext as
|
|
11837
|
+
useI18nContext as useI18nContext4
|
|
11666
11838
|
} from "@procore/core-react";
|
|
11667
11839
|
import React16 from "react";
|
|
11668
11840
|
var groupIcon = (group) => {
|
|
@@ -11682,7 +11854,7 @@ var Header = styled_components_esm_default(Flex2)`
|
|
|
11682
11854
|
}
|
|
11683
11855
|
`;
|
|
11684
11856
|
var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
11685
|
-
const I18n =
|
|
11857
|
+
const I18n = useI18nContext4();
|
|
11686
11858
|
return /* @__PURE__ */ React16.createElement(
|
|
11687
11859
|
Header,
|
|
11688
11860
|
{
|
|
@@ -11739,9 +11911,9 @@ var Panel2 = styled_components_esm_default(DetailPage.Card)`
|
|
|
11739
11911
|
var PanelContent = (props) => {
|
|
11740
11912
|
const { queryInput, selectedSavedView, tableConfig } = props;
|
|
11741
11913
|
const { showToast } = useToastAlertContext2();
|
|
11742
|
-
const I18n =
|
|
11743
|
-
const { data: savedViewsFromQuery, error: savedViewsError } =
|
|
11744
|
-
const updateMutation =
|
|
11914
|
+
const I18n = useI18nContext5();
|
|
11915
|
+
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
11916
|
+
const updateMutation = useUpdateSavedView(queryInput);
|
|
11745
11917
|
const { mutate: updateSavedView } = updateMutation;
|
|
11746
11918
|
const isUpdateLoading = "isPending" in updateMutation ? updateMutation.isPending : updateMutation.isLoading ?? false;
|
|
11747
11919
|
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
@@ -11752,14 +11924,14 @@ var PanelContent = (props) => {
|
|
|
11752
11924
|
errorToastRef.current = savedViewsError;
|
|
11753
11925
|
}
|
|
11754
11926
|
}, [savedViewsError, showToast, I18n]);
|
|
11755
|
-
const { data: permissions } = props.
|
|
11756
|
-
props.queryInput
|
|
11757
|
-
);
|
|
11927
|
+
const { data: permissions } = useSavedViewsPermissions(props.queryInput);
|
|
11758
11928
|
const selectedRowRef = useScrollToRef(savedViews);
|
|
11759
|
-
const { groups, toggleGroup } = useGroups();
|
|
11760
11929
|
const isTemporarySelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === "temporary";
|
|
11761
11930
|
const temporaryView = savedViews == null ? void 0 : savedViews.find((view) => view.id === "temporary");
|
|
11762
11931
|
const presetViews = props.presetViews || [props.defaultView];
|
|
11932
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
11933
|
+
const viewLevels = getViewLevels(isProjectLevelTool);
|
|
11934
|
+
const { groups, toggleGroup } = useGroups(isProjectLevelTool);
|
|
11763
11935
|
const onUpdate = (data) => {
|
|
11764
11936
|
const newSavedView = {
|
|
11765
11937
|
...data,
|
|
@@ -11788,8 +11960,7 @@ var PanelContent = (props) => {
|
|
|
11788
11960
|
{
|
|
11789
11961
|
item: temporaryView,
|
|
11790
11962
|
selected: isTemporarySelected,
|
|
11791
|
-
onClearTemporary: props.onClearTemporary
|
|
11792
|
-
enableSharingViews: false
|
|
11963
|
+
onClearTemporary: props.onClearTemporary
|
|
11793
11964
|
}
|
|
11794
11965
|
)
|
|
11795
11966
|
), presetViews.map((presetView) => {
|
|
@@ -11806,12 +11977,11 @@ var PanelContent = (props) => {
|
|
|
11806
11977
|
SavedViewCollectionMenuItem,
|
|
11807
11978
|
{
|
|
11808
11979
|
item: presetView,
|
|
11809
|
-
selected: isSelected
|
|
11810
|
-
enableSharingViews: false
|
|
11980
|
+
selected: isSelected
|
|
11811
11981
|
}
|
|
11812
11982
|
)
|
|
11813
11983
|
);
|
|
11814
|
-
}),
|
|
11984
|
+
}), viewLevels.map((level) => {
|
|
11815
11985
|
const isExpanded = groups[level];
|
|
11816
11986
|
const views = isExpanded && savedViews ? savedViews.filter(
|
|
11817
11987
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
@@ -11855,8 +12025,7 @@ var PanelContent = (props) => {
|
|
|
11855
12025
|
isUpdateProcessing: isUpdateLoading,
|
|
11856
12026
|
onEdit: () => props.openModal("update" /* UPDATE */),
|
|
11857
12027
|
onDelete: props.onDelete,
|
|
11858
|
-
permissions
|
|
11859
|
-
enableSharingViews: false
|
|
12028
|
+
permissions
|
|
11860
12029
|
}
|
|
11861
12030
|
)
|
|
11862
12031
|
);
|
|
@@ -11873,7 +12042,7 @@ import {
|
|
|
11873
12042
|
Tooltip,
|
|
11874
12043
|
useI18nContext as useI18nContext11
|
|
11875
12044
|
} from "@procore/core-react";
|
|
11876
|
-
import React22, { useState as useState4, useEffect as
|
|
12045
|
+
import React22, { useState as useState4, useEffect as useEffect3, useCallback as useCallback3 } from "react";
|
|
11877
12046
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
11878
12047
|
import { useToastAlertContext as useToastAlertContext3, ToastAlertProvider } from "@procore/toast-alert";
|
|
11879
12048
|
|
|
@@ -11883,7 +12052,7 @@ import {
|
|
|
11883
12052
|
ConfirmModal,
|
|
11884
12053
|
Modal,
|
|
11885
12054
|
P as P2,
|
|
11886
|
-
useI18nContext as
|
|
12055
|
+
useI18nContext as useI18nContext6
|
|
11887
12056
|
} from "@procore/core-react";
|
|
11888
12057
|
import React18 from "react";
|
|
11889
12058
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
@@ -11891,7 +12060,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11891
12060
|
onDelete,
|
|
11892
12061
|
open
|
|
11893
12062
|
}) => {
|
|
11894
|
-
const i18n =
|
|
12063
|
+
const i18n = useI18nContext6();
|
|
11895
12064
|
return /* @__PURE__ */ React18.createElement(
|
|
11896
12065
|
ConfirmModal,
|
|
11897
12066
|
{
|
|
@@ -11922,7 +12091,7 @@ import {
|
|
|
11922
12091
|
Modal as Modal2,
|
|
11923
12092
|
spacing as spacing3,
|
|
11924
12093
|
Typography as Typography2,
|
|
11925
|
-
useI18nContext as
|
|
12094
|
+
useI18nContext as useI18nContext7
|
|
11926
12095
|
} from "@procore/core-react";
|
|
11927
12096
|
import * as React19 from "react";
|
|
11928
12097
|
|
|
@@ -14219,10 +14388,11 @@ var TupleSchema = class extends Schema {
|
|
|
14219
14388
|
create$1.prototype = TupleSchema.prototype;
|
|
14220
14389
|
|
|
14221
14390
|
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
14222
|
-
var getViewLevelOptions = (permissions, i18n) => {
|
|
14391
|
+
var getViewLevelOptions = (permissions, i18n, isProjectLevelTool = true) => {
|
|
14223
14392
|
const options = ["personal"];
|
|
14224
|
-
if (permissions == null ? void 0 : permissions.can_create_project_saved_views)
|
|
14393
|
+
if (isProjectLevelTool && (permissions == null ? void 0 : permissions.can_create_project_saved_views)) {
|
|
14225
14394
|
options.push("project");
|
|
14395
|
+
}
|
|
14226
14396
|
if (permissions == null ? void 0 : permissions.can_create_company_saved_views)
|
|
14227
14397
|
options.push("company");
|
|
14228
14398
|
return options.map((option) => ({
|
|
@@ -14252,7 +14422,6 @@ function extractMessage(error, I18n) {
|
|
|
14252
14422
|
}
|
|
14253
14423
|
|
|
14254
14424
|
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14255
|
-
var { useEffect: useEffect2, useRef: useRef2 } = React19;
|
|
14256
14425
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14257
14426
|
overflow: auto;
|
|
14258
14427
|
`;
|
|
@@ -14269,38 +14438,22 @@ var FormModalBase = ({
|
|
|
14269
14438
|
defaultView,
|
|
14270
14439
|
selectedSavedView,
|
|
14271
14440
|
setOpenEditCreateModal,
|
|
14272
|
-
onSelect
|
|
14273
|
-
backend
|
|
14441
|
+
onSelect
|
|
14274
14442
|
}) => {
|
|
14275
|
-
const I18n =
|
|
14443
|
+
const I18n = useI18nContext7();
|
|
14276
14444
|
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
14445
|
const {
|
|
14293
14446
|
mutate: createSavedView,
|
|
14294
14447
|
isPending: isCreating,
|
|
14295
14448
|
error: createError,
|
|
14296
14449
|
reset: resetCreateMutation
|
|
14297
|
-
} =
|
|
14450
|
+
} = useCreateSavedView(queryInput);
|
|
14298
14451
|
const {
|
|
14299
14452
|
mutate: updateSavedView,
|
|
14300
14453
|
isPending: isUpdating,
|
|
14301
14454
|
error: updateError,
|
|
14302
14455
|
reset: resetUpdateMutation
|
|
14303
|
-
} =
|
|
14456
|
+
} = useUpdateSavedView(queryInput);
|
|
14304
14457
|
const resetMutations = () => {
|
|
14305
14458
|
resetCreateMutation();
|
|
14306
14459
|
resetUpdateMutation();
|
|
@@ -14309,7 +14462,7 @@ var FormModalBase = ({
|
|
|
14309
14462
|
resetMutations();
|
|
14310
14463
|
onCancel();
|
|
14311
14464
|
};
|
|
14312
|
-
const { data: permissions } =
|
|
14465
|
+
const { data: permissions } = useSavedViewsPermissions(queryInput);
|
|
14313
14466
|
const isLoading = isCreating || isUpdating;
|
|
14314
14467
|
const errors = extractMessage(createError || updateError, I18n);
|
|
14315
14468
|
const handleOnSubmit = (data) => {
|
|
@@ -14340,7 +14493,12 @@ var FormModalBase = ({
|
|
|
14340
14493
|
});
|
|
14341
14494
|
}
|
|
14342
14495
|
};
|
|
14343
|
-
const
|
|
14496
|
+
const isProjectLevelTool = !!queryInput.projectId;
|
|
14497
|
+
const viewLevelOptions = getViewLevelOptions(
|
|
14498
|
+
permissions,
|
|
14499
|
+
I18n,
|
|
14500
|
+
isProjectLevelTool
|
|
14501
|
+
);
|
|
14344
14502
|
return /* @__PURE__ */ React19.createElement(
|
|
14345
14503
|
Modal2,
|
|
14346
14504
|
{
|
|
@@ -14420,7 +14578,6 @@ var FormModalBase = ({
|
|
|
14420
14578
|
Form.Select,
|
|
14421
14579
|
{
|
|
14422
14580
|
name: "view_level",
|
|
14423
|
-
qa: { label: "view-level" },
|
|
14424
14581
|
options: viewLevelOptions,
|
|
14425
14582
|
label: I18n.t("savedViews.modal.fields.viewLevel"),
|
|
14426
14583
|
colWidth: 12,
|
|
@@ -14444,7 +14601,7 @@ var FormModalBase = ({
|
|
|
14444
14601
|
};
|
|
14445
14602
|
|
|
14446
14603
|
// src/components/modals/form-modal/FormModal.tsx
|
|
14447
|
-
import { useI18nContext as
|
|
14604
|
+
import { useI18nContext as useI18nContext8 } from "@procore/core-react";
|
|
14448
14605
|
var FormModal = ({
|
|
14449
14606
|
open,
|
|
14450
14607
|
mode,
|
|
@@ -14455,10 +14612,9 @@ var FormModal = ({
|
|
|
14455
14612
|
selectedSavedView,
|
|
14456
14613
|
setOpenEditCreateModal,
|
|
14457
14614
|
onSelect,
|
|
14458
|
-
defaultView
|
|
14459
|
-
backend
|
|
14615
|
+
defaultView
|
|
14460
14616
|
}) => {
|
|
14461
|
-
const i18n =
|
|
14617
|
+
const i18n = useI18nContext8();
|
|
14462
14618
|
return /* @__PURE__ */ React20.createElement(
|
|
14463
14619
|
FormModalBase,
|
|
14464
14620
|
{
|
|
@@ -14474,8 +14630,7 @@ var FormModal = ({
|
|
|
14474
14630
|
selectedSavedView,
|
|
14475
14631
|
setOpenEditCreateModal,
|
|
14476
14632
|
onSelect,
|
|
14477
|
-
defaultView
|
|
14478
|
-
backend
|
|
14633
|
+
defaultView
|
|
14479
14634
|
}
|
|
14480
14635
|
);
|
|
14481
14636
|
};
|
|
@@ -14492,7 +14647,7 @@ import {
|
|
|
14492
14647
|
P as P3,
|
|
14493
14648
|
spacing as spacing4,
|
|
14494
14649
|
Typography as Typography3,
|
|
14495
|
-
useI18nContext as
|
|
14650
|
+
useI18nContext as useI18nContext9
|
|
14496
14651
|
} from "@procore/core-react";
|
|
14497
14652
|
import * as React21 from "react";
|
|
14498
14653
|
var SharedViewFormModal = ({
|
|
@@ -14505,7 +14660,7 @@ var SharedViewFormModal = ({
|
|
|
14505
14660
|
isCreating,
|
|
14506
14661
|
resetCreateError
|
|
14507
14662
|
}) => {
|
|
14508
|
-
const I18n =
|
|
14663
|
+
const I18n = useI18nContext9();
|
|
14509
14664
|
const NAME_MAX_LENGTH = 150;
|
|
14510
14665
|
const errors = extractMessage(createError, I18n);
|
|
14511
14666
|
const handleNameChange = () => {
|
|
@@ -14635,9 +14790,9 @@ var SharedViewFormModal = ({
|
|
|
14635
14790
|
};
|
|
14636
14791
|
|
|
14637
14792
|
// src/utils/hooks/useViewSelection.ts
|
|
14638
|
-
import { useState as useState3, useCallback as useCallback2, useEffect as
|
|
14793
|
+
import { useState as useState3, useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useMemo } from "react";
|
|
14639
14794
|
import { useSearchParams } from "react-router-dom";
|
|
14640
|
-
import { useI18nContext as
|
|
14795
|
+
import { useI18nContext as useI18nContext10 } from "@procore/core-react";
|
|
14641
14796
|
|
|
14642
14797
|
// src/utils/viewStorage.ts
|
|
14643
14798
|
var ViewStorage = {
|
|
@@ -14700,11 +14855,12 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
14700
14855
|
}
|
|
14701
14856
|
};
|
|
14702
14857
|
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
14703
|
-
const I18n =
|
|
14704
|
-
const
|
|
14858
|
+
const I18n = useI18nContext10();
|
|
14859
|
+
const projectIdSegment = config.projectId ?? "company";
|
|
14860
|
+
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
14705
14861
|
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14706
14862
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
14707
|
-
const previousSavedViewParamRef =
|
|
14863
|
+
const previousSavedViewParamRef = useRef2(null);
|
|
14708
14864
|
const [selectedSavedView, setSelectedSavedView] = useState3(() => {
|
|
14709
14865
|
const stored = ViewStorage.load(storageKey, config.defaultView);
|
|
14710
14866
|
return stored ?? config.defaultView;
|
|
@@ -14775,7 +14931,7 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14775
14931
|
},
|
|
14776
14932
|
[isViewAlreadySelected, openSharedViewModal, allViews, selectView]
|
|
14777
14933
|
);
|
|
14778
|
-
|
|
14934
|
+
useEffect2(() => {
|
|
14779
14935
|
const savedViewId = searchParams.get("saved-view");
|
|
14780
14936
|
restoreUrlParameter(
|
|
14781
14937
|
savedViewId,
|
|
@@ -14799,177 +14955,6 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
14799
14955
|
};
|
|
14800
14956
|
};
|
|
14801
14957
|
|
|
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
14958
|
// src/components/saved-views/SavedViews.tsx
|
|
14974
14959
|
var StyledPanel = styled_components_esm_default.div`
|
|
14975
14960
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
@@ -14977,15 +14962,14 @@ var StyledPanel = styled_components_esm_default.div`
|
|
|
14977
14962
|
var queryClient = new QueryClient();
|
|
14978
14963
|
var SavedViewsContent = (props) => {
|
|
14979
14964
|
const { projectId, companyId } = props;
|
|
14980
|
-
const backend = createQueries(props.backend);
|
|
14981
14965
|
const queryInput = {
|
|
14982
14966
|
domain: props.domain,
|
|
14983
14967
|
tableName: props.tableName,
|
|
14984
|
-
projectId,
|
|
14968
|
+
projectId: projectId ?? void 0,
|
|
14985
14969
|
companyId
|
|
14986
14970
|
};
|
|
14987
|
-
const { data: savedViews } =
|
|
14988
|
-
const { mutate: deleteSavedView } =
|
|
14971
|
+
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14972
|
+
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14989
14973
|
const { showToast } = useToastAlertContext3();
|
|
14990
14974
|
const i18n = useI18nContext11();
|
|
14991
14975
|
const [activeModal, setActiveModal] = useState4(null);
|
|
@@ -15013,7 +14997,7 @@ var SavedViewsContent = (props) => {
|
|
|
15013
14997
|
domain: props.domain,
|
|
15014
14998
|
tableName: props.tableName,
|
|
15015
14999
|
userId: props.userId,
|
|
15016
|
-
projectId,
|
|
15000
|
+
projectId: projectId ?? void 0,
|
|
15017
15001
|
companyId,
|
|
15018
15002
|
defaultView: props.defaultView,
|
|
15019
15003
|
onSelect: props.onSelect
|
|
@@ -15022,7 +15006,7 @@ var SavedViewsContent = (props) => {
|
|
|
15022
15006
|
props.presetViews,
|
|
15023
15007
|
openSharedViewModal
|
|
15024
15008
|
);
|
|
15025
|
-
const { data: fetchedView, isError: fetchError } =
|
|
15009
|
+
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
15026
15010
|
(modalData == null ? void 0 : modalData.viewId) ?? null,
|
|
15027
15011
|
queryInput,
|
|
15028
15012
|
Boolean(modalData == null ? void 0 : modalData.viewId)
|
|
@@ -15032,8 +15016,8 @@ var SavedViewsContent = (props) => {
|
|
|
15032
15016
|
isPending: isCreating,
|
|
15033
15017
|
error: createError,
|
|
15034
15018
|
reset: resetCreateError
|
|
15035
|
-
} =
|
|
15036
|
-
|
|
15019
|
+
} = useCreateSavedView(queryInput);
|
|
15020
|
+
useEffect3(() => {
|
|
15037
15021
|
if (fetchError) {
|
|
15038
15022
|
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
15039
15023
|
selectView(selectedView ?? props.defaultView);
|
|
@@ -15119,8 +15103,7 @@ var SavedViewsContent = (props) => {
|
|
|
15119
15103
|
savedViews: allViews,
|
|
15120
15104
|
provider: props.provider,
|
|
15121
15105
|
userId: props.userId,
|
|
15122
|
-
onClearTemporary: clearTemporaryView
|
|
15123
|
-
backend
|
|
15106
|
+
onClearTemporary: clearTemporaryView
|
|
15124
15107
|
}
|
|
15125
15108
|
))
|
|
15126
15109
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ React22.createElement(
|
|
@@ -15135,8 +15118,7 @@ var SavedViewsContent = (props) => {
|
|
|
15135
15118
|
selectedSavedView: selectedView,
|
|
15136
15119
|
onSelect: selectView,
|
|
15137
15120
|
setOpenEditCreateModal: closeModal,
|
|
15138
|
-
defaultView: props.defaultView
|
|
15139
|
-
backend
|
|
15121
|
+
defaultView: props.defaultView
|
|
15140
15122
|
}
|
|
15141
15123
|
), selectedView && isModalOpen("delete" /* DELETE */) && /* @__PURE__ */ React22.createElement(
|
|
15142
15124
|
SavedViewsDeleteConfirmationModalShared,
|
|
@@ -15181,37 +15163,27 @@ var DEFAULT_COLUMN_STATE = {
|
|
|
15181
15163
|
rowGroupIndex: null,
|
|
15182
15164
|
flex: null
|
|
15183
15165
|
};
|
|
15184
|
-
var
|
|
15185
|
-
return "children" in colDef && Array.isArray(colDef.children);
|
|
15186
|
-
};
|
|
15166
|
+
var flattenColumnDefs = (defs) => defs.flatMap((d) => "children" in d ? flattenColumnDefs(d.children) : [d]);
|
|
15187
15167
|
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
|
-
};
|
|
15168
|
+
return flattenColumnDefs(columnDefs).map((colDef) => {
|
|
15169
|
+
const field = colDef.field ?? colDef.colId;
|
|
15170
|
+
if (!field)
|
|
15171
|
+
return null;
|
|
15172
|
+
return {
|
|
15173
|
+
colId: field,
|
|
15174
|
+
hide: colDef.hide ?? false,
|
|
15175
|
+
pinned: colDef.pinned ?? null,
|
|
15176
|
+
width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
|
|
15177
|
+
sort: null,
|
|
15178
|
+
sortIndex: null,
|
|
15179
|
+
pivot: false,
|
|
15180
|
+
pivotIndex: null,
|
|
15181
|
+
aggFunc: null,
|
|
15182
|
+
rowGroup: false,
|
|
15183
|
+
rowGroupIndex: null,
|
|
15184
|
+
flex: colDef.flex ?? null
|
|
15185
|
+
};
|
|
15186
|
+
}).filter((col) => col !== null);
|
|
15215
15187
|
};
|
|
15216
15188
|
var extractDefaultView = (gridApi, receivedConfig) => {
|
|
15217
15189
|
var _a, _b;
|
|
@@ -15239,7 +15211,7 @@ var useNormalizedDefaultViews = (defaultViews, gridApi) => {
|
|
|
15239
15211
|
};
|
|
15240
15212
|
|
|
15241
15213
|
// src/components/adapters/smart-grid/useSmartGridConfig.ts
|
|
15242
|
-
import { useState as useState5, useEffect as
|
|
15214
|
+
import { useState as useState5, useEffect as useEffect4 } from "react";
|
|
15243
15215
|
var GRID_STATE_EVENTS = [
|
|
15244
15216
|
"sortChanged",
|
|
15245
15217
|
"filterOpened",
|
|
@@ -15258,14 +15230,10 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15258
15230
|
const [config, setConfig] = useState5(
|
|
15259
15231
|
() => getSmartGridConfig(gridApi)
|
|
15260
15232
|
);
|
|
15261
|
-
|
|
15262
|
-
useEffect5(() => {
|
|
15233
|
+
useEffect4(() => {
|
|
15263
15234
|
if (!gridApi)
|
|
15264
15235
|
return;
|
|
15265
15236
|
const updateConfig = () => {
|
|
15266
|
-
if (eventListenersDisabledRef.current) {
|
|
15267
|
-
return;
|
|
15268
|
-
}
|
|
15269
15237
|
setConfig(getSmartGridConfig(gridApi));
|
|
15270
15238
|
};
|
|
15271
15239
|
GRID_STATE_EVENTS.forEach((event) => {
|
|
@@ -15277,55 +15245,34 @@ var useSmartGridConfig = (gridApi) => {
|
|
|
15277
15245
|
});
|
|
15278
15246
|
};
|
|
15279
15247
|
}, [gridApi]);
|
|
15280
|
-
|
|
15281
|
-
eventListenersDisabledRef.current = true;
|
|
15282
|
-
};
|
|
15283
|
-
const enableEventListeners = () => {
|
|
15284
|
-
eventListenersDisabledRef.current = false;
|
|
15285
|
-
};
|
|
15286
|
-
return { config, setConfig, disableEventListeners, enableEventListeners };
|
|
15248
|
+
return { config, setConfig };
|
|
15287
15249
|
};
|
|
15288
15250
|
|
|
15289
15251
|
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15290
15252
|
var SmartGridSavedViews = (props) => {
|
|
15291
15253
|
const { gridApi, userId, projectId, companyId } = props;
|
|
15292
|
-
const {
|
|
15293
|
-
config: tableConfig,
|
|
15294
|
-
setConfig: setTableConfig,
|
|
15295
|
-
disableEventListeners,
|
|
15296
|
-
enableEventListeners
|
|
15297
|
-
} = useSmartGridConfig(gridApi);
|
|
15254
|
+
const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
|
|
15298
15255
|
const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
|
|
15299
15256
|
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15300
15257
|
const onSelect = useCallback4(
|
|
15301
15258
|
({ item }) => {
|
|
15302
|
-
var _a;
|
|
15303
15259
|
if (!gridApi)
|
|
15304
15260
|
return item;
|
|
15305
15261
|
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
15262
|
if (isPresetView) {
|
|
15310
15263
|
updateTableConfig(item, gridApi, "smart-grid");
|
|
15311
|
-
setTableConfig(
|
|
15312
|
-
setTimeout(() => {
|
|
15313
|
-
enableEventListeners();
|
|
15314
|
-
}, 0);
|
|
15264
|
+
setTableConfig(item.table_config);
|
|
15315
15265
|
return item;
|
|
15316
15266
|
}
|
|
15317
15267
|
const updatedView = {
|
|
15318
15268
|
...item,
|
|
15319
15269
|
table_config: customAndConfigSync(
|
|
15320
|
-
|
|
15270
|
+
item.table_config,
|
|
15321
15271
|
tableConfig
|
|
15322
15272
|
)
|
|
15323
15273
|
};
|
|
15324
15274
|
updateTableConfig(updatedView, gridApi, "smart-grid");
|
|
15325
15275
|
setTableConfig(updatedView.table_config);
|
|
15326
|
-
setTimeout(() => {
|
|
15327
|
-
enableEventListeners();
|
|
15328
|
-
}, 0);
|
|
15329
15276
|
return updatedView;
|
|
15330
15277
|
},
|
|
15331
15278
|
[gridApi, tableConfig, setTableConfig]
|
|
@@ -15342,8 +15289,7 @@ var SmartGridSavedViews = (props) => {
|
|
|
15342
15289
|
defaultView,
|
|
15343
15290
|
presetViews,
|
|
15344
15291
|
tableName: props.tableName,
|
|
15345
|
-
tableConfig
|
|
15346
|
-
backend: props.backend
|
|
15292
|
+
tableConfig
|
|
15347
15293
|
}
|
|
15348
15294
|
);
|
|
15349
15295
|
};
|