common-header-lib 0.20.2 → 0.20.4

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/index.d.ts CHANGED
@@ -8,11 +8,17 @@ import { HttpInterceptorFn } from '@angular/common/http';
8
8
  declare class ConfirmDialogComponent {
9
9
  header: _angular_core.InputSignal<string>;
10
10
  message: _angular_core.InputSignal<string>;
11
+ /** Extra class(es) to layer onto the underlying p-confirmDialog root, e.g.
12
+ * a per-instance marker so a specific confirm dialog (like the LOB change
13
+ * confirmation) can be targeted from consuming apps' global styles.
14
+ * Always combined with the library's own `lib-dialog` scoping class —
15
+ * see _dialogs.scss. */
16
+ styleClass: _angular_core.InputSignal<string>;
11
17
  result: _angular_core.OutputEmitterRef<boolean>;
12
18
  private readonly confirmationService;
13
19
  openConfirmModal(event: Event): void;
14
20
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<ConfirmDialogComponent, never>;
15
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<ConfirmDialogComponent, "confirm-dialog", never, { "header": { "alias": "header"; "required": false; "isSignal": true; }; "message": { "alias": "message"; "required": false; "isSignal": true; }; }, { "result": "result"; }, never, never, true, never>;
21
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ConfirmDialogComponent, "confirm-dialog", never, { "header": { "alias": "header"; "required": false; "isSignal": true; }; "message": { "alias": "message"; "required": false; "isSignal": true; }; "styleClass": { "alias": "styleClass"; "required": false; "isSignal": true; }; }, { "result": "result"; }, never, never, true, never>;
16
22
  }
17
23
 
