@alfresco/aca-shared 8.1.0-37916619404 → 8.1.0-37922544708

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.
@@ -1188,6 +1188,188 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImpo
1188
1188
  args: [{ providedIn: 'root' }]
1189
1189
  }], propDecorators: { peopleApi: [] } });
1190
1190
 
1191
+ /*!
1192
+ * Copyright © 2005-2026 Hyland Software, Inc. and its affiliates. All rights reserved.
1193
+ *
1194
+ * Alfresco Example Content Application
1195
+ *
1196
+ * This file is part of the Alfresco Example Content Application.
1197
+ * If the software was purchased under a paid Alfresco license, the terms of
1198
+ * the paid license agreement will prevail. Otherwise, the software is
1199
+ * provided under the following open source license terms:
1200
+ *
1201
+ * The Alfresco Example Content Application is free software: you can redistribute it and/or modify
1202
+ * it under the terms of the GNU Lesser General Public License as published by
1203
+ * the Free Software Foundation, either version 3 of the License, or
1204
+ * (at your option) any later version.
1205
+ *
1206
+ * The Alfresco Example Content Application is distributed in the hope that it will be useful,
1207
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1208
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1209
+ * GNU Lesser General Public License for more details.
1210
+ *
1211
+ * You should have received a copy of the GNU Lesser General Public License
1212
+ * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
1213
+ */
1214
+ const PAGINATION_SEGMENT = '_pagination_';
1215
+ class PaginationStateBaseService {
1216
+ constructor() {
1217
+ this.lastContext = null;
1218
+ }
1219
+ prepareContext() {
1220
+ const context = this.getCurrentContext();
1221
+ if (this.lastContext === null) {
1222
+ this.lastContext = context;
1223
+ return;
1224
+ }
1225
+ if (context !== this.lastContext) {
1226
+ this.lastContext = context;
1227
+ this.clearAll();
1228
+ }
1229
+ }
1230
+ getPaginationState(key) {
1231
+ if (!key) {
1232
+ return null;
1233
+ }
1234
+ const raw = this.read(this.getStorageKey(key));
1235
+ if (!raw) {
1236
+ return null;
1237
+ }
1238
+ try {
1239
+ const parsed = JSON.parse(raw);
1240
+ if (typeof parsed?.skipCount === 'number' && typeof parsed?.maxItems === 'number') {
1241
+ return { skipCount: parsed.skipCount, maxItems: parsed.maxItems };
1242
+ }
1243
+ }
1244
+ catch {
1245
+ /* malformed entry, ignore */
1246
+ }
1247
+ return null;
1248
+ }
1249
+ setPaginationState(key, state) {
1250
+ if (!key) {
1251
+ return;
1252
+ }
1253
+ if (!state?.skipCount) {
1254
+ this.resetPaginationState(key);
1255
+ return;
1256
+ }
1257
+ this.write(this.getStorageKey(key), JSON.stringify({ skipCount: state.skipCount, maxItems: state.maxItems }));
1258
+ }
1259
+ resetPaginationState(key) {
1260
+ if (!key) {
1261
+ return;
1262
+ }
1263
+ this.remove(this.getStorageKey(key));
1264
+ }
1265
+ clearAll() {
1266
+ const storage = this.getStorage();
1267
+ if (!storage) {
1268
+ return;
1269
+ }
1270
+ try {
1271
+ const keysToRemove = [];
1272
+ for (let i = 0; i < storage.length; i++) {
1273
+ const storageKey = storage.key(i);
1274
+ if (storageKey?.includes(PAGINATION_SEGMENT)) {
1275
+ keysToRemove.push(storageKey);
1276
+ }
1277
+ }
1278
+ keysToRemove.forEach((storageKey) => storage.removeItem(storageKey));
1279
+ }
1280
+ catch {
1281
+ /* sessionStorage not available */
1282
+ }
1283
+ }
1284
+ getStorageKey(key) {
1285
+ const user = this.getUsername() || 'anonymous';
1286
+ return `${user}${PAGINATION_SEGMENT}${key}`;
1287
+ }
1288
+ getStorage() {
1289
+ try {
1290
+ return typeof sessionStorage !== 'undefined' ? sessionStorage : null;
1291
+ }
1292
+ catch {
1293
+ return null;
1294
+ }
1295
+ }
1296
+ read(storageKey) {
1297
+ try {
1298
+ return this.getStorage()?.getItem(storageKey) ?? null;
1299
+ }
1300
+ catch {
1301
+ return null;
1302
+ }
1303
+ }
1304
+ write(storageKey, value) {
1305
+ try {
1306
+ this.getStorage()?.setItem(storageKey, value);
1307
+ }
1308
+ catch {
1309
+ /* sessionStorage not available or quota exceeded */
1310
+ }
1311
+ }
1312
+ remove(storageKey) {
1313
+ try {
1314
+ this.getStorage()?.removeItem(storageKey);
1315
+ }
1316
+ catch {
1317
+ /* sessionStorage not available */
1318
+ }
1319
+ }
1320
+ }
1321
+
1322
+ /*!
1323
+ * Copyright © 2005-2026 Hyland Software, Inc. and its affiliates. All rights reserved.
1324
+ *
1325
+ * Alfresco Example Content Application
1326
+ *
1327
+ * This file is part of the Alfresco Example Content Application.
1328
+ * If the software was purchased under a paid Alfresco license, the terms of
1329
+ * the paid license agreement will prevail. Otherwise, the software is
1330
+ * provided under the following open source license terms:
1331
+ *
1332
+ * The Alfresco Example Content Application is free software: you can redistribute it and/or modify
1333
+ * it under the terms of the GNU Lesser General Public License as published by
1334
+ * the Free Software Foundation, either version 3 of the License, or
1335
+ * (at your option) any later version.
1336
+ *
1337
+ * The Alfresco Example Content Application is distributed in the hope that it will be useful,
1338
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1339
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1340
+ * GNU Lesser General Public License for more details.
1341
+ *
1342
+ * You should have received a copy of the GNU Lesser General Public License
1343
+ * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
1344
+ */
1345
+ class PaginationStateService extends PaginationStateBaseService {
1346
+ constructor() {
1347
+ super(...arguments);
1348
+ this.authenticationService = inject(AuthenticationService);
1349
+ this.router = inject(Router);
1350
+ }
1351
+ getUsername() {
1352
+ return this.authenticationService.getUsername();
1353
+ }
1354
+ getCurrentContext() {
1355
+ const path = (this.router.url || '').split('?')[0].split('#')[0];
1356
+ const segments = path.split('/').filter((segment) => !!segment);
1357
+ if (segments.includes('libraries')) {
1358
+ return segments[0] === 'favorite' ? 'favorite/libraries' : 'libraries';
1359
+ }
1360
+ if (segments[0] === 'favorite') {
1361
+ return segments.slice(0, 2).join('/');
1362
+ }
1363
+ return segments[0] ?? '';
1364
+ }
1365
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: PaginationStateService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
1366
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: PaginationStateService, providedIn: 'root' }); }
1367
+ }
1368
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: PaginationStateService, decorators: [{
1369
+ type: Injectable,
1370
+ args: [{ providedIn: 'root' }]
1371
+ }] });
1372
+
1191
1373
  /*!
1192
1374
  * Copyright © 2005-2026 Hyland Software, Inc. and its affiliates. All rights reserved.
1193
1375
  *
@@ -1238,6 +1420,7 @@ class AppService {
1238
1420
  this.appSettingsService = inject(AppSettingsService);
1239
1421
  this.userProfileService = inject(UserProfileService);
1240
1422
  this.storage = inject(StorageService);
1423
+ this.paginationStateService = inject(PaginationStateService);
1241
1424
  this.notificationService = inject(NotificationService);
1242
1425
  this.matDialog = inject(MatDialog);
1243
1426
  this.pageHeading = new BehaviorSubject('');
@@ -1257,6 +1440,7 @@ class AppService {
1257
1440
  });
1258
1441
  this.authenticationService.onLogout.subscribe(() => {
1259
1442
  this.storage.removeItem(this.preferencesService.getPropertyKey('expandedSidenav'));
1443
+ this.paginationStateService.clearAll();
1260
1444
  searchQueryBuilderService.resetToDefaults();
1261
1445
  acaMobileAppSwitcherService.clearSessionExpireTime();
1262
1446
  acaMobileAppSwitcherService.closeDialog();
@@ -3386,5 +3570,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImpo
3386
3570
  * Generated bundle index. Do not edit.
3387
3571
  */
