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.
170 lines
5.5 KiB
170 lines
5.5 KiB
11 years ago
|
//-- copyright
|
||
|
// OpenProject is a project management system.
|
||
|
// Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
|
||
|
//
|
||
|
// 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.
|
||
|
//++
|
||
|
|
||
10 years ago
|
module.exports = function(I18n, columnsModal, exportModal, saveModal, settingsModal, shareModal, sortingModal, groupingModal, QueryService, AuthorisationService, $window, $state, $timeout){
|
||
11 years ago
|
|
||
|
return {
|
||
|
restrict: 'AE',
|
||
|
scope: true,
|
||
|
link: function(scope, element, attributes) {
|
||
11 years ago
|
angular.element($window).bind('click', function() {
|
||
|
scope.$emit('hideAllDropdowns');
|
||
|
});
|
||
11 years ago
|
|
||
10 years ago
|
scope.$watch('query.displaySums', function(newValue, oldValue) {
|
||
|
$timeout(function() {
|
||
|
scope.displaySumsLabel = (newValue) ? I18n.t('js.toolbar.settings.hide_sums')
|
||
|
: I18n.t('js.toolbar.settings.display_sums');
|
||
|
});
|
||
|
});
|
||
|
|
||
11 years ago
|
scope.saveQuery = function(event){
|
||
11 years ago
|
if(scope.query.isNew()){
|
||
11 years ago
|
if( allowQueryAction(event, 'create') ){
|
||
|
scope.$emit('hideAllDropdowns');
|
||
|
saveModal.activate();
|
||
|
}
|
||
11 years ago
|
} else {
|
||
11 years ago
|
if( allowQueryAction(event, 'update') ) {
|
||
|
QueryService.saveQuery()
|
||
|
.then(function(data){
|
||
|
scope.$emit('flashMessage', data.status);
|
||
10 years ago
|
$state.go('work-packages.list',
|
||
|
{ query_id: scope.query.id, query_props: null },
|
||
|
{ notify: false });
|
||
11 years ago
|
});
|
||
|
}
|
||
11 years ago
|
}
|
||
|
};
|
||
|
|
||
11 years ago
|
scope.deleteQuery = function(event){
|
||
11 years ago
|
if( allowQueryAction(event, 'delete') && preventNewQueryAction(event) && deleteConfirmed() ){
|
||
11 years ago
|
QueryService.deleteQuery()
|
||
|
.then(function(data){
|
||
|
settingsModal.deactivate();
|
||
|
scope.$emit('flashMessage', data.status);
|
||
10 years ago
|
$state.go('work-packages.list',
|
||
|
{ query_id: null, query_props: null },
|
||
|
{ reload: true });
|
||
11 years ago
|
});
|
||
11 years ago
|
}
|
||
11 years ago
|
};
|
||
|
|
||
11 years ago
|
// Modals
|
||
11 years ago
|
scope.showSaveAsModal = function(event){
|
||
11 years ago
|
if( allowQueryAction(event, 'create') ) {
|
||
|
showExistingQueryModal.call(saveModal, event);
|
||
|
}
|
||
11 years ago
|
};
|
||
|
|
||
11 years ago
|
scope.showShareModal = function(event){
|
||
10 years ago
|
if (allowQueryAction(event, 'publicize') || allowQueryAction(event, 'star')) {
|
||
|
showExistingQueryModal.call(shareModal, event);
|
||
|
}
|
||
10 years ago
|
};
|
||
11 years ago
|
|
||
|
scope.showSettingsModal = function(event){
|
||
11 years ago
|
if( allowQueryAction(event, 'update') ) {
|
||
|
showExistingQueryModal.call(settingsModal, event);
|
||
|
}
|
||
11 years ago
|
};
|
||
|
|
||
11 years ago
|
scope.showExportModal = function(event){
|
||
11 years ago
|
if( allowWorkPackageAction(event, 'export') ) {
|
||
|
showModal.call(exportModal);
|
||
|
}
|
||
11 years ago
|
};
|
||
|
|
||
11 years ago
|
scope.showColumnsModal = function(){
|
||
|
showModal.call(columnsModal);
|
||
11 years ago
|
};
|
||
|
|
||
|
scope.showGroupingModal = function(){
|
||
|
showModal.call(groupingModal);
|
||
|
};
|
||
|
|
||
11 years ago
|
scope.showSortingModal = function(){
|
||
|
showModal.call(sortingModal);
|
||
11 years ago
|
};
|
||
11 years ago
|
|
||
11 years ago
|
scope.toggleDisplaySums = function(){
|
||
11 years ago
|
scope.$emit('hideAllDropdowns');
|
||
11 years ago
|
scope.query.displaySums = !scope.query.displaySums;
|
||
10 years ago
|
|
||
|
// This eventually calls the resize event handler defined in the
|
||
|
// WorkPackagesTable directive and ensures that the sum row at the
|
||
|
// table footer is properly displayed.
|
||
|
angular.element($window).trigger('resize');
|
||
11 years ago
|
};
|
||
11 years ago
|
|
||
11 years ago
|
function preventNewQueryAction(event){
|
||
11 years ago
|
if (event && scope.query.isNew()) {
|
||
|
event.preventDefault();
|
||
|
event.stopPropagation();
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
function showModal() {
|
||
|
scope.$emit('hideAllDropdowns');
|
||
|
this.activate();
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
function showExistingQueryModal(event) {
|
||
11 years ago
|
if( preventNewQueryAction(event) ){
|
||
11 years ago
|
scope.$emit('hideAllDropdowns');
|
||
|
this.activate();
|
||
|
}
|
||
|
}
|
||
|
|
||
11 years ago
|
function allowQueryAction(event, action) {
|
||
11 years ago
|
return allowAction(event, 'query', action);
|
||
|
}
|
||
|
|
||
|
function allowWorkPackageAction(event, action) {
|
||
|
return allowAction(event, 'work_package', action);
|
||
|
}
|
||
|
|
||
|
function allowAction(event, modelName, action) {
|
||
|
if(AuthorisationService.can(modelName, action)){
|
||
11 years ago
|
return true;
|
||
|
} else {
|
||
|
event.preventDefault();
|
||
|
event.stopPropagation();
|
||
11 years ago
|
return false;
|
||
11 years ago
|
}
|
||
|
}
|
||
|
|
||
11 years ago
|
function deleteConfirmed() {
|
||
|
return $window.confirm(I18n.t('js.text_query_destroy_confirmation'));
|
||
|
}
|
||
11 years ago
|
}
|
||
|
};
|
||
10 years ago
|
};
|