From e73732937d9843be7195d931c204a4441597c3df Mon Sep 17 00:00:00 2001 From: leekelleher Date: Fri, 20 Jul 2018 11:38:24 +0100 Subject: [PATCH] Code amends & housekeeping --- .../InnerContentPropertyValueEditor.cs | 11 ++++--- .../InnerContent/css/innercontent.css | 7 ++-- .../InnerContent/js/innercontent.js | 32 +++++++++++++------ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Our.Umbraco.InnerContent/PropertyEditors/InnerContentPropertyValueEditor.cs b/src/Our.Umbraco.InnerContent/PropertyEditors/InnerContentPropertyValueEditor.cs index 55178c8..5e99441 100644 --- a/src/Our.Umbraco.InnerContent/PropertyEditors/InnerContentPropertyValueEditor.cs +++ b/src/Our.Umbraco.InnerContent/PropertyEditors/InnerContentPropertyValueEditor.cs @@ -3,6 +3,7 @@ using System.Linq; using Newtonsoft.Json.Linq; using Our.Umbraco.InnerContent.Helpers; +using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; @@ -70,7 +71,7 @@ protected void ConvertInnerContentDbToString(JObject item, IDataTypeService data var propEditor = PropertyEditorResolver.Current.GetByAlias(propType.PropertyEditorAlias); // Get the editor to do it's conversion, and store it back - item[propKey] = propEditor.ValueEditor.ConvertDbToString(prop, propType, dataTypeService); + item[propKey] = propEditor?.ValueEditor?.ConvertDbToString(prop, propType, dataTypeService); } catch (InvalidOperationException) { @@ -116,7 +117,7 @@ protected void ConvertInnerContentDbToEditor(JObject item, IDataTypeService data foreach (var propKey in propValueKeys) { - var propType = contentType.CompositionPropertyTypes.FirstOrDefault(x => x.Alias == propKey); + var propType = contentType.CompositionPropertyTypes.FirstOrDefault(x => x.Alias.InvariantEquals(propKey)); if (propType == null) { if (IsSystemPropertyKey(propKey) == false) @@ -136,7 +137,7 @@ protected void ConvertInnerContentDbToEditor(JObject item, IDataTypeService data var propEditor = PropertyEditorResolver.Current.GetByAlias(propType.PropertyEditorAlias); // Get the editor to do it's conversion - var newValue = propEditor.ValueEditor.ConvertDbToEditor(prop, propType, dataTypeService); + var newValue = propEditor?.ValueEditor?.ConvertDbToEditor(prop, propType, dataTypeService); // Store the value back item[propKey] = (newValue == null) ? null : JToken.FromObject(newValue); @@ -144,7 +145,7 @@ protected void ConvertInnerContentDbToEditor(JObject item, IDataTypeService data catch (InvalidOperationException) { // https://github.com/umco/umbraco-nested-content/issues/111 - // Catch any invalid cast operations as likely means courier failed due to missing + // Catch any invalid cast operations as likely means Courier failed due to missing // or trashed item so couldn't convert a guid back to an int item[propKey] = null; @@ -153,7 +154,7 @@ protected void ConvertInnerContentDbToEditor(JObject item, IDataTypeService data } // Process children - var childrenProp = item.Properties().FirstOrDefault(x => x.Name == "children"); + var childrenProp = item.Properties().FirstOrDefault(x => x.Name.InvariantEquals("children")); if (childrenProp != null) { ConvertInnerContentDbToEditor(childrenProp.Value.Value(), dataTypeService); diff --git a/src/Our.Umbraco.InnerContent/Web/UI/App_Plugins/InnerContent/css/innercontent.css b/src/Our.Umbraco.InnerContent/Web/UI/App_Plugins/InnerContent/css/innercontent.css index b8c6dfc..5fe1ff7 100644 --- a/src/Our.Umbraco.InnerContent/Web/UI/App_Plugins/InnerContent/css/innercontent.css +++ b/src/Our.Umbraco.InnerContent/Web/UI/App_Plugins/InnerContent/css/innercontent.css @@ -1,6 +1,4 @@ -/* - Inner Content - Doc Type Picker -*/ +/* Inner Content - Doc Type Picker */ .inner-content__doctypepicker table input, .inner-content__doctypepicker table select { @@ -23,6 +21,9 @@ width: 1px; } + +/* Inner Content - Content Overlay Panel */ + .inner-content-overlay > .umb-overlay-right > .umb-overlay__form > .umb-overlay-container { padding: 0; position: static; 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 4dd51bc..ce0e38b 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 @@ -81,10 +81,9 @@ angular.module("umbraco").controller("Our.Umbraco.InnerContent.Controllers.DocTy angular.module("umbraco").controller("Our.Umbraco.InnerContent.Controllers.InnerContentCreateController", [ "$scope", - "$rootScope", "blueprintConfig", - function ($scope, $rootScope, blueprintConfig) { + function ($scope, blueprintConfig) { function initialize() { @@ -364,8 +363,7 @@ angular.module("umbraco.directives").directive("innerContentUnsavedChanges", [ if (scope.canConfirmClose) { overlayScope.oldCloseOverLay = overlayScope.closeOverLay; overlayScope.closeOverLay = function () { - // TODO: Find out why this throws an error with nested IC editors. (`$dirty` is undefined) [LK:2018-02-28] - if (overlayScope.overlayForm.$dirty) { + if (overlayScope.overlayForm && overlayScope.overlayForm.$dirty) { scope.showConfirmClose = true; } else { overlayScope.oldCloseOverLay.apply(overlayScope); @@ -399,13 +397,11 @@ angular.module("umbraco.directives").directive("innerContentUnsavedChanges", [ // Services angular.module("umbraco").factory("innerContentService", [ - "$q", "$interpolate", - "contentResource", "localStorageService", "Our.Umbraco.InnerContent.Resources.InnerContentResources", - function ($q, $interpolate, contentResource, localStorageService, icResources) { + function ($interpolate, localStorageService, icResources) { var self = {}; @@ -651,8 +647,12 @@ angular.module("umbraco").factory("innerContentService", [ ]); // Resources -angular.module("umbraco.resources").factory("Our.Umbraco.InnerContent.Resources.InnerContentResources", - function ($q, $http, umbRequestHelper) { +angular.module("umbraco.resources").factory("Our.Umbraco.InnerContent.Resources.InnerContentResources", [ + + "$http", + "umbRequestHelper", + + function ($http, umbRequestHelper) { return { getAllContentTypes: function () { return umbRequestHelper.resourcePromise( @@ -712,6 +712,18 @@ angular.module("umbraco.resources").factory("Our.Umbraco.InnerContent.Resources. }), "Failed to retrieve content type scaffold by blueprint Id" ); + }, + createBlueprintFromContent: function (data, userId) { + return umbRequestHelper.resourcePromise( + $http({ + url: umbRequestHelper.convertVirtualToAbsolutePath("~/umbraco/backoffice/InnerContent/InnerContentApi/CreateBlueprintFromContent"), + method: "POST", + params: { userId: userId }, + data: data + }), + "Failed to create blueprint from content" + ); } }; - }); + } +]);