Eliminate code duplication in route state config

pull/3572/head
Alex Dik 9 years ago committed by Stefan Botzenhart
parent c5067f1299
commit f98c50f53f
  1. 28
      frontend/app/routing.js

@ -32,6 +32,8 @@ angular.module('openproject')
'$stateProvider',
'$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
var wpListStateCfg;
// redirect to default activity tab when user lands at /work_packages/:id
// TODO: Preserve #note-4 part of the URL.
$urlRouterProvider.when('/work_packages/{id}', '/work_packages/{id}/activity');
@ -108,7 +110,7 @@ angular.module('openproject')
controllerAs: 'watchers'
})
.state('work-packages.list', {
.state('work-packages.list', wpListStateCfg = {
url: '/projects/{projectPath}/work_packages?query_id&query_props',
controller: 'WorkPackagesListController',
templateUrl: '/templates/work_packages.list.html',
@ -126,26 +128,10 @@ angular.module('openproject')
onExit: function(){
jQuery('body').removeClass('action-index');
}
})
.state('work-packages.list-all', {
url: '/work_packages?query_id&query_props',
controller: 'WorkPackagesListController',
templateUrl: '/templates/work_packages.list.html',
reloadOnSearch: false,
// HACK
// This is to avoid problems with the css depending on which page the
// browser starts from (deep-link). As we have CSS rules that change the
// layout drastically when on the index action (e.g. position: absolute,
// heigt of footer, ...), and this should not be applied to the other
// states, we need to remove the trigger used in the CSS The correct fix
// would be to alter the CSS.
onEnter: function(){
jQuery('body').addClass('action-index');
},
onExit: function(){
jQuery('body').removeClass('action-index');
}
})
})
.state('work-packages.list-all', _.extend(_.clone(wpListStateCfg), {
url: '/work_packages?query_id&query_props'
}))
.state('work-packages.list.new', {
url: '/create_new?type',
controller: 'WorkPackageNewController',

Loading…
Cancel
Save