@procore/saved-views 5.1.0-alpha.3 → 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 +439 -312
- package/dist/legacy/index.mjs +419 -295
- package/dist/modern/index.d.mts +61 -40
- package/dist/modern/index.d.ts +61 -40
- package/dist/modern/index.js +437 -310
- package/dist/modern/index.mjs +417 -293
- package/package.json +1 -1
package/dist/legacy/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) => {
|
|
@@ -11283,7 +11376,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11283
11376
|
},
|
|
11284
11377
|
props.item.name
|
|
11285
11378
|
),
|
|
11286
|
-
/* @__PURE__ */ React15.createElement(RowActionsBox, null, /* @__PURE__ */ React15.createElement(Box, { justifyContent: "space-between" }, props.item.
|
|
11379
|
+
/* @__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(
|
|
11287
11380
|
Button2,
|
|
11288
11381
|
{
|
|
11289
11382
|
onClick: updateItem,
|
|
@@ -11294,7 +11387,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11294
11387
|
loading: props.isUpdateProcessing
|
|
11295
11388
|
},
|
|
11296
11389
|
i18n.t("savedViews.actions.update")
|
|
11297
|
-
)), props.item.
|
|
11390
|
+
)), props.item.view_level !== "default" && props.selected && !props.canUpdate && props.item.id !== "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
|
|
11298
11391
|
Button2,
|
|
11299
11392
|
{
|
|
11300
11393
|
onClick: copyShareLink,
|
|
@@ -11303,7 +11396,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11303
11396
|
"aria-label": i18n.t("savedViews.actions.copyShareLink"),
|
|
11304
11397
|
"data-testid": "copy-share-link-button"
|
|
11305
11398
|
},
|
|
11306
|
-
/* @__PURE__ */ React15.createElement(Link_default, { size: "sm" })
|
|
11399
|
+
/* @__PURE__ */ React15.createElement(IconWrapper, null, /* @__PURE__ */ React15.createElement(Link_default, { size: "sm" }))
|
|
11307
11400
|
)), props.item.id === "temporary" && /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(
|
|
11308
11401
|
Button2,
|
|
11309
11402
|
{
|
|
@@ -11318,8 +11411,8 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11318
11411
|
title: i18n.t("savedViews.actions.clearTemporary"),
|
|
11319
11412
|
"data-testid": "clear-temporary-view-button"
|
|
11320
11413
|
},
|
|
11321
|
-
/* @__PURE__ */ React15.createElement(Clear_default, { size: "sm" })
|
|
11322
|
-
))), /* @__PURE__ */ React15.createElement(Box, null, props.item.
|
|
11414
|
+
/* @__PURE__ */ React15.createElement(IconWrapper, null, /* @__PURE__ */ React15.createElement(Clear_default, { size: "sm" }))
|
|
11415
|
+
))), /* @__PURE__ */ React15.createElement(Box, null, props.item.view_level !== "default" && props.canEditOrDelete && /* @__PURE__ */ React15.createElement("div", { onClick: (e2) => e2.stopPropagation() }, /* @__PURE__ */ React15.createElement(
|
|
11323
11416
|
DropdownFlyout,
|
|
11324
11417
|
{
|
|
11325
11418
|
"data-testid": "saved-view-overflow-button",
|
|
@@ -11334,7 +11427,7 @@ var SavedViewCollectionMenuItem = (props) => {
|
|
|
11334
11427
|
);
|
|
11335
11428
|
};
|
|
11336
11429
|
|
|
11337
|
-
// src/
|
|
11430
|
+
// src/components/panels/ExpandedPanel.tsx
|
|
11338
11431
|
import { Panel } from "@procore/core-react";
|
|
11339
11432
|
var ExpandedPanel = styled_components_esm_default(Panel)`
|
|
11340
11433
|
width: ${({ provider }) => provider === "data-table" ? "316px" : "100%"};
|
|
@@ -11342,15 +11435,8 @@ var ExpandedPanel = styled_components_esm_default(Panel)`
|
|
|
11342
11435
|
border-radius: 4px 0 0 4px;
|
|
11343
11436
|
`;
|
|
11344
11437
|
|
|
11345
|
-
// src/
|
|
11346
|
-
import {
|
|
11347
|
-
colors as colors2,
|
|
11348
|
-
DetailPage,
|
|
11349
|
-
Flex as Flex3,
|
|
11350
|
-
UNSAFE_Menu as MenuImperative,
|
|
11351
|
-
spacing as spacing2,
|
|
11352
|
-
useI18nContext as useI18nContext5
|
|
11353
|
-
} from "@procore/core-react";
|
|
11438
|
+
// src/components/panels/PanelContent.tsx
|
|
11439
|
+
import { Flex as Flex3, useI18nContext as useI18nContext5 } from "@procore/core-react";
|
|
11354
11440
|
import { useToastAlertContext as useToastAlertContext2 } from "@procore/toast-alert";
|
|
11355
11441
|
import React17 from "react";
|
|
11356
11442
|
|
|
@@ -11396,10 +11482,10 @@ function requestJSON(url, requestParams = {}) {
|
|
|
11396
11482
|
);
|
|
11397
11483
|
}
|
|
11398
11484
|
|
|
11399
|
-
// src/utils/
|
|
11485
|
+
// src/utils/api/queries.ts
|
|
11400
11486
|
import { useQuery } from "@tanstack/react-query";
|
|
11401
11487
|
|
|
11402
|
-
// src/utils/
|
|
11488
|
+
// src/utils/api/queriesHandler.ts
|
|
11403
11489
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
11404
11490
|
import { useI18nContext as useI18nContext3 } from "@procore/core-react";
|
|
11405
11491
|
var useApiRequest = (props, method, mutationKey) => {
|
|
@@ -11464,10 +11550,10 @@ var useApiRequest = (props, method, mutationKey) => {
|
|
|
11464
11550
|
});
|
|
11465
11551
|
};
|
|
11466
11552
|
|
|
11467
|
-
// src/utils/
|
|
11553
|
+
// src/utils/constants/viewLevels.ts
|
|
11468
11554
|
var VIEW_LEVELS = ["company", "project", "personal"];
|
|
11469
11555
|
|
|
11470
|
-
// src/utils/
|
|
11556
|
+
// src/utils/api/queries.ts
|
|
11471
11557
|
var PAGE_SIZE = 50 * VIEW_LEVELS.length;
|
|
11472
11558
|
var useSavedViewsQuery = (props) => {
|
|
11473
11559
|
const { projectId, companyId, domain, tableName } = props;
|
|
@@ -11520,24 +11606,23 @@ var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
|
|
|
11520
11606
|
});
|
|
11521
11607
|
};
|
|
11522
11608
|
|
|
11523
|
-
// src/
|
|
11609
|
+
// src/components/panels/PanelContentUtils.ts
|
|
11524
11610
|
var import_lodash = __toESM(require_lodash());
|
|
11525
11611
|
|
|
11526
|
-
// src/
|
|
11612
|
+
// src/components/adapters/smart-grid/SmartGridUtils.ts
|
|
11527
11613
|
function getSmartGridConfig(api) {
|
|
11528
|
-
const
|
|
11529
|
-
const
|
|
11530
|
-
const
|
|
11531
|
-
const
|
|
11532
|
-
const
|
|
11533
|
-
|
|
11534
|
-
columnState
|
|
11535
|
-
rowHeight
|
|
11536
|
-
columnGroupState
|
|
11537
|
-
rowGroupState
|
|
11538
|
-
filterState
|
|
11614
|
+
const columnState = api.getColumnState();
|
|
11615
|
+
const columnGroupState = api.getColumnGroupState();
|
|
11616
|
+
const rowGroupState = api.getRowGroupColumns().map((col) => col.getColId());
|
|
11617
|
+
const rowHeight = api.getGridOption("rowHeight") ?? api.getSizesForCurrentTheme().rowHeight;
|
|
11618
|
+
const filterState = api.getFilterModel();
|
|
11619
|
+
return {
|
|
11620
|
+
columnState,
|
|
11621
|
+
rowHeight,
|
|
11622
|
+
columnGroupState,
|
|
11623
|
+
rowGroupState,
|
|
11624
|
+
filterState
|
|
11539
11625
|
};
|
|
11540
|
-
return smartGridConfig;
|
|
11541
11626
|
}
|
|
11542
11627
|
function setSmartGridConfig(api, config) {
|
|
11543
11628
|
api.applyColumnState({
|
|
@@ -11552,7 +11637,7 @@ function setSmartGridConfig(api, config) {
|
|
|
11552
11637
|
}
|
|
11553
11638
|
}
|
|
11554
11639
|
|
|
11555
|
-
// src/
|
|
11640
|
+
// src/components/saved-views/SavedViewsUtils.ts
|
|
11556
11641
|
var customAndConfigSync = (viewTableConfig, defaultTableConfig) => {
|
|
11557
11642
|
if (!viewTableConfig && !defaultTableConfig)
|
|
11558
11643
|
return void 0;
|
|
@@ -11611,7 +11696,7 @@ var updateTableConfig = (view, tableApi, provider) => {
|
|
|
11611
11696
|
}
|
|
11612
11697
|
};
|
|
11613
11698
|
|
|
11614
|
-
// src/
|
|
11699
|
+
// src/components/panels/PanelContentUtils.ts
|
|
11615
11700
|
var getOrderedVisibleColumns = (columns, idKey) => {
|
|
11616
11701
|
if (!columns)
|
|
11617
11702
|
return [];
|
|
@@ -11706,7 +11791,7 @@ var hasPermissionForViewLevel = (viewLevel, permissions) => {
|
|
|
11706
11791
|
}
|
|
11707
11792
|
};
|
|
11708
11793
|
|
|
11709
|
-
// src/
|
|
11794
|
+
// src/components/panels/useGroups.ts
|
|
11710
11795
|
import { useState as useState2 } from "react";
|
|
11711
11796
|
var useGroups = () => {
|
|
11712
11797
|
const [groups, setGroups] = useState2(
|
|
@@ -11718,7 +11803,7 @@ var useGroups = () => {
|
|
|
11718
11803
|
return { groups, toggleGroup };
|
|
11719
11804
|
};
|
|
11720
11805
|
|
|
11721
|
-
// src/
|
|
11806
|
+
// src/components/panels/ViewLevelHeader.tsx
|
|
11722
11807
|
import {
|
|
11723
11808
|
colors,
|
|
11724
11809
|
Flex as Flex2,
|
|
@@ -11761,7 +11846,7 @@ var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
|
|
|
11761
11846
|
};
|
|
11762
11847
|
var ViewLevelHeader_default = ViewLevelHeader;
|
|
11763
11848
|
|
|
11764
|
-
// src/utils/
|
|
11849
|
+
// src/utils/hooks/useScrollToRef.ts
|
|
11765
11850
|
import { useEffect, useRef } from "react";
|
|
11766
11851
|
var useScrollToRef = (dependency) => {
|
|
11767
11852
|
const ref = useRef(null);
|
|
@@ -11773,7 +11858,13 @@ var useScrollToRef = (dependency) => {
|
|
|
11773
11858
|
return ref;
|
|
11774
11859
|
};
|
|
11775
11860
|
|
|
11776
|
-
// src/
|
|
11861
|
+
// src/components/panels/PanelContent.styles.ts
|
|
11862
|
+
import {
|
|
11863
|
+
colors as colors2,
|
|
11864
|
+
DetailPage,
|
|
11865
|
+
UNSAFE_Menu as MenuImperative,
|
|
11866
|
+
spacing as spacing2
|
|
11867
|
+
} from "@procore/core-react";
|
|
11777
11868
|
var Row = styled_components_esm_default(MenuImperative.Item)`
|
|
11778
11869
|
width: 100%;
|
|
11779
11870
|
padding-left: 35px;
|
|
@@ -11790,12 +11881,15 @@ var Panel2 = styled_components_esm_default(DetailPage.Card)`
|
|
|
11790
11881
|
padding-top: ${spacing2.sm}px;
|
|
11791
11882
|
box-shadow: none;
|
|
11792
11883
|
`;
|
|
11884
|
+
|
|
11885
|
+
// src/components/panels/PanelContent.tsx
|
|
11793
11886
|
var PanelContent = (props) => {
|
|
11794
|
-
|
|
11887
|
+
const { queryInput, selectedSavedView, tableConfig } = props;
|
|
11795
11888
|
const { showToast } = useToastAlertContext2();
|
|
11796
11889
|
const I18n = useI18nContext5();
|
|
11797
|
-
const {
|
|
11798
|
-
const {
|
|
11890
|
+
const { data: savedViewsFromQuery, error: savedViewsError } = useSavedViewsQuery(props.queryInput);
|
|
11891
|
+
const { mutate: updateSavedView, isPending: isUpdateLoading } = useUpdateSavedView(queryInput);
|
|
11892
|
+
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
11799
11893
|
const errorToastRef = React17.useRef(null);
|
|
11800
11894
|
React17.useEffect(() => {
|
|
11801
11895
|
if (savedViewsError && savedViewsError !== errorToastRef.current) {
|
|
@@ -11804,12 +11898,16 @@ var PanelContent = (props) => {
|
|
|
11804
11898
|
}
|
|
11805
11899
|
}, [savedViewsError, showToast, I18n]);
|
|
11806
11900
|
const { data: permissions } = useSavedViewsPermissions(props.queryInput);
|
|
11807
|
-
const selectedRowRef = useScrollToRef(
|
|
11901
|
+
const selectedRowRef = useScrollToRef(savedViews);
|
|
11902
|
+
const { groups, toggleGroup } = useGroups();
|
|
11903
|
+
const isTemporarySelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === "temporary";
|
|
11904
|
+
const temporaryView = savedViews == null ? void 0 : savedViews.find((view) => view.id === "temporary");
|
|
11905
|
+
const presetViews = props.presetViews || [props.defaultView];
|
|
11808
11906
|
const onUpdate = (data) => {
|
|
11809
11907
|
const newSavedView = {
|
|
11810
11908
|
...data,
|
|
11811
|
-
...
|
|
11812
|
-
table_config:
|
|
11909
|
+
...selectedSavedView,
|
|
11910
|
+
table_config: tableConfig
|
|
11813
11911
|
};
|
|
11814
11912
|
updateSavedView(newSavedView, {
|
|
11815
11913
|
onSuccess: () => {
|
|
@@ -11821,12 +11919,6 @@ var PanelContent = (props) => {
|
|
|
11821
11919
|
}
|
|
11822
11920
|
});
|
|
11823
11921
|
};
|
|
11824
|
-
const { groups, toggleGroup } = useGroups();
|
|
11825
|
-
const isDefaultSelected = ((_a = props.selectedSavedView) == null ? void 0 : _a.id) === "default";
|
|
11826
|
-
const isTemporarySelected = ((_b = props.selectedSavedView) == null ? void 0 : _b.id) === "temporary";
|
|
11827
|
-
const temporaryView = (_c = props.savedViews) == null ? void 0 : _c.find(
|
|
11828
|
-
(view) => view.id === "temporary"
|
|
11829
|
-
);
|
|
11830
11922
|
return /* @__PURE__ */ React17.createElement(Panel2, { "data-testid": "inner-panel" }, /* @__PURE__ */ React17.createElement(Flex3, { direction: "column", style: { height: "100%", width: "100%" } }, temporaryView && /* @__PURE__ */ React17.createElement(
|
|
11831
11923
|
Row,
|
|
11832
11924
|
{
|
|
@@ -11842,23 +11934,27 @@ var PanelContent = (props) => {
|
|
|
11842
11934
|
onClearTemporary: props.onClearTemporary
|
|
11843
11935
|
}
|
|
11844
11936
|
)
|
|
11845
|
-
),
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
onClick: () => props.onSelect({ item: props.defaultView }),
|
|
11850
|
-
ref: isDefaultSelected ? selectedRowRef : null
|
|
11851
|
-
},
|
|
11852
|
-
/* @__PURE__ */ React17.createElement(
|
|
11853
|
-
SavedViewCollectionMenuItem,
|
|
11937
|
+
), presetViews.map((presetView) => {
|
|
11938
|
+
const isSelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === presetView.id;
|
|
11939
|
+
return /* @__PURE__ */ React17.createElement(
|
|
11940
|
+
Row,
|
|
11854
11941
|
{
|
|
11855
|
-
|
|
11856
|
-
selected:
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11942
|
+
key: presetView.id,
|
|
11943
|
+
selected: isSelected,
|
|
11944
|
+
onClick: () => props.onSelect({ item: presetView }),
|
|
11945
|
+
ref: isSelected ? selectedRowRef : null
|
|
11946
|
+
},
|
|
11947
|
+
/* @__PURE__ */ React17.createElement(
|
|
11948
|
+
SavedViewCollectionMenuItem,
|
|
11949
|
+
{
|
|
11950
|
+
item: presetView,
|
|
11951
|
+
selected: isSelected
|
|
11952
|
+
}
|
|
11953
|
+
)
|
|
11954
|
+
);
|
|
11955
|
+
}), VIEW_LEVELS.map((level) => {
|
|
11860
11956
|
const isExpanded = groups[level];
|
|
11861
|
-
const views = isExpanded &&
|
|
11957
|
+
const views = isExpanded && savedViews ? savedViews.filter(
|
|
11862
11958
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
11863
11959
|
) : [];
|
|
11864
11960
|
return /* @__PURE__ */ React17.createElement(React17.Fragment, { key: level }, /* @__PURE__ */ React17.createElement(
|
|
@@ -11869,11 +11965,10 @@ var PanelContent = (props) => {
|
|
|
11869
11965
|
expanded: isExpanded
|
|
11870
11966
|
}
|
|
11871
11967
|
), views.map((view) => {
|
|
11872
|
-
|
|
11873
|
-
const isSelected = ((_a2 = props.selectedSavedView) == null ? void 0 : _a2.id) === view.id;
|
|
11968
|
+
const isSelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === view.id;
|
|
11874
11969
|
const canUpdate = isSelected && hasPermissionForViewLevel(view.view_level, permissions) && !isEqual(
|
|
11875
11970
|
view.table_config,
|
|
11876
|
-
|
|
11971
|
+
tableConfig,
|
|
11877
11972
|
props.defaultView.table_config,
|
|
11878
11973
|
props.provider
|
|
11879
11974
|
);
|
|
@@ -11909,67 +12004,7 @@ var PanelContent = (props) => {
|
|
|
11909
12004
|
})));
|
|
11910
12005
|
};
|
|
11911
12006
|
|
|
11912
|
-
// src/
|
|
11913
|
-
import React23, { useCallback as useCallback4 } from "react";
|
|
11914
|
-
|
|
11915
|
-
// src/SavedViews/components/SavedViews/SmartGrid/SmartGridDefaultSavedView.tsx
|
|
11916
|
-
import { useI18nContext as useI18nContext6 } from "@procore/core-react";
|
|
11917
|
-
var useDefaultViewName = (domain, defaultViewName) => {
|
|
11918
|
-
const i18n = useI18nContext6();
|
|
11919
|
-
return defaultViewName || i18n.t(domain, {
|
|
11920
|
-
scope: "savedViews.defaultViewTitle",
|
|
11921
|
-
defaultValue: "Default View"
|
|
11922
|
-
});
|
|
11923
|
-
};
|
|
11924
|
-
var useDefaultView = (props) => {
|
|
11925
|
-
const name = useDefaultViewName(props.domain, props.defaultViewName);
|
|
11926
|
-
return {
|
|
11927
|
-
id: "default",
|
|
11928
|
-
view_level: "default",
|
|
11929
|
-
name,
|
|
11930
|
-
table_config: {}
|
|
11931
|
-
};
|
|
11932
|
-
};
|
|
11933
|
-
|
|
11934
|
-
// src/SavedViews/components/SavedViews/SmartGrid/useSmartGridConfig.ts
|
|
11935
|
-
import { useState as useState3, useEffect as useEffect2 } from "react";
|
|
11936
|
-
var GRID_STATE_EVENTS = [
|
|
11937
|
-
"sortChanged",
|
|
11938
|
-
"filterOpened",
|
|
11939
|
-
"filterChanged",
|
|
11940
|
-
"columnRowGroupChanged",
|
|
11941
|
-
"dragStopped",
|
|
11942
|
-
"columnResized",
|
|
11943
|
-
"columnVisible",
|
|
11944
|
-
"columnPinned",
|
|
11945
|
-
"columnMoved",
|
|
11946
|
-
"modelUpdated",
|
|
11947
|
-
"gridColumnsChanged",
|
|
11948
|
-
"gridReady"
|
|
11949
|
-
];
|
|
11950
|
-
var useSmartGridConfig = (gridApi) => {
|
|
11951
|
-
const [config, setConfig] = useState3(
|
|
11952
|
-
() => getSmartGridConfig(gridApi)
|
|
11953
|
-
);
|
|
11954
|
-
useEffect2(() => {
|
|
11955
|
-
if (!gridApi)
|
|
11956
|
-
return;
|
|
11957
|
-
const updateConfig = () => {
|
|
11958
|
-
setConfig(getSmartGridConfig(gridApi));
|
|
11959
|
-
};
|
|
11960
|
-
GRID_STATE_EVENTS.forEach((event) => {
|
|
11961
|
-
gridApi.addEventListener(event, updateConfig);
|
|
11962
|
-
});
|
|
11963
|
-
return () => {
|
|
11964
|
-
GRID_STATE_EVENTS.forEach((event) => {
|
|
11965
|
-
gridApi.removeEventListener(event, updateConfig);
|
|
11966
|
-
});
|
|
11967
|
-
};
|
|
11968
|
-
}, [gridApi]);
|
|
11969
|
-
return { config, setConfig };
|
|
11970
|
-
};
|
|
11971
|
-
|
|
11972
|
-
// src/SavedViews/components/SavedViews/SavedViews.tsx
|
|
12007
|
+
// src/components/saved-views/SavedViews.tsx
|
|
11973
12008
|
import {
|
|
11974
12009
|
Box as Box2,
|
|
11975
12010
|
Button as Button6,
|
|
@@ -11978,16 +12013,17 @@ import {
|
|
|
11978
12013
|
Tooltip,
|
|
11979
12014
|
useI18nContext as useI18nContext11
|
|
11980
12015
|
} from "@procore/core-react";
|
|
11981
|
-
import React22, { useState as
|
|
12016
|
+
import React22, { useState as useState4, useEffect as useEffect3, useCallback as useCallback3 } from "react";
|
|
11982
12017
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
12018
|
+
import { useToastAlertContext as useToastAlertContext3 } from "@procore/toast-alert";
|
|
11983
12019
|
|
|
11984
|
-
// src/
|
|
12020
|
+
// src/components/modals/DeleteConfirmationModal.tsx
|
|
11985
12021
|
import {
|
|
11986
12022
|
Button as Button3,
|
|
11987
12023
|
ConfirmModal,
|
|
11988
12024
|
Modal,
|
|
11989
12025
|
P as P2,
|
|
11990
|
-
useI18nContext as
|
|
12026
|
+
useI18nContext as useI18nContext6
|
|
11991
12027
|
} from "@procore/core-react";
|
|
11992
12028
|
import React18 from "react";
|
|
11993
12029
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
@@ -11995,7 +12031,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11995
12031
|
onDelete,
|
|
11996
12032
|
open
|
|
11997
12033
|
}) => {
|
|
11998
|
-
const i18n =
|
|
12034
|
+
const i18n = useI18nContext6();
|
|
11999
12035
|
return /* @__PURE__ */ React18.createElement(
|
|
12000
12036
|
ConfirmModal,
|
|
12001
12037
|
{
|
|
@@ -12011,10 +12047,10 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
12011
12047
|
);
|
|
12012
12048
|
};
|
|
12013
12049
|
|
|
12014
|
-
// src/
|
|
12050
|
+
// src/components/modals/form-modal/FormModal.tsx
|
|
12015
12051
|
import React20 from "react";
|
|
12016
12052
|
|
|
12017
|
-
// src/
|
|
12053
|
+
// src/components/modals/form-modal/FormModalBase.tsx
|
|
12018
12054
|
import {
|
|
12019
12055
|
Banner,
|
|
12020
12056
|
Button as Button4,
|
|
@@ -12026,7 +12062,7 @@ import {
|
|
|
12026
12062
|
Modal as Modal2,
|
|
12027
12063
|
spacing as spacing3,
|
|
12028
12064
|
Typography as Typography2,
|
|
12029
|
-
useI18nContext as
|
|
12065
|
+
useI18nContext as useI18nContext7
|
|
12030
12066
|
} from "@procore/core-react";
|
|
12031
12067
|
import * as React19 from "react";
|
|
12032
12068
|
|
|
@@ -14322,7 +14358,7 @@ var TupleSchema = class extends Schema {
|
|
|
14322
14358
|
};
|
|
14323
14359
|
create$1.prototype = TupleSchema.prototype;
|
|
14324
14360
|
|
|
14325
|
-
// src/
|
|
14361
|
+
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
14326
14362
|
var getViewLevelOptions = (permissions, i18n) => {
|
|
14327
14363
|
const options = ["personal"];
|
|
14328
14364
|
if (permissions == null ? void 0 : permissions.can_create_project_saved_views)
|
|
@@ -14355,11 +14391,11 @@ function extractMessage(error, I18n) {
|
|
|
14355
14391
|
return { form: I18n.t("savedViews.modal.errors.unknown") };
|
|
14356
14392
|
}
|
|
14357
14393
|
|
|
14358
|
-
// src/
|
|
14394
|
+
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14359
14395
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14360
14396
|
overflow: auto;
|
|
14361
14397
|
`;
|
|
14362
|
-
var
|
|
14398
|
+
var FormModalBase = ({
|
|
14363
14399
|
open,
|
|
14364
14400
|
mode,
|
|
14365
14401
|
onCancel,
|
|
@@ -14374,7 +14410,7 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14374
14410
|
setOpenEditCreateModal,
|
|
14375
14411
|
onSelect
|
|
14376
14412
|
}) => {
|
|
14377
|
-
const I18n =
|
|
14413
|
+
const I18n = useI18nContext7();
|
|
14378
14414
|
const NAME_MAX_LENGTH = 150;
|
|
14379
14415
|
const {
|
|
14380
14416
|
mutate: createSavedView,
|
|
@@ -14529,9 +14565,9 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14529
14565
|
);
|
|
14530
14566
|
};
|
|
14531
14567
|
|
|
14532
|
-
// src/
|
|
14533
|
-
import { useI18nContext as
|
|
14534
|
-
var
|
|
14568
|
+
// src/components/modals/form-modal/FormModal.tsx
|
|
14569
|
+
import { useI18nContext as useI18nContext8 } from "@procore/core-react";
|
|
14570
|
+
var FormModal = ({
|
|
14535
14571
|
open,
|
|
14536
14572
|
mode,
|
|
14537
14573
|
onCancel,
|
|
@@ -14543,9 +14579,9 @@ var SavedViewsFormModal = ({
|
|
|
14543
14579
|
onSelect,
|
|
14544
14580
|
defaultView
|
|
14545
14581
|
}) => {
|
|
14546
|
-
const i18n =
|
|
14582
|
+
const i18n = useI18nContext8();
|
|
14547
14583
|
return /* @__PURE__ */ React20.createElement(
|
|
14548
|
-
|
|
14584
|
+
FormModalBase,
|
|
14549
14585
|
{
|
|
14550
14586
|
open,
|
|
14551
14587
|
mode,
|
|
@@ -14564,7 +14600,7 @@ var SavedViewsFormModal = ({
|
|
|
14564
14600
|
);
|
|
14565
14601
|
};
|
|
14566
14602
|
|
|
14567
|
-
// src/
|
|
14603
|
+
// src/components/modals/form-modal/SharedViewFormModal.tsx
|
|
14568
14604
|
import {
|
|
14569
14605
|
Banner as Banner2,
|
|
14570
14606
|
Button as Button5,
|
|
@@ -14576,7 +14612,7 @@ import {
|
|
|
14576
14612
|
P as P3,
|
|
14577
14613
|
spacing as spacing4,
|
|
14578
14614
|
Typography as Typography3,
|
|
14579
|
-
useI18nContext as
|
|
14615
|
+
useI18nContext as useI18nContext9
|
|
14580
14616
|
} from "@procore/core-react";
|
|
14581
14617
|
import * as React21 from "react";
|
|
14582
14618
|
var SharedViewFormModal = ({
|
|
@@ -14589,7 +14625,7 @@ var SharedViewFormModal = ({
|
|
|
14589
14625
|
isCreating,
|
|
14590
14626
|
resetCreateError
|
|
14591
14627
|
}) => {
|
|
14592
|
-
const I18n =
|
|
14628
|
+
const I18n = useI18nContext9();
|
|
14593
14629
|
const NAME_MAX_LENGTH = 150;
|
|
14594
14630
|
const errors = extractMessage(createError, I18n);
|
|
14595
14631
|
const handleNameChange = () => {
|
|
@@ -14718,21 +14754,25 @@ var SharedViewFormModal = ({
|
|
|
14718
14754
|
);
|
|
14719
14755
|
};
|
|
14720
14756
|
|
|
14721
|
-
// src/
|
|
14722
|
-
import {
|
|
14757
|
+
// src/components/saved-views/SavedViews.tsx
|
|
14758
|
+
import { ToastAlertProvider } from "@procore/toast-alert";
|
|
14759
|
+
|
|
14760
|
+
// src/utils/hooks/useViewSelection.ts
|
|
14761
|
+
import { useState as useState3, useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useMemo } from "react";
|
|
14723
14762
|
import { useSearchParams } from "react-router-dom";
|
|
14763
|
+
import { useI18nContext as useI18nContext10 } from "@procore/core-react";
|
|
14724
14764
|
|
|
14725
14765
|
// src/utils/viewStorage.ts
|
|
14726
14766
|
var ViewStorage = {
|
|
14727
14767
|
save(key, view) {
|
|
14728
14768
|
localStorage.setItem(key, JSON.stringify(view));
|
|
14729
14769
|
},
|
|
14730
|
-
load(key) {
|
|
14770
|
+
load(key, defaultView) {
|
|
14731
14771
|
try {
|
|
14732
14772
|
const stored = localStorage.getItem(key);
|
|
14733
14773
|
return stored ? JSON.parse(stored) : null;
|
|
14734
14774
|
} catch (e2) {
|
|
14735
|
-
return
|
|
14775
|
+
return defaultView;
|
|
14736
14776
|
}
|
|
14737
14777
|
},
|
|
14738
14778
|
remove(key) {
|
|
@@ -14740,11 +14780,11 @@ var ViewStorage = {
|
|
|
14740
14780
|
}
|
|
14741
14781
|
};
|
|
14742
14782
|
|
|
14743
|
-
// src/utils/
|
|
14783
|
+
// src/utils/hooks/useViewSelection.ts
|
|
14744
14784
|
var getUpdatedSearchParams = (currentParams, view) => {
|
|
14745
14785
|
const updatedParams = new URLSearchParams(currentParams);
|
|
14746
14786
|
if (view.id === "default") {
|
|
14747
|
-
updatedParams.
|
|
14787
|
+
updatedParams.set("saved-view", "default");
|
|
14748
14788
|
} else if (view.id === "temporary") {
|
|
14749
14789
|
updatedParams.set("saved-view", "temporary");
|
|
14750
14790
|
} else {
|
|
@@ -14755,54 +14795,68 @@ var getUpdatedSearchParams = (currentParams, view) => {
|
|
|
14755
14795
|
var checkIsViewSelected = (selectedView, viewId) => {
|
|
14756
14796
|
return (selectedView == null ? void 0 : selectedView.share_token) === viewId || (selectedView == null ? void 0 : selectedView.id) === viewId;
|
|
14757
14797
|
};
|
|
14798
|
+
var findViewByToken = (views, token) => {
|
|
14799
|
+
return views.find((view) => view.share_token === token);
|
|
14800
|
+
};
|
|
14801
|
+
var setViewInUrl = (view, setSearchParams) => {
|
|
14802
|
+
setSearchParams(
|
|
14803
|
+
(currentParams) => getUpdatedSearchParams(currentParams, view),
|
|
14804
|
+
{ replace: true }
|
|
14805
|
+
);
|
|
14806
|
+
};
|
|
14807
|
+
var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
14808
|
+
if (previousParam && !currentParam) {
|
|
14809
|
+
setSearchParams(
|
|
14810
|
+
(currentParams) => {
|
|
14811
|
+
const updatedParams = new URLSearchParams(currentParams);
|
|
14812
|
+
updatedParams.set("saved-view", previousParam);
|
|
14813
|
+
return updatedParams;
|
|
14814
|
+
},
|
|
14815
|
+
{ replace: true }
|
|
14816
|
+
);
|
|
14817
|
+
}
|
|
14818
|
+
};
|
|
14758
14819
|
var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
14759
|
-
const
|
|
14760
|
-
const
|
|
14820
|
+
const I18n = useI18nContext10();
|
|
14821
|
+
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${config.projectId}_${config.userId}`;
|
|
14822
|
+
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14761
14823
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
14762
|
-
const
|
|
14763
|
-
|
|
14824
|
+
const previousSavedViewParamRef = useRef2(null);
|
|
14825
|
+
const [selectedSavedView, setSelectedSavedView] = useState3(() => {
|
|
14826
|
+
const stored = ViewStorage.load(storageKey, config.defaultView);
|
|
14764
14827
|
return stored ?? config.defaultView;
|
|
14765
14828
|
});
|
|
14766
|
-
const [temporaryView, setTemporaryView] =
|
|
14767
|
-
return ViewStorage.load(temporaryStorageKey);
|
|
14829
|
+
const [temporaryView, setTemporaryView] = useState3(() => {
|
|
14830
|
+
return ViewStorage.load(temporaryStorageKey, config.defaultView);
|
|
14768
14831
|
});
|
|
14769
|
-
const
|
|
14770
|
-
(view) => {
|
|
14771
|
-
if (config.stickyViewsKey) {
|
|
14772
|
-
ViewStorage.save(storageKey, view);
|
|
14773
|
-
}
|
|
14774
|
-
},
|
|
14775
|
-
[config.stickyViewsKey, storageKey]
|
|
14776
|
-
);
|
|
14777
|
-
const updateUrlForView = useCallback2(
|
|
14832
|
+
const persistViewToStorageAndUrl = useCallback2(
|
|
14778
14833
|
(view) => {
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
return getUpdatedSearchParams(currentParams, view);
|
|
14782
|
-
},
|
|
14783
|
-
{ replace: true }
|
|
14784
|
-
);
|
|
14834
|
+
ViewStorage.save(storageKey, view);
|
|
14835
|
+
setViewInUrl(view, setSearchParams);
|
|
14785
14836
|
},
|
|
14786
|
-
[setSearchParams]
|
|
14837
|
+
[storageKey, setSearchParams]
|
|
14787
14838
|
);
|
|
14788
14839
|
const baseViews = savedViews ?? [];
|
|
14789
|
-
const allViews =
|
|
14840
|
+
const allViews = useMemo(
|
|
14841
|
+
() => temporaryView ? [...baseViews, temporaryView] : baseViews,
|
|
14842
|
+
[baseViews, temporaryView]
|
|
14843
|
+
);
|
|
14790
14844
|
const selectView = useCallback2(
|
|
14791
14845
|
(view) => {
|
|
14792
14846
|
const viewToSelect = config.onSelect({ item: view });
|
|
14793
14847
|
setSelectedSavedView(viewToSelect);
|
|
14794
|
-
|
|
14795
|
-
updateUrlForView(viewToSelect);
|
|
14848
|
+
persistViewToStorageAndUrl(viewToSelect);
|
|
14796
14849
|
return viewToSelect;
|
|
14797
14850
|
},
|
|
14798
|
-
[config,
|
|
14851
|
+
[config, persistViewToStorageAndUrl, temporaryView, temporaryStorageKey]
|
|
14799
14852
|
);
|
|
14800
14853
|
const createTemporaryView = useCallback2(
|
|
14801
14854
|
(fetchedView) => {
|
|
14802
14855
|
const tempView = {
|
|
14803
14856
|
...fetchedView,
|
|
14804
14857
|
id: "temporary",
|
|
14805
|
-
name: "
|
|
14858
|
+
name: I18n.t("savedViews.temporaryViewName"),
|
|
14859
|
+
view_level: "temporary"
|
|
14806
14860
|
};
|
|
14807
14861
|
ViewStorage.save(temporaryStorageKey, tempView);
|
|
14808
14862
|
setTemporaryView(tempView);
|
|
@@ -14825,26 +14879,34 @@ var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
|
14825
14879
|
if (isViewAlreadySelected(viewId)) {
|
|
14826
14880
|
return;
|
|
14827
14881
|
}
|
|
14828
|
-
const viewInList = allViews
|
|
14882
|
+
const viewInList = findViewByToken(allViews, viewId);
|
|
14829
14883
|
if (viewInList) {
|
|
14830
14884
|
selectView(viewInList);
|
|
14885
|
+
} else {
|
|
14886
|
+
openSharedViewModal(viewId);
|
|
14831
14887
|
}
|
|
14832
|
-
openSharedViewModal(viewId);
|
|
14833
14888
|
},
|
|
14834
14889
|
[isViewAlreadySelected, openSharedViewModal, allViews, selectView]
|
|
14835
14890
|
);
|
|
14836
|
-
|
|
14837
|
-
if (!allViews.length)
|
|
14838
|
-
return;
|
|
14891
|
+
useEffect2(() => {
|
|
14839
14892
|
const savedViewId = searchParams.get("saved-view");
|
|
14893
|
+
restoreUrlParameter(
|
|
14894
|
+
savedViewId,
|
|
14895
|
+
previousSavedViewParamRef.current,
|
|
14896
|
+
setSearchParams
|
|
14897
|
+
);
|
|
14840
14898
|
if (savedViewId) {
|
|
14899
|
+
previousSavedViewParamRef.current = savedViewId;
|
|
14900
|
+
}
|
|
14901
|
+
if (savedViewId && allViews.length > 0) {
|
|
14841
14902
|
handleSavedViewFromUrl(savedViewId);
|
|
14842
14903
|
}
|
|
14843
14904
|
}, [
|
|
14844
|
-
searchParams
|
|
14905
|
+
searchParams,
|
|
14845
14906
|
savedViews,
|
|
14846
14907
|
temporaryView,
|
|
14847
14908
|
handleSavedViewFromUrl,
|
|
14909
|
+
setSearchParams,
|
|
14848
14910
|
allViews.length
|
|
14849
14911
|
]);
|
|
14850
14912
|
return {
|
|
@@ -14857,7 +14919,7 @@ var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
|
14857
14919
|
};
|
|
14858
14920
|
};
|
|
14859
14921
|
|
|
14860
|
-
// src/
|
|
14922
|
+
// src/components/saved-views/SavedViews.tsx
|
|
14861
14923
|
var StyledPanel = styled_components_esm_default.div`
|
|
14862
14924
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
14863
14925
|
`;
|
|
@@ -14867,14 +14929,15 @@ var SavedViewsContent = (props) => {
|
|
|
14867
14929
|
const queryInput = {
|
|
14868
14930
|
domain: props.domain,
|
|
14869
14931
|
tableName: props.tableName,
|
|
14870
|
-
enableSavedViews: props.enableSavedViews,
|
|
14871
14932
|
projectId,
|
|
14872
14933
|
companyId
|
|
14873
14934
|
};
|
|
14874
14935
|
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14875
14936
|
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14876
|
-
const
|
|
14877
|
-
const
|
|
14937
|
+
const { showToast } = useToastAlertContext3();
|
|
14938
|
+
const i18n = useI18nContext11();
|
|
14939
|
+
const [activeModal, setActiveModal] = useState4(null);
|
|
14940
|
+
const [modalData, setModalData] = useState4(null);
|
|
14878
14941
|
const openModal = (type, data) => {
|
|
14879
14942
|
setActiveModal(type);
|
|
14880
14943
|
setModalData(data ?? null);
|
|
@@ -14897,9 +14960,9 @@ var SavedViewsContent = (props) => {
|
|
|
14897
14960
|
{
|
|
14898
14961
|
domain: props.domain,
|
|
14899
14962
|
tableName: props.tableName,
|
|
14900
|
-
stickyViewsKey: props.stickyViewsKey,
|
|
14901
14963
|
userId: props.userId,
|
|
14902
14964
|
projectId,
|
|
14965
|
+
companyId,
|
|
14903
14966
|
defaultView: props.defaultView,
|
|
14904
14967
|
onSelect: props.onSelect
|
|
14905
14968
|
},
|
|
@@ -14917,8 +14980,9 @@ var SavedViewsContent = (props) => {
|
|
|
14917
14980
|
error: createError,
|
|
14918
14981
|
reset: resetCreateError
|
|
14919
14982
|
} = useCreateSavedView(queryInput);
|
|
14920
|
-
|
|
14983
|
+
useEffect3(() => {
|
|
14921
14984
|
if (fetchError) {
|
|
14985
|
+
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
14922
14986
|
selectView(selectedView ?? props.defaultView);
|
|
14923
14987
|
closeModal();
|
|
14924
14988
|
}
|
|
@@ -14942,6 +15006,7 @@ var SavedViewsContent = (props) => {
|
|
|
14942
15006
|
};
|
|
14943
15007
|
createSavedView(viewToCreate, {
|
|
14944
15008
|
onSuccess: (newView) => {
|
|
15009
|
+
showToast.success(i18n.t("savedViews.create.success"));
|
|
14945
15010
|
selectView(newView);
|
|
14946
15011
|
closeModal();
|
|
14947
15012
|
}
|
|
@@ -14963,7 +15028,6 @@ var SavedViewsContent = (props) => {
|
|
|
14963
15028
|
deleteSelectedView();
|
|
14964
15029
|
closeModal();
|
|
14965
15030
|
};
|
|
14966
|
-
const i18n = useI18nContext11();
|
|
14967
15031
|
return /* @__PURE__ */ React22.createElement(StyledPanel, { provider: props.provider }, /* @__PURE__ */ React22.createElement(
|
|
14968
15032
|
ExpandedPanel,
|
|
14969
15033
|
{
|
|
@@ -14998,7 +15062,7 @@ var SavedViewsContent = (props) => {
|
|
|
14998
15062
|
selectedSavedView: selectedView,
|
|
14999
15063
|
tableConfig: props.tableConfig,
|
|
15000
15064
|
defaultView: props.defaultView,
|
|
15001
|
-
|
|
15065
|
+
presetViews: props.presetViews,
|
|
15002
15066
|
savedViews: allViews,
|
|
15003
15067
|
provider: props.provider,
|
|
15004
15068
|
userId: props.userId,
|
|
@@ -15006,7 +15070,7 @@ var SavedViewsContent = (props) => {
|
|
|
15006
15070
|
}
|
|
15007
15071
|
))
|
|
15008
15072
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ React22.createElement(
|
|
15009
|
-
|
|
15073
|
+
FormModal,
|
|
15010
15074
|
{
|
|
15011
15075
|
open: true,
|
|
15012
15076
|
mode: activeModal,
|
|
@@ -15041,31 +15105,125 @@ var SavedViewsContent = (props) => {
|
|
|
15041
15105
|
));
|
|
15042
15106
|
};
|
|
15043
15107
|
var SavedViews = (props) => {
|
|
15044
|
-
return /* @__PURE__ */ React22.createElement(EnvironmentI18nProvider, null, /* @__PURE__ */ React22.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React22.createElement(SavedViewsContent, { ...props })));
|
|
15108
|
+
return /* @__PURE__ */ React22.createElement(EnvironmentI18nProvider, null, /* @__PURE__ */ React22.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React22.createElement(ToastAlertProvider, null, /* @__PURE__ */ React22.createElement(SavedViewsContent, { ...props }))));
|
|
15045
15109
|
};
|
|
15046
15110
|
|
|
15047
|
-
// src/
|
|
15048
|
-
import {
|
|
15049
|
-
|
|
15050
|
-
|
|
15111
|
+
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15112
|
+
import React23, { useCallback as useCallback4 } from "react";
|
|
15113
|
+
|
|
15114
|
+
// src/components/adapters/smart-grid/SmartGridDefaultSavedView.tsx
|
|
15115
|
+
import { useMemo as useMemo2 } from "react";
|
|
15116
|
+
var DEFAULT_COLUMN_STATE = {
|
|
15117
|
+
hide: false,
|
|
15118
|
+
pinned: null,
|
|
15119
|
+
width: 200,
|
|
15120
|
+
sort: null,
|
|
15121
|
+
sortIndex: null,
|
|
15122
|
+
pivot: false,
|
|
15123
|
+
pivotIndex: null,
|
|
15124
|
+
aggFunc: null,
|
|
15125
|
+
rowGroup: false,
|
|
15126
|
+
rowGroupIndex: null,
|
|
15127
|
+
flex: null
|
|
15128
|
+
};
|
|
15129
|
+
var getColumnStateFromDefs = (columnDefs) => {
|
|
15130
|
+
return columnDefs.map((colDef) => {
|
|
15131
|
+
const field = colDef.field ?? colDef.colId;
|
|
15132
|
+
if (!field)
|
|
15133
|
+
return null;
|
|
15134
|
+
return {
|
|
15135
|
+
colId: field,
|
|
15136
|
+
hide: colDef.hide ?? false,
|
|
15137
|
+
pinned: colDef.pinned ?? null,
|
|
15138
|
+
width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
|
|
15139
|
+
sort: null,
|
|
15140
|
+
sortIndex: null,
|
|
15141
|
+
pivot: false,
|
|
15142
|
+
pivotIndex: null,
|
|
15143
|
+
aggFunc: null,
|
|
15144
|
+
rowGroup: false,
|
|
15145
|
+
rowGroupIndex: null,
|
|
15146
|
+
flex: colDef.flex ?? null
|
|
15147
|
+
};
|
|
15148
|
+
}).filter((col) => col !== null);
|
|
15149
|
+
};
|
|
15150
|
+
var extractDefaultView = (gridApi, receivedConfig) => {
|
|
15151
|
+
var _a, _b;
|
|
15152
|
+
const columnDefs = gridApi.getColumnDefs() ?? [];
|
|
15153
|
+
const defaultColumnState = getColumnStateFromDefs(columnDefs);
|
|
15154
|
+
const result = {
|
|
15155
|
+
columnState: ((_a = receivedConfig == null ? void 0 : receivedConfig.columnState) == null ? void 0 : _a.length) ? receivedConfig.columnState : defaultColumnState,
|
|
15156
|
+
columnGroupState: (receivedConfig == null ? void 0 : receivedConfig.columnGroupState) ?? [],
|
|
15157
|
+
rowGroupState: (receivedConfig == null ? void 0 : receivedConfig.rowGroupState) ?? [],
|
|
15158
|
+
filterState: (receivedConfig == null ? void 0 : receivedConfig.filterState) ?? {},
|
|
15159
|
+
rowHeight: (receivedConfig == null ? void 0 : receivedConfig.rowHeight) ?? ((_b = gridApi.getSizesForCurrentTheme()) == null ? void 0 : _b.rowHeight)
|
|
15160
|
+
};
|
|
15161
|
+
return result;
|
|
15162
|
+
};
|
|
15163
|
+
var useNormalizedDefaultViews = (defaultViews, gridApi) => {
|
|
15164
|
+
return useMemo2(() => {
|
|
15165
|
+
if (!gridApi)
|
|
15166
|
+
return defaultViews.map((view) => ({ ...view, share_token: view.id }));
|
|
15167
|
+
return defaultViews.map((view) => ({
|
|
15168
|
+
...view,
|
|
15169
|
+
share_token: view.id,
|
|
15170
|
+
table_config: extractDefaultView(gridApi, view.table_config)
|
|
15171
|
+
}));
|
|
15172
|
+
}, [defaultViews, gridApi]);
|
|
15051
15173
|
};
|
|
15174
|
+
|
|
15175
|
+
// src/components/adapters/smart-grid/useSmartGridConfig.ts
|
|
15176
|
+
import { useState as useState5, useEffect as useEffect4 } from "react";
|
|
15177
|
+
var GRID_STATE_EVENTS = [
|
|
15178
|
+
"sortChanged",
|
|
15179
|
+
"filterOpened",
|
|
15180
|
+
"filterChanged",
|
|
15181
|
+
"columnRowGroupChanged",
|
|
15182
|
+
"dragStopped",
|
|
15183
|
+
"columnResized",
|
|
15184
|
+
"columnVisible",
|
|
15185
|
+
"columnPinned",
|
|
15186
|
+
"columnMoved",
|
|
15187
|
+
"modelUpdated",
|
|
15188
|
+
"gridColumnsChanged",
|
|
15189
|
+
"gridReady"
|
|
15190
|
+
];
|
|
15191
|
+
var useSmartGridConfig = (gridApi) => {
|
|
15192
|
+
const [config, setConfig] = useState5(
|
|
15193
|
+
() => getSmartGridConfig(gridApi)
|
|
15194
|
+
);
|
|
15195
|
+
useEffect4(() => {
|
|
15196
|
+
if (!gridApi)
|
|
15197
|
+
return;
|
|
15198
|
+
const updateConfig = () => {
|
|
15199
|
+
setConfig(getSmartGridConfig(gridApi));
|
|
15200
|
+
};
|
|
15201
|
+
GRID_STATE_EVENTS.forEach((event) => {
|
|
15202
|
+
gridApi.addEventListener(event, updateConfig);
|
|
15203
|
+
});
|
|
15204
|
+
return () => {
|
|
15205
|
+
GRID_STATE_EVENTS.forEach((event) => {
|
|
15206
|
+
gridApi.removeEventListener(event, updateConfig);
|
|
15207
|
+
});
|
|
15208
|
+
};
|
|
15209
|
+
}, [gridApi]);
|
|
15210
|
+
return { config, setConfig };
|
|
15211
|
+
};
|
|
15212
|
+
|
|
15213
|
+
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15052
15214
|
var SmartGridSavedViews = (props) => {
|
|
15053
15215
|
const { gridApi, userId, projectId, companyId } = props;
|
|
15054
15216
|
const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
|
|
15055
|
-
const
|
|
15056
|
-
|
|
15057
|
-
domain: props.domain
|
|
15058
|
-
});
|
|
15217
|
+
const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
|
|
15218
|
+
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15059
15219
|
const onSelect = useCallback4(
|
|
15060
15220
|
({ item }) => {
|
|
15061
15221
|
if (!gridApi)
|
|
15062
15222
|
return item;
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
gridApi
|
|
15066
|
-
|
|
15067
|
-
gridApi.setGridOption("rowHeight", props.defaultRowHeight);
|
|
15068
|
-
gridApi.refreshCells();
|
|
15223
|
+
const isPresetView = item.view_level === "default";
|
|
15224
|
+
if (isPresetView) {
|
|
15225
|
+
updateTableConfig(item, gridApi, "smart-grid");
|
|
15226
|
+
setTableConfig(item.table_config);
|
|
15069
15227
|
return item;
|
|
15070
15228
|
}
|
|
15071
15229
|
const updatedView = {
|
|
@@ -15079,22 +15237,9 @@ var SmartGridSavedViews = (props) => {
|
|
|
15079
15237
|
setTableConfig(updatedView.table_config);
|
|
15080
15238
|
return updatedView;
|
|
15081
15239
|
},
|
|
15082
|
-
[
|
|
15083
|
-
gridApi,
|
|
15084
|
-
props.defaultViewFilters,
|
|
15085
|
-
props.defaultRowHeight,
|
|
15086
|
-
tableConfig,
|
|
15087
|
-
setTableConfig
|
|
15088
|
-
]
|
|
15089
|
-
);
|
|
15090
|
-
const stickyViewsKey = generateStickyViewsKey(
|
|
15091
|
-
props.domain,
|
|
15092
|
-
props.tableName,
|
|
15093
|
-
userId,
|
|
15094
|
-
projectId,
|
|
15095
|
-
companyId
|
|
15240
|
+
[gridApi, tableConfig, setTableConfig]
|
|
15096
15241
|
);
|
|
15097
|
-
return /* @__PURE__ */ React23.createElement(
|
|
15242
|
+
return /* @__PURE__ */ React23.createElement(
|
|
15098
15243
|
SavedViews,
|
|
15099
15244
|
{
|
|
15100
15245
|
onSelect,
|
|
@@ -15104,14 +15249,14 @@ var SmartGridSavedViews = (props) => {
|
|
|
15104
15249
|
companyId,
|
|
15105
15250
|
provider: "smart-grid",
|
|
15106
15251
|
defaultView,
|
|
15252
|
+
presetViews,
|
|
15107
15253
|
tableName: props.tableName,
|
|
15108
|
-
tableConfig
|
|
15109
|
-
stickyViewsKey
|
|
15254
|
+
tableConfig
|
|
15110
15255
|
}
|
|
15111
|
-
)
|
|
15256
|
+
);
|
|
15112
15257
|
};
|
|
15113
15258
|
|
|
15114
|
-
// src/
|
|
15259
|
+
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
15115
15260
|
import React24, {
|
|
15116
15261
|
forwardRef as forwardRef11,
|
|
15117
15262
|
useImperativeHandle,
|
|
@@ -15119,10 +15264,9 @@ import React24, {
|
|
|
15119
15264
|
useCallback as useCallback5
|
|
15120
15265
|
} from "react";
|
|
15121
15266
|
|
|
15122
|
-
// src/
|
|
15123
|
-
import { useMemo } from "react";
|
|
15124
|
-
|
|
15125
|
-
var DEFAULT_COLUMN_STATE = {
|
|
15267
|
+
// src/components/adapters/data-table/DataTableDefaultSavedView.tsx
|
|
15268
|
+
import { useMemo as useMemo3 } from "react";
|
|
15269
|
+
var DEFAULT_COLUMN_STATE2 = {
|
|
15126
15270
|
hidden: false,
|
|
15127
15271
|
pinned: null,
|
|
15128
15272
|
width: 200,
|
|
@@ -15137,7 +15281,7 @@ var getColumnState = (columnDefinitions) => {
|
|
|
15137
15281
|
if (column.field.includes("custom_field")) {
|
|
15138
15282
|
return {
|
|
15139
15283
|
field: column.field,
|
|
15140
|
-
...
|
|
15284
|
+
...DEFAULT_COLUMN_STATE2
|
|
15141
15285
|
};
|
|
15142
15286
|
}
|
|
15143
15287
|
return {
|
|
@@ -15148,11 +15292,11 @@ var getColumnState = (columnDefinitions) => {
|
|
|
15148
15292
|
rowGroupIndex: null,
|
|
15149
15293
|
sort: null,
|
|
15150
15294
|
sortIndex: null,
|
|
15151
|
-
width: (column.minWidth ??
|
|
15295
|
+
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
|
|
15152
15296
|
};
|
|
15153
15297
|
});
|
|
15154
15298
|
};
|
|
15155
|
-
var
|
|
15299
|
+
var extractDefaultView2 = (columnDefinitions, receivedConfigFromTool) => {
|
|
15156
15300
|
var _a, _b, _c;
|
|
15157
15301
|
const defaultColumnState = getColumnState(columnDefinitions);
|
|
15158
15302
|
const result = {
|
|
@@ -15168,52 +15312,38 @@ var extractDefaultView = (columnDefinitions, receivedConfigFromTool) => {
|
|
|
15168
15312
|
};
|
|
15169
15313
|
return result;
|
|
15170
15314
|
};
|
|
15171
|
-
var
|
|
15172
|
-
|
|
15173
|
-
|
|
15174
|
-
|
|
15175
|
-
|
|
15176
|
-
|
|
15177
|
-
}
|
|
15178
|
-
|
|
15179
|
-
const name = useDefaultViewName2(props.domain, props.defaultViewName);
|
|
15180
|
-
const extractedDefaultConfig = useMemo(
|
|
15181
|
-
() => extractDefaultView(props.columnDefinitions, props.receivedConfigFromTool),
|
|
15182
|
-
[props.columnDefinitions, props.receivedConfigFromTool]
|
|
15315
|
+
var useNormalizedDefaultViews2 = (defaultViews, columnDefinitions) => {
|
|
15316
|
+
return useMemo3(
|
|
15317
|
+
() => defaultViews.map((view) => ({
|
|
15318
|
+
...view,
|
|
15319
|
+
share_token: "",
|
|
15320
|
+
table_config: extractDefaultView2(columnDefinitions, view.table_config)
|
|
15321
|
+
})),
|
|
15322
|
+
[defaultViews, columnDefinitions]
|
|
15183
15323
|
);
|
|
15184
|
-
return {
|
|
15185
|
-
id: "default",
|
|
15186
|
-
view_level: "default",
|
|
15187
|
-
name,
|
|
15188
|
-
table_config: extractedDefaultConfig
|
|
15189
|
-
};
|
|
15190
15324
|
};
|
|
15191
15325
|
|
|
15192
|
-
// src/
|
|
15193
|
-
import { ToastAlertProvider as ToastAlertProvider2 } from "@procore/toast-alert";
|
|
15194
|
-
var generateStickyViewsKey2 = (domain, tableName, userId, projectId, companyId) => {
|
|
15195
|
-
return `savedView-${domain}-${tableName}-${companyId}-${projectId}-${userId}`;
|
|
15196
|
-
};
|
|
15326
|
+
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
15197
15327
|
var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
15328
|
+
var _a;
|
|
15198
15329
|
const { tableApi, userId, projectId, companyId } = props;
|
|
15330
|
+
const presetViews = useNormalizedDefaultViews2(
|
|
15331
|
+
props.defaultViews,
|
|
15332
|
+
props.columnDefinitions
|
|
15333
|
+
);
|
|
15334
|
+
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15199
15335
|
const [internalTableConfig, setInternalTableConfig] = useState6(
|
|
15200
|
-
props.
|
|
15336
|
+
((_a = ViewStorage.load(props.stickyViewsKey, defaultView)) == null ? void 0 : _a.table_config) ?? defaultView.table_config
|
|
15201
15337
|
);
|
|
15202
15338
|
useImperativeHandle(ref, () => ({
|
|
15203
15339
|
setTableConfig: (newConfig) => {
|
|
15204
15340
|
setInternalTableConfig(newConfig);
|
|
15205
15341
|
}
|
|
15206
15342
|
}));
|
|
15207
|
-
const defaultView = useDefaultView2({
|
|
15208
|
-
defaultViewName: props.defaultViewName,
|
|
15209
|
-
receivedConfigFromTool: props.defaultViewConfig,
|
|
15210
|
-
domain: props.domain,
|
|
15211
|
-
columnDefinitions: props.columnDefinitions
|
|
15212
|
-
});
|
|
15213
15343
|
const onSelect = useCallback5(
|
|
15214
15344
|
({ item }) => {
|
|
15215
|
-
const
|
|
15216
|
-
const updatedView =
|
|
15345
|
+
const isPresetView = item.view_level === "default";
|
|
15346
|
+
const updatedView = isPresetView ? item : {
|
|
15217
15347
|
...item,
|
|
15218
15348
|
table_config: customAndConfigSync(
|
|
15219
15349
|
item.table_config,
|
|
@@ -15229,14 +15359,7 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
15229
15359
|
if (!internalTableConfig) {
|
|
15230
15360
|
return null;
|
|
15231
15361
|
}
|
|
15232
|
-
|
|
15233
|
-
props.domain,
|
|
15234
|
-
props.tableName,
|
|
15235
|
-
userId,
|
|
15236
|
-
projectId,
|
|
15237
|
-
companyId
|
|
15238
|
-
);
|
|
15239
|
-
return /* @__PURE__ */ React24.createElement(ToastAlertProvider2, null, /* @__PURE__ */ React24.createElement(
|
|
15362
|
+
return /* @__PURE__ */ React24.createElement(
|
|
15240
15363
|
SavedViews,
|
|
15241
15364
|
{
|
|
15242
15365
|
onSelect,
|
|
@@ -15246,20 +15369,21 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
15246
15369
|
companyId,
|
|
15247
15370
|
provider: "data-table",
|
|
15248
15371
|
defaultView,
|
|
15372
|
+
presetViews,
|
|
15249
15373
|
tableName: props.tableName,
|
|
15250
|
-
tableConfig: internalTableConfig
|
|
15251
|
-
stickyViewsKey
|
|
15374
|
+
tableConfig: internalTableConfig
|
|
15252
15375
|
}
|
|
15253
|
-
)
|
|
15376
|
+
);
|
|
15254
15377
|
});
|
|
15255
15378
|
DataTableSavedViews.displayName = "DataTableSavedViews";
|
|
15256
15379
|
export {
|
|
15257
15380
|
DataTableSavedViews,
|
|
15258
15381
|
ExpandedPanel,
|
|
15382
|
+
FormModal,
|
|
15259
15383
|
PanelContent,
|
|
15260
15384
|
SavedViewCollectionMenuItem,
|
|
15385
|
+
SavedViews,
|
|
15261
15386
|
SavedViewsDeleteConfirmationModalShared,
|
|
15262
|
-
SavedViewsFormModal,
|
|
15263
15387
|
SmartGridSavedViews,
|
|
15264
15388
|
getTranslations,
|
|
15265
15389
|
useSavedViewsPanel_default as useSavedViewsPanel
|