Pull request #395: RED-4590

Merge in RED/ui from RED-4590 to master

* commit '588432a0db67bdb141f28e49221e5361e1337fdb':
  RED-4590: Replace else statments with early returns.
  RED-4590: Sort method mutates the underlying array as well as return it. Separate blocks to emphasize.
  RED-4590: Delete commented lines.
  RED-4590: Group Regex so precedence is obvious.
This commit is contained in:
George Balanesc 2023-02-06 14:05:30 +01:00 committed by Dan Percic
commit cdbd979459
5 changed files with 29 additions and 31 deletions

View File

@ -391,7 +391,7 @@ export class AnnotationWrapper implements IListable, Record<string, unknown> {
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);
}

View File

@ -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);

View File

@ -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,
});

View File

@ -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,
});

View File

@ -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]);
}
}