geonetwork-ui 2.10.0-dev.896c4b637 → 2.10.0-dev.984a9212e

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.
@@ -3,7 +3,7 @@ import {
3
3
  HttpErrorResponse,
4
4
  HttpHeaders,
5
5
  } from '@angular/common/http'
6
- import { Injectable, inject } from '@angular/core'
6
+ import { Injectable, InjectionToken, inject } from '@angular/core'
7
7
  import {
8
8
  assertValidXml,
9
9
  findConverterForDocument,
@@ -57,6 +57,10 @@ const TEMPORARY_ID_PREFIX = 'TEMP-ID-'
57
57
 
58
58
  export type RecordAsXml = string
59
59
 
60
+ export const DISABLE_DRAFT = new InjectionToken<boolean>('gnDisableDraft', {
61
+ factory: () => false,
62
+ })
63
+
60
64
  @Injectable()
61
65
  export class Gn4Repository implements RecordsRepositoryInterface {
62
66
  private httpClient = inject(HttpClient)
@@ -67,6 +71,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
67
71
  private platformService = inject(PlatformServiceInterface)
68
72
  private gn4LanguagesApi = inject(LanguagesApiService)
69
73
  private settingsService = inject(Gn4SettingsService)
74
+ private disableDraft = inject(DISABLE_DRAFT, { optional: true }) ?? false
70
75
 
71
76
  _draftsChanged = new Subject<void>()
72
77
  draftsChanged$ = this._draftsChanged.asObservable()
@@ -350,7 +355,9 @@ export class Gn4Repository implements RecordsRepositoryInterface {
350
355
  openRecordForEdition(
351
356
  uniqueIdentifier: string
352
357
  ): Observable<[CatalogRecord, string, boolean] | null> {
353
- const draft$ = of(this.getRecordFromLocalStorage(uniqueIdentifier))
358
+ const draft$ = this.disableDraft
359
+ ? of(null)
360
+ : of(this.getRecordFromLocalStorage(uniqueIdentifier))
354
361
  const recordAsXml$ = this.getRecordAsXml(uniqueIdentifier)
355
362
 
356
363
  return combineLatest([draft$, recordAsXml$]).pipe(
@@ -475,6 +482,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
475
482
  record: CatalogRecord,
476
483
  referenceRecordSource?: string
477
484
  ): Observable<string> {
485
+ if (this.disableDraft) return of('')
478
486
  return this.serializeRecordToXml(record, referenceRecordSource).pipe(
479
487
  tap((recordXml) => {
480
488
  this.saveRecordToLocalStorage(recordXml, record.uniqueIdentifier)
@@ -484,16 +492,19 @@ export class Gn4Repository implements RecordsRepositoryInterface {
484
492
  }
485
493
 
486
494
  clearRecordDraft(uniqueIdentifier: string): void {
495
+ if (this.disableDraft) return
487
496
  this.removeRecordFromLocalStorage(uniqueIdentifier)
488
497
  this._draftsChanged.next()
489
498
  }
490
499
 
491
500
  recordHasDraft(uniqueIdentifier: string): boolean {
501
+ if (this.disableDraft) return false
492
502
  return this.getRecordFromLocalStorage(uniqueIdentifier) !== null
493
503
  }
494
504
 
495
505
  // generated by copilot
496
506
  getAllDrafts(): Observable<CatalogRecord[]> {
507
+ if (this.disableDraft) return of([])
497
508
  const items = { ...window.localStorage }
498
509
  const drafts = Object.keys(items)
499
510
  .filter((key) => key.startsWith('geonetwork-ui-draft-'))
@@ -509,6 +520,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
509
520
  }
510
521
 
511
522
  getDraftsCount(): Observable<number> {
523
+ if (this.disableDraft) return of(0)
512
524
  const items = { ...window.localStorage }
513
525
  const draftCount = Object.keys(items)
514
526
  .filter((key) => key.startsWith('geonetwork-ui-draft-'))
@@ -6,7 +6,7 @@ import {
6
6
  } from './platform/gn4-platform.service'
7
7
  import { Gn4PlatformMapper } from './platform/gn4-platform.mapper'
8
8
  import { RecordsRepositoryInterface } from '../../../../../../libs/common/domain/src/lib/repository/records-repository.interface'
9
- import { Gn4Repository } from './gn4-repository'
9
+ import { Gn4Repository, DISABLE_DRAFT } from './gn4-repository'
10
10
  import { AvatarServiceInterface, GravatarService } from './auth'
11
11
  import { OrganizationsServiceInterface } from '../../../../../../libs/common/domain/src/lib/organizations.service.interface'
12
12
  import {
@@ -22,6 +22,7 @@ import { TranslateService } from '@ngx-translate/core'
22
22
 
23
23
  interface Gn4ProvideOptions {
24
24
  disableAuth?: boolean
25
+ disableDraft?: boolean
25
26
  }
26
27
 
27
28
  export function provideGn4(provideOptions?: Gn4ProvideOptions): Provider[] {
@@ -30,6 +31,10 @@ export function provideGn4(provideOptions?: Gn4ProvideOptions): Provider[] {
30
31
  provide: DISABLE_AUTH,
31
32
  useValue: provideOptions?.disableAuth,
32
33
  },
34
+ {
35
+ provide: DISABLE_DRAFT,
36
+ useValue: provideOptions?.disableDraft,
37
+ },
33
38
  {
34
39
  provide: PlatformServiceInterface,
35
40
  useClass: Gn4PlatformService,
@@ -12,7 +12,6 @@ import {
12
12
  } from './editor.selectors'
13
13
  import { RecordsRepositoryInterface } from '../../../../../../libs/common/domain/src/lib/repository/records-repository.interface'
14
14
  import { PlatformServiceInterface } from '../../../../../../libs/common/domain/src/lib/platform.service.interface'
15
-
16
15
  @Injectable()
17
16
  export class EditorEffects {
18
17
  private actions$ = inject(Actions)