Move from ValidationErrorResult to HttpBadRequest, and support object-level errors too

This commit is contained in:
SteveSandersonMS
2015-12-14 12:02:41 +00:00
parent bba388944d
commit 8a148d8535
6 changed files with 72 additions and 39 deletions

View File

@@ -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>

View File

@@ -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