@procore/saved-views 1.1.0-alpha.6 → 1.1.0-alpha.7
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.js +57 -4
- package/dist/legacy/index.mjs +57 -4
- package/dist/modern/index.js +56 -4
- package/dist/modern/index.mjs +56 -4
- package/package.json +2 -2
package/dist/legacy/index.js
CHANGED
|
@@ -5601,7 +5601,7 @@ var de_DE_default = {
|
|
|
5601
5601
|
required: "Kann nicht leer sein.",
|
|
5602
5602
|
duplicateName: "Es existiert bereits eine gespeicherte Ansicht mit diesem Namen. Bitte benennen Sie sie um und versuchen Sie es erneut.",
|
|
5603
5603
|
unknown: "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.",
|
|
5604
|
-
title: "
|
|
5604
|
+
title: "Es tut uns leid, wir konnten diese gespeicherte Ansicht nicht {{mode}}",
|
|
5605
5605
|
description: {
|
|
5606
5606
|
create: "Bitte beheben Sie die folgenden Fehler und versuchen Sie erneut, die Datei zu erstellen",
|
|
5607
5607
|
update: "Bitte beheben Sie die folgenden Fehler und versuchen Sie erneut, die Aktualisierung durchzuf\xFChren"
|
|
@@ -5625,7 +5625,7 @@ var de_DE_default = {
|
|
|
5625
5625
|
success: "Der Link wurde erfolgreich erstellt und in die Zwischenablage kopiert."
|
|
5626
5626
|
},
|
|
5627
5627
|
errors: {
|
|
5628
|
-
fetch: "
|
|
5628
|
+
fetch: "Es tut uns leid, die gespeicherten Ansichten konnten nicht abgerufen werden. Versuchen Sie es noch einmal.",
|
|
5629
5629
|
create: "Die gespeicherte Ansicht konnte leider nicht erstellt werden. Versuchen Sie es noch einmal.",
|
|
5630
5630
|
update: "Die gespeicherte Ansicht konnte leider nicht aktualisiert werden. Versuchen Sie es noch einmal.",
|
|
5631
5631
|
delete: "Die gespeicherte Ansicht konnte leider nicht gel\xF6scht werden. Versuchen Sie es noch einmal.",
|
|
@@ -10131,6 +10131,18 @@ var ViewStorage = {
|
|
|
10131
10131
|
};
|
|
10132
10132
|
|
|
10133
10133
|
// src/utils/hooks/useViewSelection.ts
|
|
10134
|
+
var isSmartGridConfig = (config) => {
|
|
10135
|
+
return config != null && "rowGroupState" in config;
|
|
10136
|
+
};
|
|
10137
|
+
var areRowGroupStatesEqual = (a2, b2) => {
|
|
10138
|
+
if (!a2 && !b2)
|
|
10139
|
+
return true;
|
|
10140
|
+
if (!a2 || !b2)
|
|
10141
|
+
return false;
|
|
10142
|
+
if (a2.length !== b2.length)
|
|
10143
|
+
return false;
|
|
10144
|
+
return a2.every((val, idx) => val === b2[idx]);
|
|
10145
|
+
};
|
|
10134
10146
|
var getUpdatedSearchParams = (currentParams, view) => {
|
|
10135
10147
|
const updatedParams = new URLSearchParams(currentParams);
|
|
10136
10148
|
if (view.id === "default") {
|
|
@@ -10166,7 +10178,7 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
10166
10178
|
);
|
|
10167
10179
|
}
|
|
10168
10180
|
};
|
|
10169
|
-
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
10181
|
+
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, tableConfig) => {
|
|
10170
10182
|
const I18n = (0, import_core_react14.useI18nContext)();
|
|
10171
10183
|
const projectIdSegment = config.projectId ?? "company";
|
|
10172
10184
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
@@ -10257,6 +10269,46 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
10257
10269
|
handleSavedViewFromUrl(savedViewId);
|
|
10258
10270
|
}
|
|
10259
10271
|
}, [searchParams, handleSavedViewFromUrl, allViews.length]);
|
|
10272
|
+
const previousRowGroupStateRef = (0, import_react12.useRef)(
|
|
10273
|
+
isSmartGridConfig(tableConfig) ? tableConfig.rowGroupState : void 0
|
|
10274
|
+
);
|
|
10275
|
+
const selectedViewRef = (0, import_react12.useRef)(selectedSavedView);
|
|
10276
|
+
selectedViewRef.current = selectedSavedView;
|
|
10277
|
+
const defaultViewRef = (0, import_react12.useRef)(config.defaultView);
|
|
10278
|
+
defaultViewRef.current = config.defaultView;
|
|
10279
|
+
(0, import_react12.useEffect)(() => {
|
|
10280
|
+
var _a;
|
|
10281
|
+
if (!isSmartGridConfig(tableConfig) || !(presetViews == null ? void 0 : presetViews.length))
|
|
10282
|
+
return;
|
|
10283
|
+
const currentView = selectedViewRef.current;
|
|
10284
|
+
const isPresetSelected = !currentView || currentView.view_level === "default";
|
|
10285
|
+
if (!isPresetSelected)
|
|
10286
|
+
return;
|
|
10287
|
+
const currentRowGroupState = tableConfig.rowGroupState;
|
|
10288
|
+
if (!currentRowGroupState)
|
|
10289
|
+
return;
|
|
10290
|
+
if (areRowGroupStatesEqual(
|
|
10291
|
+
previousRowGroupStateRef.current,
|
|
10292
|
+
currentRowGroupState
|
|
10293
|
+
)) {
|
|
10294
|
+
return;
|
|
10295
|
+
}
|
|
10296
|
+
previousRowGroupStateRef.current = currentRowGroupState;
|
|
10297
|
+
const matchingPreset = presetViews.find((preset) => {
|
|
10298
|
+
const presetConfig = isSmartGridConfig(preset.table_config) ? preset.table_config : void 0;
|
|
10299
|
+
return areRowGroupStatesEqual(
|
|
10300
|
+
presetConfig == null ? void 0 : presetConfig.rowGroupState,
|
|
10301
|
+
currentRowGroupState
|
|
10302
|
+
);
|
|
10303
|
+
});
|
|
10304
|
+
if (matchingPreset && matchingPreset.id !== ((_a = selectedViewRef.current) == null ? void 0 : _a.id)) {
|
|
10305
|
+
setSelectedSavedView(matchingPreset);
|
|
10306
|
+
persistViewToStorageAndUrl(matchingPreset);
|
|
10307
|
+
} else if (!matchingPreset && (currentView == null ? void 0 : currentView.id) !== defaultViewRef.current.id) {
|
|
10308
|
+
setSelectedSavedView(defaultViewRef.current);
|
|
10309
|
+
persistViewToStorageAndUrl(defaultViewRef.current);
|
|
10310
|
+
}
|
|
10311
|
+
}, [tableConfig, presetViews, persistViewToStorageAndUrl]);
|
|
10260
10312
|
return {
|
|
10261
10313
|
selectedView: selectedSavedView,
|
|
10262
10314
|
selectView,
|
|
@@ -10316,7 +10368,8 @@ var SavedViewsContent = (props) => {
|
|
|
10316
10368
|
},
|
|
10317
10369
|
savedViews,
|
|
10318
10370
|
props.presetViews,
|
|
10319
|
-
openSharedViewModal
|
|
10371
|
+
openSharedViewModal,
|
|
10372
|
+
props.tableConfig
|
|
10320
10373
|
);
|
|
10321
10374
|
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
10322
10375
|
(modalData == null ? void 0 : modalData.viewId) ?? null,
|
package/dist/legacy/index.mjs
CHANGED
|
@@ -5588,7 +5588,7 @@ var de_DE_default = {
|
|
|
5588
5588
|
required: "Kann nicht leer sein.",
|
|
5589
5589
|
duplicateName: "Es existiert bereits eine gespeicherte Ansicht mit diesem Namen. Bitte benennen Sie sie um und versuchen Sie es erneut.",
|
|
5590
5590
|
unknown: "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.",
|
|
5591
|
-
title: "
|
|
5591
|
+
title: "Es tut uns leid, wir konnten diese gespeicherte Ansicht nicht {{mode}}",
|
|
5592
5592
|
description: {
|
|
5593
5593
|
create: "Bitte beheben Sie die folgenden Fehler und versuchen Sie erneut, die Datei zu erstellen",
|
|
5594
5594
|
update: "Bitte beheben Sie die folgenden Fehler und versuchen Sie erneut, die Aktualisierung durchzuf\xFChren"
|
|
@@ -5612,7 +5612,7 @@ var de_DE_default = {
|
|
|
5612
5612
|
success: "Der Link wurde erfolgreich erstellt und in die Zwischenablage kopiert."
|
|
5613
5613
|
},
|
|
5614
5614
|
errors: {
|
|
5615
|
-
fetch: "
|
|
5615
|
+
fetch: "Es tut uns leid, die gespeicherten Ansichten konnten nicht abgerufen werden. Versuchen Sie es noch einmal.",
|
|
5616
5616
|
create: "Die gespeicherte Ansicht konnte leider nicht erstellt werden. Versuchen Sie es noch einmal.",
|
|
5617
5617
|
update: "Die gespeicherte Ansicht konnte leider nicht aktualisiert werden. Versuchen Sie es noch einmal.",
|
|
5618
5618
|
delete: "Die gespeicherte Ansicht konnte leider nicht gel\xF6scht werden. Versuchen Sie es noch einmal.",
|
|
@@ -10171,6 +10171,18 @@ var ViewStorage = {
|
|
|
10171
10171
|
};
|
|
10172
10172
|
|
|
10173
10173
|
// src/utils/hooks/useViewSelection.ts
|
|
10174
|
+
var isSmartGridConfig = (config) => {
|
|
10175
|
+
return config != null && "rowGroupState" in config;
|
|
10176
|
+
};
|
|
10177
|
+
var areRowGroupStatesEqual = (a2, b2) => {
|
|
10178
|
+
if (!a2 && !b2)
|
|
10179
|
+
return true;
|
|
10180
|
+
if (!a2 || !b2)
|
|
10181
|
+
return false;
|
|
10182
|
+
if (a2.length !== b2.length)
|
|
10183
|
+
return false;
|
|
10184
|
+
return a2.every((val, idx) => val === b2[idx]);
|
|
10185
|
+
};
|
|
10174
10186
|
var getUpdatedSearchParams = (currentParams, view) => {
|
|
10175
10187
|
const updatedParams = new URLSearchParams(currentParams);
|
|
10176
10188
|
if (view.id === "default") {
|
|
@@ -10206,7 +10218,7 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
10206
10218
|
);
|
|
10207
10219
|
}
|
|
10208
10220
|
};
|
|
10209
|
-
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
10221
|
+
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, tableConfig) => {
|
|
10210
10222
|
const I18n = useI18nContext11();
|
|
10211
10223
|
const projectIdSegment = config.projectId ?? "company";
|
|
10212
10224
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
@@ -10297,6 +10309,46 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
10297
10309
|
handleSavedViewFromUrl(savedViewId);
|
|
10298
10310
|
}
|
|
10299
10311
|
}, [searchParams, handleSavedViewFromUrl, allViews.length]);
|
|
10312
|
+
const previousRowGroupStateRef = useRef2(
|
|
10313
|
+
isSmartGridConfig(tableConfig) ? tableConfig.rowGroupState : void 0
|
|
10314
|
+
);
|
|
10315
|
+
const selectedViewRef = useRef2(selectedSavedView);
|
|
10316
|
+
selectedViewRef.current = selectedSavedView;
|
|
10317
|
+
const defaultViewRef = useRef2(config.defaultView);
|
|
10318
|
+
defaultViewRef.current = config.defaultView;
|
|
10319
|
+
useEffect3(() => {
|
|
10320
|
+
var _a;
|
|
10321
|
+
if (!isSmartGridConfig(tableConfig) || !(presetViews == null ? void 0 : presetViews.length))
|
|
10322
|
+
return;
|
|
10323
|
+
const currentView = selectedViewRef.current;
|
|
10324
|
+
const isPresetSelected = !currentView || currentView.view_level === "default";
|
|
10325
|
+
if (!isPresetSelected)
|
|
10326
|
+
return;
|
|
10327
|
+
const currentRowGroupState = tableConfig.rowGroupState;
|
|
10328
|
+
if (!currentRowGroupState)
|
|
10329
|
+
return;
|
|
10330
|
+
if (areRowGroupStatesEqual(
|
|
10331
|
+
previousRowGroupStateRef.current,
|
|
10332
|
+
currentRowGroupState
|
|
10333
|
+
)) {
|
|
10334
|
+
return;
|
|
10335
|
+
}
|
|
10336
|
+
previousRowGroupStateRef.current = currentRowGroupState;
|
|
10337
|
+
const matchingPreset = presetViews.find((preset) => {
|
|
10338
|
+
const presetConfig = isSmartGridConfig(preset.table_config) ? preset.table_config : void 0;
|
|
10339
|
+
return areRowGroupStatesEqual(
|
|
10340
|
+
presetConfig == null ? void 0 : presetConfig.rowGroupState,
|
|
10341
|
+
currentRowGroupState
|
|
10342
|
+
);
|
|
10343
|
+
});
|
|
10344
|
+
if (matchingPreset && matchingPreset.id !== ((_a = selectedViewRef.current) == null ? void 0 : _a.id)) {
|
|
10345
|
+
setSelectedSavedView(matchingPreset);
|
|
10346
|
+
persistViewToStorageAndUrl(matchingPreset);
|
|
10347
|
+
} else if (!matchingPreset && (currentView == null ? void 0 : currentView.id) !== defaultViewRef.current.id) {
|
|
10348
|
+
setSelectedSavedView(defaultViewRef.current);
|
|
10349
|
+
persistViewToStorageAndUrl(defaultViewRef.current);
|
|
10350
|
+
}
|
|
10351
|
+
}, [tableConfig, presetViews, persistViewToStorageAndUrl]);
|
|
10300
10352
|
return {
|
|
10301
10353
|
selectedView: selectedSavedView,
|
|
10302
10354
|
selectView,
|
|
@@ -10356,7 +10408,8 @@ var SavedViewsContent = (props) => {
|
|
|
10356
10408
|
},
|
|
10357
10409
|
savedViews,
|
|
10358
10410
|
props.presetViews,
|
|
10359
|
-
openSharedViewModal
|
|
10411
|
+
openSharedViewModal,
|
|
10412
|
+
props.tableConfig
|
|
10360
10413
|
);
|
|
10361
10414
|
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
10362
10415
|
(modalData == null ? void 0 : modalData.viewId) ?? null,
|
package/dist/modern/index.js
CHANGED
|
@@ -5601,7 +5601,7 @@ var de_DE_default = {
|
|
|
5601
5601
|
required: "Kann nicht leer sein.",
|
|
5602
5602
|
duplicateName: "Es existiert bereits eine gespeicherte Ansicht mit diesem Namen. Bitte benennen Sie sie um und versuchen Sie es erneut.",
|
|
5603
5603
|
unknown: "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.",
|
|
5604
|
-
title: "
|
|
5604
|
+
title: "Es tut uns leid, wir konnten diese gespeicherte Ansicht nicht {{mode}}",
|
|
5605
5605
|
description: {
|
|
5606
5606
|
create: "Bitte beheben Sie die folgenden Fehler und versuchen Sie erneut, die Datei zu erstellen",
|
|
5607
5607
|
update: "Bitte beheben Sie die folgenden Fehler und versuchen Sie erneut, die Aktualisierung durchzuf\xFChren"
|
|
@@ -5625,7 +5625,7 @@ var de_DE_default = {
|
|
|
5625
5625
|
success: "Der Link wurde erfolgreich erstellt und in die Zwischenablage kopiert."
|
|
5626
5626
|
},
|
|
5627
5627
|
errors: {
|
|
5628
|
-
fetch: "
|
|
5628
|
+
fetch: "Es tut uns leid, die gespeicherten Ansichten konnten nicht abgerufen werden. Versuchen Sie es noch einmal.",
|
|
5629
5629
|
create: "Die gespeicherte Ansicht konnte leider nicht erstellt werden. Versuchen Sie es noch einmal.",
|
|
5630
5630
|
update: "Die gespeicherte Ansicht konnte leider nicht aktualisiert werden. Versuchen Sie es noch einmal.",
|
|
5631
5631
|
delete: "Die gespeicherte Ansicht konnte leider nicht gel\xF6scht werden. Versuchen Sie es noch einmal.",
|
|
@@ -10127,6 +10127,18 @@ var ViewStorage = {
|
|
|
10127
10127
|
};
|
|
10128
10128
|
|
|
10129
10129
|
// src/utils/hooks/useViewSelection.ts
|
|
10130
|
+
var isSmartGridConfig = (config) => {
|
|
10131
|
+
return config != null && "rowGroupState" in config;
|
|
10132
|
+
};
|
|
10133
|
+
var areRowGroupStatesEqual = (a2, b2) => {
|
|
10134
|
+
if (!a2 && !b2)
|
|
10135
|
+
return true;
|
|
10136
|
+
if (!a2 || !b2)
|
|
10137
|
+
return false;
|
|
10138
|
+
if (a2.length !== b2.length)
|
|
10139
|
+
return false;
|
|
10140
|
+
return a2.every((val, idx) => val === b2[idx]);
|
|
10141
|
+
};
|
|
10130
10142
|
var getUpdatedSearchParams = (currentParams, view) => {
|
|
10131
10143
|
const updatedParams = new URLSearchParams(currentParams);
|
|
10132
10144
|
if (view.id === "default") {
|
|
@@ -10162,7 +10174,7 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
10162
10174
|
);
|
|
10163
10175
|
}
|
|
10164
10176
|
};
|
|
10165
|
-
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
10177
|
+
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, tableConfig) => {
|
|
10166
10178
|
const I18n = (0, import_core_react14.useI18nContext)();
|
|
10167
10179
|
const projectIdSegment = config.projectId ?? "company";
|
|
10168
10180
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
@@ -10253,6 +10265,45 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
10253
10265
|
handleSavedViewFromUrl(savedViewId);
|
|
10254
10266
|
}
|
|
10255
10267
|
}, [searchParams, handleSavedViewFromUrl, allViews.length]);
|
|
10268
|
+
const previousRowGroupStateRef = (0, import_react12.useRef)(
|
|
10269
|
+
isSmartGridConfig(tableConfig) ? tableConfig.rowGroupState : void 0
|
|
10270
|
+
);
|
|
10271
|
+
const selectedViewRef = (0, import_react12.useRef)(selectedSavedView);
|
|
10272
|
+
selectedViewRef.current = selectedSavedView;
|
|
10273
|
+
const defaultViewRef = (0, import_react12.useRef)(config.defaultView);
|
|
10274
|
+
defaultViewRef.current = config.defaultView;
|
|
10275
|
+
(0, import_react12.useEffect)(() => {
|
|
10276
|
+
if (!isSmartGridConfig(tableConfig) || !presetViews?.length)
|
|
10277
|
+
return;
|
|
10278
|
+
const currentView = selectedViewRef.current;
|
|
10279
|
+
const isPresetSelected = !currentView || currentView.view_level === "default";
|
|
10280
|
+
if (!isPresetSelected)
|
|
10281
|
+
return;
|
|
10282
|
+
const currentRowGroupState = tableConfig.rowGroupState;
|
|
10283
|
+
if (!currentRowGroupState)
|
|
10284
|
+
return;
|
|
10285
|
+
if (areRowGroupStatesEqual(
|
|
10286
|
+
previousRowGroupStateRef.current,
|
|
10287
|
+
currentRowGroupState
|
|
10288
|
+
)) {
|
|
10289
|
+
return;
|
|
10290
|
+
}
|
|
10291
|
+
previousRowGroupStateRef.current = currentRowGroupState;
|
|
10292
|
+
const matchingPreset = presetViews.find((preset) => {
|
|
10293
|
+
const presetConfig = isSmartGridConfig(preset.table_config) ? preset.table_config : void 0;
|
|
10294
|
+
return areRowGroupStatesEqual(
|
|
10295
|
+
presetConfig?.rowGroupState,
|
|
10296
|
+
currentRowGroupState
|
|
10297
|
+
);
|
|
10298
|
+
});
|
|
10299
|
+
if (matchingPreset && matchingPreset.id !== selectedViewRef.current?.id) {
|
|
10300
|
+
setSelectedSavedView(matchingPreset);
|
|
10301
|
+
persistViewToStorageAndUrl(matchingPreset);
|
|
10302
|
+
} else if (!matchingPreset && currentView?.id !== defaultViewRef.current.id) {
|
|
10303
|
+
setSelectedSavedView(defaultViewRef.current);
|
|
10304
|
+
persistViewToStorageAndUrl(defaultViewRef.current);
|
|
10305
|
+
}
|
|
10306
|
+
}, [tableConfig, presetViews, persistViewToStorageAndUrl]);
|
|
10256
10307
|
return {
|
|
10257
10308
|
selectedView: selectedSavedView,
|
|
10258
10309
|
selectView,
|
|
@@ -10312,7 +10363,8 @@ var SavedViewsContent = (props) => {
|
|
|
10312
10363
|
},
|
|
10313
10364
|
savedViews,
|
|
10314
10365
|
props.presetViews,
|
|
10315
|
-
openSharedViewModal
|
|
10366
|
+
openSharedViewModal,
|
|
10367
|
+
props.tableConfig
|
|
10316
10368
|
);
|
|
10317
10369
|
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
10318
10370
|
modalData?.viewId ?? null,
|
package/dist/modern/index.mjs
CHANGED
|
@@ -5588,7 +5588,7 @@ var de_DE_default = {
|
|
|
5588
5588
|
required: "Kann nicht leer sein.",
|
|
5589
5589
|
duplicateName: "Es existiert bereits eine gespeicherte Ansicht mit diesem Namen. Bitte benennen Sie sie um und versuchen Sie es erneut.",
|
|
5590
5590
|
unknown: "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.",
|
|
5591
|
-
title: "
|
|
5591
|
+
title: "Es tut uns leid, wir konnten diese gespeicherte Ansicht nicht {{mode}}",
|
|
5592
5592
|
description: {
|
|
5593
5593
|
create: "Bitte beheben Sie die folgenden Fehler und versuchen Sie erneut, die Datei zu erstellen",
|
|
5594
5594
|
update: "Bitte beheben Sie die folgenden Fehler und versuchen Sie erneut, die Aktualisierung durchzuf\xFChren"
|
|
@@ -5612,7 +5612,7 @@ var de_DE_default = {
|
|
|
5612
5612
|
success: "Der Link wurde erfolgreich erstellt und in die Zwischenablage kopiert."
|
|
5613
5613
|
},
|
|
5614
5614
|
errors: {
|
|
5615
|
-
fetch: "
|
|
5615
|
+
fetch: "Es tut uns leid, die gespeicherten Ansichten konnten nicht abgerufen werden. Versuchen Sie es noch einmal.",
|
|
5616
5616
|
create: "Die gespeicherte Ansicht konnte leider nicht erstellt werden. Versuchen Sie es noch einmal.",
|
|
5617
5617
|
update: "Die gespeicherte Ansicht konnte leider nicht aktualisiert werden. Versuchen Sie es noch einmal.",
|
|
5618
5618
|
delete: "Die gespeicherte Ansicht konnte leider nicht gel\xF6scht werden. Versuchen Sie es noch einmal.",
|
|
@@ -10167,6 +10167,18 @@ var ViewStorage = {
|
|
|
10167
10167
|
};
|
|
10168
10168
|
|
|
10169
10169
|
// src/utils/hooks/useViewSelection.ts
|
|
10170
|
+
var isSmartGridConfig = (config) => {
|
|
10171
|
+
return config != null && "rowGroupState" in config;
|
|
10172
|
+
};
|
|
10173
|
+
var areRowGroupStatesEqual = (a2, b2) => {
|
|
10174
|
+
if (!a2 && !b2)
|
|
10175
|
+
return true;
|
|
10176
|
+
if (!a2 || !b2)
|
|
10177
|
+
return false;
|
|
10178
|
+
if (a2.length !== b2.length)
|
|
10179
|
+
return false;
|
|
10180
|
+
return a2.every((val, idx) => val === b2[idx]);
|
|
10181
|
+
};
|
|
10170
10182
|
var getUpdatedSearchParams = (currentParams, view) => {
|
|
10171
10183
|
const updatedParams = new URLSearchParams(currentParams);
|
|
10172
10184
|
if (view.id === "default") {
|
|
@@ -10202,7 +10214,7 @@ var restoreUrlParameter = (currentParam, previousParam, setSearchParams) => {
|
|
|
10202
10214
|
);
|
|
10203
10215
|
}
|
|
10204
10216
|
};
|
|
10205
|
-
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) => {
|
|
10217
|
+
var useViewSelection = (config, savedViews, presetViews, openSharedViewModal, tableConfig) => {
|
|
10206
10218
|
const I18n = useI18nContext11();
|
|
10207
10219
|
const projectIdSegment = config.projectId ?? "company";
|
|
10208
10220
|
const storageKey = `savedView_${config.domain}_${config.tableName}_${config.companyId}_${projectIdSegment}_${config.userId}`;
|
|
@@ -10293,6 +10305,45 @@ var useViewSelection = (config, savedViews, presetViews, openSharedViewModal) =>
|
|
|
10293
10305
|
handleSavedViewFromUrl(savedViewId);
|
|
10294
10306
|
}
|
|
10295
10307
|
}, [searchParams, handleSavedViewFromUrl, allViews.length]);
|
|
10308
|
+
const previousRowGroupStateRef = useRef2(
|
|
10309
|
+
isSmartGridConfig(tableConfig) ? tableConfig.rowGroupState : void 0
|
|
10310
|
+
);
|
|
10311
|
+
const selectedViewRef = useRef2(selectedSavedView);
|
|
10312
|
+
selectedViewRef.current = selectedSavedView;
|
|
10313
|
+
const defaultViewRef = useRef2(config.defaultView);
|
|
10314
|
+
defaultViewRef.current = config.defaultView;
|
|
10315
|
+
useEffect3(() => {
|
|
10316
|
+
if (!isSmartGridConfig(tableConfig) || !presetViews?.length)
|
|
10317
|
+
return;
|
|
10318
|
+
const currentView = selectedViewRef.current;
|
|
10319
|
+
const isPresetSelected = !currentView || currentView.view_level === "default";
|
|
10320
|
+
if (!isPresetSelected)
|
|
10321
|
+
return;
|
|
10322
|
+
const currentRowGroupState = tableConfig.rowGroupState;
|
|
10323
|
+
if (!currentRowGroupState)
|
|
10324
|
+
return;
|
|
10325
|
+
if (areRowGroupStatesEqual(
|
|
10326
|
+
previousRowGroupStateRef.current,
|
|
10327
|
+
currentRowGroupState
|
|
10328
|
+
)) {
|
|
10329
|
+
return;
|
|
10330
|
+
}
|
|
10331
|
+
previousRowGroupStateRef.current = currentRowGroupState;
|
|
10332
|
+
const matchingPreset = presetViews.find((preset) => {
|
|
10333
|
+
const presetConfig = isSmartGridConfig(preset.table_config) ? preset.table_config : void 0;
|
|
10334
|
+
return areRowGroupStatesEqual(
|
|
10335
|
+
presetConfig?.rowGroupState,
|
|
10336
|
+
currentRowGroupState
|
|
10337
|
+
);
|
|
10338
|
+
});
|
|
10339
|
+
if (matchingPreset && matchingPreset.id !== selectedViewRef.current?.id) {
|
|
10340
|
+
setSelectedSavedView(matchingPreset);
|
|
10341
|
+
persistViewToStorageAndUrl(matchingPreset);
|
|
10342
|
+
} else if (!matchingPreset && currentView?.id !== defaultViewRef.current.id) {
|
|
10343
|
+
setSelectedSavedView(defaultViewRef.current);
|
|
10344
|
+
persistViewToStorageAndUrl(defaultViewRef.current);
|
|
10345
|
+
}
|
|
10346
|
+
}, [tableConfig, presetViews, persistViewToStorageAndUrl]);
|
|
10296
10347
|
return {
|
|
10297
10348
|
selectedView: selectedSavedView,
|
|
10298
10349
|
selectView,
|
|
@@ -10352,7 +10403,8 @@ var SavedViewsContent = (props) => {
|
|
|
10352
10403
|
},
|
|
10353
10404
|
savedViews,
|
|
10354
10405
|
props.presetViews,
|
|
10355
|
-
openSharedViewModal
|
|
10406
|
+
openSharedViewModal,
|
|
10407
|
+
props.tableConfig
|
|
10356
10408
|
);
|
|
10357
10409
|
const { data: fetchedView, isError: fetchError } = useFetchSavedViewById(
|
|
10358
10410
|
modalData?.viewId ?? null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@procore/saved-views",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.7",
|
|
4
4
|
"description": "Saved Views Component for Data Table",
|
|
5
5
|
"author": "Procore Technologies, Inc",
|
|
6
6
|
"repository": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@babel/preset-react": "^7.26.3",
|
|
68
68
|
"@babel/preset-typescript": "^7.26.0",
|
|
69
69
|
"@dotenvx/dotenvx": "1.6.4",
|
|
70
|
-
"@procore/core-react": "^12.
|
|
70
|
+
"@procore/core-react": "^12.45.0",
|
|
71
71
|
"@procore/data-table": "14.27.1",
|
|
72
72
|
"@procore/hammer": "^1.2.0",
|
|
73
73
|
"@procore/hammer-test-jest": "^0.9.1",
|