Don't YSOD when editing doctype from content that hasn't been saved yet
This commit is contained in:
committed by
Sebastiaan Janssen
parent
1acb6f5215
commit
ca8d5b948c
+35
-19
@@ -153,9 +153,16 @@
|
||||
|
||||
function reload() {
|
||||
$scope.page.loading = true;
|
||||
loadContent().then(function () {
|
||||
$scope.page.loading = false;
|
||||
});
|
||||
|
||||
if ($scope.page.isNew) {
|
||||
loadScaffold().then(function () {
|
||||
$scope.page.loading = false;
|
||||
});
|
||||
} else {
|
||||
loadContent().then(function () {
|
||||
$scope.page.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function bindEvents() {
|
||||
@@ -224,6 +231,28 @@
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This loads the content scaffold for when creating new content
|
||||
*/
|
||||
function loadScaffold() {
|
||||
//we are creating so get an empty content item
|
||||
return $scope.getScaffoldMethod()()
|
||||
.then(function (data) {
|
||||
|
||||
$scope.content = data;
|
||||
|
||||
init();
|
||||
startWatches($scope.content);
|
||||
|
||||
resetLastListPageNumber($scope.content);
|
||||
|
||||
eventsService.emit("content.newReady", { content: $scope.content });
|
||||
|
||||
return $q.resolve($scope.content);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the save/publish/preview buttons for the view
|
||||
* @param {any} content the content node
|
||||
@@ -489,22 +518,9 @@
|
||||
|
||||
$scope.page.loading = true;
|
||||
|
||||
//we are creating so get an empty content item
|
||||
$scope.getScaffoldMethod()()
|
||||
.then(function (data) {
|
||||
|
||||
$scope.content = data;
|
||||
|
||||
init();
|
||||
startWatches($scope.content);
|
||||
|
||||
resetLastListPageNumber($scope.content);
|
||||
|
||||
eventsService.emit("content.newReady", { content: $scope.content });
|
||||
|
||||
$scope.page.loading = false;
|
||||
|
||||
});
|
||||
loadScaffold().then(function () {
|
||||
$scope.page.loading = false;
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
-2
@@ -150,8 +150,6 @@
|
||||
const editor = {
|
||||
id: documentType.id,
|
||||
submit: function (model) {
|
||||
const args = { node: scope.node };
|
||||
eventsService.emit("editors.content.reload", args);
|
||||
editorService.close();
|
||||
},
|
||||
close: function () {
|
||||
|
||||
@@ -80,17 +80,19 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
||||
|
||||
formHelper.resetForm({ scope: args.scope });
|
||||
|
||||
self.handleSuccessfulSave({
|
||||
scope: args.scope,
|
||||
savedContent: data,
|
||||
softRedirect: args.softRedirect,
|
||||
rebindCallback: function () {
|
||||
rebindCallback.apply(self, [args.content, data]);
|
||||
}
|
||||
});
|
||||
if (!args.infiniteMode) {
|
||||
self.handleSuccessfulSave({
|
||||
scope: args.scope,
|
||||
savedContent: data,
|
||||
softRedirect: args.softRedirect,
|
||||
rebindCallback: function () {
|
||||
rebindCallback.apply(self, [args.content, data]);
|
||||
}
|
||||
});
|
||||
|
||||
//update editor state to what is current
|
||||
editorState.set(args.content);
|
||||
//update editor state to what is current
|
||||
editorState.set(args.content);
|
||||
}
|
||||
|
||||
return $q.resolve(data);
|
||||
|
||||
|
||||
@@ -338,6 +338,7 @@
|
||||
saveMethod: contentTypeResource.save,
|
||||
scope: $scope,
|
||||
content: vm.contentType,
|
||||
infiniteMode: infiniteMode,
|
||||
// we need to rebind... the IDs that have been created!
|
||||
rebindCallback: function (origContentType, savedContentType) {
|
||||
vm.contentType.id = savedContentType.id;
|
||||
|
||||
Reference in New Issue
Block a user