mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-24 10:40:23 +00:00
Move from ValidationErrorResult to HttpBadRequest, and support object-level errors too
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
|
||||
<form-field>
|
||||
<div *ng-if="changesSaved" class="alert alert-success"><b>Done!</b> Your changes were saved.</div>
|
||||
<div *ng-for="#errorMessage of formErrors" class="alert alert-danger">{{ errorMessage }}</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
<button type="button" class="btn btn-danger" (click)="deleteprompt.show(originalAlbum)">Delete</button>
|
||||
<a class="btn btn-default" [router-link]="['/Admin/Albums']">Back to List</a>
|
||||
|
||||
@@ -69,7 +69,7 @@ export class AlbumEdit {
|
||||
var albumId = this.originalAlbum.AlbumId;
|
||||
|
||||
this._putJson(`/api/albums/${ albumId }/update`, this.form.value).subscribe(response => {
|
||||
if (response.ok) {
|
||||
if (response.status === 200) {
|
||||
this.changesSaved = true;
|
||||
} else {
|
||||
AspNet.Validation.showValidationErrors(response, this.form);
|
||||
@@ -88,6 +88,10 @@ export class AlbumEdit {
|
||||
headers: new Headers({ 'Content-Type': 'application/json' })
|
||||
});
|
||||
}
|
||||
|
||||
public get formErrors() {
|
||||
return Object.keys(this.form.errors || {});
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Figure out what type declaration is provided by Angular/RxJs and use that instead
|
||||
|
||||
Reference in New Issue
Block a user