Send over a PropertyEditor's DefaultPreValues when building the property view

* Add static mappings for DefaultPreValues to config file (for now - should be able to pull them out)
* Merge in the DefaultPreValues to the Prevalues when building the config
This commit is contained in:
Tom Fulton
2014-01-31 02:27:22 -07:00
parent 548113a34a
commit bc7025ec69
3 changed files with 27 additions and 11 deletions
+12 -6
View File
@@ -13,11 +13,13 @@
},
{
"propertyEditorAlias": "Umbraco.Date",
"view": "datepicker"
"view": "datepicker",
"defaultPreValues": [{ "format": "yyyy-MM-dd", "pickTime": false }]
},
{
"propertyEditorAlias": "Umbraco.DateTime",
"view": "datepicker"
"view": "datepicker",
"format": "yyyy-MM-dd hh:mm:ss"
},
{
"propertyEditorAlias": "Umbraco.DropDown",
@@ -69,7 +71,8 @@
},
{
"propertyEditorAlias": "Umbraco.MediaPicker",
"view": "mediapicker"
"view": "mediapicker",
"defaultPreValues": [{ "multiPicker": "0" }]
},
{
"propertyEditorAlias": "Umbraco.MemberGroupPicker",
@@ -81,7 +84,8 @@
},
{
"propertyEditorAlias": "Umbraco.MultiNodeTreePicker",
"view": "contentpicker"
"view": "contentpicker",
"defaultPreValues": [{ "multiPicker": "1" }]
},
{
"propertyEditorAlias": "Umbraco.MultipleMediaPicker",
@@ -109,7 +113,8 @@
},
{
"propertyEditorAlias": "Umbraco.Tags",
"view": "tags"
"view": "tags",
"defaultPreValues": [{ "group": "default" }]
},
{
"propertyEditorAlias": "Umbraco.TextboxMultiple",
@@ -125,7 +130,8 @@
},
{
"propertyEditorAlias": "Umbraco.UserPicker",
"view": "entitypicker"
"view": "entitypicker",
"defaultPreValues": [{ "entityType": "User" }]
},
{
"propertyEditorAlias": "Umbraco.NoEdit",
+13 -3
View File
@@ -67,9 +67,19 @@ angular.module("umbraco").directive('archetypeProperty', function ($compile, $ht
config = configObj;
//determine the view to use [...] and load it
propertyEditorResource.getViewForPropertyEditor(data.selectedEditor).then(function(data) {
var pathToView = umbPropEditorHelper.getViewPath(data);
loadView(pathToView, config, defaultValue, alias, scope, element);
propertyEditorResource.getPropertyEditorMapping(data.selectedEditor).then(function(propertyEditor) {
var pathToView = umbPropEditorHelper.getViewPath(propertyEditor.view);
//load in the DefaultPreValues for the PropertyEditor, if any
var defaultConfigObj = {};
if (propertyEditor.hasOwnProperty('defaultPreValues')) {
_.each(propertyEditor.defaultPreValues, function(p) {
_.extend(defaultConfigObj, p)
});
}
var mergedConfig = _.extend(defaultConfigObj, config);
loadView(pathToView, mergedConfig, defaultValue, alias, scope, element);
});
});
+2 -2
View File
@@ -15,7 +15,7 @@ angular.module('umbraco').factory('propertyEditorResource', function($q, $http,
$http.get("/umbraco/backoffice/UmbracoApi/DataType/GetById?id=" + id), 'Failed to retrieve datatype'
);
},
getViewForPropertyEditor: function(alias) {
getPropertyEditorMapping: function(alias) {
return umbRequestHelper.resourcePromise(
$http.get("/App_plugins/Archetype/js/propertyEditors.views.js"), 'Failed to retrieve datatype mappings'
).then(function (data) {
@@ -24,7 +24,7 @@ angular.module('umbraco').factory('propertyEditorResource', function($q, $http,
});
if (result != null)
return result.view;
return result;
return "";
});