Errores en el login no se mostraban

This commit is contained in:
Juan Ferrer Toribio 2017-11-16 14:30:17 +01:00
parent e03d257930
commit 719168565c
5 changed files with 35 additions and 22 deletions

View File

@ -48,7 +48,6 @@ export default class Controller {
onLoginErr(json) {
this.loading = false;
this.password = '';
this.focusUser();
let message;
@ -64,6 +63,7 @@ export default class Controller {
}
this.showMessage(message);
this.focusUser();
}
focusUser() {
this.$.userField.select();

View File

@ -31,6 +31,6 @@ export default class App {
this.$rootScope.loading = false;
}
}
App.$inject = ['$rootScope']
App.$inject = ['$rootScope'];
module.service('vnApp', App);

View File

@ -0,0 +1,13 @@
import Component from './component';
/**
* Component that host an input.
*/
export default class Input extends Component {
select() {
this.input.select();
}
focus() {
this.input.focus();
}
}

View File

@ -4,8 +4,7 @@
ng-focus="$ctrl.hasFocus = true"
ng-blur="$ctrl.hasFocus = false"
ng-mouseenter="$ctrl.hasMouseIn = true"
ng-mouseleave="$ctrl.hasMouseIn = false"
>
ng-mouseleave="$ctrl.hasMouseIn = false">
<input
class="mdl-textfield__input"
type="{{$ctrl.type}}"
@ -13,11 +12,19 @@
ng-model="$ctrl.value"
vn-validation="{{$ctrl.rule}}"
ng-disabled="$ctrl.disabled"
ng-readonly="$ctrl.readonly"
/>
ng-readonly="$ctrl.readonly"/>
<div class="mdl-chip__action">
<i class="material-icons" ng-if="$ctrl.hasInfo" vn-tooltip="{{$ctrl.info}}" tooltip-position="up">info_outline</i>
<i class="material-icons pointer" ng-show="$ctrl.hasValue&&($ctrl.hasFocus||$ctrl.hasMouseIn)" ng-click="$ctrl.clear()">clear</i>
<i class="material-icons"
ng-if="$ctrl.hasInfo"
vn-tooltip="{{$ctrl.info}}"
tooltip-position="up">
info_outline
</i>
<i class="material-icons pointer"
ng-show="$ctrl.hasValue && ($ctrl.hasFocus || $ctrl.hasMouseIn)"
ng-click="$ctrl.clear()">
clear
</i>
</div>
<label class="mdl-textfield__label" translate>{{$ctrl.label}}</label>
</div>

View File

@ -1,9 +1,8 @@
import {module} from '../module';
import Component from '../lib/component';
import * as normalizerFactory from '../lib/inputAttrsNormalizer';
import Input from '../lib/input';
import './style.scss';
export default class TextfieldController extends Component {
export default class Textfield extends Input {
constructor($element, $scope, $attrs, $timeout, normalizer) {
super($element);
@ -15,45 +14,39 @@ export default class TextfieldController extends Component {
this.$timeout = $timeout;
this._value = null;
this.type = this.$attrs.type || 'text';
this.type = $attrs.type || 'text';
this.showActions = false;
this.input = $element[0].querySelector('input');
this.focus = false;
this.hasInfo = Boolean(this.$attrs.info);
this.info = this.$attrs.info || null;
this.hasInfo = Boolean($attrs.info);
this.info = $attrs.info || null;
this.hasFocus = false;
this.hasMouseIn = false;
componentHandler.upgradeElement($element[0].firstChild);
}
get value() {
return this._value;
}
set value(value) {
this._value = (value === undefined || value === '') ? null : value;
this.input.value = this._value;
this.hasValue = Boolean(this._value);
this.mdlUpdate();
}
mdlUpdate() {
let mdlField = this.$element[0].firstChild.MaterialTextfield;
if (mdlField)
mdlField.updateClasses_();
}
clear() {
this.value = null;
this.input.focus();
}
}
TextfieldController.$inject = ['$element', '$scope', '$attrs', '$timeout', normalizerFactory.NAME];
Textfield.$inject = ['$element', '$scope', '$attrs', '$timeout', 'vnInputAttrsNormalizer'];
module.component('vnTextfield', {
template: require('./textfield.html'),
controller: TextfieldController,
controller: Textfield,
bindings: {
value: '=model',
label: '@?',