2019-01-21 10:45:53 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
import Component from '../../lib/component';
|
|
|
|
|
|
|
|
class Controller extends Component {
|
|
|
|
constructor($element, $scope) {
|
|
|
|
super($element, $scope);
|
2019-03-12 14:04:09 +00:00
|
|
|
this.$scope = $scope;
|
2019-01-21 10:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
toggle(item) {
|
|
|
|
this.treeview.onToggle(item);
|
|
|
|
}
|
|
|
|
|
2019-02-18 07:37:26 +00:00
|
|
|
select(item, value) {
|
|
|
|
this.treeview.onSelection(item, value);
|
2019-01-21 10:45:53 +00:00
|
|
|
}
|
2019-03-12 14:04:09 +00:00
|
|
|
|
2019-04-23 06:29:23 +00:00
|
|
|
onIconClick(icon, item, parent, index) {
|
2019-04-29 09:49:43 +00:00
|
|
|
let parentController = this.parentScope.$ctrl;
|
2019-03-12 14:04:09 +00:00
|
|
|
icon.callback.call(parentController, item, parent, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
onCreate(parent) {
|
|
|
|
this.treeview.onCreate(parent);
|
|
|
|
}
|
|
|
|
|
2019-04-23 06:29:23 +00:00
|
|
|
onDrop(item, dragged, dropped) {
|
|
|
|
this.treeview.onDrop(item, dragged, dropped);
|
|
|
|
}
|
|
|
|
|
2019-03-12 14:04:09 +00:00
|
|
|
get isInsertable() {
|
|
|
|
return Array.isArray(this.parent) || this.parent.childs;
|
|
|
|
}
|
2019-01-21 10:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnTreeviewChild', {
|
|
|
|
template: require('./child.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2019-03-12 14:04:09 +00:00
|
|
|
items: '<',
|
|
|
|
parent: '<',
|
|
|
|
icons: '<?',
|
|
|
|
disabled: '<?',
|
|
|
|
selectable: '<?',
|
|
|
|
editable: '<?',
|
2019-04-29 09:49:43 +00:00
|
|
|
draggable: '<?',
|
|
|
|
droppable: '<?',
|
2019-03-12 14:04:09 +00:00
|
|
|
aclRole: '<?',
|
2019-04-29 09:49:43 +00:00
|
|
|
parentScope: '<'
|
2019-01-21 10:45:53 +00:00
|
|
|
},
|
|
|
|
require: {
|
|
|
|
treeview: '^vnTreeview'
|
|
|
|
}
|
|
|
|
});
|