2018-02-10 15:18:01 +00:00
|
|
|
import ngModule from '../../module';
|
2018-05-08 07:28:25 +00:00
|
|
|
import Input from '../../lib/input';
|
|
|
|
import asignProps from '../../lib/asign-props';
|
2017-06-15 09:22:47 +00:00
|
|
|
import './style.scss';
|
2017-06-13 11:08:06 +00:00
|
|
|
|
2018-05-08 07:28:25 +00:00
|
|
|
export default class IconMenu extends Input {
|
|
|
|
constructor($element, $scope, $transclude) {
|
|
|
|
super($element, $scope);
|
|
|
|
this.$transclude = $transclude;
|
|
|
|
this.input = this.element.querySelector('.mdl-button');
|
|
|
|
this.valueField = 'id';
|
|
|
|
this.showField = 'name';
|
2017-06-13 11:08:06 +00:00
|
|
|
}
|
2017-10-04 06:47:16 +00:00
|
|
|
|
2018-05-08 07:28:25 +00:00
|
|
|
getFields() {
|
|
|
|
let fields = [];
|
|
|
|
fields.push(this.valueField);
|
|
|
|
fields.push(this.showField);
|
2017-10-04 06:47:16 +00:00
|
|
|
|
2018-05-08 07:28:25 +00:00
|
|
|
if (this.selectFields)
|
|
|
|
for (let field of this.selectFields)
|
|
|
|
fields.push(field);
|
2017-06-29 11:56:52 +00:00
|
|
|
|
2018-05-08 07:28:25 +00:00
|
|
|
return fields;
|
2017-06-29 11:56:52 +00:00
|
|
|
}
|
2017-10-04 06:47:16 +00:00
|
|
|
|
2018-05-08 07:28:25 +00:00
|
|
|
onClick(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
this.showDropDown();
|
2017-06-13 11:08:06 +00:00
|
|
|
}
|
2017-10-04 06:47:16 +00:00
|
|
|
|
2018-05-08 07:28:25 +00:00
|
|
|
onDropDownSelect(value) {
|
|
|
|
this.field = value;
|
2017-07-03 06:38:45 +00:00
|
|
|
|
2018-05-08 07:28:25 +00:00
|
|
|
if (this.onChange)
|
|
|
|
this.onChange({value});
|
|
|
|
}
|
2017-11-23 13:09:38 +00:00
|
|
|
|
2018-05-08 07:28:25 +00:00
|
|
|
showDropDown() {
|
|
|
|
Object.assign(this.$.dropDown.$.model, {
|
|
|
|
url: this.url,
|
|
|
|
staticData: this.data
|
2017-06-13 11:08:06 +00:00
|
|
|
});
|
|
|
|
|
2018-05-08 07:28:25 +00:00
|
|
|
asignProps(this, this.$.dropDown, [
|
|
|
|
'valueField',
|
|
|
|
'showField',
|
|
|
|
'where',
|
|
|
|
'order',
|
|
|
|
'showFilter',
|
|
|
|
'multiple',
|
|
|
|
'limit',
|
|
|
|
'$transclude'
|
|
|
|
]);
|
|
|
|
|
|
|
|
this.$.dropDown.selectFields = this.getFields();
|
|
|
|
this.$.dropDown.parent = this.input;
|
|
|
|
this.$.dropDown.show();
|
2017-06-15 05:45:01 +00:00
|
|
|
}
|
2017-06-13 11:08:06 +00:00
|
|
|
}
|
2018-05-08 07:28:25 +00:00
|
|
|
IconMenu.$inject = ['$element', '$scope', '$transclude'];
|
2017-06-13 11:08:06 +00:00
|
|
|
|
2018-02-10 15:18:01 +00:00
|
|
|
ngModule.component('vnIconMenu', {
|
2017-06-13 11:08:06 +00:00
|
|
|
template: require('./icon-menu.html'),
|
|
|
|
bindings: {
|
|
|
|
url: '@?',
|
2018-05-08 07:28:25 +00:00
|
|
|
data: '<?',
|
|
|
|
showField: '@?',
|
|
|
|
valueField: '@?',
|
|
|
|
selectFields: '<?',
|
|
|
|
disabled: '<?',
|
|
|
|
where: '@?',
|
|
|
|
order: '@?',
|
|
|
|
label: '@',
|
|
|
|
initialData: '<?',
|
|
|
|
field: '=?',
|
|
|
|
limit: '<?',
|
|
|
|
showFilter: '<?',
|
|
|
|
selection: '<?',
|
|
|
|
multiple: '<?',
|
|
|
|
onChange: '&?',
|
|
|
|
icon: '@?'
|
|
|
|
},
|
|
|
|
transclude: {
|
|
|
|
tplItem: '?tplItem'
|
2017-06-13 11:08:06 +00:00
|
|
|
},
|
2017-06-15 13:00:43 +00:00
|
|
|
controller: IconMenu
|
2017-06-13 11:08:06 +00:00
|
|
|
});
|