Adds UDI support for the content picker

This commit is contained in:
Shannon
2017-02-01 13:38:42 +11:00
parent e95cb14d48
commit 83757c60b5
3 changed files with 42 additions and 12 deletions

View File

@@ -17,11 +17,21 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
$scope.$watch(function () {
//return the joined Ids as a string to watch
return _.map($scope.renderModel, function (i) {
return i.id;
if ($scope.model.config.idType === "udi") {
return i.udi;
}
else {
return i.id;
}
}).join();
}, function (newVal) {
var currIds = _.map($scope.renderModel, function (i) {
return i.id;
if ($scope.model.config.idType === "udi") {
return i.udi;
}
else {
return i.id;
}
});
$scope.model.value = trim(currIds.join(), ",");
@@ -200,7 +210,12 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
$scope.add = function (item) {
var currIds = _.map($scope.renderModel, function (i) {
return i.id;
if ($scope.model.config.idType === "udi") {
return i.udi;
}
else {
return i.id;
}
});
if (currIds.indexOf(item.id) < 0) {
@@ -227,7 +242,12 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
var currIds = _.map($scope.renderModel, function (i) {
return i.id;
if ($scope.model.config.idType === "udi") {
return i.udi;
}
else {
return i.id;
}
});
$scope.model.value = trim(currIds.join(), ",");
});
@@ -244,7 +264,12 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
_.each(modelIds, function (id, i) {
var entity = _.find(data, function (d) {
return d.id == id;
if ($scope.model.config.idType === "udi") {
return d.udi == id;
}
else {
return d.id == id;
}
});
if (entity) {
@@ -304,6 +329,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
$scope.renderModel.push({
"name": item.name,
"id": item.id,
"udi": item.udi,
"icon": item.icon,
"path": item.path,
"url": item.url,

View File

@@ -13,7 +13,10 @@ namespace Umbraco.Web.PropertyEditors
[PropertyEditor(Constants.PropertyEditors.ContentPickerAlias, "(Obsolete) Content Picker", PropertyEditorValueTypes.Integer, "contentpicker", IsParameterEditor = true, Group = "Pickers", IsDeprecated = true)]
public class ContentPickerPropertyEditor : ContentPickerPropertyEditor2
{
public ContentPickerPropertyEditor()
{
InternalPreValues["idType"] = "int";
}
}
/// <summary>
@@ -25,20 +28,21 @@ namespace Umbraco.Web.PropertyEditors
public ContentPickerPropertyEditor2()
{
_internalPreValues = new Dictionary<string, object>
InternalPreValues = new Dictionary<string, object>
{
{"startNodeId", "-1"},
{"showOpenButton", "0"},
{"showEditButton", "0"},
{"showPathOnHover", "0"}
{"showPathOnHover", "0"},
{"idType", "udi"}
};
}
private IDictionary<string, object> _internalPreValues;
protected IDictionary<string, object> InternalPreValues;
public override IDictionary<string, object> DefaultPreValues
{
get { return _internalPreValues; }
set { _internalPreValues = value; }
get { return InternalPreValues; }
set { InternalPreValues = value; }
}
protected override PreValueEditor CreatePreValueEditor()

View File

@@ -22,7 +22,7 @@ namespace Umbraco.Web.PropertyEditors
{
{"multiPicker", "0"},
{"onlyImages", "0"},
{"idType", "id"}
{"idType", "int"}
};
}