Merge branch 'RED-7691' into 'master'

RED-7691

See merge request redactmanager/red-ui!228
This commit is contained in:
Dan Percic 2023-12-14 11:50:07 +01:00
commit f1c4748ba4

View File

@ -18,8 +18,8 @@ import type {
import { dictionaryActionsTranslations, manualRedactionActionsTranslations } from '@translations/annotation-actions-translations';
import { Roles } from '@users/roles';
import { NGXLogger } from 'ngx-logger';
import { of } from 'rxjs';
import { tap } from 'rxjs/operators';
import { EMPTY, of, OperatorFunction, pipe } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
function getResponseType(error: boolean, isConflict: boolean) {
const isConflictError = isConflict ? 'conflictError' : 'error';
@ -150,22 +150,22 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
}
#showToast(action: ManualRedactionActions | DictionaryActions, isDictionary = false) {
return tap({
next: () => this._toaster.success(getMessage(action, isDictionary), { positionClass: 'toast-file-preview' }),
error: (error: unknown) => {
return pipe(
catchError((error: unknown) => {
const isConflict = (error as HttpErrorResponse).status === HttpStatusCode.Conflict;
this._toaster.error(getMessage(action, isDictionary, true, isConflict), {
error: error as HttpErrorResponse,
positionClass: 'toast-file-preview',
});
},
});
return EMPTY;
}),
tap(() => this._toaster.success(getMessage(action, isDictionary), { positionClass: 'toast-file-preview' })),
);
}
#showAddToDictionaryToast(body: List<IAddRedactionRequest>, dictionaryLabel?: string) {
return tap({
next: () => this._toaster.success(getDictionaryMessage('add'), { positionClass: 'toast-file-preview' }),
error: (error: unknown) => {
return pipe(
catchError((error: unknown) => {
const isConflict = (error as HttpErrorResponse).status === HttpStatusCode.Conflict;
this._toaster.error(getDictionaryMessage('add', true, isConflict), {
error: error as HttpErrorResponse,
@ -175,7 +175,9 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
},
positionClass: 'toast-file-preview',
});
},
});
return EMPTY;
}),
tap(() => this._toaster.success(getDictionaryMessage('add'), { positionClass: 'toast-file-preview' })),
);
}
}