From cc16c58a51088d581d43c0547bf589b7bf4914fd Mon Sep 17 00:00:00 2001 From: Dan White Date: Wed, 13 Mar 2019 11:29:08 -0700 Subject: [PATCH] Copy non-primitive types before assigned to prop.value on editormodel Makes discard unsaved changes work when model.value is an object. --- .../Web/UI/App_Plugins/InnerContent/js/innercontent.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Our.Umbraco.InnerContent/Web/UI/App_Plugins/InnerContent/js/innercontent.js b/src/Our.Umbraco.InnerContent/Web/UI/App_Plugins/InnerContent/js/innercontent.js index 457e607..62d7661 100644 --- a/src/Our.Umbraco.InnerContent/Web/UI/App_Plugins/InnerContent/js/innercontent.js +++ b/src/Our.Umbraco.InnerContent/Web/UI/App_Plugins/InnerContent/js/innercontent.js @@ -465,6 +465,10 @@ angular.module("umbraco").factory("innerContentService", [ } }; + var isPrimitive = function (test) { + return (test !== Object(test)); + }; + self.populateName = function (itm, idx, contentTypes) { var contentType = _.find(contentTypes, function (itm2) { @@ -532,7 +536,7 @@ angular.module("umbraco").factory("innerContentService", [ for (var p = 0; p < tab.properties.length; p++) { var prop = tab.properties[p]; if (dbModel.hasOwnProperty(prop.alias)) { - prop.value = dbModel[prop.alias]; + prop.value = isPrimitive(dbModel[prop.alias]) ? dbModel[prop.alias] : angular.copy(dbModel[prop.alias]); } } }