|
|
|
@ -24,6 +24,8 @@ export default function EntityStateController($scope, $timeout, $location, $stat |
|
|
|
|
|
|
|
vm.inited = false; |
|
|
|
|
|
|
|
vm.skipStateChange = false; |
|
|
|
|
|
|
|
vm.openState = openState; |
|
|
|
vm.updateState = updateState; |
|
|
|
vm.resetState = resetState; |
|
|
|
@ -50,11 +52,10 @@ export default function EntityStateController($scope, $timeout, $location, $stat |
|
|
|
params: params |
|
|
|
} |
|
|
|
//append new state
|
|
|
|
stopWatchStateObject(); |
|
|
|
vm.stateObject.push(newState); |
|
|
|
vm.selectedStateIndex = vm.stateObject.length-1; |
|
|
|
gotoState(vm.stateObject[vm.stateObject.length-1].id, true, openRightLayout); |
|
|
|
watchStateObject(); |
|
|
|
vm.skipStateChange = true; |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
@ -73,10 +74,9 @@ export default function EntityStateController($scope, $timeout, $location, $stat |
|
|
|
params: params |
|
|
|
} |
|
|
|
//replace with new state
|
|
|
|
stopWatchStateObject(); |
|
|
|
vm.stateObject[vm.stateObject.length - 1] = newState; |
|
|
|
gotoState(vm.stateObject[vm.stateObject.length - 1].id, true, openRightLayout); |
|
|
|
watchStateObject(); |
|
|
|
vm.skipStateChange = true; |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
@ -94,11 +94,10 @@ export default function EntityStateController($scope, $timeout, $location, $stat |
|
|
|
|
|
|
|
function navigatePrevState(index) { |
|
|
|
if (index < vm.stateObject.length-1) { |
|
|
|
stopWatchStateObject(); |
|
|
|
vm.stateObject.splice(index+1, vm.stateObject.length-index-1); |
|
|
|
vm.selectedStateIndex = vm.stateObject.length-1; |
|
|
|
gotoState(vm.stateObject[vm.stateObject.length-1].id, true); |
|
|
|
watchStateObject(); |
|
|
|
vm.skipStateChange = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -266,14 +265,22 @@ export default function EntityStateController($scope, $timeout, $location, $stat |
|
|
|
|
|
|
|
$scope.$watch('vm.dashboardCtrl.dashboardCtx.state', function () { |
|
|
|
if (vm.stateObject[vm.stateObject.length - 1].id !== vm.dashboardCtrl.dashboardCtx.state) { |
|
|
|
stopWatchStateObject(); |
|
|
|
vm.stateObject[vm.stateObject.length - 1].id = vm.dashboardCtrl.dashboardCtx.state; |
|
|
|
updateLocation(); |
|
|
|
watchStateObject(); |
|
|
|
vm.skipStateChange = true; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
watchStateObject(); |
|
|
|
$scope.$watch('vm.stateObject', function(newVal, prevVal) { |
|
|
|
if (!angular.equals(newVal, prevVal) && newVal) { |
|
|
|
if (vm.skipStateChange) { |
|
|
|
vm.skipStateChange = false; |
|
|
|
} else { |
|
|
|
vm.selectedStateIndex = vm.stateObject.length - 1; |
|
|
|
gotoState(vm.stateObject[vm.stateObject.length - 1].id, true); |
|
|
|
} |
|
|
|
} |
|
|
|
}, true); |
|
|
|
|
|
|
|
if (vm.dashboardCtrl.isMobile) { |
|
|
|
watchSelectedStateIndex(); |
|
|
|
@ -292,22 +299,6 @@ export default function EntityStateController($scope, $timeout, $location, $stat |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function stopWatchStateObject() { |
|
|
|
if (vm.stateObjectWatcher) { |
|
|
|
vm.stateObjectWatcher(); |
|
|
|
vm.stateObjectWatcher = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function watchStateObject() { |
|
|
|
vm.stateObjectWatcher = $scope.$watch('vm.stateObject', function(newVal, prevVal) { |
|
|
|
if (!angular.equals(newVal, prevVal) && newVal) { |
|
|
|
vm.selectedStateIndex = vm.stateObject.length-1; |
|
|
|
gotoState(vm.stateObject[vm.stateObject.length-1].id, true); |
|
|
|
} |
|
|
|
}, true); |
|
|
|
} |
|
|
|
|
|
|
|
function stopWatchSelectedStateIndex() { |
|
|
|
if (vm.selectedStateIndexWatcher) { |
|
|
|
vm.selectedStateIndexWatcher(); |
|
|
|
|