From 81fe84eb02940e4d6ad42fe91ec5e9fe1e21613d Mon Sep 17 00:00:00 2001 From: George Date: Mon, 6 Feb 2023 14:43:13 +0200 Subject: [PATCH 1/4] RED-4590: Group Regex so precedence is obvious. --- apps/red-ui/src/app/models/file/annotation.wrapper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index 44024837e..0f239074a 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -391,7 +391,7 @@ export class AnnotationWrapper implements IListable, Record { if (entry.reason) { content += entry.reason + '\n\n'; //remove leading and trailing commas and whitespaces - content = content.replace(/^[, ]*|[, ]*$/g, ''); + content = content.replace(/(^[, ]*)|([, ]*$)/g, ''); content = content.substring(0, 1).toUpperCase() + content.substring(1); } From d0660bcb1f2816b3270cfcc02bea332393ba5277 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 6 Feb 2023 14:43:54 +0200 Subject: [PATCH 2/4] RED-4590: Delete commented lines. --- .../user-profile-screen/user-profile-screen.component.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.ts b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.ts index fc4aae6cd..8d4bd718e 100644 --- a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.ts +++ b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen/user-profile-screen.component.ts @@ -84,8 +84,6 @@ export class UserProfileScreenComponent extends BaseFormComponent implements OnI try { if (this.profileChanged) { const value = this.form.getRawValue() as IProfile; - // delete value.language; - // delete value.darkTheme; if (this.emailChanged) { const dialogRef = this._dialogService.openDialog('confirmPassword', null, null); From c88da500450dcfea9a6204c296948f83c0a5a710 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 6 Feb 2023 14:47:25 +0200 Subject: [PATCH 3/4] RED-4590: Sort method mutates the underlying array as well as return it. Separate blocks to emphasize. --- .../src/app/modules/dossier-overview/config.service.ts | 8 ++++---- .../src/app/modules/dossiers-listing/config.service.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier-overview/config.service.ts b/apps/red-ui/src/app/modules/dossier-overview/config.service.ts index a28454e4c..d5ad67d43 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/config.service.ts +++ b/apps/red-ui/src/app/modules/dossier-overview/config.service.ts @@ -285,12 +285,12 @@ export class ConfigService { label: this._translateService.instant(workflowFileStatusTranslations[status]), }), ); - + statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]); filterGroups.push({ slug: 'statusFilters', label: this._translateService.instant('filters.documents-status'), icon: 'red:status', - filters: statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]), + filters: statusFilters, checker: keyChecker('workflowStatus'), }); } @@ -336,13 +336,13 @@ export class ConfigService { }, }), ); - + needsWorkFilters.sort(RedactionFilterSorter.byKey); filterGroups.push({ slug: 'needsWorkFilters', label: this._translateService.instant('filters.needs-work'), icon: 'red:needs-work', filterTemplate: needsWorkFilterTemplate, - filters: needsWorkFilters.sort(RedactionFilterSorter.byKey), + filters: needsWorkFilters, checker: (file: File, filter: INestedFilter) => annotationFilterChecker(file, filter, this._userService.currentUser.id), matchAll: true, }); diff --git a/apps/red-ui/src/app/modules/dossiers-listing/config.service.ts b/apps/red-ui/src/app/modules/dossiers-listing/config.service.ts index 11880d5c6..e50a6e8ef 100644 --- a/apps/red-ui/src/app/modules/dossiers-listing/config.service.ts +++ b/apps/red-ui/src/app/modules/dossiers-listing/config.service.ts @@ -144,12 +144,12 @@ export class ConfigService { label: this._translateService.instant(workflowFileStatusTranslations[status]), }), ); - + statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]); filterGroups.push({ slug: 'statusFilters', label: this._translateService.instant('filters.documents-status'), icon: 'red:status', - filters: statusFilters.sort((a, b) => StatusSorter[a.id] - StatusSorter[b.id]), + filters: statusFilters, checker: (dossier: Dossier, filter: INestedFilter) => this._dossierStatusChecker(dossier, filter), }); @@ -180,13 +180,13 @@ export class ConfigService { }, }), ); - + needsWorkFilters.sort((a, b) => RedactionFilterSorter[a.id] - RedactionFilterSorter[b.id]); filterGroups.push({ slug: 'needsWorkFilters', label: this._translateService.instant('filters.needs-work'), icon: 'red:needs-work', filterTemplate: needsWorkFilterTemplate, - filters: needsWorkFilters.sort((a, b) => RedactionFilterSorter[a.id] - RedactionFilterSorter[b.id]), + filters: needsWorkFilters, checker: (dossier: Dossier, filter: INestedFilter) => this._annotationFilterChecker(dossier, filter), matchAll: true, }); From 588432a0db67bdb141f28e49221e5361e1337fdb Mon Sep 17 00:00:00 2001 From: George Date: Mon, 6 Feb 2023 14:49:38 +0200 Subject: [PATCH 4/4] RED-4590: Replace else statments with early returns. --- .../file-workload/file-workload.component.ts | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts index c48a9f3a5..a637a1dad 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts @@ -410,32 +410,32 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy private _navigatePages($event: KeyboardEvent) { const pageIdx = this.displayedPages.indexOf(this.activeViewerPage); - if ($event.key === 'ArrowDown') { - if (pageIdx !== -1) { - // If active page has annotations - if (pageIdx !== this.displayedPages.length - 1) { - this.pdf.navigateTo(this.displayedPages[pageIdx + 1]); - } - } else { - // If active page doesn't have annotations - const nextPage = this._nextPageWithAnnotations(); - if (nextPage) { - this.pdf.navigateTo(nextPage); - } - } - } else { - if (pageIdx !== -1) { - // If active page has annotations - if (pageIdx !== 0) { - this.pdf.navigateTo(this.displayedPages[pageIdx - 1]); - } - } else { + if ($event.key !== 'ArrowDown') { + if (pageIdx === -1) { // If active page doesn't have annotations const prevPage = this._prevPageWithAnnotations(); if (prevPage) { this.pdf.navigateTo(prevPage); } + return; } + // If active page has annotations + if (pageIdx !== 0) { + this.pdf.navigateTo(this.displayedPages[pageIdx - 1]); + } + return; + } + if (pageIdx === -1) { + // If active page doesn't have annotations + const nextPage = this._nextPageWithAnnotations(); + if (nextPage) { + this.pdf.navigateTo(nextPage); + } + return; + } + // If active page has annotations + if (pageIdx !== this.displayedPages.length - 1) { + this.pdf.navigateTo(this.displayedPages[pageIdx + 1]); } }