Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Commit

Permalink
Code amends & housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
leekelleher committed Jul 20, 2018
1 parent 8c04f9f commit e737329
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand All @@ -136,15 +137,15 @@ 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);
}
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;
Expand All @@ -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<JArray>(), dataTypeService);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
Inner Content - Doc Type Picker
*/
/* Inner Content - Doc Type Picker */

.inner-content__doctypepicker table input,
.inner-content__doctypepicker table select {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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"
);
}
};
});
}
]);

0 comments on commit e737329

Please sign in to comment.