salix/client/core/src/components/icon-menu/icon-menu.js

77 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-02-10 15:18:01 +00:00
import ngModule from '../../module';
import Input from '../../lib/input';
2018-10-18 07:24:20 +00:00
import assignProps from '../../lib/assign-props';
import './style.scss';
export default class IconMenu extends Input {
constructor($element, $scope, $transclude) {
super($element, $scope);
this.$transclude = $transclude;
this.input = this.element.querySelector('.mdl-button');
}
onClick(event) {
event.preventDefault();
if (this.onOpen) this.onOpen();
this.showDropDown();
}
onDropDownSelect(value) {
this.field = value;
if (this.onChange)
this.onChange({value});
}
2017-11-23 13:09:38 +00:00
showDropDown() {
2018-10-18 07:24:20 +00:00
assignProps(this, this.$.dropDown, [
'valueField',
'showField',
'showFilter',
'multiple',
'$transclude',
2018-10-18 07:24:20 +00:00
'translateFields',
'model',
'data',
'url',
'fields',
'include',
'where',
'order',
'limit',
'searchFunction'
]);
2018-10-18 07:24:20 +00:00
this.$.dropDown.show(this.input);
}
}
IconMenu.$inject = ['$element', '$scope', '$transclude'];
2018-02-10 15:18:01 +00:00
ngModule.component('vnIconMenu', {
template: require('./icon-menu.html'),
bindings: {
2018-10-18 07:24:20 +00:00
label: '@',
showField: '@?',
2018-10-18 07:24:20 +00:00
selection: '<?',
valueField: '@?',
selectFields: '<?',
disabled: '<?',
initialData: '<?',
2018-10-18 07:24:20 +00:00
showFilter: '<?',
field: '=?',
2018-10-18 07:24:20 +00:00
url: '@?',
data: '<?',
where: '@?',
order: '@?',
limit: '<?',
multiple: '<?',
onChange: '&?',
icon: '@?',
translateFields: '<?',
onOpen: '&?'
},
transclude: {
tplItem: '?tplItem'
},
controller: IconMenu
});