refactoring autocomplete: input readonly and autofucos on search input

This commit is contained in:
Dani Herrero 2017-09-21 13:10:30 +02:00
parent 4b2f709879
commit 235cc2d8f6
5 changed files with 17 additions and 3 deletions

View File

@ -1,5 +1,5 @@
<vn-vertical ng-click="$ctrl.showDropDown = true">
<vn-textfield vn-one label="{{$ctrl.label}}" model="$ctrl.displayValue"></vn-textfield>
<vn-textfield vn-one label="{{$ctrl.label}}" model="$ctrl.displayValue" readonly="$ctrl.readonly"></vn-textfield>
<vn-drop-down vn-one
items="$ctrl.items"
show="$ctrl.showDropDown"

View File

@ -22,6 +22,7 @@ class Autocomplete extends Component {
this.items = this.data || [];
this.displayValueMultiCheck = [];
this._multiField = [];
this.readonly = true;
}
get showDropDown() {

View File

@ -12,7 +12,19 @@ export default class DropDown {
this.itemsFiltered = [];
this._activeOption = -1;
}
get show() {
return this._show;
}
set show(value) {
let oldValue = this.show;
this._show = value;
if (value && oldValue !== value && this.filter) {
let inputFilterSearch = this.$element[0].querySelector('input');
this.$timeout(() => {
inputFilterSearch.focus();
});
}
}
get search() {
return this._search;
}

View File

@ -6,6 +6,7 @@
ng-model="$ctrl.value"
vn-validation="{{$ctrl.rule}}"
ng-disabled="$ctrl.disabled"
ng-readonly="$ctrl.readonly"
/>
<div class="mdl-chip__action">
<i class="material-icons pointer" ng-show="$ctrl.hasValue" ng-click="$ctrl.clear()">clear</i>

View File

@ -20,7 +20,6 @@ export default class TextfieldController extends Component {
this.focus = false;
this.hasInfo = Boolean(this.$attrs.info);
this.info = this.$attrs.info || null;
componentHandler.upgradeElement($element[0].firstChild);
}
@ -56,6 +55,7 @@ module.component('vnTextfield', {
label: '@?',
name: '@?',
disabled: '<?',
readonly: '<?',
rule: '@?',
type: '@?'
}