merge
This commit is contained in:
@@ -112,7 +112,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// This can be overridden if perhaps you have a comma delimited string posted value but want to convert those to individual rows, or to convert
|
||||
/// a json structure to multiple rows.
|
||||
/// </remarks>
|
||||
public virtual IDictionary<string, string> FormatDataForPersistence(IDictionary<string, object> editorValue, PreValueCollection currentValue)
|
||||
public virtual IDictionary<string, string> ConvertEditorToDb(IDictionary<string, object> editorValue, PreValueCollection currentValue)
|
||||
{
|
||||
//convert to a string based value to be saved in the db
|
||||
return editorValue.ToDictionary(x => x.Key, x => x.Value == null ? null : x.Value.ToString());
|
||||
@@ -133,7 +133,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// This is generally not going to be used by anything unless a property editor wants to change the merging
|
||||
/// functionality or needs to convert some legacy persisted data, or convert the string values to strongly typed values in json (i.e. booleans)
|
||||
/// </remarks>
|
||||
public virtual IDictionary<string, object> FormatDataForEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
public virtual IDictionary<string, object> ConvertDbToEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
{
|
||||
if (defaultPreVals == null)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,34 @@ namespace Umbraco.Core.PropertyEditors
|
||||
}
|
||||
}
|
||||
|
||||
private PreValueCollection _preVals;
|
||||
protected PreValueCollection PreValues
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_preVals == null)
|
||||
{
|
||||
throw new InvalidOperationException("Pre values cannot be accessed until the Configure method has been called");
|
||||
}
|
||||
return _preVals;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called to configure the editor for display with it's prevalues, useful when properties need to change dynamically
|
||||
/// depending on what is in the pre-values.
|
||||
/// </summary>
|
||||
/// <param name="preValues"></param>
|
||||
/// <remarks>
|
||||
/// This cannot be used to change the value being sent to the editor, ConfigureEditor will be called *after* ConvertDbToEditor, pre-values
|
||||
/// should not be used to modify values.
|
||||
/// </remarks>
|
||||
public virtual void ConfigureForDisplay(PreValueCollection preValues)
|
||||
{
|
||||
if (preValues == null) throw new ArgumentNullException("preValues");
|
||||
_preVals = preValues;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the view to use for the editor, this can be one of 3 things:
|
||||
/// * the full virtual path or
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
|
||||
var editor = new ValueListPreValueEditor();
|
||||
|
||||
var result = editor.FormatDataForEditor(defaultVals, persisted);
|
||||
var result = editor.ConvertDbToEditor(defaultVals, persisted);
|
||||
|
||||
Assert.AreEqual(1, result.Count);
|
||||
Assert.IsTrue(result.ContainsKey("items"));
|
||||
|
||||
@@ -13,9 +13,8 @@ angular.module("umbraco")
|
||||
};
|
||||
|
||||
$scope.submitFolder = function(e){
|
||||
e.ev.preventDefault();
|
||||
|
||||
if(e.keyCode === 13){
|
||||
e.preventDefault();
|
||||
$scope.showFolderInput = false;
|
||||
|
||||
mediaResource
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<form novalidate name="contentForm"
|
||||
ng-controller="Umbraco.Editors.Content.EditController"
|
||||
ng-show="loaded"
|
||||
ng-submit="save()"
|
||||
val-form-manager>
|
||||
<form novalidate name="contentForm"
|
||||
ng-controller="Umbraco.Editors.Content.EditController"
|
||||
ng-show="loaded"
|
||||
ng-submit="save()"
|
||||
val-form-manager>
|
||||
<umb-panel>
|
||||
<umb-header tabs="content.tabs">
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
|
||||
<div class="btn-group">
|
||||
|
||||
<a class="btn btn-success" href="#" ng-click="saveAndPublish()"
|
||||
prevent-default data-hotkey="ctrl+p">
|
||||
<a class="btn btn-success" href="#" ng-click="saveAndPublish()" prevent-default data-hotkey="ctrl+p">
|
||||
<localize key="buttons_saveAndPublish">Publish</localize>
|
||||
</a>
|
||||
|
||||
@@ -37,12 +36,16 @@
|
||||
</a>
|
||||
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
|
||||
<li><a href="#" ng-click="save()"
|
||||
prevent-default data-hotkey="ctrl+s">
|
||||
<localize key="buttons_save">Save</localize>
|
||||
</a></li>
|
||||
<li ng-show="content.publishDate"><a href="#" ng-click="unPublish()"
|
||||
prevent-default><localize key="content_unPublish">Unpublish</localize></a></li>
|
||||
<li>
|
||||
<a href="#" ng-click="save()" prevent-default data-hotkey="ctrl+s">
|
||||
<localize key="buttons_save">Save</localize>
|
||||
</a>
|
||||
</li>
|
||||
<li ng-show="content.publishDate">
|
||||
<a href="#" ng-click="unPublish()" prevent-default>
|
||||
<localize key="content_unPublish">Unpublish</localize>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<form novalidate name="contentForm"
|
||||
ng-controller="Umbraco.Editors.DataType.EditController"
|
||||
ng-show="loaded"
|
||||
ng-submit="save()"
|
||||
val-form-manager>
|
||||
<umb-panel>
|
||||
|
||||
<umb-header>
|
||||
|
||||
<div class="span4">
|
||||
<umb-content-name
|
||||
ng-model="content.name"
|
||||
placeholder="Enter a title">
|
||||
</umb-content-name>
|
||||
</div>
|
||||
|
||||
<div class="span8">
|
||||
<div class="btn-toolbar pull-right umb-btn-toolbar">
|
||||
|
||||
<div class="btn-group">
|
||||
|
||||
<button type="submit" class="btn btn-success">Save</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</umb-header>
|
||||
|
||||
<div class="umb-panel-body umb-scrollable row-fluid">
|
||||
<div class="tab-content form-horizontal">
|
||||
<div class="umb-pane">
|
||||
|
||||
<umb-property property="properties.selectedEditor">
|
||||
<div>
|
||||
<select name="selectedEditor"
|
||||
ng-model="content.selectedEditor"
|
||||
required
|
||||
ng-options="e.alias as e.name for e in content.availableEditors"></select>
|
||||
<span class="help-inline" val-msg-for="selectedEditor" val-toggle-msg="required">Required</span>
|
||||
</div>
|
||||
|
||||
</umb-property>
|
||||
|
||||
<umb-property property="properties.selectedEditorId">
|
||||
<div>{{content.selectedEditor}}</div>
|
||||
</umb-property>
|
||||
|
||||
<hr />
|
||||
|
||||
<umb-property
|
||||
property="preValue"
|
||||
ng-repeat="preValue in preValues">
|
||||
|
||||
<umb-editor model="preValue" is-pre-value="true"></umb-editor>
|
||||
</umb-property>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</umb-panel>
|
||||
</form>
|
||||
@@ -16,6 +16,7 @@ using Umbraco.Web.Trees;
|
||||
using Umbraco.Web.UI.JavaScript;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.WebServices;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
@@ -144,6 +145,10 @@ namespace Umbraco.Web.Editors
|
||||
"updateCheckApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<UpdateCheckController>(
|
||||
controller => controller.GetCheck())
|
||||
},
|
||||
{
|
||||
"tagApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<TagsController>(
|
||||
controller => controller.GetAllTags(null))
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Umbraco.Web.Editors
|
||||
var currVal = Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dataType.PersistedDataType.Id);
|
||||
|
||||
//we need to allow for the property editor to deserialize the prevalues
|
||||
var formattedVal = dataType.PropertyEditor.PreValueEditor.FormatDataForPersistence(
|
||||
var formattedVal = dataType.PropertyEditor.PreValueEditor.ConvertEditorToDb(
|
||||
preValDictionary,
|
||||
currVal);
|
||||
|
||||
|
||||
@@ -24,16 +24,19 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
var display = base.ConvertCore(originalProp);
|
||||
|
||||
var dataTypeService = _dataTypeService.Value;
|
||||
var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(originalProp.PropertyType.DataTypeDefinitionId);
|
||||
|
||||
//configure the editor for display with the pre-values
|
||||
var valEditor = display.PropertyEditor.ValueEditor;
|
||||
valEditor.ConfigureForDisplay(preVals);
|
||||
|
||||
//set the display properties after mapping
|
||||
display.Alias = originalProp.Alias;
|
||||
display.Description = originalProp.PropertyType.Description;
|
||||
display.Label = originalProp.PropertyType.Name;
|
||||
display.HideLabel = display.PropertyEditor.ValueEditor.HideLabel;
|
||||
|
||||
var dataTypeService = _dataTypeService.Value;
|
||||
|
||||
var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(originalProp.PropertyType.DataTypeDefinitionId);
|
||||
|
||||
display.HideLabel = valEditor.HideLabel;
|
||||
|
||||
if (display.PropertyEditor == null)
|
||||
{
|
||||
//display.Config = PreValueCollection.AsDictionary(preVals);
|
||||
@@ -44,8 +47,8 @@ namespace Umbraco.Web.Models.Mapping
|
||||
else
|
||||
{
|
||||
//let the property editor format the pre-values
|
||||
display.Config = display.PropertyEditor.PreValueEditor.FormatDataForEditor(display.PropertyEditor.DefaultPreValues, preVals);
|
||||
display.View = display.PropertyEditor.ValueEditor.View;
|
||||
display.Config = display.PropertyEditor.PreValueEditor.ConvertDbToEditor(display.PropertyEditor.DefaultPreValues, preVals);
|
||||
display.View = valEditor.View;
|
||||
}
|
||||
|
||||
return display;
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
if (propEd != null)
|
||||
{
|
||||
result = propEd.PreValueEditor.Fields.Select(Mapper.Map<PreValueFieldDisplay>).ToArray();
|
||||
dictionaryVals = propEd.PreValueEditor.FormatDataForEditor(propEd.DefaultPreValues, preVals);
|
||||
dictionaryVals = propEd.PreValueEditor.ConvertDbToEditor(propEd.DefaultPreValues, preVals);
|
||||
}
|
||||
|
||||
var currentIndex = 0; //used if the collection is non-dictionary based.
|
||||
|
||||
@@ -52,9 +52,9 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <param name="defaultPreVals"></param>
|
||||
/// <param name="persistedPreVals"></param>
|
||||
/// <returns></returns>
|
||||
public override IDictionary<string, object> FormatDataForEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
public override IDictionary<string, object> ConvertDbToEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
{
|
||||
var returnVal = base.FormatDataForEditor(defaultPreVals, persistedPreVals);
|
||||
var returnVal = base.ConvertDbToEditor(defaultPreVals, persistedPreVals);
|
||||
//always add the multiple param to true
|
||||
returnVal["multiple"] = "1";
|
||||
return returnVal;
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <param name="defaultPreVals"></param>
|
||||
/// <param name="persistedPreVals"></param>
|
||||
/// <returns></returns>
|
||||
public override IDictionary<string, object> FormatDataForEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
public override IDictionary<string, object> ConvertDbToEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
{
|
||||
var result = new Dictionary<string, object>();
|
||||
|
||||
@@ -164,9 +164,9 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <param name="editorValue"></param>
|
||||
/// <param name="currentValue"></param>
|
||||
/// <returns></returns>
|
||||
public override IDictionary<string, string> FormatDataForPersistence(IDictionary<string, object> editorValue, PreValueCollection currentValue)
|
||||
public override IDictionary<string, string> ConvertEditorToDb(IDictionary<string, object> editorValue, PreValueCollection currentValue)
|
||||
{
|
||||
var result = base.FormatDataForPersistence(editorValue, currentValue);
|
||||
var result = base.ConvertEditorToDb(editorValue, currentValue);
|
||||
|
||||
//this should just be a dictionary of values, we want to re-format this so that it is just one value in the dictionary that is
|
||||
// semi-colon delimited
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <param name="editorValue"></param>
|
||||
/// <param name="currentValue"></param>
|
||||
/// <returns></returns>
|
||||
public override IDictionary<string, string> FormatDataForPersistence(IDictionary<string, object> editorValue, PreValueCollection currentValue)
|
||||
public override IDictionary<string, string> ConvertEditorToDb(IDictionary<string, object> editorValue, PreValueCollection currentValue)
|
||||
{
|
||||
//the values from the editor will be min/max fieds and we need to format to json in one field
|
||||
var min = (editorValue.ContainsKey("min") ? editorValue["min"].ToString() : "0").TryConvertTo<int>();
|
||||
@@ -73,7 +73,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <param name="defaultPreVals"></param>
|
||||
/// <param name="persistedPreVals"></param>
|
||||
/// <returns></returns>
|
||||
public override IDictionary<string, object> FormatDataForEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
public override IDictionary<string, object> ConvertDbToEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
{
|
||||
var preVals = persistedPreVals.FormatAsDictionary();
|
||||
var stringVal = preVals.Any() ? preVals.First().Value.Value : "";
|
||||
|
||||
@@ -22,6 +22,13 @@ namespace Umbraco.Web.PropertyEditors
|
||||
HideLabel = true,
|
||||
Key = "editor"
|
||||
});
|
||||
|
||||
Fields.Add(new PreValueField()
|
||||
{
|
||||
Name = "Hide Label",
|
||||
View = "boolean",
|
||||
Key = "hideLabel"
|
||||
});
|
||||
}
|
||||
|
||||
//SD: You can declare a field like this if you want to instead of in the ctor, there's some options here:
|
||||
|
||||
@@ -33,6 +33,24 @@ namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// override so that we can hide the label based on the pre-value
|
||||
/// </summary>
|
||||
/// <param name="preValues"></param>
|
||||
public override void ConfigureForDisplay(Core.Models.PreValueCollection preValues)
|
||||
{
|
||||
base.ConfigureForDisplay(preValues);
|
||||
var asDictionary = preValues.FormatAsDictionary();
|
||||
if (asDictionary.ContainsKey("hideLabel"))
|
||||
{
|
||||
var boolAttempt = asDictionary["hideLabel"].Value.TryConvertTo<bool>();
|
||||
if (boolAttempt.Success)
|
||||
{
|
||||
HideLabel = boolAttempt.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format the data for the editor
|
||||
/// </summary>
|
||||
@@ -41,7 +59,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
public override object ConvertDbToEditor(object dbValue)
|
||||
{
|
||||
if (dbValue == null)
|
||||
return dbValue;
|
||||
return null;
|
||||
|
||||
var parsed = MacroTagParser.FormatRichTextPersistedDataForEditor(dbValue.ToString(), new Dictionary<string, string>());
|
||||
return parsed;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <param name="defaultPreVals"></param>
|
||||
/// <param name="persistedPreVals"></param>
|
||||
/// <returns></returns>
|
||||
public override IDictionary<string, object> FormatDataForEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
public override IDictionary<string, object> ConvertDbToEditor(IDictionary<string, object> defaultPreVals, PreValueCollection persistedPreVals)
|
||||
{
|
||||
var dictionary = persistedPreVals.FormatAsDictionary();
|
||||
var arrayOfVals = dictionary.Select(item => item.Value).ToList();
|
||||
@@ -78,7 +78,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// <remarks>
|
||||
/// This is mostly because we want to maintain compatibility with v6 drop down property editors that store their prevalues in different db rows.
|
||||
/// </remarks>
|
||||
public override IDictionary<string, string> FormatDataForPersistence(IDictionary<string, object> editorValue, PreValueCollection currentValue)
|
||||
public override IDictionary<string, string> ConvertEditorToDb(IDictionary<string, object> editorValue, PreValueCollection currentValue)
|
||||
{
|
||||
var val = editorValue["items"] as JArray;
|
||||
var result = new Dictionary<string, string>();
|
||||
|
||||
Reference in New Issue
Block a user