Closed dnwhte closed 5 years ago
A little more info.
I don't think this is a solution, but I can get it working by making the close method on contentEditorOverlay the same as the submit method. The only difference is that the close method model is the old model.
scope.contentEditorOverlay = {
view: Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + "/innercontent/views/innercontent.dialog.html",
show: false,
submitButtonLabelKey: "bulk_done",
closeButtonLabelKey: "general_cancel",
submit: function (model) {
if (scope.config.callback) {
// Convert model to basic model
scope.config.data.model = innerContentService.createDbModel(model.dialogData.item);
// Notify callback
scope.config.callback(scope.config.data);
}
scope.closeAllOverlays();
},
close: function (model) {
if (scope.config.callback) {
// Convert model to basic model
scope.config.data.model = innerContentService.createDbModel(model.dialogData.item);
// Notify callback
scope.config.callback(scope.config.data);
}
scope.closeAllOverlays();
}
};
Think I got it. It's because an object is a reference type.
One solution is to deep copy non primitive types before assigning to prop.value on the editorModel.
Create a function to check for primitives
var isPrimitive = function (test) {
return (test !== Object(test));
};
prop.value = isPrimitive(dbModel[prop.alias]) ? dbModel[prop.alias] : angular.copy(dbModel[prop.alias]);
I can submit a PR if you are good with it.
Looks good to me. A PR would be awesome, thank you 🤘
I can't be sure if this is an Inner Content issue not (not sure how to test).
I have a simple property editor with two fields. For example, model.value.text and model.value.element. I make edits in the overlay and discard/cancel the changes and save. When I come back to the node, I see the "discarded" changes were saved.
Any ideas?