Fix error state of fields newly introduced by type switch

pull/4338/head
Oliver Günther 9 years ago
parent f2246e32c7
commit a5823dc755
  1. 5
      frontend/app/components/api/api-v3/hal-resources/work-package-resource.service.ts
  2. 4
      frontend/app/components/wp-edit/wp-edit-field/wp-edit-field.directive.ts
  3. 11
      frontend/app/components/wp-edit/wp-edit-form.directive.ts

@ -157,10 +157,11 @@ export class WorkPackageResource extends HalResource {
this.saveResource(payload)
.then(workPackage => {
angular.extend(this, workPackage);
wpCacheService.updateWorkPackage(this);
deferred.resolve(this);
}).catch((error) => {
deferred.reject(error);
deferred.reject(error);
}).finally(() => {
wpCacheService.updateWorkPackage(this);
});
})
.catch(deferred.reject);

@ -155,7 +155,7 @@ export class WorkPackageEditFieldController {
public setErrorState(error = true) {
this.errorenous = error;
this.$element.toggleClass('-error', error)
this.$element.toggleClass('-error', error);
}
@ -188,7 +188,7 @@ function wpEditFieldLink(
$timeout) {
controllers[1].formCtrl = controllers[0];
controllers[1].formCtrl.fields[scope.vm.fieldName] = scope.vm;
controllers[1].formCtrl.registerField(scope.vm);
scope.vm.initializeField();

@ -35,6 +35,8 @@ export class WorkPackageEditFormController {
public fields = {};
public firstActiveField:string;
public lastErrorFields:string[] = [];
constructor(
protected $scope:ng.IScope,
protected $q,
@ -52,6 +54,11 @@ export class WorkPackageEditFormController {
});
}
public registerField(field) {
this.fields[field.fieldName] = field;
field.setErrorState(this.lastErrorFields.indexOf(field.fieldName) !== -1);
}
public loadSchema() {
return this.workPackage.getSchema();
}
@ -61,6 +68,7 @@ export class WorkPackageEditFormController {
// Reset old error notifcations
this.$rootScope.$emit('notifications.clearAll');
this.lastErrorFields = [];
this.workPackage.save()
.then(() => {
@ -113,6 +121,9 @@ export class WorkPackageEditFormController {
attributes: attributes
});
// Save erroneous fields for when new fields appear
this.lastErrorFields = attributes;
this.$scope.$evalAsync(() => {
angular.forEach(this.fields, field => {
field.setErrorState(attributes.indexOf(field.fieldName) !== -1);

Loading…
Cancel
Save