49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
import ngModule from '../../module';
|
|
import Component from '../../lib/component';
|
|
|
|
class Controller extends Component {
|
|
constructor($element, $scope) {
|
|
super($element, $scope);
|
|
this.$scope = $scope;
|
|
}
|
|
|
|
toggle(item) {
|
|
this.treeview.onToggle(item);
|
|
}
|
|
|
|
select(item, value) {
|
|
this.treeview.onSelection(item, value);
|
|
}
|
|
|
|
onClick(icon, item, parent, index) {
|
|
let parentScope = this.$scope.$parent.$parent;
|
|
let parentController = parentScope.$ctrl;
|
|
icon.callback.call(parentController, item, parent, index);
|
|
}
|
|
|
|
onCreate(parent) {
|
|
this.treeview.onCreate(parent);
|
|
}
|
|
|
|
get isInsertable() {
|
|
return Array.isArray(this.parent) || this.parent.childs;
|
|
}
|
|
}
|
|
|
|
ngModule.component('vnTreeviewChild', {
|
|
template: require('./child.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
items: '<',
|
|
parent: '<',
|
|
icons: '<?',
|
|
disabled: '<?',
|
|
selectable: '<?',
|
|
editable: '<?',
|
|
aclRole: '<?',
|
|
},
|
|
require: {
|
|
treeview: '^vnTreeview'
|
|
}
|
|
});
|