Move "go back on cancel" method to WP new controller

pull/3813/head
Alex Dik 9 years ago
parent 3adbf3f505
commit d6e636f853
  1. 45
      frontend/app/components/routes/controllers/wp-list-new-state.controller.js
  2. 3
      frontend/app/components/routes/partials/work-packages.list.new.html
  3. 10
      frontend/app/components/work-packages/controllers/wp-new.controller.js
  4. 2
      frontend/app/components/work-packages/directives/wp-create-form/wp-create-form.directive.html
  5. 2
      frontend/app/routing.js

@ -1,45 +0,0 @@
// -- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 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.
// ++
angular
.module('openproject.workPackages')
.controller('WorkPackageListNewStateController', WorkPackageListNewStateController);
function WorkPackageListNewStateController($rootScope, $scope, $state) {
var vm = this;
vm.goBack = function() {
var args = ['^'];
if ($rootScope.previousState && $rootScope.previousState.name) {
args = [$rootScope.previousState.name, $rootScope.previousState.params];
}
vm.loaderPromise = $state.go.apply($state, args);
};
}

@ -1,5 +1,4 @@
<div class="work-packages--details-content -create-mode">
<wp-create-form on-cancel="vm.goBack()"
work-package="workPackage"
<wp-create-form work-package="workPackage"
success-state="work-packages.list.details.overview"></wp-create-form>
</div>

@ -31,6 +31,7 @@ angular
.controller('WorkPackageNewController', WorkPackageNewController);
function WorkPackageNewController($scope,
$rootScope,
$state,
$stateParams,
PathHelper,
@ -61,6 +62,15 @@ function WorkPackageNewController($scope,
vm.notifyCreation = function() {
NotificationsService.addSuccess(I18n.t('js.notice_successful_create'));
};
vm.goBack = function() {
var args = ['^'];
if ($rootScope.previousState && $rootScope.previousState.name) {
args = [$rootScope.previousState.name, $rootScope.previousState.params];
}
vm.loaderPromise = $state.go.apply($state, args);
};
$scope.I18n = I18n;

@ -57,4 +57,4 @@
</div>
</div>
<edit-actions-bar on-cancel="vm.onCancel()" on-save="vm.notifyCreation()"> </edit-actions-bar>
<edit-actions-bar on-cancel="vm.goBack()" on-save="vm.notifyCreation()"> </edit-actions-bar>

@ -155,8 +155,6 @@ angular.module('openproject')
})
.state('work-packages.list.new', {
url: '/create_new?type',
controller: 'WorkPackageListNewStateController',
controllerAs: 'vm',
templateUrl: '/components/routes/partials/work-packages.list.new.html',
reloadOnSearch: false
})

Loading…
Cancel
Save