From 0648f69a2f33a119507bc6227859c5663a09d9f6 Mon Sep 17 00:00:00 2001 From: George Date: Thu, 13 Jul 2023 14:30:23 +0300 Subject: [PATCH] DM-328, add modal checkbox and preference toggle for opening modal by default for DocuMine. --- .../src/app/modules/account/account.module.ts | 3 +- .../preferences/preferences.component.html | 8 +++-- .../preferences/preferences.component.ts | 29 +++++++++++++++---- .../rss-dialog/rss-dialog.component.html | 7 +++++ .../rss-dialog/rss-dialog.component.scss | 4 +++ .../rss-dialog/rss-dialog.component.ts | 12 +++++++- .../file-preview-screen.component.ts | 11 +++++++ .../src/app/services/permissions.service.ts | 4 +++ .../src/app/users/user-preference.service.ts | 10 +++++++ apps/red-ui/src/assets/i18n/redact/de.json | 1 + apps/red-ui/src/assets/i18n/redact/en.json | 1 + apps/red-ui/src/assets/i18n/scm/de.json | 1 + apps/red-ui/src/assets/i18n/scm/en.json | 1 + 13 files changed, 83 insertions(+), 9 deletions(-) diff --git a/apps/red-ui/src/app/modules/account/account.module.ts b/apps/red-ui/src/app/modules/account/account.module.ts index 7f35e0d7a..fac249986 100644 --- a/apps/red-ui/src/app/modules/account/account.module.ts +++ b/apps/red-ui/src/app/modules/account/account.module.ts @@ -6,7 +6,7 @@ import { AccountSideNavComponent } from './account-side-nav/account-side-nav.com import { BaseAccountScreenComponent } from './base-account-screen/base-account-screen-component'; import { NotificationPreferencesService } from './services/notification-preferences.service'; import { TranslateModule } from '@ngx-translate/core'; -import { IconButtonComponent, IqserHelpModeModule } from '@iqser/common-ui'; +import { IconButtonComponent, IqserAllowDirective, IqserHelpModeModule } from '@iqser/common-ui'; import { PreferencesComponent } from './screens/preferences/preferences.component'; import { SideNavComponent } from '@iqser/common-ui/lib/shared'; @@ -20,6 +20,7 @@ import { SideNavComponent } from '@iqser/common-ui/lib/shared'; IqserHelpModeModule, IconButtonComponent, SideNavComponent, + IqserAllowDirective, ], providers: [NotificationPreferencesService], }) diff --git a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html index 42199b989..26f5d5bfa 100644 --- a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html +++ b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html @@ -1,4 +1,4 @@ -
+
@@ -13,6 +13,11 @@ {{ 'preferences-screen.form.show-suggestions-in-preview' | translate }}
+
+ + {{ 'preferences-screen.form.open-structured-view-by-default' | translate }} + +

{{ 'preferences-screen.warnings-subtitle' | translate }}

