Merge branch 'RED-7270' into 'master'

RED-7270: Display backend provided error message for dossier states

Closes RED-7270

See merge request redactmanager/red-ui!539
This commit is contained in:
Valentin-Gabriel Mihai 2024-08-12 20:09:19 +02:00
commit 0a05d02623
5 changed files with 11 additions and 12 deletions

View File

@ -10,21 +10,24 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { mapEach } from '@iqser/common-ui/lib/utils';
const CONFLICT_MSG = _('dossier-states-listing.error.conflict');
const GENERIC_MSG = _('dossier-states-listing.error.generic');
@Injectable({
providedIn: 'root',
})
export class DossierStatesService extends EntitiesService<IDossierState, DossierState> {
protected readonly _defaultModelPath = 'dossier-status';
protected readonly _entityClass = DossierState;
readonly #toaster = inject(Toaster);
readonly #dossierTemplatesService = inject(DossierTemplatesService);
readonly #dossierStatesMapService = inject(DossierStatesMapService);
protected readonly _defaultModelPath = 'dossier-status';
protected readonly _entityClass = DossierState;
async createOrUpdate(state: IDossierState) {
const showToast = (error: HttpErrorResponse) => {
this.#toaster.error(error.status === HttpStatusCode.Conflict ? CONFLICT_MSG : GENERIC_MSG);
if (error.status === HttpStatusCode.Conflict) {
this.#toaster.error(CONFLICT_MSG);
} else {
this.#toaster.rawError(error.error.message);
}
return EMPTY;
};

View File

@ -1065,8 +1065,7 @@
"dossier-states": "{count, plural, one{Dossier-Status} other{Dossier-Status}}"
},
"error": {
"conflict": "Es gibt bereits einen Dossier-Status mit diesem Namen.",
"generic": "Speichern des Dossier-Status fehlgeschlagen."
"conflict": "Es gibt bereits einen Dossier-Status mit diesem Namen."
},
"no-data": {
"title": "Es wurde noch kein Dossier-Status angelegt."

View File

@ -1065,8 +1065,7 @@
"dossier-states": "{count, plural, one{Dossier state} other{Dossier states}}"
},
"error": {
"conflict": "Dossier state with this name already exists",
"generic": "Failed to save dossier state."
"conflict": "Dossier state with this name already exists"
},
"no-data": {
"title": "There are no dossier states."

View File

@ -1065,8 +1065,7 @@
"dossier-states": "{count, plural, one{Dossier state} other{Dossier states}}"
},
"error": {
"conflict": "Dossier state with this name already exists!",
"generic": "Failed to save dossier state!"
"conflict": "Dossier state with this name already exists!"
},
"no-data": {
"title": "There are no dossier states."

View File

@ -1065,8 +1065,7 @@
"dossier-states": "{count, plural, one{Dossier state} other{Dossier states}}"
},
"error": {
"conflict": "Dossier state with this name already exists!",
"generic": "Failed to save dossier state!"
"conflict": "Dossier state with this name already exists!"
},
"no-data": {
"title": "There are no dossier states."