18
24
  interface Language {
@@ -233,6 +239,9 @@ interface LobItem {
233
239
  * - Persist the confirmed LOB selection back to localStorage
234
240
  * - Revert the dropdown to the last confirmed LOB when the user cancels
235
241
  * - Validate LOB IDs set programmatically by the host app
242
+ * - When read-only (host sets `lobReadOnly`), freeze the LOB and refuse
243
+ * every mutation below regardless of caller — see loadLOBs()'s readOnly
244
+ * param for how a page reload during read-only mode stays frozen too.
236
245
  *
237
246
  * Provided at the component level so each header instance has isolated LOB state.
238
247
  */
@@ -248,21 +257,44 @@ declare class LobService {
248
257
  /** Tracks the last confirmed LOB ID so changes can be reverted on cancel. */
249
258
  private tempSelectedLobId;
250
259
  /** Fetches the LOB list and resolves the initial selection.
251
- * - If localStorage has a valid pre-selected LOB, it is restored.
252
- * - Otherwise the first item in the list is selected and saved to localStorage. */
253
- loadLOBs(showAllLOB: boolean): Observable<{
260
+ * - Normally: if localStorage['XOB'] has a valid pre-selected LOB, it is
261
+ * restored; otherwise the first item in the list is selected and saved.
262
+ * - When readOnly is true: localStorage['XOB'] is not trusted at all (that
263
+ * is the exact tamper vector read-only mode exists to close). Instead the
264
+ * LOB is resolved from a separate 'XOB_LOCK' key. The first time this
265
+ * runs while read-only, 'XOB_LOCK' doesn't exist yet, so the normal
266
+ * XOB-restore-or-default resolution runs once to establish a baseline,
267
+ * which is then locked into 'XOB_LOCK' — 'XOB' itself is left untouched
268
+ * so the pre-lock value is intact once read-only turns back off. Every
269
+ * subsequent call while still read-only (including across a page reload)
270
+ * reads 'XOB_LOCK' instead, so editing 'XOB' has no effect. */
271
+ loadLOBs(showAllLOB: boolean, readOnly?: boolean): Observable<{
254
272
  initialLobSelected: LobItem;
255
273
  selectedLobId: any;
256
274
  }>;
275
+ /** Read-only resolution: prefer the existing lock; if none exists yet
276
+ * (first read-only load), establish one from the normal XOB-or-default
277
+ * resolution without touching 'XOB' itself. */
278
+ private resolveReadOnlyLob;
279
+ /** Shared resolution used by both the normal and first-time-read-only
280
+ * paths: restore from `readKey` if it holds a valid, still-listed LOB;
281
+ * otherwise default to the first list item. Writes the resolved value to
282
+ * `writeKey` (only on the default branch, unless forceWrite is set — used
283
+ * by the read-only baseline path, which must persist even when it
284
+ * legitimately restored from 'XOB' rather than defaulting). */
285
+ private resolveAndPersistLob;
257
286
  /** Called when the user confirms the LOB change dialog.
258
- * Updates the temp reference and persists the new selection to localStorage. */
259
- confirmChange(selectedLobId: any): LobItem;
287
+ * Updates the temp reference and persists the new selection to localStorage.
288
+ * No-ops when readOnly is true — defense-in-depth so this stays safe even
289
+ * if a caller bypasses the component-level guard. */
290
+ confirmChange(selectedLobId: any, readOnly?: boolean): LobItem | null;
260
291
  /** Called when the user cancels the LOB change dialog.
261
292
  * Returns the last confirmed LOB ID so the dropdown can be reverted. */
262
293
  revertChange(): any;
263
294
  /** Validates a LOB ID set programmatically by the host app (via setCustomLobId).
264
- * Shows an error toast if the ID does not exist in the current list. */
265
- validateCustomLobId(lobId: any): LobItem | null;
295
+ * Shows an error toast if the ID does not exist in the current list.
296
+ * No-ops when readOnly is true — defense-in-depth, same as confirmChange. */
297
+ validateCustomLobId(lobId: any, readOnly?: boolean): LobItem | null;
266
298
  /** Finds a LOB in the list by its ID and returns a normalised LobItem.
267
299
  * Returns an empty object cast as LobItem when no match is found. */
268
300
  getLobById(list: any[], id: any): LobItem;
@@ -291,6 +323,7 @@ declare class CommonHeaderLibComponent implements OnInit {
291
323
  EnableTimeZone: _angular_core.InputSignal<boolean>;
292
324
  EnableLOB: _angular_core.InputSignal<boolean>;
293
325
  showAllLOB: _angular_core.InputSignal<boolean>;
326
+ lobReadOnly: _angular_core.InputSignal<boolean>;
294
327
  EnableMail: _angular_core.InputSignal<boolean>;
295
328
  EnableNotifications: _angular_core.InputSignal<boolean>;
296
329
  EnableMoreApps: _angular_core.InputSignal<boolean>;
@@ -324,15 +357,28 @@ declare class CommonHeaderLibComponent implements OnInit {
324
357
  OpenNotificationModal(): void;
325
358
  closeModal(): void;
326
359
  /** Called when the user picks a different LOB from the dropdown.
327
- * Stores the new value and opens the confirmation dialog before committing. */
360
+ * Stores the new value and opens the confirmation dialog before committing.
361
+ * When lobReadOnly is true: PrimeNG's [(ngModel)] has already written
362
+ * event.value into selectedLOBId by the time this handler runs (ngModel
363
+ * writeback happens before (onChange) fires), so a bare early return would
364
+ * leave the dropdown showing the tampered value — force-revert it to the
365
+ * last confirmed LOB instead, and never open the confirm dialog. */
328
366
  onLobChangeEvent(event: any): void;
329
367
  /** Called when the user confirms the LOB change dialog.
330
- * Persists the new selection and emits it to the host app. */
368
+ * Persists the new selection and emits it to the host app.
369
+ * Re-checks lobReadOnly here too (not just in onLobChangeEvent) so a
370
+ * dialog already open when read-only turns on, or the dialog's own accept
371
+ * callback invoked directly, cannot still commit a change. */
331
372
  confirmLobChange(): void;
332
373
  /** Called when the user cancels the LOB change dialog.
333
- * Reverts the dropdown back to the previously confirmed LOB. */
374
+ * Reverts the dropdown back to the previously confirmed LOB. Intentionally
375
+ * NOT gated by lobReadOnly — reverting only ever restores the last
376
+ * confirmed value, never advances it, so it's safe (and useful as a
377
+ * self-heal) to allow regardless of read-only state. */
334
378
  revertLobChange(): void;
335
- /** Public API — allows the host app to force-select a specific LOB by ID. */
379
+ /** Public API — allows the host app to force-select a specific LOB by ID.
380
+ * Also respects lobReadOnly: while read-only, nobody — including host-app
381
+ * code — can change the LOB except by first turning the flag back off. */
336
382
  setCustomLobId(lobId: any): void;
337
383
  /** Sets the base API URL once. Falls back to the current browser origin
338
384
  * if no URL has been stored in localStorage under '_WAU'. */
@@ -340,10 +386,16 @@ declare class CommonHeaderLibComponent implements OnInit {
340
386
  /** Loads the LOB list and emits the initially selected LOB to the host app.
341
387
  * detectChanges() is used (not markForCheck) because lobService properties
342
388
  * are plain values, not signals — we need an immediate re-render after the
343
- * subscription updates showLobLoader and userLOBList on the service. */
389
+ * subscription updates showLobLoader and userLOBList on the service.
390
+ * lobReadOnly is read here (not inside the constructor effect, which only
391
+ * depends on EnableLOB) so toggling lobReadOnly never re-triggers this
392
+ * call on its own — the effect's untracked() wrapper means changes here
393
+ * are inert as an effect dependency, matching the existing showAllLOB
394
+ * pattern. This is what keeps a read-only toggle from re-resolving or
395
+ * re-emitting lobSelected by itself. */
344
396
  private getListofLOB;
345
397
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CommonHeaderLibComponent, never>;
346
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<CommonHeaderLibComponent, "lib-app-header", never, { "EnableLogo": { "alias": "EnableLogo"; "required": false; "isSignal": true; }; "moduleName": { "alias": "moduleName"; "required": false; "isSignal": true; }; "EnableTimeZone": { "alias": "EnableTimeZone"; "required": false; "isSignal": true; }; "EnableLOB": { "alias": "EnableLOB"; "required": false; "isSignal": true; }; "showAllLOB": { "alias": "showAllLOB"; "required": false; "isSignal": true; }; "EnableMail": { "alias": "EnableMail"; "required": false; "isSignal": true; }; "EnableNotifications": { "alias": "EnableNotifications"; "required": false; "isSignal": true; }; "EnableMoreApps": { "alias": "EnableMoreApps"; "required": false; "isSignal": true; }; "EnableProfile": { "alias": "EnableProfile"; "required": false; "isSignal": true; }; "EnableLearningCenter": { "alias": "EnableLearningCenter"; "required": false; "isSignal": true; }; "EnableGeneralConfiguration": { "alias": "EnableGeneralConfiguration"; "required": false; "isSignal": true; }; "languages": { "alias": "languages"; "required": false; "isSignal": true; }; }, { "timezoneDetails": "timezoneDetails"; "lobSelected": "lobSelected"; "getBgImage": "getBgImage"; "langChange": "langChange"; "overlayStateChange": "overlayStateChange"; }, never, never, true, never>;
398
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CommonHeaderLibComponent, "lib-app-header", never, { "EnableLogo": { "alias": "EnableLogo"; "required": false; "isSignal": true; }; "moduleName": { "alias": "moduleName"; "required": false; "isSignal": true; }; "EnableTimeZone": { "alias": "EnableTimeZone"; "required": false; "isSignal": true; }; "EnableLOB": { "alias": "EnableLOB"; "required": false; "isSignal": true; }; "showAllLOB": { "alias": "showAllLOB"; "required": false; "isSignal": true; }; "lobReadOnly": { "alias": "lobReadOnly"; "required": false; "isSignal": true; }; "EnableMail": { "alias": "EnableMail"; "required": false; "isSignal": true; }; "EnableNotifications": { "alias": "EnableNotifications"; "required": false; "isSignal": true; }; "EnableMoreApps": { "alias": "EnableMoreApps"; "required": false; "isSignal": true; }; "EnableProfile": { "alias": "EnableProfile"; "required": false; "isSignal": true; }; "EnableLearningCenter": { "alias": "EnableLearningCenter"; "required": false; "isSignal": true; }; "EnableGeneralConfiguration": { "alias": "EnableGeneralConfiguration"; "required": false; "isSignal": true; }; "languages": { "alias": "languages"; "required": false; "isSignal": true; }; }, { "timezoneDetails": "timezoneDetails"; "lobSelected": "lobSelected"; "getBgImage": "getBgImage"; "langChange": "langChange"; "overlayStateChange": "overlayStateChange"; }, never, never, true, never>;
347
399
  }
348
400
 
349
401
  declare class SliceToTwoPipe implements PipeTransform {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "common-header-lib",
3
- "version": "0.20.2",
3
+ "version": "0.20.4",
4
4
  "peerDependencies": {
5
5
  "@angular/cdk": "^20.2.0",
6
6
  "@angular/common": "^20.3.0",