UNPKG

angular-gantt

Version:

Gantt chart component for AngularJS

79 lines (63 loc) 2.84 kB
(function(){ 'use strict'; angular.module('gantt.table', ['gantt', 'gantt.table.templates']).directive('ganttTable', ['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: '=?', columns: '=?', headers: '=?', classes: '=?', contents: '=?', headerContents: '=?', formatters: '=?', headerFormatter: '=?' }, 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.columns === undefined) { scope.columns = ['model.name']; } if (scope.headers === undefined) { scope.headers = {'model.name': 'Name'}; } if (scope.contents === undefined) { scope.contents = {}; } if (scope.headerContents === undefined) { scope.headerContents = {}; } if (scope.classes === undefined) { scope.classes = {}; } if (scope.formatters === undefined) { scope.formatters = {}; } api.directives.on.new(scope, function(directiveName, sideContentScope, sideContentElement) { if (directiveName === 'ganttSideContent') { var tableScope = sideContentScope.$new(); tableScope.pluginScope = scope; var ifElement = $document[0].createElement('div'); angular.element(ifElement).attr('data-ng-if', 'pluginScope.enabled'); angular.element(ifElement).addClass('side-element'); var tableElement = $document[0].createElement('gantt-side-content-table'); angular.element(ifElement).append(tableElement); sideContentElement.append($compile(ifElement)(tableScope)); } }); } }; }]); }());