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

Commit

Permalink
Merge pull request #26 from umco/develop
Browse files Browse the repository at this point in the history
Preparing v1.1.1 release
  • Loading branch information
leekelleher authored Apr 11, 2018
2 parents 6e30f41 + 296f450 commit a421109
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image: Visual Studio 2017

# version format
version: 1.1.0.{build}
version: 1.1.1.{build}

# UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha
# example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ public override void ConfigureForDisplay(PreValueCollection preValues)
{
base.ConfigureForDisplay(preValues);

var asDictionary = preValues.PreValuesAsDictionary.ToDictionary(x => x.Key, x => x.Value.Value);
if (asDictionary.ContainsKey("hideLabel"))
if (preValues.PreValuesAsDictionary.ContainsKey("hideLabel"))
{
var boolAttempt = asDictionary["hideLabel"].TryConvertTo<bool>();
var boolAttempt = preValues.PreValuesAsDictionary["hideLabel"].Value.TryConvertTo<bool>();
if (boolAttempt.Success)
{
HideLabel = boolAttempt.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,19 @@ public override string ConvertDbToString(Property property, PropertyType propert
return string.Empty;

// Process value
ConvertDbToStringRecursive(value, property, propertyType, dataTypeService);
ConvertDbToStringRecursive(value, dataTypeService);

// Update the value on the property
property.Value = JsonConvert.SerializeObject(value);

// Pass the call down
return base.ConvertDbToString(property, propertyType, dataTypeService);
// Return the serialized value
return JsonConvert.SerializeObject(value);
}

protected void ConvertDbToStringRecursive(JToken token, Property property, PropertyType propertyType, IDataTypeService dataTypeService)
protected void ConvertDbToStringRecursive(JToken token, IDataTypeService dataTypeService)
{
if (token is JArray jArr)
{
foreach (var item in jArr)
{
ConvertDbToStringRecursive(item, property, propertyType, dataTypeService);
ConvertDbToStringRecursive(item, dataTypeService);
}
}

Expand All @@ -60,7 +57,7 @@ protected void ConvertDbToStringRecursive(JToken token, Property property, Prope
{
if (kvp.Value is JArray || kvp.Value is JObject)
{
ConvertDbToStringRecursive(kvp.Value, property, propertyType, dataTypeService);
ConvertDbToStringRecursive(kvp.Value, dataTypeService);
}
}
}
Expand All @@ -82,22 +79,19 @@ public override object ConvertDbToEditor(Property property, PropertyType propert
return string.Empty;

// Process value
ConvertDbToEditorRecursive(value, property, propertyType, dataTypeService);
ConvertDbToEditorRecursive(value, dataTypeService);

// Update the value on the property
property.Value = JsonConvert.SerializeObject(value);

// Pass the call down
return base.ConvertDbToEditor(property, propertyType, dataTypeService);
// Return the JObject, Angular can handle it directly
return value;
}

protected void ConvertDbToEditorRecursive(JToken token, Property property, PropertyType propertyType, IDataTypeService dataTypeService)
protected void ConvertDbToEditorRecursive(JToken token, IDataTypeService dataTypeService)
{
if (token is JArray jArr)
{
foreach (var item in jArr)
{
ConvertDbToEditorRecursive(item, property, propertyType, dataTypeService);
ConvertDbToEditorRecursive(item, dataTypeService);
}
}

Expand All @@ -113,7 +107,7 @@ protected void ConvertDbToEditorRecursive(JToken token, Property property, Prope
{
if (kvp.Value is JArray || kvp.Value is JObject)
{
ConvertDbToEditorRecursive(kvp.Value, property, propertyType, dataTypeService);
ConvertDbToEditorRecursive(kvp.Value, dataTypeService);
}
}
}
Expand All @@ -123,27 +117,31 @@ protected void ConvertDbToEditorRecursive(JToken token, Property property, Prope
public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue)
{
// Convert / validate value
if (editorValue.Value == null || string.IsNullOrWhiteSpace(editorValue.Value.ToString()))
return null;
if (editorValue.Value == null)
return string.Empty;

var value = JsonConvert.DeserializeObject<JToken>(editorValue.Value.ToString());
var dbValue = editorValue.Value.ToString();
if (string.IsNullOrWhiteSpace(dbValue))
return string.Empty;

var value = JsonConvert.DeserializeObject<JToken>(dbValue);
if (value == null || (value is JArray && ((JArray)value).Count == 0))
return null;
return string.Empty;

// Process value
ConvertEditorToDbRecursive(value, editorValue, currentValue);
ConvertEditorToDbRecursive(value, currentValue);

// Return value
return JsonConvert.SerializeObject(value);
}

protected void ConvertEditorToDbRecursive(JToken token, ContentPropertyData editorValue, object currentValue)
protected void ConvertEditorToDbRecursive(JToken token, object currentValue)
{
if (token is JArray jArr)
{
foreach (var item in jArr)
{
ConvertEditorToDbRecursive(item, editorValue, currentValue);
ConvertEditorToDbRecursive(item, currentValue);
}
}

Expand All @@ -159,7 +157,7 @@ protected void ConvertEditorToDbRecursive(JToken token, ContentPropertyData edit
{
if (kvp.Value is JArray || kvp.Value is JObject)
{
ConvertEditorToDbRecursive(kvp.Value, editorValue, currentValue);
ConvertEditorToDbRecursive(kvp.Value, currentValue);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<umb-tab id="tab{{tab.id}}" ng-repeat="tab in item.tabs" rel="{{tab.id}}">

<umb-property ng-repeat="property in tab.properties" property="property">
<umb-editor model="property"></umb-editor>
<umb-property-editor model="property"></umb-property-editor>
</umb-property>

</umb-tab>
Expand Down

0 comments on commit a421109

Please sign in to comment.