Errores en el login no se mostraban
This commit is contained in:
parent
e03d257930
commit
719168565c
|
@ -48,7 +48,6 @@ export default class Controller {
|
||||||
onLoginErr(json) {
|
onLoginErr(json) {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.password = '';
|
this.password = '';
|
||||||
this.focusUser();
|
|
||||||
|
|
||||||
let message;
|
let message;
|
||||||
|
|
||||||
|
@ -64,6 +63,7 @@ export default class Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showMessage(message);
|
this.showMessage(message);
|
||||||
|
this.focusUser();
|
||||||
}
|
}
|
||||||
focusUser() {
|
focusUser() {
|
||||||
this.$.userField.select();
|
this.$.userField.select();
|
||||||
|
|
|
@ -31,6 +31,6 @@ export default class App {
|
||||||
this.$rootScope.loading = false;
|
this.$rootScope.loading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
App.$inject = ['$rootScope']
|
App.$inject = ['$rootScope'];
|
||||||
|
|
||||||
module.service('vnApp', App);
|
module.service('vnApp', App);
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,8 +4,7 @@
|
||||||
ng-focus="$ctrl.hasFocus = true"
|
ng-focus="$ctrl.hasFocus = true"
|
||||||
ng-blur="$ctrl.hasFocus = false"
|
ng-blur="$ctrl.hasFocus = false"
|
||||||
ng-mouseenter="$ctrl.hasMouseIn = true"
|
ng-mouseenter="$ctrl.hasMouseIn = true"
|
||||||
ng-mouseleave="$ctrl.hasMouseIn = false"
|
ng-mouseleave="$ctrl.hasMouseIn = false">
|
||||||
>
|
|
||||||
<input
|
<input
|
||||||
class="mdl-textfield__input"
|
class="mdl-textfield__input"
|
||||||
type="{{$ctrl.type}}"
|
type="{{$ctrl.type}}"
|
||||||
|
@ -13,11 +12,19 @@
|
||||||
ng-model="$ctrl.value"
|
ng-model="$ctrl.value"
|
||||||
vn-validation="{{$ctrl.rule}}"
|
vn-validation="{{$ctrl.rule}}"
|
||||||
ng-disabled="$ctrl.disabled"
|
ng-disabled="$ctrl.disabled"
|
||||||
ng-readonly="$ctrl.readonly"
|
ng-readonly="$ctrl.readonly"/>
|
||||||
/>
|
|
||||||
<div class="mdl-chip__action">
|
<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"
|
||||||
<i class="material-icons pointer" ng-show="$ctrl.hasValue&&($ctrl.hasFocus||$ctrl.hasMouseIn)" ng-click="$ctrl.clear()">clear</i>
|
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>
|
</div>
|
||||||
<label class="mdl-textfield__label" translate>{{$ctrl.label}}</label>
|
<label class="mdl-textfield__label" translate>{{$ctrl.label}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import {module} from '../module';
|
import {module} from '../module';
|
||||||
import Component from '../lib/component';
|
import Input from '../lib/input';
|
||||||
import * as normalizerFactory from '../lib/inputAttrsNormalizer';
|
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
export default class TextfieldController extends Component {
|
export default class Textfield extends Input {
|
||||||
constructor($element, $scope, $attrs, $timeout, normalizer) {
|
constructor($element, $scope, $attrs, $timeout, normalizer) {
|
||||||
super($element);
|
super($element);
|
||||||
|
|
||||||
|
@ -15,45 +14,39 @@ export default class TextfieldController extends Component {
|
||||||
this.$timeout = $timeout;
|
this.$timeout = $timeout;
|
||||||
|
|
||||||
this._value = null;
|
this._value = null;
|
||||||
this.type = this.$attrs.type || 'text';
|
this.type = $attrs.type || 'text';
|
||||||
this.showActions = false;
|
this.showActions = false;
|
||||||
this.input = $element[0].querySelector('input');
|
this.input = $element[0].querySelector('input');
|
||||||
this.focus = false;
|
this.hasInfo = Boolean($attrs.info);
|
||||||
this.hasInfo = Boolean(this.$attrs.info);
|
this.info = $attrs.info || null;
|
||||||
this.info = this.$attrs.info || null;
|
|
||||||
this.hasFocus = false;
|
this.hasFocus = false;
|
||||||
this.hasMouseIn = false;
|
this.hasMouseIn = false;
|
||||||
componentHandler.upgradeElement($element[0].firstChild);
|
componentHandler.upgradeElement($element[0].firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
get value() {
|
get value() {
|
||||||
return this._value;
|
return this._value;
|
||||||
}
|
}
|
||||||
|
|
||||||
set value(value) {
|
set value(value) {
|
||||||
this._value = (value === undefined || value === '') ? null : value;
|
this._value = (value === undefined || value === '') ? null : value;
|
||||||
this.input.value = this._value;
|
this.input.value = this._value;
|
||||||
this.hasValue = Boolean(this._value);
|
this.hasValue = Boolean(this._value);
|
||||||
this.mdlUpdate();
|
this.mdlUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
mdlUpdate() {
|
mdlUpdate() {
|
||||||
let mdlField = this.$element[0].firstChild.MaterialTextfield;
|
let mdlField = this.$element[0].firstChild.MaterialTextfield;
|
||||||
if (mdlField)
|
if (mdlField)
|
||||||
mdlField.updateClasses_();
|
mdlField.updateClasses_();
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
this.value = null;
|
this.value = null;
|
||||||
this.input.focus();
|
this.input.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Textfield.$inject = ['$element', '$scope', '$attrs', '$timeout', 'vnInputAttrsNormalizer'];
|
||||||
TextfieldController.$inject = ['$element', '$scope', '$attrs', '$timeout', normalizerFactory.NAME];
|
|
||||||
|
|
||||||
module.component('vnTextfield', {
|
module.component('vnTextfield', {
|
||||||
template: require('./textfield.html'),
|
template: require('./textfield.html'),
|
||||||
controller: TextfieldController,
|
controller: Textfield,
|
||||||
bindings: {
|
bindings: {
|
||||||
value: '=model',
|
value: '=model',
|
||||||
label: '@?',
|
label: '@?',
|
||||||
|
|
Loading…
Reference in New Issue