guard code for non-infinite editing to prevent route change
This commit is contained in:
@@ -73,14 +73,14 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
|
||||
|
||||
var content = $scope.content;
|
||||
|
||||
// we need to check wether an app is present in the current data, if not we will present the default app.
|
||||
// we need to check whether an app is present in the current data, if not we will present the default app.
|
||||
var isAppPresent = false;
|
||||
|
||||
// on first init, we dont have any apps. but if we are re-initializing, we do, but ...
|
||||
if ($scope.app) {
|
||||
|
||||
// lets check if it still exists as part of our apps array. (if not we have made a change to our docType, even just a re-save of the docType it will turn into new Apps.)
|
||||
_.forEach(content.apps, function(app) {
|
||||
content.apps.forEach(app => {
|
||||
if (app === $scope.app) {
|
||||
isAppPresent = true;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
|
||||
|
||||
// if we did reload our DocType, but still have the same app we will try to find it by the alias.
|
||||
if (isAppPresent === false) {
|
||||
_.forEach(content.apps, function(app) {
|
||||
content.apps.forEach(app => {
|
||||
if (app.alias === $scope.app.alias) {
|
||||
isAppPresent = true;
|
||||
app.active = true;
|
||||
@@ -182,24 +182,26 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
|
||||
|
||||
formHelper.resetForm({ scope: $scope });
|
||||
|
||||
contentEditingHelper.handleSuccessfulSave({
|
||||
scope: $scope,
|
||||
savedContent: data,
|
||||
rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data)
|
||||
});
|
||||
|
||||
editorState.set($scope.content);
|
||||
|
||||
syncTreeNode($scope.content, data.path);
|
||||
|
||||
init();
|
||||
|
||||
$scope.page.saveButtonState = "success";
|
||||
|
||||
// close the editor if it's infinite mode
|
||||
// submit function manages rebinding changes
|
||||
if(infiniteMode && $scope.model.submit) {
|
||||
$scope.model.mediaNode = $scope.content;
|
||||
$scope.model.submit($scope.model);
|
||||
} else {
|
||||
// if not infinite mode, rebind changed props etc
|
||||
contentEditingHelper.handleSuccessfulSave({
|
||||
scope: $scope,
|
||||
savedContent: data,
|
||||
rebindCallback: contentEditingHelper.reBindChangedProperties($scope.content, data)
|
||||
});
|
||||
|
||||
editorState.set($scope.content);
|
||||
|
||||
syncTreeNode($scope.content, data.path);
|
||||
|
||||
$scope.page.saveButtonState = "success";
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
}, function(err) {
|
||||
|
||||
Reference in New Issue
Block a user