From 46079393d5d6142420b000cbf8678e8bd9de65ff Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Sun, 12 Nov 2017 02:18:02 +0100 Subject: [PATCH] Fix file modal routing --- .../src/app/docs/controller/document/FileView.js | 10 ++++++++-- .../main/webapp/src/app/share/controller/FileView.js | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/FileView.js b/docs-web/src/main/webapp/src/app/docs/controller/document/FileView.js index 5e80f083..d625314a 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/FileView.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/FileView.js @@ -3,7 +3,7 @@ /** * File view controller. */ -angular.module('docs').controller('FileView', function($uibModal, $state, $stateParams) { +angular.module('docs').controller('FileView', function($uibModal, $state, $stateParams, $timeout) { var modal = $uibModal.open({ windowClass: 'modal modal-fileview', templateUrl: 'partial/docs/file.view.html', @@ -17,6 +17,12 @@ angular.module('docs').controller('FileView', function($uibModal, $state, $state modal.closed = true; }, function() { modal.closed = true; - $state.go('^', { id: $stateParams.id }); + $timeout(function () { + // After all router transitions are passed, + // if we are still on the file route, go back to the document + if ($state.current.name === 'document.view.content.file') { + $state.go('^', {id: $stateParams.id}); + } + }); }); }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/share/controller/FileView.js b/docs-web/src/main/webapp/src/app/share/controller/FileView.js index 3df5724e..800a7ceb 100644 --- a/docs-web/src/main/webapp/src/app/share/controller/FileView.js +++ b/docs-web/src/main/webapp/src/app/share/controller/FileView.js @@ -3,7 +3,7 @@ /** * File view controller. */ -angular.module('share').controller('FileView', function($uibModal, $state, $stateParams) { +angular.module('share').controller('FileView', function($uibModal, $state, $stateParams, $timeout) { var modal = $uibModal.open({ windowClass: 'modal modal-fileview', templateUrl: 'partial/share/file.view.html', @@ -17,6 +17,12 @@ angular.module('share').controller('FileView', function($uibModal, $state, $stat modal.closed = true; },function() { modal.closed = true; - $state.go('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); + $timeout(function () { + // After all router transitions are passed, + // if we are still on the file route, go back to the share + if ($state.current.name === 'share.file') { + $state.go('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId }); + } + }); }); }); \ No newline at end of file