@procore/saved-views 5.1.0-alpha.4 → 5.1.0-alpha.5
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 +61 -40
- package/dist/legacy/index.d.ts +61 -40
- package/dist/legacy/index.js +436 -326
- package/dist/legacy/index.mjs +415 -308
- package/dist/modern/index.d.mts +61 -40
- package/dist/modern/index.d.ts +61 -40
- package/dist/modern/index.js +434 -324
- package/dist/modern/index.mjs +413 -306
- package/package.json +1 -1
package/dist/modern/index.mjs
CHANGED
|
@@ -8468,7 +8468,7 @@ var require_toposort = __commonJS({
|
|
|
8468
8468
|
}
|
|
8469
8469
|
});
|
|
8470
8470
|
|
|
8471
|
-
// src/utils/
|
|
8471
|
+
// src/utils/translations/translations.ts
|
|
8472
8472
|
var import_globalization_toolkit = __toESM(require_dist());
|
|
8473
8473
|
|
|
8474
8474
|
// src/locales/de-DE.json
|
|
@@ -8851,6 +8851,9 @@ var en_default = {
|
|
|
8851
8851
|
update: {
|
|
8852
8852
|
success: "The saved view was successfully updated."
|
|
8853
8853
|
},
|
|
8854
|
+
create: {
|
|
8855
|
+
success: "The saved view was successfully created."
|
|
8856
|
+
},
|
|
8854
8857
|
copy: {
|
|
8855
8858
|
success: "The link was successfully created and copied to the clipboard."
|
|
8856
8859
|
},
|
|
@@ -8859,7 +8862,8 @@ var en_default = {
|
|
|
8859
8862
|
create: "Sorry, the saved view couldn't be created. Try again.",
|
|
8860
8863
|
update: "Sorry, the saved view couldn't be updated. Try again.",
|
|
8861
8864
|
delete: "Sorry, the saved view couldn't be deleted. Try again.",
|
|
8862
|
-
copyFailed: "Failed to copy share link to clipboard"
|
|
8865
|
+
copyFailed: "Failed to copy share link to clipboard",
|
|
8866
|
+
notFound: "Sorry, the saved view could not be found. Please try again."
|
|
8863
8867
|
},
|
|
8864
8868
|
defaultViewTitle: {
|
|
8865
8869
|
rfi: "All RFIs",
|
|
@@ -9264,6 +9268,84 @@ var is_IS_default = {
|
|
|
9264
9268
|
}
|
|
9265
9269
|
};
|
|
9266
9270
|
|
|
9271
|
+
// src/locales/it-IT.json
|
|
9272
|
+
var it_IT_default = {
|
|
9273
|
+
savedViews: {
|
|
9274
|
+
name: "Vista salvata",
|
|
9275
|
+
title: "Viste salvate",
|
|
9276
|
+
tooltip: "Creare e salvare qualsiasi layout di tabella personalizzato per tornare rapidamente alla vista preferita.",
|
|
9277
|
+
button: {
|
|
9278
|
+
title: "Viste"
|
|
9279
|
+
},
|
|
9280
|
+
actions: {
|
|
9281
|
+
update: "Aggiorna",
|
|
9282
|
+
delete: "Elimina",
|
|
9283
|
+
create: "Crea",
|
|
9284
|
+
edit: "Modifica",
|
|
9285
|
+
cancel: "Annulla",
|
|
9286
|
+
close: "Chiudi"
|
|
9287
|
+
},
|
|
9288
|
+
modal: {
|
|
9289
|
+
edit: {
|
|
9290
|
+
title: "Aggiorna vista salvata"
|
|
9291
|
+
},
|
|
9292
|
+
create: {
|
|
9293
|
+
title: "Crea vista salvata"
|
|
9294
|
+
},
|
|
9295
|
+
delete: {
|
|
9296
|
+
headline: "Elimina vista salvata",
|
|
9297
|
+
description: "Una volta eliminata, non sar\xE0 pi\xF9 possibile ripristinare la vista."
|
|
9298
|
+
},
|
|
9299
|
+
fields: {
|
|
9300
|
+
name: "Nome",
|
|
9301
|
+
description: "Descrizione",
|
|
9302
|
+
viewLevel: "Livello vista",
|
|
9303
|
+
viewLevels: {
|
|
9304
|
+
company: "Vista dell'azienda",
|
|
9305
|
+
project: "Vista del progetto",
|
|
9306
|
+
personal: "Vista personale"
|
|
9307
|
+
}
|
|
9308
|
+
},
|
|
9309
|
+
errors: {
|
|
9310
|
+
maxLengthName: "Non pu\xF2 contenere pi\xF9 di {{maxLength}} caratteri.",
|
|
9311
|
+
required: "Il campo non pu\xF2 essere vuoto.",
|
|
9312
|
+
duplicateName: "Esiste gi\xE0 una vista salvata con questo nome. Rinominarla e riprovare.",
|
|
9313
|
+
unknown: "Si \xE8 verificato un errore. Riprovare.",
|
|
9314
|
+
title: "Impossibile {{mode}} questa vista salvata",
|
|
9315
|
+
description: {
|
|
9316
|
+
create: "Correggere gli errori di seguito e provare a creare di nuovo",
|
|
9317
|
+
update: "Correggere gli errori di seguito e provare ad aggiornare di nuovo"
|
|
9318
|
+
}
|
|
9319
|
+
},
|
|
9320
|
+
info: {
|
|
9321
|
+
required_fields: "campi obbligatori"
|
|
9322
|
+
}
|
|
9323
|
+
},
|
|
9324
|
+
ariaLabels: {
|
|
9325
|
+
menuItem: "Voce di menu Viste salvate {{name}}",
|
|
9326
|
+
modal: "Finestra modale per creare/aggiornare viste salvate"
|
|
9327
|
+
},
|
|
9328
|
+
update: {
|
|
9329
|
+
success: "Vista salvata aggiornata correttamente."
|
|
9330
|
+
},
|
|
9331
|
+
errors: {
|
|
9332
|
+
fetch: "Impossibile recuperare le viste salvate. Riprovare.",
|
|
9333
|
+
create: "Impossibile creare la vista salvata. Riprovare.",
|
|
9334
|
+
update: "Impossibile aggiornare la vista salvata. Riprovare.",
|
|
9335
|
+
delete: "Impossibile eliminare la vista salvata. Riprovare."
|
|
9336
|
+
},
|
|
9337
|
+
defaultViewTitle: {
|
|
9338
|
+
rfi: "Tutte le RDI",
|
|
9339
|
+
submittal_log: "Tutti gli elementi da inoltrare"
|
|
9340
|
+
},
|
|
9341
|
+
viewLevel: {
|
|
9342
|
+
company: "Viste dell'azienda",
|
|
9343
|
+
project: "Viste del progetto",
|
|
9344
|
+
personal: "Viste personali"
|
|
9345
|
+
}
|
|
9346
|
+
}
|
|
9347
|
+
};
|
|
9348
|
+
|
|
9267
9349
|
// src/locales/ja-JP.json
|
|
9268
9350
|
var ja_JP_default = {
|
|
9269
9351
|
savedViews: {
|
|
@@ -9654,8 +9736,8 @@ var zh_SG_default = {
|
|
|
9654
9736
|
}
|
|
9655
9737
|
};
|
|
9656
9738
|
|
|
9657
|
-
// src/
|
|
9658
|
-
var
|
|
9739
|
+
// src/locales/index.ts
|
|
9740
|
+
var locales_default = {
|
|
9659
9741
|
"de-DE": de_DE_default,
|
|
9660
9742
|
"en-AU": en_AU_default,
|
|
9661
9743
|
"en-CA": en_CA_default,
|
|
@@ -9666,12 +9748,18 @@ var supportedLocales = {
|
|
|
9666
9748
|
"fr-CA": fr_CA_default,
|
|
9667
9749
|
"fr-FR": fr_FR_default,
|
|
9668
9750
|
"is-IS": is_IS_default,
|
|
9751
|
+
"it-IT": it_IT_default,
|
|
9669
9752
|
"ja-JP": ja_JP_default,
|
|
9753
|
+
"pl-PL": pl_PL_default,
|
|
9670
9754
|
"pt-BR": pt_BR_default,
|
|
9671
9755
|
"th-TH": th_TH_default,
|
|
9672
|
-
"zh-SG": zh_SG_default
|
|
9673
|
-
|
|
9674
|
-
|
|
9756
|
+
"zh-SG": zh_SG_default
|
|
9757
|
+
};
|
|
9758
|
+
|
|
9759
|
+
// src/utils/translations/translations.ts
|
|
9760
|
+
var supportedLocales = {
|
|
9761
|
+
...locales_default,
|
|
9762
|
+
pseudo: locales_default.en
|
|
9675
9763
|
};
|
|
9676
9764
|
function getTranslations(envLocale) {
|
|
9677
9765
|
return Object.fromEntries(
|
|
@@ -9682,7 +9770,7 @@ function getTranslations(envLocale) {
|
|
|
9682
9770
|
);
|
|
9683
9771
|
}
|
|
9684
9772
|
|
|
9685
|
-
// src/
|
|
9773
|
+
// src/components/buttons/useSavedViewsPanel.tsx
|
|
9686
9774
|
import { useState } from "react";
|
|
9687
9775
|
|
|
9688
9776
|
// ../../node_modules/tslib/tslib.es6.mjs
|
|
@@ -9894,7 +9982,7 @@ var Plus = React11.forwardRef(function Plus2(props, ref) {
|
|
|
9894
9982
|
Plus.displayName = "Plus";
|
|
9895
9983
|
var Plus_default = Plus;
|
|
9896
9984
|
|
|
9897
|
-
// src/
|
|
9985
|
+
// src/components/buttons/SavedViewsButton.tsx
|
|
9898
9986
|
import { Button } from "@procore/core-react";
|
|
9899
9987
|
import React13 from "react";
|
|
9900
9988
|
|
|
@@ -11109,7 +11197,7 @@ var Ue = function() {
|
|
|
11109
11197
|
"production" !== process.env.NODE_ENV && "undefined" != typeof navigator && "ReactNative" === navigator.product && console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native"), "production" !== process.env.NODE_ENV && "test" !== process.env.NODE_ENV && "undefined" != typeof window && (window["__styled-components-init__"] = window["__styled-components-init__"] || 0, 1 === window["__styled-components-init__"] && console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."), window["__styled-components-init__"] += 1);
|
|
11110
11198
|
var styled_components_esm_default = Ye;
|
|
11111
11199
|
|
|
11112
|
-
// src/
|
|
11200
|
+
// src/components/EnvironmentI18nProvider.tsx
|
|
11113
11201
|
import React12 from "react";
|
|
11114
11202
|
import { I18nContext, useI18n, useI18nContext } from "@procore/core-react";
|
|
11115
11203
|
import { useRequestTranslations } from "@procore/cdn-translations";
|
|
@@ -11139,7 +11227,7 @@ var EnvironmentI18nProvider = ({ children }) => {
|
|
|
11139
11227
|
return /* @__PURE__ */ React12.createElement(I18nContext.Provider, { value: i18n }, children);
|
|
11140
11228
|
};
|
|
11141
11229
|
|
|
11142
|
-
// src/
|
|
11230
|
+
// src/components/buttons/SavedViewsButton.tsx
|
|
11143
11231
|
var StyledButton = styled_components_esm_default(Button)`
|
|
11144
11232
|
background-color: hsl(218, 75%, 96%);
|
|
11145
11233
|
color: hsl(218, 75%, 45%);
|
|
@@ -11175,7 +11263,7 @@ var SavedViewsButton = ({
|
|
|
11175
11263
|
));
|
|
11176
11264
|
};
|
|
11177
11265
|
|
|
11178
|
-
// src/
|
|
11266
|
+
// src/components/buttons/useSavedViewsPanel.tsx
|
|
11179
11267
|
import React14 from "react";
|
|
11180
11268
|
var useSavedViewsPanel = (domain, tableName) => {
|
|
11181
11269
|
const key = (domain2, tableName2) => `savedViewsPanel-${domain2}-${tableName2}`;
|
|
@@ -11191,7 +11279,7 @@ var useSavedViewsPanel = (domain, tableName) => {
|
|
|
11191
11279
|
};
|
|
11192
11280
|
var useSavedViewsPanel_default = useSavedViewsPanel;
|
|
11193
11281
|
|
|
11194
|
-
// src/
|
|
11282
|
+
// src/components/menu-items/SavedViewsCollectionsMenuItem.tsx
|
|
11195
11283
|
import {
|
|
11196
11284
|
Box,
|
|
11197
11285
|
Button as Button2,
|
|
@@ -11215,6 +11303,11 @@ var Container2 = styled_components_esm_default(Flex)`
|
|
|
11215
11303
|
|
|
11216
11304
|
${({ "aria-selected": selected }) => selected ? "color: hsl(218, 75%, 45%);" : ""}
|
|
11217
11305
|
`;
|
|
11306
|
+
var IconWrapper = styled_components_esm_default.span`
|
|
11307
|
+
display: flex;
|
|
11308
|
+
align-items: center;
|
|
11309
|
+
justify-content: center;
|
|
11310
|
+
`;
|
|
11218
11311
|
var SavedViewCollectionMenuItem = (props) => {
|
|
11219
11312
|
const onClick = React15.useCallback(
|
|
11220
11313
|
(a2) => {
|
|
@@ -11281,7 +11374,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11281
11374
|
},
|
|
11282
11375
|
props.item.name
|
|
11283
11376
|
),
|
|
11284
|
-
/* @__PURE__ */ React15.createElement(RowActionsBox, null, /* @__PURE__ */ React15.createElement(Box, { justifyContent: "space-between" }, props.item.
|
|
11377
|
+
/* @__PURE__ */ React15.createElement(RowActionsBox, null, /* @__PURE__ */ React15.createElement(Box, { justifyContent: "space-between" }, props.item.view_level !== "default" && props.canUpdate && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
|
|
11285
11378
|
Button2,
|
|
11286
11379
|
{
|
|
11287
11380
|
onClick: updateItem,
|
|
@@ -11292,7 +11385,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11292
11385
|
loading: props.isUpdateProcessing
|
|
11293
11386
|
},
|
|
11294
11387
|
i18n.t("savedViews.actions.update")
|
|
11295
|
-
)), props.item.
|
|
11388
|
+
)), props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
|
|
11296
11389
|
Button2,
|
|
11297
11390
|
{
|
|
11298
11391
|
onClick: copyShareLink,
|
|
@@ -11301,7 +11394,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11301
11394
|
"aria-label": i18n.t("savedViews.actions.copyShareLink"),
|
|
11302
11395
|
"data-testid": "copy-share-link-button"
|
|
11303
11396
|
},
|
|
11304
|
-
/* @__PURE__ */ React15.createElement(Link_default, { size: "sm" })
|
|
11397
|
+
/* @__PURE__ */ React15.createElement(IconWrapper, null, /* @__PURE__ */ React15.createElement(Link_default, { size: "sm" }))
|
|
11305
11398
|
)), props.item.id === "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
|
|
11306
11399
|
Button2,
|
|
11307
11400
|
{
|
|
@@ -11315,8 +11408,8 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11315
11408
|
title: i18n.t("savedViews.actions.clearTemporary"),
|
|
11316
11409
|
"data-testid": "clear-temporary-view-button"
|
|
11317
11410
|
},
|
|
11318
|
-
/* @__PURE__ */ React15.createElement(Clear_default, { size: "sm" })
|
|
11319
|
-
))), /* @__PURE__ */ React15.createElement(Box, null, props.item.
|
|
11411
|
+
/* @__PURE__ */ React15.createElement(IconWrapper, null, /* @__PURE__ */ React15.createElement(Clear_default, { size: "sm" }))
|
|
11412
|
+
))), /* @__PURE__ */ React15.createElement(Box, null, props.item.view_level !== "default" && props.canEditOrDelete && /* @__PURE__ */ React15.createElement("div", { onClick: (e2) => e2.stopPropagation() }, /* @__PURE__ */ React15.createElement(
|
|
11320
11413
|
DropdownFlyout,
|
|
11321
11414
|
{
|
|
11322
11415
|
"data-testid": "saved-view-overflow-button",
|
|
@@ -11331,7 +11424,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11331
11424
|
);
|
|
11332
11425
|
};
|
|
11333
11426
|
|
|
11334
|
-
// src/
|
|
11427
|
+
// src/components/panels/ExpandedPanel.tsx
|
|
11335
11428
|
import { Panel } from "@procore/core-react";
|
|
11336
11429
|
var ExpandedPanel = styled_components_esm_default(Panel)`
|
|
11337
11430
|
width: ${({ provider }) => provider === "data-table" ? "316px" : "100%"};
|
|
@@ -11339,15 +11432,8 @@ var ExpandedPanel = styled_components_esm_default(Panel)`
|
|
|
11339
11432
|
border-radius: 4px 0 0 4px;
|
|
11340
11433
|
`;
|
|
11341
11434
|
|
|
11342
|
-
// src/
|
|
11343
|
-
import {
|
|
11344
|
-
colors as colors2,
|
|
11345
|
-
DetailPage,
|
|
11346
|
-
Flex as Flex3,
|
|
11347
|
-
UNSAFE_Menu as MenuImperative,
|
|
11348
|
-
spacing as spacing2,
|
|
11349
|
-
useI18nContext as useI18nContext5
|
|
11350
|
-
} from "@procore/core-react";
|
|
11435
|
+
// src/components/panels/PanelContent.tsx
|
|
11436
|
+
import { Flex as Flex3, useI18nContext as useI18nContext5 } from "@procore/core-react";
|
|
11351
11437
|
import { useToastAlertContext as useToastAlertContext2 } from "@procore/toast-alert";
|
|
11352
11438
|
import React17 from "react";
|
|
11353
11439
|
|
|
@@ -11393,10 +11479,10 @@ function requestJSON(url, requestParams = {}) {
|
|
|
11393
11479
|
);
|
|
11394
11480
|
}
|
|
11395
11481
|
|
|
11396
|
-
// src/utils/
|
|
11482
|
+
// src/utils/api/queries.ts
|
|
11397
11483
|
import { useQuery } from "@tanstack/react-query";
|
|
11398
11484
|
|
|
11399
|
-
// src/utils/
|
|
11485
|
+
// src/utils/api/queriesHandler.ts
|
|
11400
11486
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
11401
11487
|
import { useI18nContext as useI18nContext3 } from "@procore/core-react";
|
|
11402
11488
|
var useApiRequest = (props, method, mutationKey) => {
|
|
@@ -11461,10 +11547,10 @@ var useApiRequest = (props, method, mutationKey) => {
|
|
|
11461
11547
|
});
|
|
11462
11548
|
};
|
|
11463
11549
|
|
|
11464
|
-
// src/utils/
|
|
11550
|
+
// src/utils/constants/viewLevels.ts
|
|
11465
11551
|
var VIEW_LEVELS = ["company", "project", "personal"];
|
|
11466
11552
|
|
|
11467
|
-
// src/utils/
|
|
11553
|
+
// src/utils/api/queries.ts
|
|
11468
11554
|
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
11469
11555
|
var useSavedViewsQuery = (props) => {
|
|
11470
11556
|
const { projectId, companyId, domain, tableName } = props;
|
|
@@ -11517,24 +11603,23 @@ var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
|
11517
11603
|
});
|
|
11518
11604
|
};
|
|
11519
11605
|
|
|
11520
|
-
// src/
|
|
11606
|
+
// src/components/panels/PanelContentUtils.ts
|
|
11521
11607
|
var import_lodash = __toESM(require_lodash());
|
|
11522
11608
|
|
|
11523
|
-
// src/
|
|
11609
|
+
// src/components/adapters/smart-grid/SmartGridUtils.ts
|
|
11524
11610
|
function getSmartGridConfig(api) {
|
|
11525
|
-
const
|
|
11526
|
-
const
|
|
11527
|
-
const
|
|
11528
|
-
const
|
|
11529
|
-
const
|
|
11530
|
-
|
|
11531
|
-
columnState
|
|
11532
|
-
rowHeight
|
|
11533
|
-
columnGroupState
|
|
11534
|
-
rowGroupState
|
|
11535
|
-
filterState
|
|
11611
|
+
const columnState = api.getColumnState();
|
|
11612
|
+
const columnGroupState = api.getColumnGroupState();
|
|
11613
|
+
const rowGroupState = api.getRowGroupColumns().map((col) => col.getColId());
|
|
11614
|
+
const rowHeight = api.getGridOption("rowHeight") ?? api.getSizesForCurrentTheme().rowHeight;
|
|
11615
|
+
const filterState = api.getFilterModel();
|
|
11616
|
+
return {
|
|
11617
|
+
columnState,
|
|
11618
|
+
rowHeight,
|
|
11619
|
+
columnGroupState,
|
|
11620
|
+
rowGroupState,
|
|
11621
|
+
filterState
|
|
11536
11622
|
};
|
|
11537
|
-
return smartGridConfig;
|
|
11538
11623
|
}
|
|
11539
11624
|
function setSmartGridConfig(api, config) {
|
|
11540
11625
|
api.applyColumnState({
|
|
@@ -11549,7 +11634,7 @@ function setSmartGridConfig(api, config) {
|
|
|
11549
11634
|
}
|
|
11550
11635
|
}
|
|
11551
11636
|
|
|
11552
|
-
// src/
|
|
11637
|
+
// src/components/saved-views/SavedViewsUtils.ts
|
|
11553
11638
|
var customAndConfigSync = (viewTableConfig, defaultTableConfig) => {
|
|
11554
11639
|
if (!viewTableConfig && !defaultTableConfig)
|
|
11555
11640
|
return void 0;
|
|
@@ -11608,7 +11693,7 @@ var updateTableConfig = (view, tableApi, provider) => {
|
|
|
11608
11693
|
}
|
|
11609
11694
|
};
|
|
11610
11695
|
|
|
11611
|
-
// src/
|
|
11696
|
+
// src/components/panels/PanelContentUtils.ts
|
|
11612
11697
|
var getOrderedVisibleColumns = (columns, idKey) => {
|
|
11613
11698
|
if (!columns)
|
|
11614
11699
|
return [];
|
|
@@ -11703,7 +11788,7 @@ var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
|
11703
11788
|
}
|
|
11704
11789
|
};
|
|
11705
11790
|
|
|
11706
|
-
// src/
|
|
11791
|
+
// src/components/panels/useGroups.ts
|
|
11707
11792
|
import { useState as useState2 } from "react";
|
|
11708
11793
|
var useGroups = () => {
|
|
11709
11794
|
const [groups, setGroups] = useState2(
|
|
@@ -11715,7 +11800,7 @@ var useGroups = () => {
|
|
|
11715
11800
|
return { groups, toggleGroup };
|
|
11716
11801
|
};
|
|
11717
11802
|
|
|
11718
|
-
// src/
|
|
11803
|
+
// src/components/panels/ViewLevelHeader.tsx
|
|
11719
11804
|
import {
|
|
11720
11805
|
colors,
|
|
11721
11806
|
Flex as Flex2,
|
|
@@ -11758,7 +11843,7 @@ var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
|
11758
11843
|
};
|
|
11759
11844
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
11760
11845
|
|
|
11761
|
-
// src/utils/
|
|
11846
|
+
// src/utils/hooks/useScrollToRef.ts
|
|
11762
11847
|
import { useEffect, useRef } from "react";
|
|
11763
11848
|
var useScrollToRef = (dependency) => {
|
|
11764
11849
|
const ref = useRef(null);
|
|
@@ -11770,7 +11855,13 @@ var useScrollToRef = (dependency) => {
|
|
|
11770
11855
|
return ref;
|
|
11771
11856
|
};
|
|
11772
11857
|
|
|
11773
|
-
// src/
|
|
11858
|
+
// src/components/panels/PanelContent.styles.ts
|
|
11859
|
+
import {
|
|
11860
|
+
colors as colors2,
|
|
11861
|
+
DetailPage,
|
|
11862
|
+
UNSAFE_Menu as MenuImperative,
|
|
11863
|
+
spacing as spacing2
|
|
11864
|
+
} from "@procore/core-react";
|
|
11774
11865
|
var Row = styled_components_esm_default(MenuImperative.Item)`
|
|
11775
11866
|
width: 100%;
|
|
11776
11867
|
padding-left: 35px;
|
|
@@ -11787,11 +11878,15 @@ var Panel2 = styled_components_esm_default(DetailPage.Card)`
|
|
|
11787
11878
|
padding-top: ${spacing2.sm}px;
|
|
11788
11879
|
box-shadow: none;
|
|
11789
11880
|
`;
|
|
11881
|
+
|
|
11882
|
+
// src/components/panels/PanelContent.tsx
|
|
11790
11883
|
var PanelContent = (props) => {
|
|
11884
|
+
const { queryInput, selectedSavedView, tableConfig } = props;
|
|
11791
11885
|
const { showToast } = useToastAlertContext2();
|
|
11792
11886
|
const I18n = useI18nContext5();
|
|
11793
|
-
const {
|
|
11794
|
-
const {
|
|
11887
|
+
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
11888
|
+
const { mutate: updateSavedView, isPending: isUpdateLoading } = useUpdateSavedView(queryInput);
|
|
11889
|
+
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
11795
11890
|
const errorToastRef = React17.useRef(null);
|
|
11796
11891
|
React17.useEffect(() => {
|
|
11797
11892
|
if (savedViewsError && savedViewsError !== errorToastRef.current) {
|
|
@@ -11800,12 +11895,16 @@ var PanelContent = (props) => {
|
|
|
11800
11895
|
}
|
|
11801
11896
|
}, [savedViewsError, showToast, I18n]);
|
|
11802
11897
|
const { data: permissions } = useSavedViewsPermissions(props.queryInput);
|
|
11803
|
-
const selectedRowRef = useScrollToRef(
|
|
11898
|
+
const selectedRowRef = useScrollToRef(savedViews);
|
|
11899
|
+
const { groups, toggleGroup } = useGroups();
|
|
11900
|
+
const isTemporarySelected = selectedSavedView?.id === "temporary";
|
|
11901
|
+
const temporaryView = savedViews?.find((view) => view.id === "temporary");
|
|
11902
|
+
const presetViews = props.presetViews || [props.defaultView];
|
|
11804
11903
|
const onUpdate = (data) => {
|
|
11805
11904
|
const newSavedView = {
|
|
11806
11905
|
...data,
|
|
11807
|
-
...
|
|
11808
|
-
table_config:
|
|
11906
|
+
...selectedSavedView,
|
|
11907
|
+
table_config: tableConfig
|
|
11809
11908
|
};
|
|
11810
11909
|
updateSavedView(newSavedView, {
|
|
11811
11910
|
onSuccess: () => {
|
|
@@ -11817,12 +11916,6 @@ var PanelContent = (props) => {
|
|
|
11817
11916
|
}
|
|
11818
11917
|
});
|
|
11819
11918
|
};
|
|
11820
|
-
const { groups, toggleGroup } = useGroups();
|
|
11821
|
-
const isDefaultSelected = props.selectedSavedView?.id === "default";
|
|
11822
|
-
const isTemporarySelected = props.selectedSavedView?.id === "temporary";
|
|
11823
|
-
const temporaryView = props.savedViews?.find(
|
|
11824
|
-
(view) => view.id === "temporary"
|
|
11825
|
-
);
|
|
11826
11919
|
return /* @__PURE__ */ React17.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ React17.createElement(Flex3, { direction: "column", style: { height: "100%", width: "100%" } }, temporaryView && /* @__PURE__ */ React17.createElement(
|
|
11827
11920
|
Row,
|
|
11828
11921
|
{
|
|
@@ -11838,23 +11931,27 @@ var PanelContent = (props) => {
|
|
|
11838
11931
|
onClearTemporary: props.onClearTemporary
|
|
11839
11932
|
}
|
|
11840
11933
|
)
|
|
11841
|
-
),
|
|
11842
|
-
|
|
11843
|
-
|
|
11844
|
-
|
|
11845
|
-
onClick: () => props.onSelect({ item: props.defaultView }),
|
|
11846
|
-
ref: isDefaultSelected ? selectedRowRef : null
|
|
11847
|
-
},
|
|
11848
|
-
/* @__PURE__ */ React17.createElement(
|
|
11849
|
-
SavedViewCollectionMenuItem,
|
|
11934
|
+
), presetViews.map((presetView) => {
|
|
11935
|
+
const isSelected = selectedSavedView?.id === presetView.id;
|
|
11936
|
+
return /* @__PURE__ */ React17.createElement(
|
|
11937
|
+
Row,
|
|
11850
11938
|
{
|
|
11851
|
-
|
|
11852
|
-
selected:
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11939
|
+
key: presetView.id,
|
|
11940
|
+
selected: isSelected,
|
|
11941
|
+
onClick: () => props.onSelect({ item: presetView }),
|
|
11942
|
+
ref: isSelected ? selectedRowRef : null
|
|
11943
|
+
},
|
|
11944
|
+
/* @__PURE__ */ React17.createElement(
|
|
11945
|
+
SavedViewCollectionMenuItem,
|
|
11946
|
+
{
|
|
11947
|
+
item: presetView,
|
|
11948
|
+
selected: isSelected
|
|
11949
|
+
}
|
|
11950
|
+
)
|
|
11951
|
+
);
|
|
11952
|
+
}), VIEW_LEVELS.map((level) => {
|
|
11856
11953
|
const isExpanded = groups[level];
|
|
11857
|
-
const views = isExpanded &&
|
|
11954
|
+
const views = isExpanded && savedViews ? savedViews.filter(
|
|
11858
11955
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
11859
11956
|
) : [];
|
|
11860
11957
|
return /* @__PURE__ */ React17.createElement(React17.Fragment, { key: level }, /* @__PURE__ */ React17.createElement(
|
|
@@ -11865,10 +11962,10 @@ var PanelContent = (props) => {
|
|
|
11865
11962
|
expanded: isExpanded
|
|
11866
11963
|
}
|
|
11867
11964
|
), views.map((view) => {
|
|
11868
|
-
const isSelected =
|
|
11965
|
+
const isSelected = selectedSavedView?.id === view.id;
|
|
11869
11966
|
const canUpdate = isSelected && hasPermissionForViewLevel(view.view_level, permissions) && !isEqual(
|
|
11870
11967
|
view.table_config,
|
|
11871
|
-
|
|
11968
|
+
tableConfig,
|
|
11872
11969
|
props.defaultView.table_config,
|
|
11873
11970
|
props.provider
|
|
11874
11971
|
);
|
|
@@ -11904,67 +12001,7 @@ var PanelContent = (props) => {
|
|
|
11904
12001
|
})));
|
|
11905
12002
|
};
|
|
11906
12003
|
|
|
11907
|
-
// src/
|
|
11908
|
-
import React23, { useCallback as useCallback4 } from "react";
|
|
11909
|
-
|
|
11910
|
-
// src/SavedViews/components/SavedViews/SmartGrid/SmartGridDefaultSavedView.tsx
|
|
11911
|
-
import { useI18nContext as useI18nContext6 } from "@procore/core-react";
|
|
11912
|
-
var useDefaultViewName = (domain, defaultViewName) => {
|
|
11913
|
-
const i18n = useI18nContext6();
|
|
11914
|
-
return defaultViewName || i18n.t(domain, {
|
|
11915
|
-
scope: "savedViews.defaultViewTitle",
|
|
11916
|
-
defaultValue: "Default View"
|
|
11917
|
-
});
|
|
11918
|
-
};
|
|
11919
|
-
var useDefaultView = (props) => {
|
|
11920
|
-
const name = useDefaultViewName(props.domain, props.defaultViewName);
|
|
11921
|
-
return {
|
|
11922
|
-
id: "default",
|
|
11923
|
-
view_level: "default",
|
|
11924
|
-
name,
|
|
11925
|
-
table_config: {}
|
|
11926
|
-
};
|
|
11927
|
-
};
|
|
11928
|
-
|
|
11929
|
-
// src/SavedViews/components/SavedViews/SmartGrid/useSmartGridConfig.ts
|
|
11930
|
-
import { useState as useState3, useEffect as useEffect2 } from "react";
|
|
11931
|
-
var GRID_STATE_EVENTS = [
|
|
11932
|
-
"sortChanged",
|
|
11933
|
-
"filterOpened",
|
|
11934
|
-
"filterChanged",
|
|
11935
|
-
"columnRowGroupChanged",
|
|
11936
|
-
"dragStopped",
|
|
11937
|
-
"columnResized",
|
|
11938
|
-
"columnVisible",
|
|
11939
|
-
"columnPinned",
|
|
11940
|
-
"columnMoved",
|
|
11941
|
-
"modelUpdated",
|
|
11942
|
-
"gridColumnsChanged",
|
|
11943
|
-
"gridReady"
|
|
11944
|
-
];
|
|
11945
|
-
var useSmartGridConfig = (gridApi) => {
|
|
11946
|
-
const [config, setConfig] = useState3(
|
|
11947
|
-
() => getSmartGridConfig(gridApi)
|
|
11948
|
-
);
|
|
11949
|
-
useEffect2(() => {
|
|
11950
|
-
if (!gridApi)
|
|
11951
|
-
return;
|
|
11952
|
-
const updateConfig = () => {
|
|
11953
|
-
setConfig(getSmartGridConfig(gridApi));
|
|
11954
|
-
};
|
|
11955
|
-
GRID_STATE_EVENTS.forEach((event) => {
|
|
11956
|
-
gridApi.addEventListener(event, updateConfig);
|
|
11957
|
-
});
|
|
11958
|
-
return () => {
|
|
11959
|
-
GRID_STATE_EVENTS.forEach((event) => {
|
|
11960
|
-
gridApi.removeEventListener(event, updateConfig);
|
|
11961
|
-
});
|
|
11962
|
-
};
|
|
11963
|
-
}, [gridApi]);
|
|
11964
|
-
return { config, setConfig };
|
|
11965
|
-
};
|
|
11966
|
-
|
|
11967
|
-
// src/SavedViews/components/SavedViews/SavedViews.tsx
|
|
12004
|
+
// src/components/saved-views/SavedViews.tsx
|
|
11968
12005
|
import {
|
|
11969
12006
|
Box as Box2,
|
|
11970
12007
|
Button as Button6,
|
|
@@ -11973,16 +12010,17 @@ import {
|
|
|
11973
12010
|
Tooltip,
|
|
11974
12011
|
useI18nContext as useI18nContext11
|
|
11975
12012
|
} from "@procore/core-react";
|
|
11976
|
-
import React22, { useState as
|
|
12013
|
+
import React22, { useState as useState4, useEffect as useEffect3, useCallback as useCallback3 } from "react";
|
|
11977
12014
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
12015
|
+
import { useToastAlertContext as useToastAlertContext3 } from "@procore/toast-alert";
|
|
11978
12016
|
|
|
11979
|
-
// src/
|
|
12017
|
+
// src/components/modals/DeleteConfirmationModal.tsx
|
|
11980
12018
|
import {
|
|
11981
12019
|
Button as Button3,
|
|
11982
12020
|
ConfirmModal,
|
|
11983
12021
|
Modal,
|
|
11984
12022
|
P as P2,
|
|
11985
|
-
useI18nContext as
|
|
12023
|
+
useI18nContext as useI18nContext6
|
|
11986
12024
|
} from "@procore/core-react";
|
|
11987
12025
|
import React18 from "react";
|
|
11988
12026
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
@@ -11990,7 +12028,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11990
12028
|
onDelete,
|
|
11991
12029
|
open
|
|
11992
12030
|
}) => {
|
|
11993
|
-
const i18n =
|
|
12031
|
+
const i18n = useI18nContext6();
|
|
11994
12032
|
return /* @__PURE__ */ React18.createElement(
|
|
11995
12033
|
ConfirmModal,
|
|
11996
12034
|
{
|
|
@@ -12006,10 +12044,10 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
12006
12044
|
);
|
|
12007
12045
|
};
|
|
12008
12046
|
|
|
12009
|
-
// src/
|
|
12047
|
+
// src/components/modals/form-modal/FormModal.tsx
|
|
12010
12048
|
import React20 from "react";
|
|
12011
12049
|
|
|
12012
|
-
// src/
|
|
12050
|
+
// src/components/modals/form-modal/FormModalBase.tsx
|
|
12013
12051
|
import {
|
|
12014
12052
|
Banner,
|
|
12015
12053
|
Button as Button4,
|
|
@@ -12021,7 +12059,7 @@ import {
|
|
|
12021
12059
|
Modal as Modal2,
|
|
12022
12060
|
spacing as spacing3,
|
|
12023
12061
|
Typography as Typography2,
|
|
12024
|
-
useI18nContext as
|
|
12062
|
+
useI18nContext as useI18nContext7
|
|
12025
12063
|
} from "@procore/core-react";
|
|
12026
12064
|
import * as React19 from "react";
|
|
12027
12065
|
|
|
@@ -14317,7 +14355,7 @@ var TupleSchema = class extends Schema {
|
|
|
14317
14355
|
};
|
|
14318
14356
|
create$1.prototype = TupleSchema.prototype;
|
|
14319
14357
|
|
|
14320
|
-
// src/
|
|
14358
|
+
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
14321
14359
|
var getViewLevelOptions = (permissions, i18n) => {
|
|
14322
14360
|
const options = ["personal"];
|
|
14323
14361
|
if (permissions?.can_create_project_saved_views)
|
|
@@ -14350,11 +14388,11 @@ function extractMessage(error, I18n) {
|
|
|
14350
14388
|
return { form: I18n.t("savedViews.modal.errors.unknown") };
|
|
14351
14389
|
}
|
|
14352
14390
|
|
|
14353
|
-
// src/
|
|
14391
|
+
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14354
14392
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14355
14393
|
overflow: auto;
|
|
14356
14394
|
`;
|
|
14357
|
-
var
|
|
14395
|
+
var FormModalBase = ({
|
|
14358
14396
|
open,
|
|
14359
14397
|
mode,
|
|
14360
14398
|
onCancel,
|
|
@@ -14369,7 +14407,7 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14369
14407
|
setOpenEditCreateModal,
|
|
14370
14408
|
onSelect
|
|
14371
14409
|
}) => {
|
|
14372
|
-
const I18n =
|
|
14410
|
+
const I18n = useI18nContext7();
|
|
14373
14411
|
const NAME_MAX_LENGTH = 150;
|
|
14374
14412
|
const {
|
|
14375
14413
|
mutate: createSavedView,
|
|
@@ -14524,9 +14562,9 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14524
14562
|
);
|
|
14525
14563
|
};
|
|
14526
14564
|
|
|
14527
|
-
// src/
|
|
14528
|
-
import { useI18nContext as
|
|
14529
|
-
var
|
|
14565
|
+
// src/components/modals/form-modal/FormModal.tsx
|
|
14566
|
+
import { useI18nContext as useI18nContext8 } from "@procore/core-react";
|
|
14567
|
+
var FormModal = ({
|
|
14530
14568
|
open,
|
|
14531
14569
|
mode,
|
|
14532
14570
|
onCancel,
|
|
@@ -14538,9 +14576,9 @@ var SavedViewsFormModal = ({
|
|
|
14538
14576
|
onSelect,
|
|
14539
14577
|
defaultView
|
|
14540
14578
|
}) => {
|
|
14541
|
-
const i18n =
|
|
14579
|
+
const i18n = useI18nContext8();
|
|
14542
14580
|
return /* @__PURE__ */ React20.createElement(
|
|
14543
|
-
|
|
14581
|
+
FormModalBase,
|
|
14544
14582
|
{
|
|
14545
14583
|
open,
|
|
14546
14584
|
mode,
|
|
@@ -14559,7 +14597,7 @@ var SavedViewsFormModal = ({
|
|
|
14559
14597
|
);
|
|
14560
14598
|
};
|
|
14561
14599
|
|
|
14562
|
-
// src/
|
|
14600
|
+
// src/components/modals/form-modal/SharedViewFormModal.tsx
|
|
14563
14601
|
import {
|
|
14564
14602
|
Banner as Banner2,
|
|
14565
14603
|
Button as Button5,
|
|
@@ -14571,7 +14609,7 @@ import {
|
|
|
14571
14609
|
P as P3,
|
|
14572
14610
|
spacing as spacing4,
|
|
14573
14611
|
Typography as Typography3,
|
|
14574
|
-
useI18nContext as
|
|
14612
|
+
useI18nContext as useI18nContext9
|
|
14575
14613
|
} from "@procore/core-react";
|
|
14576
14614
|
import * as React21 from "react";
|
|
14577
14615
|
var SharedViewFormModal = ({
|
|
@@ -14584,7 +14622,7 @@ var SharedViewFormModal = ({
|
|
|
14584
14622
|
isCreating,
|
|
14585
14623
|
resetCreateError
|
|
14586
14624
|
}) => {
|
|
14587
|
-
const I18n =
|
|
14625
|
+
const I18n = useI18nContext9();
|
|
14588
14626
|
const NAME_MAX_LENGTH = 150;
|
|
14589
14627
|
const errors = extractMessage(createError, I18n);
|
|
14590
14628
|
const handleNameChange = () => {
|
|
@@ -14713,21 +14751,25 @@ var SharedViewFormModal = ({
|
|
|
14713
14751
|
);
|
|
14714
14752
|
};
|
|
14715
14753
|
|
|
14716
|
-
// src/
|
|
14717
|
-
import {
|
|
14754
|
+
// src/components/saved-views/SavedViews.tsx
|
|
14755
|
+
import { ToastAlertProvider } from "@procore/toast-alert";
|
|
14756
|
+
|
|
14757
|
+
// src/utils/hooks/useViewSelection.ts
|
|
14758
|
+
import { useState as useState3, useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useMemo } from "react";
|
|
14718
14759
|
import { useSearchParams } from "react-router-dom";
|
|
14760
|
+
import { useI18nContext as useI18nContext10 } from "@procore/core-react";
|
|
14719
14761
|
|
|
14720
14762
|
// src/utils/viewStorage.ts
|
|
14721
14763
|
var ViewStorage = {
|
|
14722
14764
|
save(key, view) {
|
|
14723
14765
|
localStorage.setItem(key, JSON.stringify(view));
|
|
14724
14766
|
},
|
|
14725
|
-
load(key) {
|
|
14767
|
+
load(key, defaultView) {
|
|
14726
14768
|
try {
|
|
14727
14769
|
const stored = localStorage.getItem(key);
|
|
14728
14770
|
return stored ? JSON.parse(stored) : null;
|
|
14729
14771
|
} catch (e2) {
|
|
14730
|
-
return
|
|
14772
|
+
return defaultView;
|
|
14731
14773
|
}
|
|
14732
14774
|
},
|
|
14733
14775
|
remove(key) {
|
|
@@ -14735,7 +14777,7 @@ var ViewStorage = {
|
|
|
14735
14777
|
}
|
|
14736
14778
|
};
|
|
14737
14779
|
|
|
14738
|
-
// src/utils/
|
|
14780
|
+
// src/utils/hooks/useViewSelection.ts
|
|
14739
14781
|
var getUpdatedSearchParams = (currentParams, view) => {
|
|
14740
14782
|
const updatedParams = new URLSearchParams(currentParams);
|
|
14741
14783
|
if (view.id === "default") {
|
|
@@ -14750,55 +14792,68 @@ var getUpdatedSearchParams = (currentParams, view) => {
|
|
|
14750
14792
|
var checkIsViewSelected = (selectedView, viewId) => {
|
|
14751
14793
|
return selectedView?.share_token === viewId || selectedView?.id === viewId;
|
|
14752
14794
|
};
|
|
14795
|
+
var findViewByToken = (views, token) => {
|
|
14796
|
+
return views.find((view) => view.share_token === token);
|
|
14797
|
+
};
|
|
14798
|
+
var setViewInUrl = (view, setSearchParams) => {
|
|
14799
|
+
setSearchParams(
|
|
14800
|
+
(currentParams) => getUpdatedSearchParams(currentParams, view),
|
|
14801
|
+
{ replace: true }
|
|
14802
|
+
);
|
|
14803
|
+
};
|
|
14804
|
+
var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
14805
|
+
if (previousParam && !currentParam) {
|
|
14806
|
+
setSearchParams(
|
|
14807
|
+
(currentParams) => {
|
|
14808
|
+
const updatedParams = new URLSearchParams(currentParams);
|
|
14809
|
+
updatedParams.set("saved-view", previousParam);
|
|
14810
|
+
return updatedParams;
|
|
14811
|
+
},
|
|
14812
|
+
{ replace: true }
|
|
14813
|
+
);
|
|
14814
|
+
}
|
|
14815
|
+
};
|
|
14753
14816
|
var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
14754
|
-
const
|
|
14755
|
-
const
|
|
14817
|
+
const I18n = useI18nContext10();
|
|
14818
|
+
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${config.projectId}_${config.userId}`;
|
|
14819
|
+
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14756
14820
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
14757
14821
|
const previousSavedViewParamRef = useRef2(null);
|
|
14758
|
-
const [selectedSavedView, setSelectedSavedView] =
|
|
14759
|
-
const stored = ViewStorage.load(storageKey);
|
|
14822
|
+
const [selectedSavedView, setSelectedSavedView] = useState3(() => {
|
|
14823
|
+
const stored = ViewStorage.load(storageKey, config.defaultView);
|
|
14760
14824
|
return stored ?? config.defaultView;
|
|
14761
14825
|
});
|
|
14762
|
-
const [temporaryView, setTemporaryView] =
|
|
14763
|
-
return ViewStorage.load(temporaryStorageKey);
|
|
14826
|
+
const [temporaryView, setTemporaryView] = useState3(() => {
|
|
14827
|
+
return ViewStorage.load(temporaryStorageKey, config.defaultView);
|
|
14764
14828
|
});
|
|
14765
|
-
const
|
|
14766
|
-
(view) => {
|
|
14767
|
-
if (config.stickyViewsKey) {
|
|
14768
|
-
ViewStorage.save(storageKey, view);
|
|
14769
|
-
}
|
|
14770
|
-
},
|
|
14771
|
-
[config.stickyViewsKey, storageKey]
|
|
14772
|
-
);
|
|
14773
|
-
const updateUrlForView = useCallback2(
|
|
14829
|
+
const persistViewToStorageAndUrl = useCallback2(
|
|
14774
14830
|
(view) => {
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
return getUpdatedSearchParams(currentParams, view);
|
|
14778
|
-
},
|
|
14779
|
-
{ replace: true }
|
|
14780
|
-
);
|
|
14831
|
+
ViewStorage.save(storageKey, view);
|
|
14832
|
+
setViewInUrl(view, setSearchParams);
|
|
14781
14833
|
},
|
|
14782
|
-
[setSearchParams]
|
|
14834
|
+
[storageKey, setSearchParams]
|
|
14783
14835
|
);
|
|
14784
14836
|
const baseViews = savedViews ?? [];
|
|
14785
|
-
const allViews =
|
|
14837
|
+
const allViews = useMemo(
|
|
14838
|
+
() => temporaryView ? [...baseViews, temporaryView] : baseViews,
|
|
14839
|
+
[baseViews, temporaryView]
|
|
14840
|
+
);
|
|
14786
14841
|
const selectView = useCallback2(
|
|
14787
14842
|
(view) => {
|
|
14788
14843
|
const viewToSelect = config.onSelect({ item: view });
|
|
14789
14844
|
setSelectedSavedView(viewToSelect);
|
|
14790
|
-
|
|
14791
|
-
updateUrlForView(viewToSelect);
|
|
14845
|
+
persistViewToStorageAndUrl(viewToSelect);
|
|
14792
14846
|
return viewToSelect;
|
|
14793
14847
|
},
|
|
14794
|
-
[config,
|
|
14848
|
+
[config, persistViewToStorageAndUrl, temporaryView, temporaryStorageKey]
|
|
14795
14849
|
);
|
|
14796
14850
|
const createTemporaryView = useCallback2(
|
|
14797
14851
|
(fetchedView) => {
|
|
14798
14852
|
const tempView = {
|
|
14799
14853
|
...fetchedView,
|
|
14800
14854
|
id: "temporary",
|
|
14801
|
-
name: "
|
|
14855
|
+
name: I18n.t("savedViews.temporaryViewName"),
|
|
14856
|
+
view_level: "temporary"
|
|
14802
14857
|
};
|
|
14803
14858
|
ViewStorage.save(temporaryStorageKey, tempView);
|
|
14804
14859
|
setTemporaryView(tempView);
|
|
@@ -14821,7 +14876,7 @@ var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
|
14821
14876
|
if (isViewAlreadySelected(viewId)) {
|
|
14822
14877
|
return;
|
|
14823
14878
|
}
|
|
14824
|
-
const viewInList = allViews
|
|
14879
|
+
const viewInList = findViewByToken(allViews, viewId);
|
|
14825
14880
|
if (viewInList) {
|
|
14826
14881
|
selectView(viewInList);
|
|
14827
14882
|
} else {
|
|
@@ -14830,36 +14885,27 @@ var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
|
14830
14885
|
},
|
|
14831
14886
|
[isViewAlreadySelected, openSharedViewModal, allViews, selectView]
|
|
14832
14887
|
);
|
|
14833
|
-
|
|
14834
|
-
if (!allViews.length)
|
|
14835
|
-
return;
|
|
14888
|
+
useEffect2(() => {
|
|
14836
14889
|
const savedViewId = searchParams.get("saved-view");
|
|
14890
|
+
restoreUrlParameter(
|
|
14891
|
+
savedViewId,
|
|
14892
|
+
previousSavedViewParamRef.current,
|
|
14893
|
+
setSearchParams
|
|
14894
|
+
);
|
|
14837
14895
|
if (savedViewId) {
|
|
14896
|
+
previousSavedViewParamRef.current = savedViewId;
|
|
14897
|
+
}
|
|
14898
|
+
if (savedViewId && allViews.length > 0) {
|
|
14838
14899
|
handleSavedViewFromUrl(savedViewId);
|
|
14839
14900
|
}
|
|
14840
14901
|
}, [
|
|
14841
|
-
searchParams
|
|
14902
|
+
searchParams,
|
|
14842
14903
|
savedViews,
|
|
14843
14904
|
temporaryView,
|
|
14844
14905
|
handleSavedViewFromUrl,
|
|
14906
|
+
setSearchParams,
|
|
14845
14907
|
allViews.length
|
|
14846
14908
|
]);
|
|
14847
|
-
useEffect3(() => {
|
|
14848
|
-
const currentSavedViewParam = searchParams.get("saved-view");
|
|
14849
|
-
if (previousSavedViewParamRef.current && !currentSavedViewParam) {
|
|
14850
|
-
setSearchParams(
|
|
14851
|
-
(currentParams) => {
|
|
14852
|
-
const updatedParams = new URLSearchParams(currentParams);
|
|
14853
|
-
updatedParams.set("saved-view", previousSavedViewParamRef.current);
|
|
14854
|
-
return updatedParams;
|
|
14855
|
-
},
|
|
14856
|
-
{ replace: true }
|
|
14857
|
-
);
|
|
14858
|
-
}
|
|
14859
|
-
if (currentSavedViewParam) {
|
|
14860
|
-
previousSavedViewParamRef.current = currentSavedViewParam;
|
|
14861
|
-
}
|
|
14862
|
-
}, [searchParams.get("saved-view"), setSearchParams]);
|
|
14863
14909
|
return {
|
|
14864
14910
|
selectedView: selectedSavedView,
|
|
14865
14911
|
selectView,
|
|
@@ -14870,7 +14916,7 @@ var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
|
14870
14916
|
};
|
|
14871
14917
|
};
|
|
14872
14918
|
|
|
14873
|
-
// src/
|
|
14919
|
+
// src/components/saved-views/SavedViews.tsx
|
|
14874
14920
|
var StyledPanel = styled_components_esm_default.div`
|
|
14875
14921
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
14876
14922
|
`;
|
|
@@ -14885,8 +14931,10 @@ var SavedViewsContent = (props) => {
|
|
|
14885
14931
|
};
|
|
14886
14932
|
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14887
14933
|
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14888
|
-
const
|
|
14889
|
-
const
|
|
14934
|
+
const { showToast } = useToastAlertContext3();
|
|
14935
|
+
const i18n = useI18nContext11();
|
|
14936
|
+
const [activeModal, setActiveModal] = useState4(null);
|
|
14937
|
+
const [modalData, setModalData] = useState4(null);
|
|
14890
14938
|
const openModal = (type, data) => {
|
|
14891
14939
|
setActiveModal(type);
|
|
14892
14940
|
setModalData(data ?? null);
|
|
@@ -14909,9 +14957,9 @@ var SavedViewsContent = (props) => {
|
|
|
14909
14957
|
{
|
|
14910
14958
|
domain: props.domain,
|
|
14911
14959
|
tableName: props.tableName,
|
|
14912
|
-
stickyViewsKey: props.stickyViewsKey,
|
|
14913
14960
|
userId: props.userId,
|
|
14914
14961
|
projectId,
|
|
14962
|
+
companyId,
|
|
14915
14963
|
defaultView: props.defaultView,
|
|
14916
14964
|
onSelect: props.onSelect
|
|
14917
14965
|
},
|
|
@@ -14929,8 +14977,9 @@ var SavedViewsContent = (props) => {
|
|
|
14929
14977
|
error: createError,
|
|
14930
14978
|
reset: resetCreateError
|
|
14931
14979
|
} = useCreateSavedView(queryInput);
|
|
14932
|
-
|
|
14980
|
+
useEffect3(() => {
|
|
14933
14981
|
if (fetchError) {
|
|
14982
|
+
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
14934
14983
|
selectView(selectedView ?? props.defaultView);
|
|
14935
14984
|
closeModal();
|
|
14936
14985
|
}
|
|
@@ -14954,6 +15003,7 @@ var SavedViewsContent = (props) => {
|
|
|
14954
15003
|
};
|
|
14955
15004
|
createSavedView(viewToCreate, {
|
|
14956
15005
|
onSuccess: (newView) => {
|
|
15006
|
+
showToast.success(i18n.t("savedViews.create.success"));
|
|
14957
15007
|
selectView(newView);
|
|
14958
15008
|
closeModal();
|
|
14959
15009
|
}
|
|
@@ -14975,7 +15025,6 @@ var SavedViewsContent = (props) => {
|
|
|
14975
15025
|
deleteSelectedView();
|
|
14976
15026
|
closeModal();
|
|
14977
15027
|
};
|
|
14978
|
-
const i18n = useI18nContext11();
|
|
14979
15028
|
return /* @__PURE__ */ React22.createElement(StyledPanel, { provider: props.provider }, /* @__PURE__ */ React22.createElement(
|
|
14980
15029
|
ExpandedPanel,
|
|
14981
15030
|
{
|
|
@@ -15010,7 +15059,7 @@ var SavedViewsContent = (props) => {
|
|
|
15010
15059
|
selectedSavedView: selectedView,
|
|
15011
15060
|
tableConfig: props.tableConfig,
|
|
15012
15061
|
defaultView: props.defaultView,
|
|
15013
|
-
|
|
15062
|
+
presetViews: props.presetViews,
|
|
15014
15063
|
savedViews: allViews,
|
|
15015
15064
|
provider: props.provider,
|
|
15016
15065
|
userId: props.userId,
|
|
@@ -15018,7 +15067,7 @@ var SavedViewsContent = (props) => {
|
|
|
15018
15067
|
}
|
|
15019
15068
|
))
|
|
15020
15069
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ React22.createElement(
|
|
15021
|
-
|
|
15070
|
+
FormModal,
|
|
15022
15071
|
{
|
|
15023
15072
|
open: true,
|
|
15024
15073
|
mode: activeModal,
|
|
@@ -15053,31 +15102,124 @@ var SavedViewsContent = (props) => {
|
|
|
15053
15102
|
));
|
|
15054
15103
|
};
|
|
15055
15104
|
var SavedViews = (props) => {
|
|
15056
|
-
return /* @__PURE__ */ React22.createElement(EnvironmentI18nProvider, null, /* @__PURE__ */ React22.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React22.createElement(SavedViewsContent, { ...props })));
|
|
15105
|
+
return /* @__PURE__ */ React22.createElement(EnvironmentI18nProvider, null, /* @__PURE__ */ React22.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React22.createElement(ToastAlertProvider, null, /* @__PURE__ */ React22.createElement(SavedViewsContent, { ...props }))));
|
|
15057
15106
|
};
|
|
15058
15107
|
|
|
15059
|
-
// src/
|
|
15060
|
-
import {
|
|
15061
|
-
|
|
15062
|
-
|
|
15108
|
+
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15109
|
+
import React23, { useCallback as useCallback4 } from "react";
|
|
15110
|
+
|
|
15111
|
+
// src/components/adapters/smart-grid/SmartGridDefaultSavedView.tsx
|
|
15112
|
+
import { useMemo as useMemo2 } from "react";
|
|
15113
|
+
var DEFAULT_COLUMN_STATE = {
|
|
15114
|
+
hide: false,
|
|
15115
|
+
pinned: null,
|
|
15116
|
+
width: 200,
|
|
15117
|
+
sort: null,
|
|
15118
|
+
sortIndex: null,
|
|
15119
|
+
pivot: false,
|
|
15120
|
+
pivotIndex: null,
|
|
15121
|
+
aggFunc: null,
|
|
15122
|
+
rowGroup: false,
|
|
15123
|
+
rowGroupIndex: null,
|
|
15124
|
+
flex: null
|
|
15125
|
+
};
|
|
15126
|
+
var getColumnStateFromDefs = (columnDefs) => {
|
|
15127
|
+
return columnDefs.map((colDef) => {
|
|
15128
|
+
const field = colDef.field ?? colDef.colId;
|
|
15129
|
+
if (!field)
|
|
15130
|
+
return null;
|
|
15131
|
+
return {
|
|
15132
|
+
colId: field,
|
|
15133
|
+
hide: colDef.hide ?? false,
|
|
15134
|
+
pinned: colDef.pinned ?? null,
|
|
15135
|
+
width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
|
|
15136
|
+
sort: null,
|
|
15137
|
+
sortIndex: null,
|
|
15138
|
+
pivot: false,
|
|
15139
|
+
pivotIndex: null,
|
|
15140
|
+
aggFunc: null,
|
|
15141
|
+
rowGroup: false,
|
|
15142
|
+
rowGroupIndex: null,
|
|
15143
|
+
flex: colDef.flex ?? null
|
|
15144
|
+
};
|
|
15145
|
+
}).filter((col) => col !== null);
|
|
15146
|
+
};
|
|
15147
|
+
var extractDefaultView = (gridApi, receivedConfig) => {
|
|
15148
|
+
const columnDefs = gridApi.getColumnDefs() ?? [];
|
|
15149
|
+
const defaultColumnState = getColumnStateFromDefs(columnDefs);
|
|
15150
|
+
const result = {
|
|
15151
|
+
columnState: receivedConfig?.columnState?.length ? receivedConfig.columnState : defaultColumnState,
|
|
15152
|
+
columnGroupState: receivedConfig?.columnGroupState ?? [],
|
|
15153
|
+
rowGroupState: receivedConfig?.rowGroupState ?? [],
|
|
15154
|
+
filterState: receivedConfig?.filterState ?? {},
|
|
15155
|
+
rowHeight: receivedConfig?.rowHeight ?? gridApi.getSizesForCurrentTheme()?.rowHeight
|
|
15156
|
+
};
|
|
15157
|
+
return result;
|
|
15158
|
+
};
|
|
15159
|
+
var useNormalizedDefaultViews = (defaultViews, gridApi) => {
|
|
15160
|
+
return useMemo2(() => {
|
|
15161
|
+
if (!gridApi)
|
|
15162
|
+
return defaultViews.map((view) => ({ ...view, share_token: view.id }));
|
|
15163
|
+
return defaultViews.map((view) => ({
|
|
15164
|
+
...view,
|
|
15165
|
+
share_token: view.id,
|
|
15166
|
+
table_config: extractDefaultView(gridApi, view.table_config)
|
|
15167
|
+
}));
|
|
15168
|
+
}, [defaultViews, gridApi]);
|
|
15063
15169
|
};
|
|
15170
|
+
|
|
15171
|
+
// src/components/adapters/smart-grid/useSmartGridConfig.ts
|
|
15172
|
+
import { useState as useState5, useEffect as useEffect4 } from "react";
|
|
15173
|
+
var GRID_STATE_EVENTS = [
|
|
15174
|
+
"sortChanged",
|
|
15175
|
+
"filterOpened",
|
|
15176
|
+
"filterChanged",
|
|
15177
|
+
"columnRowGroupChanged",
|
|
15178
|
+
"dragStopped",
|
|
15179
|
+
"columnResized",
|
|
15180
|
+
"columnVisible",
|
|
15181
|
+
"columnPinned",
|
|
15182
|
+
"columnMoved",
|
|
15183
|
+
"modelUpdated",
|
|
15184
|
+
"gridColumnsChanged",
|
|
15185
|
+
"gridReady"
|
|
15186
|
+
];
|
|
15187
|
+
var useSmartGridConfig = (gridApi) => {
|
|
15188
|
+
const [config, setConfig] = useState5(
|
|
15189
|
+
() => getSmartGridConfig(gridApi)
|
|
15190
|
+
);
|
|
15191
|
+
useEffect4(() => {
|
|
15192
|
+
if (!gridApi)
|
|
15193
|
+
return;
|
|
15194
|
+
const updateConfig = () => {
|
|
15195
|
+
setConfig(getSmartGridConfig(gridApi));
|
|
15196
|
+
};
|
|
15197
|
+
GRID_STATE_EVENTS.forEach((event) => {
|
|
15198
|
+
gridApi.addEventListener(event, updateConfig);
|
|
15199
|
+
});
|
|
15200
|
+
return () => {
|
|
15201
|
+
GRID_STATE_EVENTS.forEach((event) => {
|
|
15202
|
+
gridApi.removeEventListener(event, updateConfig);
|
|
15203
|
+
});
|
|
15204
|
+
};
|
|
15205
|
+
}, [gridApi]);
|
|
15206
|
+
return { config, setConfig };
|
|
15207
|
+
};
|
|
15208
|
+
|
|
15209
|
+
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15064
15210
|
var SmartGridSavedViews = (props) => {
|
|
15065
15211
|
const { gridApi, userId, projectId, companyId } = props;
|
|
15066
15212
|
const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
|
|
15067
|
-
const
|
|
15068
|
-
|
|
15069
|
-
domain: props.domain
|
|
15070
|
-
});
|
|
15213
|
+
const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
|
|
15214
|
+
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15071
15215
|
const onSelect = useCallback4(
|
|
15072
15216
|
({ item }) => {
|
|
15073
15217
|
if (!gridApi)
|
|
15074
15218
|
return item;
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
gridApi
|
|
15078
|
-
|
|
15079
|
-
gridApi.setGridOption("rowHeight", props.defaultRowHeight);
|
|
15080
|
-
gridApi.refreshCells();
|
|
15219
|
+
const isPresetView = item.view_level === "default";
|
|
15220
|
+
if (isPresetView) {
|
|
15221
|
+
updateTableConfig(item, gridApi, "smart-grid");
|
|
15222
|
+
setTableConfig(item.table_config);
|
|
15081
15223
|
return item;
|
|
15082
15224
|
}
|
|
15083
15225
|
const updatedView = {
|
|
@@ -15091,22 +15233,9 @@ var SmartGridSavedViews = (props) => {
|
|
|
15091
15233
|
setTableConfig(updatedView.table_config);
|
|
15092
15234
|
return updatedView;
|
|
15093
15235
|
},
|
|
15094
|
-
[
|
|
15095
|
-
gridApi,
|
|
15096
|
-
props.defaultViewFilters,
|
|
15097
|
-
props.defaultRowHeight,
|
|
15098
|
-
tableConfig,
|
|
15099
|
-
setTableConfig
|
|
15100
|
-
]
|
|
15101
|
-
);
|
|
15102
|
-
const stickyViewsKey = generateStickyViewsKey(
|
|
15103
|
-
props.domain,
|
|
15104
|
-
props.tableName,
|
|
15105
|
-
userId,
|
|
15106
|
-
projectId,
|
|
15107
|
-
companyId
|
|
15236
|
+
[gridApi, tableConfig, setTableConfig]
|
|
15108
15237
|
);
|
|
15109
|
-
return /* @__PURE__ */ React23.createElement(
|
|
15238
|
+
return /* @__PURE__ */ React23.createElement(
|
|
15110
15239
|
SavedViews,
|
|
15111
15240
|
{
|
|
15112
15241
|
onSelect,
|
|
@@ -15116,14 +15245,14 @@ var SmartGridSavedViews = (props) => {
|
|
|
15116
15245
|
companyId,
|
|
15117
15246
|
provider: "smart-grid",
|
|
15118
15247
|
defaultView,
|
|
15248
|
+
presetViews,
|
|
15119
15249
|
tableName: props.tableName,
|
|
15120
|
-
tableConfig
|
|
15121
|
-
stickyViewsKey
|
|
15250
|
+
tableConfig
|
|
15122
15251
|
}
|
|
15123
|
-
)
|
|
15252
|
+
);
|
|
15124
15253
|
};
|
|
15125
15254
|
|
|
15126
|
-
// src/
|
|
15255
|
+
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
15127
15256
|
import React24, {
|
|
15128
15257
|
forwardRef as forwardRef11,
|
|
15129
15258
|
useImperativeHandle,
|
|
@@ -15131,10 +15260,9 @@ import React24, {
|
|
|
15131
15260
|
useCallback as useCallback5
|
|
15132
15261
|
} from "react";
|
|
15133
15262
|
|
|
15134
|
-
// src/
|
|
15135
|
-
import { useMemo } from "react";
|
|
15136
|
-
|
|
15137
|
-
var DEFAULT_COLUMN_STATE = {
|
|
15263
|
+
// src/components/adapters/data-table/DataTableDefaultSavedView.tsx
|
|
15264
|
+
import { useMemo as useMemo3 } from "react";
|
|
15265
|
+
var DEFAULT_COLUMN_STATE2 = {
|
|
15138
15266
|
hidden: false,
|
|
15139
15267
|
pinned: null,
|
|
15140
15268
|
width: 200,
|
|
@@ -15149,7 +15277,7 @@ var getColumnState = (columnDefinitions) => {
|
|
|
15149
15277
|
if (column.field.includes("custom_field")) {
|
|
15150
15278
|
return {
|
|
15151
15279
|
field: column.field,
|
|
15152
|
-
...
|
|
15280
|
+
...DEFAULT_COLUMN_STATE2
|
|
15153
15281
|
};
|
|
15154
15282
|
}
|
|
15155
15283
|
return {
|
|
@@ -15160,11 +15288,11 @@ var getColumnState = (columnDefinitions) => {
|
|
|
15160
15288
|
rowGroupIndex: null,
|
|
15161
15289
|
sort: null,
|
|
15162
15290
|
sortIndex: null,
|
|
15163
|
-
width: (column.minWidth ??
|
|
15291
|
+
width: (column.minWidth ?? DEFAULT_COLUMN_STATE2.width) > DEFAULT_COLUMN_STATE2.width ? column.minWidth ?? DEFAULT_COLUMN_STATE2.width : (column.maxWidth ?? DEFAULT_COLUMN_STATE2.width) < DEFAULT_COLUMN_STATE2.width ? column.maxWidth ?? DEFAULT_COLUMN_STATE2.width : DEFAULT_COLUMN_STATE2.width
|
|
15164
15292
|
};
|
|
15165
15293
|
});
|
|
15166
15294
|
};
|
|
15167
|
-
var
|
|
15295
|
+
var extractDefaultView2 = (columnDefinitions, receivedConfigFromTool) => {
|
|
15168
15296
|
const defaultColumnState = getColumnState(columnDefinitions);
|
|
15169
15297
|
const result = {
|
|
15170
15298
|
columnState: receivedConfigFromTool?.columnState?.length ? receivedConfigFromTool.columnState : defaultColumnState,
|
|
@@ -15179,52 +15307,37 @@ var extractDefaultView = (columnDefinitions, receivedConfigFromTool) => {
|
|
|
15179
15307
|
};
|
|
15180
15308
|
return result;
|
|
15181
15309
|
};
|
|
15182
|
-
var
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
|
|
15187
|
-
|
|
15188
|
-
}
|
|
15189
|
-
|
|
15190
|
-
const name = useDefaultViewName2(props.domain, props.defaultViewName);
|
|
15191
|
-
const extractedDefaultConfig = useMemo(
|
|
15192
|
-
() => extractDefaultView(props.columnDefinitions, props.receivedConfigFromTool),
|
|
15193
|
-
[props.columnDefinitions, props.receivedConfigFromTool]
|
|
15310
|
+
var useNormalizedDefaultViews2 = (defaultViews, columnDefinitions) => {
|
|
15311
|
+
return useMemo3(
|
|
15312
|
+
() => defaultViews.map((view) => ({
|
|
15313
|
+
...view,
|
|
15314
|
+
share_token: "",
|
|
15315
|
+
table_config: extractDefaultView2(columnDefinitions, view.table_config)
|
|
15316
|
+
})),
|
|
15317
|
+
[defaultViews, columnDefinitions]
|
|
15194
15318
|
);
|
|
15195
|
-
return {
|
|
15196
|
-
id: "default",
|
|
15197
|
-
view_level: "default",
|
|
15198
|
-
name,
|
|
15199
|
-
table_config: extractedDefaultConfig
|
|
15200
|
-
};
|
|
15201
15319
|
};
|
|
15202
15320
|
|
|
15203
|
-
// src/
|
|
15204
|
-
import { ToastAlertProvider as ToastAlertProvider2 } from "@procore/toast-alert";
|
|
15205
|
-
var generateStickyViewsKey2 = (domain, tableName, userId, projectId, companyId) => {
|
|
15206
|
-
return `savedView-${domain}-${tableName}-${companyId}-${projectId}-${userId}`;
|
|
15207
|
-
};
|
|
15321
|
+
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
15208
15322
|
var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
15209
15323
|
const { tableApi, userId, projectId, companyId } = props;
|
|
15324
|
+
const presetViews = useNormalizedDefaultViews2(
|
|
15325
|
+
props.defaultViews,
|
|
15326
|
+
props.columnDefinitions
|
|
15327
|
+
);
|
|
15328
|
+
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15210
15329
|
const [internalTableConfig, setInternalTableConfig] = useState6(
|
|
15211
|
-
props.
|
|
15330
|
+
ViewStorage.load(props.stickyViewsKey, defaultView)?.table_config ?? defaultView.table_config
|
|
15212
15331
|
);
|
|
15213
15332
|
useImperativeHandle(ref, () => ({
|
|
15214
15333
|
setTableConfig: (newConfig) => {
|
|
15215
15334
|
setInternalTableConfig(newConfig);
|
|
15216
15335
|
}
|
|
15217
15336
|
}));
|
|
15218
|
-
const defaultView = useDefaultView2({
|
|
15219
|
-
defaultViewName: props.defaultViewName,
|
|
15220
|
-
receivedConfigFromTool: props.defaultViewConfig,
|
|
15221
|
-
domain: props.domain,
|
|
15222
|
-
columnDefinitions: props.columnDefinitions
|
|
15223
|
-
});
|
|
15224
15337
|
const onSelect = useCallback5(
|
|
15225
15338
|
({ item }) => {
|
|
15226
|
-
const
|
|
15227
|
-
const updatedView =
|
|
15339
|
+
const isPresetView = item.view_level === "default";
|
|
15340
|
+
const updatedView = isPresetView ? item : {
|
|
15228
15341
|
...item,
|
|
15229
15342
|
table_config: customAndConfigSync(
|
|
15230
15343
|
item.table_config,
|
|
@@ -15240,14 +15353,7 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
15240
15353
|
if (!internalTableConfig) {
|
|
15241
15354
|
return null;
|
|
15242
15355
|
}
|
|
15243
|
-
|
|
15244
|
-
props.domain,
|
|
15245
|
-
props.tableName,
|
|
15246
|
-
userId,
|
|
15247
|
-
projectId,
|
|
15248
|
-
companyId
|
|
15249
|
-
);
|
|
15250
|
-
return /* @__PURE__ */ React24.createElement(ToastAlertProvider2, null, /* @__PURE__ */ React24.createElement(
|
|
15356
|
+
return /* @__PURE__ */ React24.createElement(
|
|
15251
15357
|
SavedViews,
|
|
15252
15358
|
{
|
|
15253
15359
|
onSelect,
|
|
@@ -15257,20 +15363,21 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
15257
15363
|
companyId,
|
|
15258
15364
|
provider: "data-table",
|
|
15259
15365
|
defaultView,
|
|
15366
|
+
presetViews,
|
|
15260
15367
|
tableName: props.tableName,
|
|
15261
|
-
tableConfig: internalTableConfig
|
|
15262
|
-
stickyViewsKey
|
|
15368
|
+
tableConfig: internalTableConfig
|
|
15263
15369
|
}
|
|
15264
|
-
)
|
|
15370
|
+
);
|
|
15265
15371
|
});
|
|
15266
15372
|
DataTableSavedViews.displayName = "DataTableSavedViews";
|
|
15267
15373
|
export {
|
|
15268
15374
|
DataTableSavedViews,
|
|
15269
15375
|
ExpandedPanel,
|
|
15376
|
+
FormModal,
|
|
15270
15377
|
PanelContent,
|
|
15271
15378
|
SavedViewCollectionMenuItem,
|
|
15379
|
+
SavedViews,
|
|
15272
15380
|
SavedViewsDeleteConfirmationModalShared,
|
|
15273
|
-
SavedViewsFormModal,
|
|
15274
15381
|
SmartGridSavedViews,
|
|
15275
15382
|
getTranslations,
|
|
15276
15383
|
useSavedViewsPanel_default as useSavedViewsPanel
|