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-03-12 14:04:09 +00:00
|
|
|
this.$scope = $scope;
|
2019-10-01 13:09:55 +00:00
|
|
|
this.$transclude = $transclude;
|
|
|
|
|
|
|
|
$transclude($scope.$parent, tClone => {
|
|
|
|
this.element.querySelector('.tplItem').appendChild(tClone[0]);
|
|
|
|
}, null, 'tplItem');
|
2019-01-21 10:45:53 +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-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
|
|
|
},
|
2019-10-01 13:09:55 +00:00
|
|
|
transclude: {
|
|
|
|
tplItem: '?tplItem'
|
|
|
|
},
|
2019-01-21 10:45:53 +00:00
|
|
|
require: {
|
|
|
|
treeview: '^vnTreeview'
|
|
|
|
}
|
|
|
|
});
|