Fix file modal routing

This commit is contained in:
Benjamin Gamard 2017-11-12 02:18:02 +01:00
parent 517e4a4507
commit 46079393d5
2 changed files with 16 additions and 4 deletions

View File

@ -3,7 +3,7 @@
/** /**
* File view controller. * 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({ var modal = $uibModal.open({
windowClass: 'modal modal-fileview', windowClass: 'modal modal-fileview',
templateUrl: 'partial/docs/file.view.html', templateUrl: 'partial/docs/file.view.html',
@ -17,6 +17,12 @@ angular.module('docs').controller('FileView', function($uibModal, $state, $state
modal.closed = true; modal.closed = true;
}, function() { }, function() {
modal.closed = true; 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});
}
});
}); });
}); });

View File

@ -3,7 +3,7 @@
/** /**
* File view controller. * 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({ var modal = $uibModal.open({
windowClass: 'modal modal-fileview', windowClass: 'modal modal-fileview',
templateUrl: 'partial/share/file.view.html', templateUrl: 'partial/share/file.view.html',
@ -17,6 +17,12 @@ angular.module('share').controller('FileView', function($uibModal, $state, $stat
modal.closed = true; modal.closed = true;
},function() { },function() {
modal.closed = true; 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 });
}
});
}); });
}); });