Fixes angular file controllers to not sync the tree if an item is being created, redirects to the correct path if the file is renamed
This commit is contained in:
@@ -48,20 +48,25 @@
|
||||
});
|
||||
});
|
||||
|
||||
vm.page.saveButtonState = "success";
|
||||
vm.partialViewMacro = saved;
|
||||
//check if the name changed, if so we need to redirect
|
||||
if (vm.partialViewMacro.id !== saved.id) {
|
||||
contentEditingHelper.redirectToRenamedContent(saved.id);
|
||||
}
|
||||
else {
|
||||
vm.page.saveButtonState = "success";
|
||||
vm.partialViewMacro = saved;
|
||||
|
||||
//sync state
|
||||
editorState.set(vm.partialViewMacro);
|
||||
//sync state
|
||||
editorState.set(vm.partialViewMacro);
|
||||
|
||||
// normal tree sync
|
||||
navigationService.syncTree({ tree: "partialViewMacros", path: vm.partialViewMacro.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
|
||||
// clear $dirty state on form
|
||||
setFormState("pristine");
|
||||
// normal tree sync
|
||||
navigationService.syncTree({ tree: "partialViewMacros", path: vm.partialViewMacro.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
|
||||
// clear $dirty state on form
|
||||
setFormState("pristine");
|
||||
}
|
||||
}, function (err) {
|
||||
|
||||
vm.page.saveButtonState = "error";
|
||||
@@ -237,26 +242,29 @@
|
||||
}
|
||||
|
||||
codefileResource.getScaffold("partialViewMacros", $routeParams.id, snippet).then(function (partialViewMacro) {
|
||||
ready(partialViewMacro);
|
||||
ready(partialViewMacro, false);
|
||||
});
|
||||
|
||||
} else {
|
||||
codefileResource.getByPath('partialViewMacros', $routeParams.id).then(function (partialViewMacro) {
|
||||
ready(partialViewMacro);
|
||||
ready(partialViewMacro, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function ready(partialViewMacro) {
|
||||
function ready(partialViewMacro, syncTree) {
|
||||
|
||||
vm.page.loading = false;
|
||||
vm.partialViewMacro = partialViewMacro;
|
||||
|
||||
//sync state
|
||||
editorState.set(vm.partialViewMacro);
|
||||
navigationService.syncTree({ tree: "partialViewMacros", path: vm.partialViewMacro.virtualPath, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
|
||||
if (syncTree) {
|
||||
navigationService.syncTree({ tree: "partialViewMacros", path: vm.partialViewMacro.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
}
|
||||
|
||||
// ace configuration
|
||||
vm.aceOption = {
|
||||
|
||||
@@ -58,20 +58,25 @@
|
||||
});
|
||||
});
|
||||
|
||||
vm.page.saveButtonState = "success";
|
||||
vm.partialView = saved;
|
||||
//check if the name changed, if so we need to redirect
|
||||
if (vm.partialView.id !== saved.id) {
|
||||
contentEditingHelper.redirectToRenamedContent(saved.id);
|
||||
}
|
||||
else {
|
||||
vm.page.saveButtonState = "success";
|
||||
vm.partialView = saved;
|
||||
|
||||
//sync state
|
||||
editorState.set(vm.partialView);
|
||||
//sync state
|
||||
editorState.set(vm.partialView);
|
||||
|
||||
// normal tree sync
|
||||
navigationService.syncTree({ tree: "partialViews", path: vm.partialView.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
|
||||
// clear $dirty state on form
|
||||
setFormState("pristine");
|
||||
// normal tree sync
|
||||
navigationService.syncTree({ tree: "partialViews", path: vm.partialView.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
|
||||
// clear $dirty state on form
|
||||
setFormState("pristine");
|
||||
}
|
||||
}, function (err) {
|
||||
|
||||
vm.page.saveButtonState = "error";
|
||||
@@ -247,18 +252,18 @@
|
||||
}
|
||||
|
||||
codefileResource.getScaffold("partialViews", $routeParams.id, snippet).then(function (partialView) {
|
||||
ready(partialView);
|
||||
ready(partialView, false);
|
||||
});
|
||||
|
||||
} else {
|
||||
codefileResource.getByPath('partialViews', $routeParams.id).then(function (partialView) {
|
||||
ready(partialView);
|
||||
ready(partialView, true);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function ready(partialView) {
|
||||
function ready(partialView, syncTree) {
|
||||
|
||||
vm.page.loading = false;
|
||||
vm.partialView = partialView;
|
||||
@@ -266,9 +271,11 @@
|
||||
//sync state
|
||||
editorState.set(vm.partialView);
|
||||
|
||||
navigationService.syncTree({ tree: "partialViews", path: vm.partialView.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
if (syncTree) {
|
||||
navigationService.syncTree({ tree: "partialViews", path: vm.partialView.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
}
|
||||
|
||||
// ace configuration
|
||||
vm.aceOption = {
|
||||
|
||||
@@ -55,16 +55,22 @@
|
||||
notificationsService.success(header, message);
|
||||
});
|
||||
|
||||
vm.page.saveButtonState = "success";
|
||||
vm.script = saved;
|
||||
//check if the name changed, if so we need to redirect
|
||||
if (vm.script.id !== saved.id) {
|
||||
contentEditingHelper.redirectToRenamedContent(saved.id);
|
||||
}
|
||||
else {
|
||||
vm.page.saveButtonState = "success";
|
||||
vm.script = saved;
|
||||
|
||||
//sync state
|
||||
editorState.set(vm.script);
|
||||
|
||||
// sync tree
|
||||
navigationService.syncTree({ tree: "scripts", path: vm.script.virtualPath, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
//sync state
|
||||
editorState.set(vm.script);
|
||||
|
||||
// sync tree
|
||||
navigationService.syncTree({ tree: "scripts", path: vm.script.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
}
|
||||
|
||||
}, function (err) {
|
||||
|
||||
@@ -90,17 +96,17 @@
|
||||
|
||||
if ($routeParams.create) {
|
||||
codefileResource.getScaffold("scripts", $routeParams.id).then(function (script) {
|
||||
ready(script);
|
||||
ready(script, false);
|
||||
});
|
||||
} else {
|
||||
codefileResource.getByPath('scripts', $routeParams.id).then(function (script) {
|
||||
ready(script);
|
||||
ready(script, true);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function ready(script) {
|
||||
function ready(script, syncTree) {
|
||||
|
||||
vm.page.loading = false;
|
||||
|
||||
@@ -109,9 +115,11 @@
|
||||
//sync state
|
||||
editorState.set(vm.script);
|
||||
|
||||
navigationService.syncTree({ tree: "scripts", path: vm.script.virtualPath, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
if (syncTree) {
|
||||
navigationService.syncTree({ tree: "scripts", path: vm.script.path, forceReload: true }).then(function (syncArgs) {
|
||||
vm.page.menu.currentNode = syncArgs.node;
|
||||
});
|
||||
}
|
||||
|
||||
vm.aceOption = {
|
||||
mode: "javascript",
|
||||
|
||||
Reference in New Issue
Block a user