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.
*/
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});
}
});
});
});

View File

@ -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;
$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 });
}
});
});
});