From f98c50f53f93d8280bb7246d8c7e658828e197fc Mon Sep 17 00:00:00 2001 From: Alex Dik Date: Fri, 25 Sep 2015 23:07:24 +0200 Subject: [PATCH] Eliminate code duplication in route state config --- frontend/app/routing.js | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/frontend/app/routing.js b/frontend/app/routing.js index fbeeb2775c..2d1006e2bd 100644 --- a/frontend/app/routing.js +++ b/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',