angular-gantt
Version:
Gantt chart component for AngularJS
63 lines (51 loc) • 2.44 kB
JavaScript
(function(){
'use strict';
angular.module('gantt.tree', ['gantt', 'gantt.tree.templates', 'ui.tree']).directive('ganttTree', ['ganttUtils', '$compile', '$document', function(utils, $compile, $document) {
// Provides the row sort functionality to any Gantt row
// Uses the sortableState to share the current row
return {
restrict: 'E',
require: '^gantt',
scope: {
enabled: '=?',
header: '=?',
content: '=?',
headerContent: '=?',
keepAncestorOnFilterRow: '=?'
},
link: function(scope, element, attrs, ganttCtrl) {
var api = ganttCtrl.gantt.api;
// Load options from global options attribute.
if (scope.options && typeof(scope.options.sortable) === 'object') {
for (var option in scope.options.sortable) {
scope[option] = scope.options[option];
}
}
if (scope.enabled === undefined) {
scope.enabled = true;
}
if (scope.header === undefined) {
scope.header = 'Name';
}
if (scope.headerContent === undefined) {
scope.headerContent = '{{getHeader()}}';
}
if (scope.keepAncestorOnFilterRow === undefined) {
scope.keepAncestorOnFilterRow = false;
}
api.directives.on.new(scope, function(directiveName, sideContentScope, sideContentElement) {
if (directiveName === 'ganttSideContent') {
var labelsScope = sideContentScope.$new();
labelsScope.pluginScope = scope;
var ifElement = $document[0].createElement('div');
angular.element(ifElement).attr('data-ng-if', 'pluginScope.enabled');
angular.element(ifElement).addClass('side-element');
var labelsElement = $document[0].createElement('gantt-side-content-tree');
angular.element(ifElement).append(labelsElement);
sideContentElement.append($compile(ifElement)(labelsScope));
}
});
}
};
}]);
}());