RED-2424: Add stopword error toast

This commit is contained in:
Adina Țeudan 2021-10-19 20:10:22 +03:00
parent 2e2d4fa4c3
commit d2394452e8
5 changed files with 17 additions and 10 deletions

View File

@ -71,7 +71,7 @@ export class AddEditDossierAttributeDialogComponent extends AutoUnsubscribe impl
},
(error: HttpErrorResponse) => {
this._loadingService.stop();
this._toaster.error(_('add-edit-dossier-attribute.error.generic'), { error: error });
this._toaster.error(_('add-edit-dossier-attribute.error.generic'), { error });
},
);
}

View File

@ -11,7 +11,7 @@ import {
RemoveRedactionRequest,
} from '@redaction/red-ui-http';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { ErrorMessageService, GenericService, RequiredParam, Toaster, Validate } from '@iqser/common-ui';
import { CONFLICT_ERROR_CODE, ErrorMessageService, GenericService, RequiredParam, Toaster, Validate } from '@iqser/common-ui';
import { TranslateService } from '@ngx-translate/core';
import { tap } from 'rxjs/operators';
import { UserService } from '@services/user.service';
@ -20,6 +20,7 @@ import { AnnotationActionMode } from '../models/annotation-action-mode.model';
import { annotationActionsTranslations } from '../translations/annotation-actions-translations';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { DossiersService } from '@services/entity-services/dossiers.service';
import { HttpErrorResponse } from '@angular/common/http';
@Injectable()
export class ManualAnnotationService extends GenericService<ManualAddResponse> {
@ -63,9 +64,14 @@ export class ManualAnnotationService extends GenericService<ManualAddResponse> {
return obs.pipe(
tap(
() => this._toaster.success(this._getMessage(mode, modifyDictionary), { positionClass: 'toast-file-preview' }),
error => {
this._toaster.error(this._getMessage(mode, modifyDictionary, true), {
params: { error: this._errorMessageService.getMessage(error) },
(error: HttpErrorResponse) => {
const isConflict = error.status === CONFLICT_ERROR_CODE;
this._toaster.error(this._getMessage(mode, modifyDictionary, true, isConflict), {
error,
params: {
dictionaryName: this._appStateService.getDictionaryTypeValue(body.type).label,
content: body.value,
},
positionClass: 'toast-file-preview',
});
},
@ -318,9 +324,9 @@ export class ManualAnnotationService extends GenericService<ManualAddResponse> {
return this._post(body, url);
}
private _getMessage(mode: AnnotationActionMode, modifyDictionary?: boolean, error: boolean = false) {
private _getMessage(mode: AnnotationActionMode, modifyDictionary?: boolean, error = false, isConflict = false) {
const type = modifyDictionary ? 'dictionary' : 'manual-redaction';
const resultType = error ? 'error' : 'success';
const resultType = error ? (isConflict ? 'conflictError' : 'error') : 'success';
return annotationActionsTranslations[type][mode][resultType];
}
}

View File

@ -1,7 +1,7 @@
import { AnnotationActionMode } from '../models/annotation-action-mode.model';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
type ActionType = { [key in AnnotationActionMode]?: { error: string; success: string } };
type ActionType = { [key in AnnotationActionMode]?: { error: string; success: string; conflictError?: string } };
export const annotationActionsTranslations: {
dictionary: ActionType;
@ -10,6 +10,7 @@ export const annotationActionsTranslations: {
dictionary: {
add: {
error: _('annotation-actions.message.dictionary.add.error'),
conflictError: _('annotation-actions.message.dictionary.add.conflict-error'),
success: _('annotation-actions.message.dictionary.add.success'),
},
approve: {

View File

@ -150,6 +150,7 @@
"message": {
"dictionary": {
"add": {
"conflict-error": "Cannot add ''{content}'' to the {dictionaryName} dictionary because it was recognized as a general term that appears too often in texts.",
"error": "Failed to add entry to dictionary: {error}",
"success": "Entry added to dictionary. Changes will be visible after reanalysis."
},
@ -1210,7 +1211,6 @@
},
"end-user-license-text": "The use of this product is subject to the terms of the Redaction End User Agreement, unless otherwise specified therein.",
"end-user-license-title": "End User License Agreement",
"frontend-version": "Frontend Application Version",
"licensed-page-count": "Number of licensed pages",
"licensed-to": "Licensed to",
"licensing-details": "Licensing Details",

@ -1 +1 @@
Subproject commit 127c47576b6b93f7cdbaabc5fd8d27a4bfc3680c
Subproject commit dfd4a420c8911bfac6c2ffe94247dd2b378d5bc5