2019-01-21 10:45:53 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
import Component from '../../lib/component';
|
|
|
|
|
|
|
|
class Controller extends Component {
|
2019-10-01 13:09:55 +00:00
|
|
|
constructor($element, $scope, $transclude) {
|
2019-01-21 10:45:53 +00:00
|
|
|
super($element, $scope);
|
2019-10-01 13:09:55 +00:00
|
|
|
this.$transclude = $transclude;
|
2019-10-02 07:54:52 +00:00
|
|
|
}
|
2019-10-01 13:09:55 +00:00
|
|
|
|
2019-10-01 09:15:15 +00:00
|
|
|
toggle(event, item) {
|
|
|
|
if (event.defaultPrevented || !item.sons) return;
|
|
|
|
event.preventDefault();
|
2019-01-21 10:45:53 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-10-01 13:09:55 +00:00
|
|
|
Controller.$inject = ['$element', '$scope', '$transclude'];
|
|
|
|
|
2019-10-02 07:54:52 +00:00
|
|
|
ngModule.component('vnTreeviewChilds', {
|
|
|
|
template: require('./childs.html'),
|
2019-01-21 10:45:53 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2019-03-12 14:04:09 +00:00
|
|
|
items: '<',
|
2019-10-02 12:12:17 +00:00
|
|
|
parent: '<?'
|
2019-10-01 13:09:55 +00:00
|
|
|
},
|
2019-01-21 10:45:53 +00:00
|
|
|
require: {
|
|
|
|
treeview: '^vnTreeview'
|
|
|
|
}
|
|
|
|
});
|