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.
117 lines
3.9 KiB
117 lines
3.9 KiB
11 years ago
|
//-- copyright
|
||
|
// OpenProject is a project management system.
|
||
8 years ago
|
// Copyright (C) 2012-2017 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:
|
||
8 years ago
|
// Copyright (C) 2006-2017 Jean-Philippe Lang
|
||
11 years ago
|
// 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.
|
||
|
//++
|
||
|
|
||
8 years ago
|
import {States} from "../states.service";
|
||
9 years ago
|
angular
|
||
9 years ago
|
.module('openproject.services')
|
||
|
.factory('WorkPackageService', WorkPackageService);
|
||
|
|
||
8 years ago
|
function WorkPackageService($http:ng.IHttpService,
|
||
|
$window:ng.IWindowService,
|
||
|
$cacheFactory:any,
|
||
|
$state:ng.ui.IStateService,
|
||
|
states:States,
|
||
|
I18n:op.I18n,
|
||
|
PathHelper:any,
|
||
|
UrlParamsHelper:any,
|
||
|
NotificationsService:any) {
|
||
9 years ago
|
|
||
9 years ago
|
var workPackageCache = $cacheFactory('workPackageCache');
|
||
9 years ago
|
|
||
11 years ago
|
var WorkPackageService = {
|
||
11 years ago
|
|
||
8 years ago
|
doQuery: function (url:string, params:any) {
|
||
11 years ago
|
return $http({
|
||
|
method: 'GET',
|
||
|
url: url,
|
||
|
params: params,
|
||
9 years ago
|
headers: {
|
||
9 years ago
|
'caching': {enabled: false},
|
||
9 years ago
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||
|
}
|
||
9 years ago
|
}).then(function (response) {
|
||
|
return response.data;
|
||
|
},
|
||
|
function (failedResponse) {
|
||
8 years ago
|
var error = '';
|
||
|
if (failedResponse.status === 404) {
|
||
|
error = I18n.t('js.work_packages.query.errors.not_found');
|
||
|
}
|
||
|
else {
|
||
|
error = I18n.t('js.work_packages.query.errors.unretrievable_query');
|
||
|
}
|
||
|
|
||
|
NotificationsService.addError(error);
|
||
9 years ago
|
}
|
||
10 years ago
|
);
|
||
11 years ago
|
},
|
||
|
|
||
8 years ago
|
performBulkDelete: function (ids:any, defaultHandling:any) {
|
||
10 years ago
|
if (defaultHandling && !$window.confirm(I18n.t('js.text_work_packages_destroy_confirmation'))) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
11 years ago
|
var params = {
|
||
10 years ago
|
'ids[]': ids
|
||
11 years ago
|
};
|
||
9 years ago
|
var promise = $http['delete'](PathHelper.workPackagesBulkDeletePath(), {params: params});
|
||
10 years ago
|
|
||
|
if (defaultHandling) {
|
||
9 years ago
|
promise
|
||
|
.then(function () {
|
||
|
// TODO wire up to API and process API response
|
||
|
NotificationsService.addSuccess(
|
||
9 years ago
|
I18n.t('js.work_packages.message_successful_bulk_delete')
|
||
9 years ago
|
);
|
||
8 years ago
|
states.table.refreshRequired.putValue(true);
|
||
9 years ago
|
|
||
|
if ($state.includes('**.list.details.**')
|
||
|
&& ids.indexOf(+$state.params.workPackageId) > -1) {
|
||
|
$state.go('work-packages.list', $state.params);
|
||
|
}
|
||
|
})
|
||
|
.catch(function () {
|
||
|
// FIXME catch this kind of failover in angular instead of redirecting
|
||
|
// to a rails-based legacy view
|
||
|
params = UrlParamsHelper.buildQueryString(params);
|
||
8 years ago
|
window.location.href = PathHelper.workPackagesBulkDeletePath() + '?' + params;
|
||
9 years ago
|
});
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
return promise;
|
||
9 years ago
|
},
|
||
|
|
||
9 years ago
|
cache: function () {
|
||
9 years ago
|
return workPackageCache;
|
||
11 years ago
|
}
|
||
9 years ago
|
|
||
11 years ago
|
};
|
||
|
|
||
|
return WorkPackageService;
|
||
9 years ago
|
}
|