3388
3572
 
3389
- export { AppExtensionService, AppHookService, AppService, AppSettingsService, AppSharedRuleGuard, AutoDownloadService, ContentApiService, ContextActionsDirective, DefaultExtensionLoaderFactory, DefaultMimeTypes, DocumentBasePageService, DocumentBasePageServiceMock, EXTENSION_DATA_LOADERS, ExtensionsDataLoaderGuard, GenericErrorComponent, InfoDrawerComponent, LibTestingModule, LockedByComponent, NavigationHistoryService, NodePermissionService, OpenInAppComponent, PageComponent, PageLayoutComponent, PageLayoutContentComponent, PageLayoutErrorComponent, PageLayoutHeaderComponent, PageLayoutModule, PaginationDirective, PluginEnabledGuard, RouterExtensionService, ToolbarActionComponent, ToolbarButtonComponent, ToolbarButtonType, ToolbarComponent, ToolbarMenuComponent, ToolbarMenuItemComponent, UserProfileService, discoveryApiServiceMockValue, initialState, isLibrary, isLocked, isWorkingCopy, provideContentAppExtensions, resetInvoked };
3573
+ export { AppExtensionService, AppHookService, AppService, AppSettingsService, AppSharedRuleGuard, AutoDownloadService, ContentApiService, ContextActionsDirective, DefaultExtensionLoaderFactory, DefaultMimeTypes, DocumentBasePageService, DocumentBasePageServiceMock, EXTENSION_DATA_LOADERS, ExtensionsDataLoaderGuard, GenericErrorComponent, InfoDrawerComponent, LibTestingModule, LockedByComponent, NavigationHistoryService, NodePermissionService, OpenInAppComponent, PageComponent, PageLayoutComponent, PageLayoutContentComponent, PageLayoutErrorComponent, PageLayoutHeaderComponent, PageLayoutModule, PaginationDirective, PaginationStateBaseService, PaginationStateService, PluginEnabledGuard, RouterExtensionService, ToolbarActionComponent, ToolbarButtonComponent, ToolbarButtonType, ToolbarComponent, ToolbarMenuComponent, ToolbarMenuItemComponent, UserProfileService, discoveryApiServiceMockValue, initialState, isLibrary, isLocked, isWorkingCopy, provideContentAppExtensions, resetInvoked };
3390
3574
  //# sourceMappingURL=alfresco-aca-shared.mjs.map