@procore/saved-views 5.1.0-alpha.4 → 5.1.0-alpha.6
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 +447 -335
- package/dist/legacy/index.mjs +426 -317
- package/dist/modern/index.d.mts +61 -40
- package/dist/modern/index.d.ts +61 -40
- package/dist/modern/index.js +446 -333
- package/dist/modern/index.mjs +425 -315
- 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,17 @@ 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 updateMutation = useUpdateSavedView(queryInput);
|
|
11892
|
+
const { mutate: updateSavedView } = updateMutation;
|
|
11893
|
+
const isUpdateLoading = "isPending" in updateMutation ? updateMutation.isPending : updateMutation.isLoading ?? false;
|
|
11894
|
+
const savedViews = props.savedViews ?? savedViewsFromQuery;
|
|
11799
11895
|
const errorToastRef = React17.useRef(null);
|
|
11800
11896
|
React17.useEffect(() => {
|
|
11801
11897
|
if (savedViewsError && savedViewsError !== errorToastRef.current) {
|
|
@@ -11804,12 +11900,16 @@ var PanelContent = (props) => {
|
|
|
11804
11900
|
}
|
|
11805
11901
|
}, [savedViewsError, showToast, I18n]);
|
|
11806
11902
|
const { data: permissions } = useSavedViewsPermissions(props.queryInput);
|
|
11807
|
-
const selectedRowRef = useScrollToRef(
|
|
11903
|
+
const selectedRowRef = useScrollToRef(savedViews);
|
|
11904
|
+
const { groups, toggleGroup } = useGroups();
|
|
11905
|
+
const isTemporarySelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === "temporary";
|
|
11906
|
+
const temporaryView = savedViews == null ? void 0 : savedViews.find((view) => view.id === "temporary");
|
|
11907
|
+
const presetViews = props.presetViews || [props.defaultView];
|
|
11808
11908
|
const onUpdate = (data) => {
|
|
11809
11909
|
const newSavedView = {
|
|
11810
11910
|
...data,
|
|
11811
|
-
...
|
|
11812
|
-
table_config:
|
|
11911
|
+
...selectedSavedView,
|
|
11912
|
+
table_config: tableConfig
|
|
11813
11913
|
};
|
|
11814
11914
|
updateSavedView(newSavedView, {
|
|
11815
11915
|
onSuccess: () => {
|
|
@@ -11821,12 +11921,6 @@ var PanelContent = (props) => {
|
|
|
11821
11921
|
}
|
|
11822
11922
|
});
|
|
11823
11923
|
};
|
|
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
11924
|
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
11925
|
Row,
|
|
11832
11926
|
{
|
|
@@ -11842,23 +11936,27 @@ var PanelContent = (props) => {
|
|
|
11842
11936
|
onClearTemporary: props.onClearTemporary
|
|
11843
11937
|
}
|
|
11844
11938
|
)
|
|
11845
|
-
),
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
onClick: () => props.onSelect({ item: props.defaultView }),
|
|
11850
|
-
ref: isDefaultSelected ? selectedRowRef : null
|
|
11851
|
-
},
|
|
11852
|
-
/* @__PURE__ */ React17.createElement(
|
|
11853
|
-
SavedViewCollectionMenuItem,
|
|
11939
|
+
), presetViews.map((presetView) => {
|
|
11940
|
+
const isSelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === presetView.id;
|
|
11941
|
+
return /* @__PURE__ */ React17.createElement(
|
|
11942
|
+
Row,
|
|
11854
11943
|
{
|
|
11855
|
-
|
|
11856
|
-
selected:
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11944
|
+
key: presetView.id,
|
|
11945
|
+
selected: isSelected,
|
|
11946
|
+
onClick: () => props.onSelect({ item: presetView }),
|
|
11947
|
+
ref: isSelected ? selectedRowRef : null
|
|
11948
|
+
},
|
|
11949
|
+
/* @__PURE__ */ React17.createElement(
|
|
11950
|
+
SavedViewCollectionMenuItem,
|
|
11951
|
+
{
|
|
11952
|
+
item: presetView,
|
|
11953
|
+
selected: isSelected
|
|
11954
|
+
}
|
|
11955
|
+
)
|
|
11956
|
+
);
|
|
11957
|
+
}), VIEW_LEVELS.map((level) => {
|
|
11860
11958
|
const isExpanded = groups[level];
|
|
11861
|
-
const views = isExpanded &&
|
|
11959
|
+
const views = isExpanded && savedViews ? savedViews.filter(
|
|
11862
11960
|
(view) => view.view_level === level && view.id !== "temporary"
|
|
11863
11961
|
) : [];
|
|
11864
11962
|
return /* @__PURE__ */ React17.createElement(React17.Fragment, { key: level }, /* @__PURE__ */ React17.createElement(
|
|
@@ -11869,11 +11967,10 @@ var PanelContent = (props) => {
|
|
|
11869
11967
|
expanded: isExpanded
|
|
11870
11968
|
}
|
|
11871
11969
|
), views.map((view) => {
|
|
11872
|
-
|
|
11873
|
-
const isSelected = ((_a2 = props.selectedSavedView) == null ? void 0 : _a2.id) === view.id;
|
|
11970
|
+
const isSelected = (selectedSavedView == null ? void 0 : selectedSavedView.id) === view.id;
|
|
11874
11971
|
const canUpdate = isSelected && hasPermissionForViewLevel(view.view_level, permissions) && !isEqual(
|
|
11875
11972
|
view.table_config,
|
|
11876
|
-
|
|
11973
|
+
tableConfig,
|
|
11877
11974
|
props.defaultView.table_config,
|
|
11878
11975
|
props.provider
|
|
11879
11976
|
);
|
|
@@ -11909,67 +12006,7 @@ var PanelContent = (props) => {
|
|
|
11909
12006
|
})));
|
|
11910
12007
|
};
|
|
11911
12008
|
|
|
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
|
|
12009
|
+
// src/components/saved-views/SavedViews.tsx
|
|
11973
12010
|
import {
|
|
11974
12011
|
Box as Box2,
|
|
11975
12012
|
Button as Button6,
|
|
@@ -11978,16 +12015,17 @@ import {
|
|
|
11978
12015
|
Tooltip,
|
|
11979
12016
|
useI18nContext as useI18nContext11
|
|
11980
12017
|
} from "@procore/core-react";
|
|
11981
|
-
import React22, { useState as
|
|
12018
|
+
import React22, { useState as useState4, useEffect as useEffect3, useCallback as useCallback3 } from "react";
|
|
11982
12019
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
12020
|
+
import { useToastAlertContext as useToastAlertContext3, ToastAlertProvider } from "@procore/toast-alert";
|
|
11983
12021
|
|
|
11984
|
-
// src/
|
|
12022
|
+
// src/components/modals/DeleteConfirmationModal.tsx
|
|
11985
12023
|
import {
|
|
11986
12024
|
Button as Button3,
|
|
11987
12025
|
ConfirmModal,
|
|
11988
12026
|
Modal,
|
|
11989
12027
|
P as P2,
|
|
11990
|
-
useI18nContext as
|
|
12028
|
+
useI18nContext as useI18nContext6
|
|
11991
12029
|
} from "@procore/core-react";
|
|
11992
12030
|
import React18 from "react";
|
|
11993
12031
|
var SavedViewsDeleteConfirmationModalShared = ({
|
|
@@ -11995,7 +12033,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
11995
12033
|
onDelete,
|
|
11996
12034
|
open
|
|
11997
12035
|
}) => {
|
|
11998
|
-
const i18n =
|
|
12036
|
+
const i18n = useI18nContext6();
|
|
11999
12037
|
return /* @__PURE__ */ React18.createElement(
|
|
12000
12038
|
ConfirmModal,
|
|
12001
12039
|
{
|
|
@@ -12011,10 +12049,10 @@ var SavedViewsDeleteConfirmationModalShared = ({
|
|
|
12011
12049
|
);
|
|
12012
12050
|
};
|
|
12013
12051
|
|
|
12014
|
-
// src/
|
|
12052
|
+
// src/components/modals/form-modal/FormModal.tsx
|
|
12015
12053
|
import React20 from "react";
|
|
12016
12054
|
|
|
12017
|
-
// src/
|
|
12055
|
+
// src/components/modals/form-modal/FormModalBase.tsx
|
|
12018
12056
|
import {
|
|
12019
12057
|
Banner,
|
|
12020
12058
|
Button as Button4,
|
|
@@ -12026,7 +12064,7 @@ import {
|
|
|
12026
12064
|
Modal as Modal2,
|
|
12027
12065
|
spacing as spacing3,
|
|
12028
12066
|
Typography as Typography2,
|
|
12029
|
-
useI18nContext as
|
|
12067
|
+
useI18nContext as useI18nContext7
|
|
12030
12068
|
} from "@procore/core-react";
|
|
12031
12069
|
import * as React19 from "react";
|
|
12032
12070
|
|
|
@@ -14322,7 +14360,7 @@ var TupleSchema = class extends Schema {
|
|
|
14322
14360
|
};
|
|
14323
14361
|
create$1.prototype = TupleSchema.prototype;
|
|
14324
14362
|
|
|
14325
|
-
// src/
|
|
14363
|
+
// src/components/modals/form-modal/FormModalBaseUtils.ts
|
|
14326
14364
|
var getViewLevelOptions = (permissions, i18n) => {
|
|
14327
14365
|
const options = ["personal"];
|
|
14328
14366
|
if (permissions == null ? void 0 : permissions.can_create_project_saved_views)
|
|
@@ -14355,11 +14393,11 @@ function extractMessage(error, I18n) {
|
|
|
14355
14393
|
return { form: I18n.t("savedViews.modal.errors.unknown") };
|
|
14356
14394
|
}
|
|
14357
14395
|
|
|
14358
|
-
// src/
|
|
14396
|
+
// src/components/modals/form-modal/FormModalBase.tsx
|
|
14359
14397
|
var ScrollContainer = styled_components_esm_default("div")`
|
|
14360
14398
|
overflow: auto;
|
|
14361
14399
|
`;
|
|
14362
|
-
var
|
|
14400
|
+
var FormModalBase = ({
|
|
14363
14401
|
open,
|
|
14364
14402
|
mode,
|
|
14365
14403
|
onCancel,
|
|
@@ -14374,7 +14412,7 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14374
14412
|
setOpenEditCreateModal,
|
|
14375
14413
|
onSelect
|
|
14376
14414
|
}) => {
|
|
14377
|
-
const I18n =
|
|
14415
|
+
const I18n = useI18nContext7();
|
|
14378
14416
|
const NAME_MAX_LENGTH = 150;
|
|
14379
14417
|
const {
|
|
14380
14418
|
mutate: createSavedView,
|
|
@@ -14529,9 +14567,9 @@ var SavedViewsCreateUpdateModalBase = ({
|
|
|
14529
14567
|
);
|
|
14530
14568
|
};
|
|
14531
14569
|
|
|
14532
|
-
// src/
|
|
14533
|
-
import { useI18nContext as
|
|
14534
|
-
var
|
|
14570
|
+
// src/components/modals/form-modal/FormModal.tsx
|
|
14571
|
+
import { useI18nContext as useI18nContext8 } from "@procore/core-react";
|
|
14572
|
+
var FormModal = ({
|
|
14535
14573
|
open,
|
|
14536
14574
|
mode,
|
|
14537
14575
|
onCancel,
|
|
@@ -14543,9 +14581,9 @@ var SavedViewsFormModal = ({
|
|
|
14543
14581
|
onSelect,
|
|
14544
14582
|
defaultView
|
|
14545
14583
|
}) => {
|
|
14546
|
-
const i18n =
|
|
14584
|
+
const i18n = useI18nContext8();
|
|
14547
14585
|
return /* @__PURE__ */ React20.createElement(
|
|
14548
|
-
|
|
14586
|
+
FormModalBase,
|
|
14549
14587
|
{
|
|
14550
14588
|
open,
|
|
14551
14589
|
mode,
|
|
@@ -14564,7 +14602,7 @@ var SavedViewsFormModal = ({
|
|
|
14564
14602
|
);
|
|
14565
14603
|
};
|
|
14566
14604
|
|
|
14567
|
-
// src/
|
|
14605
|
+
// src/components/modals/form-modal/SharedViewFormModal.tsx
|
|
14568
14606
|
import {
|
|
14569
14607
|
Banner as Banner2,
|
|
14570
14608
|
Button as Button5,
|
|
@@ -14576,7 +14614,7 @@ import {
|
|
|
14576
14614
|
P as P3,
|
|
14577
14615
|
spacing as spacing4,
|
|
14578
14616
|
Typography as Typography3,
|
|
14579
|
-
useI18nContext as
|
|
14617
|
+
useI18nContext as useI18nContext9
|
|
14580
14618
|
} from "@procore/core-react";
|
|
14581
14619
|
import * as React21 from "react";
|
|
14582
14620
|
var SharedViewFormModal = ({
|
|
@@ -14589,7 +14627,7 @@ var SharedViewFormModal = ({
|
|
|
14589
14627
|
isCreating,
|
|
14590
14628
|
resetCreateError
|
|
14591
14629
|
}) => {
|
|
14592
|
-
const I18n =
|
|
14630
|
+
const I18n = useI18nContext9();
|
|
14593
14631
|
const NAME_MAX_LENGTH = 150;
|
|
14594
14632
|
const errors = extractMessage(createError, I18n);
|
|
14595
14633
|
const handleNameChange = () => {
|
|
@@ -14718,21 +14756,28 @@ var SharedViewFormModal = ({
|
|
|
14718
14756
|
);
|
|
14719
14757
|
};
|
|
14720
14758
|
|
|
14721
|
-
// src/utils/
|
|
14722
|
-
import { useState as
|
|
14759
|
+
// src/utils/hooks/useViewSelection.ts
|
|
14760
|
+
import { useState as useState3, useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useMemo } from "react";
|
|
14723
14761
|
import { useSearchParams } from "react-router-dom";
|
|
14762
|
+
import { useI18nContext as useI18nContext10 } from "@procore/core-react";
|
|
14724
14763
|
|
|
14725
14764
|
// src/utils/viewStorage.ts
|
|
14726
14765
|
var ViewStorage = {
|
|
14727
14766
|
save(key, view) {
|
|
14728
14767
|
localStorage.setItem(key, JSON.stringify(view));
|
|
14729
14768
|
},
|
|
14730
|
-
load(key) {
|
|
14769
|
+
load(key, defaultView) {
|
|
14731
14770
|
try {
|
|
14732
14771
|
const stored = localStorage.getItem(key);
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14772
|
+
if (!stored)
|
|
14773
|
+
return defaultView;
|
|
14774
|
+
const parsed = JSON.parse(stored);
|
|
14775
|
+
if (!parsed)
|
|
14776
|
+
return defaultView;
|
|
14777
|
+
const isTableConfigOnly = !parsed.id && !parsed.share_token;
|
|
14778
|
+
return isTableConfigOnly ? { ...defaultView, table_config: parsed } : parsed;
|
|
14779
|
+
} catch {
|
|
14780
|
+
return defaultView;
|
|
14736
14781
|
}
|
|
14737
14782
|
},
|
|
14738
14783
|
remove(key) {
|
|
@@ -14740,7 +14785,7 @@ var ViewStorage = {
|
|
|
14740
14785
|
}
|
|
14741
14786
|
};
|
|
14742
14787
|
|
|
14743
|
-
// src/utils/
|
|
14788
|
+
// src/utils/hooks/useViewSelection.ts
|
|
14744
14789
|
var getUpdatedSearchParams = (currentParams, view) => {
|
|
14745
14790
|
const updatedParams = new URLSearchParams(currentParams);
|
|
14746
14791
|
if (view.id === "default") {
|
|
@@ -14755,55 +14800,72 @@ var getUpdatedSearchParams = (currentParams, view) => {
|
|
|
14755
14800
|
var checkIsViewSelected = (selectedView, viewId) => {
|
|
14756
14801
|
return (selectedView == null ? void 0 : selectedView.share_token) === viewId || (selectedView == null ? void 0 : selectedView.id) === viewId;
|
|
14757
14802
|
};
|
|
14758
|
-
var
|
|
14759
|
-
|
|
14760
|
-
|
|
14803
|
+
var findViewByToken = (views, token) => {
|
|
14804
|
+
return views.find((view) => view.share_token === token);
|
|
14805
|
+
};
|
|
14806
|
+
var setViewInUrl = (view, setSearchParams) => {
|
|
14807
|
+
setSearchParams(
|
|
14808
|
+
(currentParams) => getUpdatedSearchParams(currentParams, view),
|
|
14809
|
+
{ replace: true }
|
|
14810
|
+
);
|
|
14811
|
+
};
|
|
14812
|
+
var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
14813
|
+
if (previousParam && !currentParam) {
|
|
14814
|
+
setSearchParams(
|
|
14815
|
+
(currentParams) => {
|
|
14816
|
+
const updatedParams = new URLSearchParams(currentParams);
|
|
14817
|
+
updatedParams.set("saved-view", previousParam);
|
|
14818
|
+
return updatedParams;
|
|
14819
|
+
},
|
|
14820
|
+
{ replace: true }
|
|
14821
|
+
);
|
|
14822
|
+
}
|
|
14823
|
+
};
|
|
14824
|
+
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
14825
|
+
const I18n = useI18nContext10();
|
|
14826
|
+
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${config.projectId}_${config.userId}`;
|
|
14827
|
+
const temporaryStorageKey = `${storageKey}-temporary`;
|
|
14761
14828
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
14762
14829
|
const previousSavedViewParamRef = useRef2(null);
|
|
14763
|
-
const [selectedSavedView, setSelectedSavedView] =
|
|
14764
|
-
const stored = ViewStorage.load(storageKey);
|
|
14830
|
+
const [selectedSavedView, setSelectedSavedView] = useState3(() => {
|
|
14831
|
+
const stored = ViewStorage.load(storageKey, config.defaultView);
|
|
14765
14832
|
return stored ?? config.defaultView;
|
|
14766
14833
|
});
|
|
14767
|
-
const [temporaryView, setTemporaryView] =
|
|
14768
|
-
|
|
14834
|
+
const [temporaryView, setTemporaryView] = useState3(() => {
|
|
14835
|
+
const loaded = ViewStorage.load(temporaryStorageKey, config.defaultView);
|
|
14836
|
+
return loaded && (loaded.id === "temporary" || loaded.view_level === "temporary") ? loaded : null;
|
|
14769
14837
|
});
|
|
14770
|
-
const
|
|
14838
|
+
const persistViewToStorageAndUrl = useCallback2(
|
|
14771
14839
|
(view) => {
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
}
|
|
14840
|
+
ViewStorage.save(storageKey, view);
|
|
14841
|
+
setViewInUrl(view, setSearchParams);
|
|
14775
14842
|
},
|
|
14776
|
-
[
|
|
14843
|
+
[storageKey, setSearchParams]
|
|
14777
14844
|
);
|
|
14778
|
-
const
|
|
14779
|
-
(
|
|
14780
|
-
|
|
14781
|
-
|
|
14782
|
-
|
|
14783
|
-
|
|
14784
|
-
|
|
14785
|
-
);
|
|
14786
|
-
},
|
|
14787
|
-
[setSearchParams]
|
|
14845
|
+
const baseViews = useMemo(
|
|
14846
|
+
() => [...savedViews ?? [], ...presetViews ?? []],
|
|
14847
|
+
[savedViews, presetViews]
|
|
14848
|
+
);
|
|
14849
|
+
const allViews = useMemo(
|
|
14850
|
+
() => temporaryView ? [...baseViews, temporaryView] : baseViews,
|
|
14851
|
+
[baseViews, temporaryView]
|
|
14788
14852
|
);
|
|
14789
|
-
const baseViews = savedViews ?? [];
|
|
14790
|
-
const allViews = temporaryView ? [...baseViews, temporaryView] : baseViews;
|
|
14791
14853
|
const selectView = useCallback2(
|
|
14792
14854
|
(view) => {
|
|
14793
14855
|
const viewToSelect = config.onSelect({ item: view });
|
|
14794
14856
|
setSelectedSavedView(viewToSelect);
|
|
14795
|
-
|
|
14796
|
-
updateUrlForView(viewToSelect);
|
|
14857
|
+
persistViewToStorageAndUrl(viewToSelect);
|
|
14797
14858
|
return viewToSelect;
|
|
14798
14859
|
},
|
|
14799
|
-
[config,
|
|
14860
|
+
[config, persistViewToStorageAndUrl]
|
|
14800
14861
|
);
|
|
14801
14862
|
const createTemporaryView = useCallback2(
|
|
14802
14863
|
(fetchedView) => {
|
|
14803
14864
|
const tempView = {
|
|
14804
14865
|
...fetchedView,
|
|
14805
14866
|
id: "temporary",
|
|
14806
|
-
name: "
|
|
14867
|
+
name: I18n.t("savedViews.temporaryViewName"),
|
|
14868
|
+
view_level: "temporary"
|
|
14807
14869
|
};
|
|
14808
14870
|
ViewStorage.save(temporaryStorageKey, tempView);
|
|
14809
14871
|
setTemporaryView(tempView);
|
|
@@ -14826,7 +14888,7 @@ var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
|
14826
14888
|
if (isViewAlreadySelected(viewId)) {
|
|
14827
14889
|
return;
|
|
14828
14890
|
}
|
|
14829
|
-
const viewInList = allViews
|
|
14891
|
+
const viewInList = findViewByToken(allViews, viewId);
|
|
14830
14892
|
if (viewInList) {
|
|
14831
14893
|
selectView(viewInList);
|
|
14832
14894
|
} else {
|
|
@@ -14835,36 +14897,20 @@ var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
|
14835
14897
|
},
|
|
14836
14898
|
[isViewAlreadySelected, openSharedViewModal, allViews, selectView]
|
|
14837
14899
|
);
|
|
14838
|
-
|
|
14839
|
-
if (!allViews.length)
|
|
14840
|
-
return;
|
|
14900
|
+
useEffect2(() => {
|
|
14841
14901
|
const savedViewId = searchParams.get("saved-view");
|
|
14902
|
+
restoreUrlParameter(
|
|
14903
|
+
savedViewId,
|
|
14904
|
+
previousSavedViewParamRef.current,
|
|
14905
|
+
setSearchParams
|
|
14906
|
+
);
|
|
14842
14907
|
if (savedViewId) {
|
|
14843
|
-
|
|
14908
|
+
previousSavedViewParamRef.current = savedViewId;
|
|
14844
14909
|
}
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
savedViews,
|
|
14848
|
-
temporaryView,
|
|
14849
|
-
handleSavedViewFromUrl,
|
|
14850
|
-
allViews.length
|
|
14851
|
-
]);
|
|
14852
|
-
useEffect3(() => {
|
|
14853
|
-
const currentSavedViewParam = searchParams.get("saved-view");
|
|
14854
|
-
if (previousSavedViewParamRef.current && !currentSavedViewParam) {
|
|
14855
|
-
setSearchParams(
|
|
14856
|
-
(currentParams) => {
|
|
14857
|
-
const updatedParams = new URLSearchParams(currentParams);
|
|
14858
|
-
updatedParams.set("saved-view", previousSavedViewParamRef.current);
|
|
14859
|
-
return updatedParams;
|
|
14860
|
-
},
|
|
14861
|
-
{ replace: true }
|
|
14862
|
-
);
|
|
14863
|
-
}
|
|
14864
|
-
if (currentSavedViewParam) {
|
|
14865
|
-
previousSavedViewParamRef.current = currentSavedViewParam;
|
|
14910
|
+
if (savedViewId && allViews.length > 0) {
|
|
14911
|
+
handleSavedViewFromUrl(savedViewId);
|
|
14866
14912
|
}
|
|
14867
|
-
}, [searchParams
|
|
14913
|
+
}, [searchParams, handleSavedViewFromUrl, allViews.length]);
|
|
14868
14914
|
return {
|
|
14869
14915
|
selectedView: selectedSavedView,
|
|
14870
14916
|
selectView,
|
|
@@ -14875,7 +14921,7 @@ var useViewSelection = (config, savedViews, openSharedViewModal) => {
|
|
|
14875
14921
|
};
|
|
14876
14922
|
};
|
|
14877
14923
|
|
|
14878
|
-
// src/
|
|
14924
|
+
// src/components/saved-views/SavedViews.tsx
|
|
14879
14925
|
var StyledPanel = styled_components_esm_default.div`
|
|
14880
14926
|
border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
|
|
14881
14927
|
`;
|
|
@@ -14890,8 +14936,10 @@ var SavedViewsContent = (props) => {
|
|
|
14890
14936
|
};
|
|
14891
14937
|
const { data: savedViews } = useSavedViewsQuery(queryInput);
|
|
14892
14938
|
const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
|
|
14893
|
-
const
|
|
14894
|
-
const
|
|
14939
|
+
const { showToast } = useToastAlertContext3();
|
|
14940
|
+
const i18n = useI18nContext11();
|
|
14941
|
+
const [activeModal, setActiveModal] = useState4(null);
|
|
14942
|
+
const [modalData, setModalData] = useState4(null);
|
|
14895
14943
|
const openModal = (type, data) => {
|
|
14896
14944
|
setActiveModal(type);
|
|
14897
14945
|
setModalData(data ?? null);
|
|
@@ -14914,13 +14962,14 @@ var SavedViewsContent = (props) => {
|
|
|
14914
14962
|
{
|
|
14915
14963
|
domain: props.domain,
|
|
14916
14964
|
tableName: props.tableName,
|
|
14917
|
-
stickyViewsKey: props.stickyViewsKey,
|
|
14918
14965
|
userId: props.userId,
|
|
14919
14966
|
projectId,
|
|
14967
|
+
companyId,
|
|
14920
14968
|
defaultView: props.defaultView,
|
|
14921
14969
|
onSelect: props.onSelect
|
|
14922
14970
|
},
|
|
14923
14971
|
savedViews,
|
|
14972
|
+
props.presetViews,
|
|
14924
14973
|
openSharedViewModal
|
|
14925
14974
|
);
|
|
14926
14975
|
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
@@ -14934,8 +14983,9 @@ var SavedViewsContent = (props) => {
|
|
|
14934
14983
|
error: createError,
|
|
14935
14984
|
reset: resetCreateError
|
|
14936
14985
|
} = useCreateSavedView(queryInput);
|
|
14937
|
-
|
|
14986
|
+
useEffect3(() => {
|
|
14938
14987
|
if (fetchError) {
|
|
14988
|
+
showToast.error(i18n.t("savedViews.errors.notFound"));
|
|
14939
14989
|
selectView(selectedView ?? props.defaultView);
|
|
14940
14990
|
closeModal();
|
|
14941
14991
|
}
|
|
@@ -14959,6 +15009,7 @@ var SavedViewsContent = (props) => {
|
|
|
14959
15009
|
};
|
|
14960
15010
|
createSavedView(viewToCreate, {
|
|
14961
15011
|
onSuccess: (newView) => {
|
|
15012
|
+
showToast.success(i18n.t("savedViews.create.success"));
|
|
14962
15013
|
selectView(newView);
|
|
14963
15014
|
closeModal();
|
|
14964
15015
|
}
|
|
@@ -14980,7 +15031,6 @@ var SavedViewsContent = (props) => {
|
|
|
14980
15031
|
deleteSelectedView();
|
|
14981
15032
|
closeModal();
|
|
14982
15033
|
};
|
|
14983
|
-
const i18n = useI18nContext11();
|
|
14984
15034
|
return /* @__PURE__ */ React22.createElement(StyledPanel, { provider: props.provider }, /* @__PURE__ */ React22.createElement(
|
|
14985
15035
|
ExpandedPanel,
|
|
14986
15036
|
{
|
|
@@ -15015,7 +15065,7 @@ var SavedViewsContent = (props) => {
|
|
|
15015
15065
|
selectedSavedView: selectedView,
|
|
15016
15066
|
tableConfig: props.tableConfig,
|
|
15017
15067
|
defaultView: props.defaultView,
|
|
15018
|
-
|
|
15068
|
+
presetViews: props.presetViews,
|
|
15019
15069
|
savedViews: allViews,
|
|
15020
15070
|
provider: props.provider,
|
|
15021
15071
|
userId: props.userId,
|
|
@@ -15023,7 +15073,7 @@ var SavedViewsContent = (props) => {
|
|
|
15023
15073
|
}
|
|
15024
15074
|
))
|
|
15025
15075
|
), (isModalOpen("create" /* CREATE */) || isModalOpen("update" /* UPDATE */)) && /* @__PURE__ */ React22.createElement(
|
|
15026
|
-
|
|
15076
|
+
FormModal,
|
|
15027
15077
|
{
|
|
15028
15078
|
open: true,
|
|
15029
15079
|
mode: activeModal,
|
|
@@ -15058,31 +15108,125 @@ var SavedViewsContent = (props) => {
|
|
|
15058
15108
|
));
|
|
15059
15109
|
};
|
|
15060
15110
|
var SavedViews = (props) => {
|
|
15061
|
-
return /* @__PURE__ */ React22.createElement(EnvironmentI18nProvider, null, /* @__PURE__ */ React22.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React22.createElement(SavedViewsContent, { ...props })));
|
|
15111
|
+
return /* @__PURE__ */ React22.createElement(EnvironmentI18nProvider, null, /* @__PURE__ */ React22.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React22.createElement(ToastAlertProvider, null, /* @__PURE__ */ React22.createElement(SavedViewsContent, { ...props }))));
|
|
15112
|
+
};
|
|
15113
|
+
|
|
15114
|
+
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15115
|
+
import React23, { useCallback as useCallback4 } from "react";
|
|
15116
|
+
|
|
15117
|
+
// src/components/adapters/smart-grid/SmartGridDefaultSavedView.tsx
|
|
15118
|
+
import { useMemo as useMemo2 } from "react";
|
|
15119
|
+
var DEFAULT_COLUMN_STATE = {
|
|
15120
|
+
hide: false,
|
|
15121
|
+
pinned: null,
|
|
15122
|
+
width: 200,
|
|
15123
|
+
sort: null,
|
|
15124
|
+
sortIndex: null,
|
|
15125
|
+
pivot: false,
|
|
15126
|
+
pivotIndex: null,
|
|
15127
|
+
aggFunc: null,
|
|
15128
|
+
rowGroup: false,
|
|
15129
|
+
rowGroupIndex: null,
|
|
15130
|
+
flex: null
|
|
15131
|
+
};
|
|
15132
|
+
var getColumnStateFromDefs = (columnDefs) => {
|
|
15133
|
+
return columnDefs.map((colDef) => {
|
|
15134
|
+
const field = colDef.field ?? colDef.colId;
|
|
15135
|
+
if (!field)
|
|
15136
|
+
return null;
|
|
15137
|
+
return {
|
|
15138
|
+
colId: field,
|
|
15139
|
+
hide: colDef.hide ?? false,
|
|
15140
|
+
pinned: colDef.pinned ?? null,
|
|
15141
|
+
width: colDef.width ?? colDef.minWidth ?? DEFAULT_COLUMN_STATE.width,
|
|
15142
|
+
sort: null,
|
|
15143
|
+
sortIndex: null,
|
|
15144
|
+
pivot: false,
|
|
15145
|
+
pivotIndex: null,
|
|
15146
|
+
aggFunc: null,
|
|
15147
|
+
rowGroup: false,
|
|
15148
|
+
rowGroupIndex: null,
|
|
15149
|
+
flex: colDef.flex ?? null
|
|
15150
|
+
};
|
|
15151
|
+
}).filter((col) => col !== null);
|
|
15152
|
+
};
|
|
15153
|
+
var extractDefaultView = (gridApi, receivedConfig) => {
|
|
15154
|
+
var _a, _b;
|
|
15155
|
+
const columnDefs = gridApi.getColumnDefs() ?? [];
|
|
15156
|
+
const defaultColumnState = ((_a = receivedConfig == null ? void 0 : receivedConfig.columnState) == null ? void 0 : _a.length) ? receivedConfig.columnState : getColumnStateFromDefs(columnDefs);
|
|
15157
|
+
const result = {
|
|
15158
|
+
columnState: defaultColumnState,
|
|
15159
|
+
columnGroupState: (receivedConfig == null ? void 0 : receivedConfig.columnGroupState) ?? [],
|
|
15160
|
+
rowGroupState: (receivedConfig == null ? void 0 : receivedConfig.rowGroupState) ?? [],
|
|
15161
|
+
filterState: (receivedConfig == null ? void 0 : receivedConfig.filterState) ?? {},
|
|
15162
|
+
rowHeight: (receivedConfig == null ? void 0 : receivedConfig.rowHeight) ?? ((_b = gridApi.getSizesForCurrentTheme()) == null ? void 0 : _b.rowHeight)
|
|
15163
|
+
};
|
|
15164
|
+
return result;
|
|
15165
|
+
};
|
|
15166
|
+
var useNormalizedDefaultViews = (defaultViews, gridApi) => {
|
|
15167
|
+
return useMemo2(() => {
|
|
15168
|
+
if (!gridApi)
|
|
15169
|
+
return defaultViews.map((view) => ({ ...view, share_token: view.id }));
|
|
15170
|
+
return defaultViews.map((view) => ({
|
|
15171
|
+
...view,
|
|
15172
|
+
share_token: view.id,
|
|
15173
|
+
table_config: extractDefaultView(gridApi, view.table_config)
|
|
15174
|
+
}));
|
|
15175
|
+
}, [defaultViews, gridApi]);
|
|
15062
15176
|
};
|
|
15063
15177
|
|
|
15064
|
-
// src/
|
|
15065
|
-
import {
|
|
15066
|
-
var
|
|
15067
|
-
|
|
15178
|
+
// src/components/adapters/smart-grid/useSmartGridConfig.ts
|
|
15179
|
+
import { useState as useState5, useEffect as useEffect4 } from "react";
|
|
15180
|
+
var GRID_STATE_EVENTS = [
|
|
15181
|
+
"sortChanged",
|
|
15182
|
+
"filterOpened",
|
|
15183
|
+
"filterChanged",
|
|
15184
|
+
"columnRowGroupChanged",
|
|
15185
|
+
"dragStopped",
|
|
15186
|
+
"columnResized",
|
|
15187
|
+
"columnVisible",
|
|
15188
|
+
"columnPinned",
|
|
15189
|
+
"columnMoved",
|
|
15190
|
+
"modelUpdated",
|
|
15191
|
+
"gridColumnsChanged",
|
|
15192
|
+
"gridReady"
|
|
15193
|
+
];
|
|
15194
|
+
var useSmartGridConfig = (gridApi) => {
|
|
15195
|
+
const [config, setConfig] = useState5(
|
|
15196
|
+
() => getSmartGridConfig(gridApi)
|
|
15197
|
+
);
|
|
15198
|
+
useEffect4(() => {
|
|
15199
|
+
if (!gridApi)
|
|
15200
|
+
return;
|
|
15201
|
+
const updateConfig = () => {
|
|
15202
|
+
setConfig(getSmartGridConfig(gridApi));
|
|
15203
|
+
};
|
|
15204
|
+
GRID_STATE_EVENTS.forEach((event) => {
|
|
15205
|
+
gridApi.addEventListener(event, updateConfig);
|
|
15206
|
+
});
|
|
15207
|
+
return () => {
|
|
15208
|
+
GRID_STATE_EVENTS.forEach((event) => {
|
|
15209
|
+
gridApi.removeEventListener(event, updateConfig);
|
|
15210
|
+
});
|
|
15211
|
+
};
|
|
15212
|
+
}, [gridApi]);
|
|
15213
|
+
return { config, setConfig };
|
|
15068
15214
|
};
|
|
15215
|
+
|
|
15216
|
+
// src/components/adapters/smart-grid/SmartGridSavedViews.tsx
|
|
15069
15217
|
var SmartGridSavedViews = (props) => {
|
|
15070
15218
|
const { gridApi, userId, projectId, companyId } = props;
|
|
15071
15219
|
const { config: tableConfig, setConfig: setTableConfig } = useSmartGridConfig(gridApi);
|
|
15072
|
-
const
|
|
15073
|
-
|
|
15074
|
-
domain: props.domain
|
|
15075
|
-
});
|
|
15220
|
+
const presetViews = useNormalizedDefaultViews(props.defaultViews, gridApi);
|
|
15221
|
+
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15076
15222
|
const onSelect = useCallback4(
|
|
15077
15223
|
({ item }) => {
|
|
15078
15224
|
if (!gridApi)
|
|
15079
15225
|
return item;
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
gridApi
|
|
15083
|
-
|
|
15084
|
-
gridApi.setGridOption("rowHeight", props.defaultRowHeight);
|
|
15085
|
-
gridApi.refreshCells();
|
|
15226
|
+
const isPresetView = item.view_level === "default";
|
|
15227
|
+
if (isPresetView) {
|
|
15228
|
+
updateTableConfig(item, gridApi, "smart-grid");
|
|
15229
|
+
setTableConfig(item.table_config);
|
|
15086
15230
|
return item;
|
|
15087
15231
|
}
|
|
15088
15232
|
const updatedView = {
|
|
@@ -15096,22 +15240,9 @@ var SmartGridSavedViews = (props) => {
|
|
|
15096
15240
|
setTableConfig(updatedView.table_config);
|
|
15097
15241
|
return updatedView;
|
|
15098
15242
|
},
|
|
15099
|
-
[
|
|
15100
|
-
gridApi,
|
|
15101
|
-
props.defaultViewFilters,
|
|
15102
|
-
props.defaultRowHeight,
|
|
15103
|
-
tableConfig,
|
|
15104
|
-
setTableConfig
|
|
15105
|
-
]
|
|
15106
|
-
);
|
|
15107
|
-
const stickyViewsKey = generateStickyViewsKey(
|
|
15108
|
-
props.domain,
|
|
15109
|
-
props.tableName,
|
|
15110
|
-
userId,
|
|
15111
|
-
projectId,
|
|
15112
|
-
companyId
|
|
15243
|
+
[gridApi, tableConfig, setTableConfig]
|
|
15113
15244
|
);
|
|
15114
|
-
return /* @__PURE__ */ React23.createElement(
|
|
15245
|
+
return /* @__PURE__ */ React23.createElement(
|
|
15115
15246
|
SavedViews,
|
|
15116
15247
|
{
|
|
15117
15248
|
onSelect,
|
|
@@ -15121,14 +15252,14 @@ var SmartGridSavedViews = (props) => {
|
|
|
15121
15252
|
companyId,
|
|
15122
15253
|
provider: "smart-grid",
|
|
15123
15254
|
defaultView,
|
|
15255
|
+
presetViews,
|
|
15124
15256
|
tableName: props.tableName,
|
|
15125
|
-
tableConfig
|
|
15126
|
-
stickyViewsKey
|
|
15257
|
+
tableConfig
|
|
15127
15258
|
}
|
|
15128
|
-
)
|
|
15259
|
+
);
|
|
15129
15260
|
};
|
|
15130
15261
|
|
|
15131
|
-
// src/
|
|
15262
|
+
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
15132
15263
|
import React24, {
|
|
15133
15264
|
forwardRef as forwardRef11,
|
|
15134
15265
|
useImperativeHandle,
|
|
@@ -15136,10 +15267,9 @@ import React24, {
|
|
|
15136
15267
|
useCallback as useCallback5
|
|
15137
15268
|
} from "react";
|
|
15138
15269
|
|
|
15139
|
-
// src/
|
|
15140
|
-
import { useMemo } from "react";
|
|
15141
|
-
|
|
15142
|
-
var DEFAULT_COLUMN_STATE = {
|
|
15270
|
+
// src/components/adapters/data-table/DataTableDefaultSavedView.tsx
|
|
15271
|
+
import { useMemo as useMemo3 } from "react";
|
|
15272
|
+
var DEFAULT_COLUMN_STATE2 = {
|
|
15143
15273
|
hidden: false,
|
|
15144
15274
|
pinned: null,
|
|
15145
15275
|
width: 200,
|
|
@@ -15154,7 +15284,7 @@ var getColumnState = (columnDefinitions) => {
|
|
|
15154
15284
|
if (column.field.includes("custom_field")) {
|
|
15155
15285
|
return {
|
|
15156
15286
|
field: column.field,
|
|
15157
|
-
...
|
|
15287
|
+
...DEFAULT_COLUMN_STATE2
|
|
15158
15288
|
};
|
|
15159
15289
|
}
|
|
15160
15290
|
return {
|
|
@@ -15165,11 +15295,11 @@ var getColumnState = (columnDefinitions) => {
|
|
|
15165
15295
|
rowGroupIndex: null,
|
|
15166
15296
|
sort: null,
|
|
15167
15297
|
sortIndex: null,
|
|
15168
|
-
width: (column.minWidth ??
|
|
15298
|
+
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
|
|
15169
15299
|
};
|
|
15170
15300
|
});
|
|
15171
15301
|
};
|
|
15172
|
-
var
|
|
15302
|
+
var extractDefaultView2 = (columnDefinitions, receivedConfigFromTool) => {
|
|
15173
15303
|
var _a, _b, _c;
|
|
15174
15304
|
const defaultColumnState = getColumnState(columnDefinitions);
|
|
15175
15305
|
const result = {
|
|
@@ -15185,52 +15315,37 @@ var extractDefaultView = (columnDefinitions, receivedConfigFromTool) => {
|
|
|
15185
15315
|
};
|
|
15186
15316
|
return result;
|
|
15187
15317
|
};
|
|
15188
|
-
var
|
|
15189
|
-
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
|
|
15193
|
-
|
|
15194
|
-
}
|
|
15195
|
-
|
|
15196
|
-
const name = useDefaultViewName2(props.domain, props.defaultViewName);
|
|
15197
|
-
const extractedDefaultConfig = useMemo(
|
|
15198
|
-
() => extractDefaultView(props.columnDefinitions, props.receivedConfigFromTool),
|
|
15199
|
-
[props.columnDefinitions, props.receivedConfigFromTool]
|
|
15318
|
+
var useNormalizedDefaultViews2 = (defaultViews, columnDefinitions) => {
|
|
15319
|
+
return useMemo3(
|
|
15320
|
+
() => defaultViews.map((view) => ({
|
|
15321
|
+
...view,
|
|
15322
|
+
share_token: "",
|
|
15323
|
+
table_config: extractDefaultView2(columnDefinitions, view.table_config)
|
|
15324
|
+
})),
|
|
15325
|
+
[defaultViews, columnDefinitions]
|
|
15200
15326
|
);
|
|
15201
|
-
return {
|
|
15202
|
-
id: "default",
|
|
15203
|
-
view_level: "default",
|
|
15204
|
-
name,
|
|
15205
|
-
table_config: extractedDefaultConfig
|
|
15206
|
-
};
|
|
15207
15327
|
};
|
|
15208
15328
|
|
|
15209
|
-
// src/
|
|
15210
|
-
import { ToastAlertProvider as ToastAlertProvider2 } from "@procore/toast-alert";
|
|
15211
|
-
var generateStickyViewsKey2 = (domain, tableName, userId, projectId, companyId) => {
|
|
15212
|
-
return `savedView-${domain}-${tableName}-${companyId}-${projectId}-${userId}`;
|
|
15213
|
-
};
|
|
15329
|
+
// src/components/adapters/data-table/DataTableSavedViews.tsx
|
|
15214
15330
|
var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
15215
15331
|
const { tableApi, userId, projectId, companyId } = props;
|
|
15332
|
+
const presetViews = useNormalizedDefaultViews2(
|
|
15333
|
+
props.defaultViews,
|
|
15334
|
+
props.columnDefinitions
|
|
15335
|
+
);
|
|
15336
|
+
const defaultView = presetViews.find((view) => view.id === "default") ?? presetViews[0];
|
|
15216
15337
|
const [internalTableConfig, setInternalTableConfig] = useState6(
|
|
15217
|
-
props.
|
|
15338
|
+
ViewStorage.load(props.stickyViewsKey, defaultView).table_config
|
|
15218
15339
|
);
|
|
15219
15340
|
useImperativeHandle(ref, () => ({
|
|
15220
15341
|
setTableConfig: (newConfig) => {
|
|
15221
15342
|
setInternalTableConfig(newConfig);
|
|
15222
15343
|
}
|
|
15223
15344
|
}));
|
|
15224
|
-
const defaultView = useDefaultView2({
|
|
15225
|
-
defaultViewName: props.defaultViewName,
|
|
15226
|
-
receivedConfigFromTool: props.defaultViewConfig,
|
|
15227
|
-
domain: props.domain,
|
|
15228
|
-
columnDefinitions: props.columnDefinitions
|
|
15229
|
-
});
|
|
15230
15345
|
const onSelect = useCallback5(
|
|
15231
15346
|
({ item }) => {
|
|
15232
|
-
const
|
|
15233
|
-
const updatedView =
|
|
15347
|
+
const isPresetView = item.view_level === "default";
|
|
15348
|
+
const updatedView = isPresetView ? item : {
|
|
15234
15349
|
...item,
|
|
15235
15350
|
table_config: customAndConfigSync(
|
|
15236
15351
|
item.table_config,
|
|
@@ -15246,14 +15361,7 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
15246
15361
|
if (!internalTableConfig) {
|
|
15247
15362
|
return null;
|
|
15248
15363
|
}
|
|
15249
|
-
|
|
15250
|
-
props.domain,
|
|
15251
|
-
props.tableName,
|
|
15252
|
-
userId,
|
|
15253
|
-
projectId,
|
|
15254
|
-
companyId
|
|
15255
|
-
);
|
|
15256
|
-
return /* @__PURE__ */ React24.createElement(ToastAlertProvider2, null, /* @__PURE__ */ React24.createElement(
|
|
15364
|
+
return /* @__PURE__ */ React24.createElement(
|
|
15257
15365
|
SavedViews,
|
|
15258
15366
|
{
|
|
15259
15367
|
onSelect,
|
|
@@ -15263,20 +15371,21 @@ var DataTableSavedViews = forwardRef11((props, ref) => {
|
|
|
15263
15371
|
companyId,
|
|
15264
15372
|
provider: "data-table",
|
|
15265
15373
|
defaultView,
|
|
15374
|
+
presetViews,
|
|
15266
15375
|
tableName: props.tableName,
|
|
15267
|
-
tableConfig: internalTableConfig
|
|
15268
|
-
stickyViewsKey
|
|
15376
|
+
tableConfig: internalTableConfig
|
|
15269
15377
|
}
|
|
15270
|
-
)
|
|
15378
|
+
);
|
|
15271
15379
|
});
|
|
15272
15380
|
DataTableSavedViews.displayName = "DataTableSavedViews";
|
|
15273
15381
|
export {
|
|
15274
15382
|
DataTableSavedViews,
|
|
15275
15383
|
ExpandedPanel,
|
|
15384
|
+
FormModal,
|
|
15276
15385
|
PanelContent,
|
|
15277
15386
|
SavedViewCollectionMenuItem,
|
|
15387
|
+
SavedViews,
|
|
15278
15388
|
SavedViewsDeleteConfirmationModalShared,
|
|
15279
|
-
SavedViewsFormModal,
|
|
15280
15389
|
SmartGridSavedViews,
|
|
15281
15390
|
getTranslations,
|
|
15282
15391
|
useSavedViewsPanel_default as useSavedViewsPanel
|