notify library ID conflict (#509)

This commit is contained in:
Cilibiu Bogdan
2018-07-13 22:22:26 +03:00
committed by GitHub
parent 0504b28b3c
commit 53c2e88689
2 changed files with 13 additions and 2 deletions

View File

@@ -112,7 +112,7 @@ export class LibraryDialogComponent implements OnInit {
this.success.emit(folder);
dialog.close(folder);
},
(error) => this.error.emit('LIBRARY.ERRORS.GENERIC')
(error) => this.handleError(error)
);
}
@@ -137,4 +137,14 @@ export class LibraryDialogComponent implements OnInit {
.replace(/[\s]/g, '-')
.replace(/[^A-Za-z0-9-]/g, '');
}
private handleError(error: any): any {
const { error: { statusCode } } = JSON.parse(error.message);
if (statusCode === 409) {
this.form.controls['id'].setErrors({ message: 'LIBRARY.ERRORS.CONFLICT' });
}
return error;
}
}

View File

@@ -287,7 +287,8 @@
},
"ERRORS": {
"GENERIC": "There was an error",
"EXISTENT_SITE": "ID already used (it might be in the trashcan).",
"EXISTENT_SITE": "This Site ID isn't available. Try a different one",
"CONFLICT": "ID already used (it might be in the trashcan).",
"ID_TOO_LONG": "Use 72 characters or less for the URL name",
"DESCRIPTION_TOO_LONG": "Use 512 characters or less for description",
"TITLE_TOO_LONG": "Use 256 characters or less for title",