diff --git a/client/auth/src/login/login.js b/client/auth/src/login/login.js
index 229c1a345..22783f9ab 100644
--- a/client/auth/src/login/login.js
+++ b/client/auth/src/login/login.js
@@ -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();
diff --git a/client/core/src/lib/app.js b/client/core/src/lib/app.js
index 4830fead3..3b58309b4 100644
--- a/client/core/src/lib/app.js
+++ b/client/core/src/lib/app.js
@@ -31,6 +31,6 @@ export default class App {
this.$rootScope.loading = false;
}
}
-App.$inject = ['$rootScope']
+App.$inject = ['$rootScope'];
module.service('vnApp', App);
diff --git a/client/core/src/lib/input.js b/client/core/src/lib/input.js
new file mode 100644
index 000000000..8db191c33
--- /dev/null
+++ b/client/core/src/lib/input.js
@@ -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();
+ }
+}
diff --git a/client/core/src/textfield/textfield.html b/client/core/src/textfield/textfield.html
index 3b8f24e1e..b2dc608f5 100644
--- a/client/core/src/textfield/textfield.html
+++ b/client/core/src/textfield/textfield.html
@@ -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">
+ ng-readonly="$ctrl.readonly"/>
- info_outline
- clear
+
+ info_outline
+
+
+ clear
+
diff --git a/client/core/src/textfield/textfield.js b/client/core/src/textfield/textfield.js
index 09d65ab9d..c6ca4cb1e 100644
--- a/client/core/src/textfield/textfield.js
+++ b/client/core/src/textfield/textfield.js
@@ -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: '@?',