Reenable ng $location service HTML5 mode

Update Router to fall back to full page load (i.e. Rails) when a route
is not matched on the client-side.

Also update Router paths/params correspondingly.

Task # 8869

Signed-off-by: Alex Coles <alex@alexbcoles.com>
pull/1453/head
Alex Coles 11 years ago
parent a4ba6b0b2c
commit bb65ce4e0e
  1. 3
      app/assets/javascripts/angular/openproject-app.js
  2. 16
      app/assets/javascripts/angular/routing.js

@ -124,8 +124,7 @@ window.appBasePath = jQuery('meta[name=app_base_path]').attr('content') || '';
openprojectApp
.config(['$locationProvider', '$httpProvider', function($locationProvider, $httpProvider) {
// Note: Not using this because we want to use $location to get the url params and html5Mode prevents all the links from working normally.
// $locationProvider.html5Mode(true);
$locationProvider.html5Mode(true);
$httpProvider.defaults.headers.common['X-CSRF-TOKEN'] = jQuery('meta[name=csrf-token]').attr('content'); // TODO find a more elegant way to keep the session alive
$httpProvider.interceptors.push(function ($q) {

@ -31,11 +31,21 @@ openprojectApp.config([
'$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/wp");
// All unmatched routes should be handled by Rails
// (i.e. invoke a full-page load)
//
// a better behaviour here would be for Angular's HTML5-mode to provide an
// option to turn link hijacking off by default (and use a `target` attribute
// to turn it on for selected links).
$urlRouterProvider.otherwise(function($injector, $location) {
$window = $injector.get('$window');
$window.location.replace($location.path());
});
$stateProvider
.state('work-packages', {
url: "/wp?query_id",
url: "/projects/:projectIdentifier/work_packages?query_id",
abstract: true,
templateUrl: "/templates/work_packages.html",
controller: 'WorkPackagesController'
@ -45,7 +55,7 @@ openprojectApp.config([
templateUrl: "/templates/work_packages.list.html"
})
.state('work-packages.list.details', {
url: "/:workPackageId",
url: "/{workPackageId:[0-9]+}",
templateUrl: "/templates/work_packages.list.details.html",
controller: 'WorkPackageDetailsController'
});

Loading…
Cancel
Save