53 lines
1.2 KiB
JavaScript
53 lines
1.2 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);
|
|
}
|
|
|
|
onIconClick(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);
|
|
}
|
|
|
|
onDrop(item, dragged, dropped) {
|
|
this.treeview.onDrop(item, dragged, dropped);
|
|
}
|
|
|
|
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'
|
|
}
|
|
});
|