From ec5e37f2a1a01fdd25368ae38605f936d95e87e3 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 29 Aug 2016 17:30:37 -0300 Subject: [PATCH] Remove dispensable interface for error messages --- src/app/account/register-component.html | 4 ++-- src/app/account/register.component.ts | 28 +++++++++++++++------------- src/app/shared/components/interfaces.ts | 4 ---- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/app/account/register-component.html b/src/app/account/register-component.html index 5f2f0e6..7c836a0 100644 --- a/src/app/account/register-component.html +++ b/src/app/account/register-component.html @@ -4,10 +4,10 @@
-
+

{{ "account.register.errorMessagesTitle" | translate }}

    -
  • {{ error.fieldName | translate }} {{ error.message | translate }}
  • +
  • {{ error.fieldName | translate }} {{ error.message | translate }}
diff --git a/src/app/account/register.component.ts b/src/app/account/register.component.ts index 3265a56..5f31222 100644 --- a/src/app/account/register.component.ts +++ b/src/app/account/register.component.ts @@ -4,7 +4,7 @@ import { NotificationService } from "./../shared/services/notification.service"; import { EnvironmentService } from "../../lib/ng-noosfero-api/http/environment.service"; import { RegisterController } from "./register.controller"; import { AuthController } from "./../login"; -import { IModalComponent, IErrorMessages } from "../shared/components/interfaces"; +import { IModalComponent } from "../shared/components/interfaces"; @Component({ selector: 'noosfero-register', @@ -21,10 +21,12 @@ export class RegisterComponent { modalInstance: ng.ui.bootstrap.IModalServiceInstance; + errorMessages: any[]; + constructor( private $state: ng.ui.IStateService, private $uibModal: ng.ui.bootstrap.IModalService, - private $scope: IErrorMessages, + private $scope: ng.IScope, public registerService: RegisterService, private notificationService: NotificationService, private environmentService: EnvironmentService @@ -37,21 +39,21 @@ export class RegisterComponent { let error = ''; let errors: any; let field = ''; - this.$scope.errorMessages = []; + this.errorMessages = []; this.registerService.createAccount(this.account).then((response) => { this.$state.transitionTo('main.environment'); this.notificationService.success({ title: "account.register.success.title", message: "account.register.success.message" }); }).catch((response) => { - if ( response.data.error ) { - errors = response.data['error'].split(', '); - for (error in errors) { - this.$scope.errorMessages.push({ message: errors[error] }); - } - } else if ( response.data.message ) { - errors = JSON.parse(response.data.message); - for (field in errors) { - this.$scope.errorMessages.push({ fieldName: field, message: errors[field][0] }); - } + if (response.data.error) { + errors = response.data['error'].split(', '); + for (error in errors) { + this.errorMessages.push({ message: errors[error] }); + } + } else if (response.data.message) { + errors = JSON.parse(response.data.message); + for (field in errors) { + this.errorMessages.push({ fieldName: field, message: errors[field][0] }); + } } this.notificationService.error({ title: "account.register.save.failed" }); }); diff --git a/src/app/shared/components/interfaces.ts b/src/app/shared/components/interfaces.ts index 9bc96d0..8f932a4 100644 --- a/src/app/shared/components/interfaces.ts +++ b/src/app/shared/components/interfaces.ts @@ -6,7 +6,3 @@ export interface IModalComponent { $uibModal: ng.ui.bootstrap.IModalService; modalInstance: ng.ui.bootstrap.IModalServiceInstance; } - -export interface IErrorMessages extends ng.IScope { - errorMessages: any; -} -- libgit2 0.21.2