kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
6.0 KiB
187 lines
6.0 KiB
9 years ago
|
// -- copyright
|
||
11 years ago
|
// OpenProject is a project management system.
|
||
10 years ago
|
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
11 years ago
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License version 3.
|
||
|
//
|
||
|
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
// Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License
|
||
|
// as published by the Free Software Foundation; either version 2
|
||
|
// of the License, or (at your option) any later version.
|
||
|
//
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program; if not, write to the Free Software
|
||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
//
|
||
|
// See doc/COPYRIGHT.rdoc for more details.
|
||
9 years ago
|
// ++
|
||
11 years ago
|
|
||
9 years ago
|
angular
|
||
|
.module('openproject.workPackages.directives')
|
||
9 years ago
|
.directive('wpTable', wpTable);
|
||
11 years ago
|
|
||
9 years ago
|
function wpTable(WorkPackagesTableService, $window, featureFlags, PathHelper){
|
||
11 years ago
|
return {
|
||
|
restrict: 'E',
|
||
|
replace: true,
|
||
9 years ago
|
templateUrl: '/components/wp-table/wp-table.directive.html',
|
||
11 years ago
|
scope: {
|
||
|
projectIdentifier: '=',
|
||
|
columns: '=',
|
||
|
rows: '=',
|
||
11 years ago
|
query: '=',
|
||
11 years ago
|
countByGroup: '=',
|
||
11 years ago
|
groupBy: '=',
|
||
11 years ago
|
groupByColumn: '=',
|
||
11 years ago
|
displaySums: '=',
|
||
|
totalSums: '=',
|
||
10 years ago
|
groupSums: '=',
|
||
|
activationCallback: '&'
|
||
11 years ago
|
},
|
||
9 years ago
|
|
||
9 years ago
|
controller: WorkPackagesTableController,
|
||
|
|
||
9 years ago
|
link: function(scope, element) {
|
||
10 years ago
|
var activeSelectionBorderIndex;
|
||
|
|
||
11 years ago
|
scope.workPackagesTableData = WorkPackagesTableService.getWorkPackagesTableData();
|
||
9 years ago
|
scope.workPackagePath = PathHelper.workPackagePath;
|
||
11 years ago
|
|
||
11 years ago
|
var topMenuHeight = angular.element('#top-menu').prop('offsetHeight') || 0;
|
||
11 years ago
|
scope.adaptVerticalPosition = function(event) {
|
||
|
event.pageY -= topMenuHeight;
|
||
|
};
|
||
|
|
||
11 years ago
|
// groupings
|
||
11 years ago
|
scope.grouped = scope.groupByColumn !== undefined;
|
||
11 years ago
|
scope.groupExpanded = {};
|
||
11 years ago
|
|
||
10 years ago
|
scope.$watchCollection('columns', function() {
|
||
|
// force Browser rerender
|
||
|
element.hide().show(0);
|
||
|
|
||
|
angular.element($window).trigger('resize');
|
||
|
});
|
||
|
scope.$watchCollection('rows', function() {
|
||
|
// force Browser rerender
|
||
|
element.hide().show(0);
|
||
|
|
||
|
angular.element($window).trigger('resize');
|
||
|
});
|
||
|
|
||
11 years ago
|
scope.setCheckedStateForAllRows = function(state) {
|
||
10 years ago
|
WorkPackagesTableService.setCheckedStateForAllRows(scope.rows, state);
|
||
11 years ago
|
};
|
||
11 years ago
|
|
||
11 years ago
|
var groupableColumns = WorkPackagesTableService.getGroupableColumns();
|
||
|
scope.$watch('query.groupBy', function(groupBy) {
|
||
|
if (scope.columns) {
|
||
|
var groupByColumnIndex = groupableColumns.map(function(column){
|
||
|
return column.name;
|
||
|
}).indexOf(groupBy);
|
||
|
|
||
|
scope.groupByColumn = groupableColumns[groupByColumnIndex];
|
||
10 years ago
|
}
|
||
11 years ago
|
});
|
||
|
|
||
11 years ago
|
scope.$watch(function() {
|
||
9 years ago
|
return featureFlags.isOn('detailsView');
|
||
11 years ago
|
}, function(detailsEnabled) {
|
||
|
scope.hideWorkPackageDetails = !detailsEnabled;
|
||
|
});
|
||
10 years ago
|
|
||
|
// Thanks to http://stackoverflow.com/a/880518
|
||
|
function clearSelection() {
|
||
|
if(document.selection && document.selection.empty) {
|
||
10 years ago
|
document.selection.empty();
|
||
10 years ago
|
} else if(window.getSelection) {
|
||
10 years ago
|
var sel = window.getSelection();
|
||
|
sel.removeAllRanges();
|
||
10 years ago
|
}
|
||
|
}
|
||
|
|
||
10 years ago
|
function setRowSelectionState(row, selected) {
|
||
10 years ago
|
activeSelectionBorderIndex = scope.rows.indexOf(row);
|
||
10 years ago
|
WorkPackagesTableService.setRowSelection(row, selected);
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
function mulipleRowsChecked(){
|
||
|
var counter = 0;
|
||
10 years ago
|
for (var i = 0, l = scope.rows.length; i<l; i++) {
|
||
|
if (scope.rows[i].checked) {
|
||
|
if (++counter === 2) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
scope.selectWorkPackage = function(row, $event) {
|
||
|
if ($event.target.type != 'checkbox') {
|
||
|
var currentRowCheckState = row.checked;
|
||
10 years ago
|
var multipleChecked = mulipleRowsChecked();
|
||
10 years ago
|
var isLink = angular.element($event.target).is('a');
|
||
10 years ago
|
|
||
|
if (!($event.ctrlKey || $event.shiftKey)) {
|
||
|
scope.setCheckedStateForAllRows(false);
|
||
|
}
|
||
|
|
||
10 years ago
|
if(isLink) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
10 years ago
|
if ($event.shiftKey) {
|
||
|
clearSelection();
|
||
|
activeSelectionBorderIndex = WorkPackagesTableService.selectRowRange(scope.rows, row, activeSelectionBorderIndex);
|
||
10 years ago
|
} else if($event.ctrlKey){
|
||
|
setRowSelectionState(row, multipleChecked ? true : !currentRowCheckState);
|
||
10 years ago
|
} else {
|
||
10 years ago
|
setRowSelectionState(row, multipleChecked ? true : !currentRowCheckState);
|
||
10 years ago
|
|
||
|
scope.activationCallback({ id: row.object.id, force: false });
|
||
10 years ago
|
}
|
||
10 years ago
|
}
|
||
|
};
|
||
10 years ago
|
|
||
10 years ago
|
scope.showWorkPackageDetails = function(row) {
|
||
10 years ago
|
clearSelection();
|
||
|
|
||
10 years ago
|
scope.setCheckedStateForAllRows(false);
|
||
|
|
||
|
setRowSelectionState(row, true);
|
||
|
|
||
10 years ago
|
scope.activationCallback({ id: row.object.id, force: true });
|
||
10 years ago
|
};
|
||
11 years ago
|
}
|
||
|
};
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
|
function WorkPackagesTableController($scope) {
|
||
|
$scope.locale = I18n.locale;
|
||
|
|
||
|
$scope.text = {
|
||
9 years ago
|
collapse: I18n.t('js.label_collapse'),
|
||
|
expand: I18n.t('js.label_expand'),
|
||
|
sumFor: I18n.t('js.label_sum_for'),
|
||
|
allWorkPackages: I18n.t('js.label_all_work_packages'),
|
||
|
noResults: I18n.t('js.work_packages.no_results.title'),
|
||
|
noResultsDescription: I18n.t('js.work_packages.no_results.description_html')
|
||
9 years ago
|
};
|
||
9 years ago
|
|
||
|
$scope.$watch('workPackagesTableData.allRowsChecked', function(checked) {
|
||
|
$scope.text.toggleRows =
|
||
|
checked ? I18n.t('js.button_uncheck_all') : I18n.t('js.button_check_all');
|
||
|
});
|
||
9 years ago
|
}
|