@@ -38,7 +43,6 @@ (action)="save()" [disabled]="!valid || !changed" [label]="'preferences-screen.actions.save' | translate" - [submit]="true" [type]="iconButtonTypes.primary" >
diff --git a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts index 765aeeeec..c7fb30560 100644 --- a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts +++ b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts @@ -10,6 +10,7 @@ interface PreferencesForm { // preferences autoExpandFiltersOnActions: boolean; displaySuggestionsInPreview: boolean; + openStructuredComponentManagementDialogByDefault: boolean; // warnings preferences unapprovedSuggestionsWarning: boolean; loadAllAnnotationsWarning: boolean; @@ -35,6 +36,7 @@ export class PreferencesComponent extends BaseFormComponent { readonly currentScreen: Screen; readonly screens = Screens; initialFormValue: PreferencesForm; + readonly roles = Roles; constructor( readonly userPreferenceService: UserPreferenceService, @@ -48,6 +50,9 @@ export class PreferencesComponent extends BaseFormComponent { // preferences autoExpandFiltersOnActions: [this.userPreferenceService.getAutoExpandFiltersOnActions()], displaySuggestionsInPreview: [this.userPreferenceService.getDisplaySuggestionsInPreview()], + openStructuredComponentManagementDialogByDefault: [ + this.userPreferenceService.getOpenStructuredComponentManagementDialogByDefault(), + ], // warnings preferences unapprovedSuggestionsWarning: [this.userPreferenceService.getUnapprovedSuggestionsWarning()], loadAllAnnotationsWarning: [this.userPreferenceService.getBool(PreferencesKeys.loadAllAnnotationsWarning)], @@ -68,6 +73,12 @@ export class PreferencesComponent extends BaseFormComponent { if (this.form.controls.displaySuggestionsInPreview.value !== this.userPreferenceService.getDisplaySuggestionsInPreview()) { await this.userPreferenceService.toggleDisplaySuggestionsInPreview(); } + if ( + this.form.controls.openStructuredComponentManagementDialogByDefault.value !== + this.userPreferenceService.getOpenStructuredComponentManagementDialogByDefault() + ) { + await this.userPreferenceService.toggleOpenStructuredComponentManagementDialogByDefault(); + } if (this.form.controls.unapprovedSuggestionsWarning.value !== this.userPreferenceService.getUnapprovedSuggestionsWarning()) { await this.userPreferenceService.toggleUnapprovedSuggestionsWarning(); } @@ -83,12 +94,20 @@ export class PreferencesComponent extends BaseFormComponent { } await this.userPreferenceService.reload(); - this.form.patchValue({ - autoExpandFiltersOnActions: this.userPreferenceService.getAutoExpandFiltersOnActions(), - displaySuggestionsInPreview: this.userPreferenceService.getDisplaySuggestionsInPreview(), - unapprovedSuggestionsWarning: this.userPreferenceService.getUnapprovedSuggestionsWarning(), - }); + this.#patchValues(); + this.initialFormValue = this.form.getRawValue(); this._changeRef.markForCheck(); } + + #patchValues() { + this.form.patchValue({ + autoExpandFiltersOnActions: this.userPreferenceService.getAutoExpandFiltersOnActions(), + displaySuggestionsInPreview: this.userPreferenceService.getDisplaySuggestionsInPreview(), + openStructuredComponentManagementDialogByDefault: + this.userPreferenceService.getOpenStructuredComponentManagementDialogByDefault(), + unapprovedSuggestionsWarning: this.userPreferenceService.getUnapprovedSuggestionsWarning(), + loadAllAnnotationsWarning: this.userPreferenceService.getBool(PreferencesKeys.loadAllAnnotationsWarning), + }); + } } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.html index f4a705dd6..dbb5374f0 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.html @@ -80,6 +80,13 @@ >
+ Display by default when opening documents diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.scss b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.scss index cf04f8aa6..7c1268089 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.scss +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.scss @@ -63,3 +63,7 @@ ul { .output-data > div:nth-child(8n + 12) { background: var(--iqser-grey-8); } + +.ml-auto { + margin-left: auto; +} diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.ts index 7b9204110..ac6eaf72a 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/rss-dialog/rss-dialog.component.ts @@ -17,8 +17,10 @@ interface RssData { }) export class RssDialogComponent extends BaseDialogComponent implements OnInit { readonly circleButtonTypes = CircleButtonTypes; - readonly rssData = signal(undefined); + readonly openStructuredComponentManagementDialogByDefault = signal( + this.userPreferences.getOpenStructuredComponentManagementDialogByDefault(), + ); constructor( protected readonly _dialogRef: MatDialogRef, @@ -56,6 +58,14 @@ export class RssDialogComponent extends BaseDialogComponent implements OnInit { return this.exportJSON(); } + async toggleOpenStructuredComponentManagementDialogByDefault() { + await this.userPreferences.toggleOpenStructuredComponentManagementDialogByDefault(); + await this.userPreferences.reload(); + this.openStructuredComponentManagementDialogByDefault.set( + this.userPreferences.getOpenStructuredComponentManagementDialogByDefault(), + ); + } + async undo(originalKey: string) { this._loadingService.start(); await firstValueFrom(this._rssService.revertOverride(this.data.file.dossierId, this.data.file.fileId, [originalKey])); diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 7f122e60a..54c5ed99a 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -317,6 +317,8 @@ export class FilePreviewScreenComponent this.pdfProxyService.configureElements(); this.#restoreOldFilters(); document.documentElement.addEventListener('fullscreenchange', this.fullscreenListener); + + this.#openRssDialogIfDefault(); } ngAfterViewInit() { @@ -831,4 +833,13 @@ export class FilePreviewScreenComponent } }); } + + #openRssDialogIfDefault() { + if ( + this.permissionsService.canViewRssDialog() && + this.userPreferenceService.getOpenStructuredComponentManagementDialogByDefault() + ) { + this.openRSSView(); + } + } } diff --git a/apps/red-ui/src/app/services/permissions.service.ts b/apps/red-ui/src/app/services/permissions.service.ts index 1040f8cf8..8eade5337 100644 --- a/apps/red-ui/src/app/services/permissions.service.ts +++ b/apps/red-ui/src/app/services/permissions.service.ts @@ -354,6 +354,10 @@ export class PermissionsService { return this._iqserPermissionsService.has(Roles.rules.write) && this.isAdmin(); } + canViewRssDialog() { + return this._iqserPermissionsService.has(Roles.getRss); + } + #canDeleteEntity(entity: Dictionary): boolean { return !entity.systemManaged; } diff --git a/apps/red-ui/src/app/users/user-preference.service.ts b/apps/red-ui/src/app/users/user-preference.service.ts index 7f4ed1082..4f8423e91 100644 --- a/apps/red-ui/src/app/users/user-preference.service.ts +++ b/apps/red-ui/src/app/users/user-preference.service.ts @@ -10,6 +10,7 @@ export const PreferencesKeys = { displaySuggestionsInPreview: 'Display-Suggestions-In-Preview', unapprovedSuggestionsWarning: 'Unapproved-Suggestions-Warning', loadAllAnnotationsWarning: 'Load-All-Annotations-Warning', + openStructuredComponentManagementDialogByDefault: 'Open-Structured-Component-Management-By-Default', } as const; @Injectable({ @@ -53,6 +54,15 @@ export class UserPreferenceService extends IqserUserPreferenceService { await this.save(PreferencesKeys.autoExpandFiltersOnActions, nextValue); } + getOpenStructuredComponentManagementDialogByDefault(): boolean { + return this._getAttribute(PreferencesKeys.openStructuredComponentManagementDialogByDefault, 'false') === 'true'; + } + + async toggleOpenStructuredComponentManagementDialogByDefault(): Promise { + const nextValue = (!this.getOpenStructuredComponentManagementDialogByDefault()).toString(); + await this.save(PreferencesKeys.openStructuredComponentManagementDialogByDefault, nextValue); + } + getDisplaySuggestionsInPreview(): boolean { return this._getAttribute(PreferencesKeys.displaySuggestionsInPreview, 'false') === 'true'; } diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index 9469284fd..f5f8c111e 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -1860,6 +1860,7 @@ "form": { "auto-expand-filters-on-action": "", "load-all-annotations-warning": "", + "open-structured-view-by-default": "", "show-suggestions-in-preview": "", "unapproved-suggestions-warning": "" }, diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 01547ec36..6c4f99aba 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -1860,6 +1860,7 @@ "form": { "auto-expand-filters-on-action": "Auto-expand filters on my actions", "load-all-annotations-warning": "Warning regarding loading all annotations at once in file preview", + "open-structured-view-by-default": "Display structured component management modal by default", "show-suggestions-in-preview": "Display suggestions in document preview", "unapproved-suggestions-warning": "Warning regarding unapproved suggestions in document Preview mode" }, diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index efa545a5e..64584c1a1 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -1860,6 +1860,7 @@ "form": { "auto-expand-filters-on-action": "", "load-all-annotations-warning": "", + "open-structured-view-by-default": "", "show-suggestions-in-preview": "", "unapproved-suggestions-warning": "" }, diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index 1fc437315..b0108bfff 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -1860,6 +1860,7 @@ "form": { "auto-expand-filters-on-action": "Auto expand filters on my actions", "load-all-annotations-warning": "Warning regarding loading all annotations at once in file preview", + "open-structured-view-by-default": "Display structured component management modal by default", "show-suggestions-in-preview": "Display suggestions in document preview", "unapproved-suggestions-warning": "Warning regarding unapproved suggestions in document Preview mode" },