salix/front/core/components/treeview/childs.js

68 lines
1.6 KiB
JavaScript
Raw Normal View History

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-02 07:54:52 +00:00
$onInit() {
this.transcludeFunc((tClone, $scope) => {
$scope.item = this.item;
let content = this.element.querySelector('.content');
angular.element(content).append(tClone);
});
2019-01-21 10:45:53 +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
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);
}
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: '<',
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-10-02 07:54:52 +00:00
parentScope: '<',
transcludeFunc: '<'
2019-10-01 13:09:55 +00:00
},
2019-01-21 10:45:53 +00:00
require: {
treeview: '^vnTreeview'
}
});