Gets member picker working with UDI, ensures that the GUID is indexed for all things - can't believe this wasn't being done, updates the search model mapper to return the UDI
This commit is contained in:
@@ -17,21 +17,11 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
$scope.$watch(function () {
|
||||
//return the joined Ids as a string to watch
|
||||
return _.map($scope.renderModel, function (i) {
|
||||
if ($scope.model.config.idType === "udi") {
|
||||
return i.udi;
|
||||
}
|
||||
else {
|
||||
return i.id;
|
||||
}
|
||||
return $scope.model.config.idType === "udi" ? i.udi : i.id;
|
||||
}).join();
|
||||
}, function (newVal) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
if ($scope.model.config.idType === "udi") {
|
||||
return i.udi;
|
||||
}
|
||||
else {
|
||||
return i.id;
|
||||
}
|
||||
return $scope.model.config.idType === "udi" ? i.udi : i.id;
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
|
||||
@@ -210,15 +200,12 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
|
||||
$scope.add = function (item) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
if ($scope.model.config.idType === "udi") {
|
||||
return i.udi;
|
||||
}
|
||||
else {
|
||||
return i.id;
|
||||
}
|
||||
return $scope.model.config.idType === "udi" ? i.udi : i.id;
|
||||
});
|
||||
|
||||
if (currIds.indexOf(item.id) < 0) {
|
||||
var itemId = $scope.model.config.idType === "udi" ? item.udi : item.id;
|
||||
|
||||
if (currIds.indexOf(itemId) < 0) {
|
||||
setEntityUrl(item);
|
||||
}
|
||||
};
|
||||
@@ -242,12 +229,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
|
||||
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
|
||||
var currIds = _.map($scope.renderModel, function (i) {
|
||||
if ($scope.model.config.idType === "udi") {
|
||||
return i.udi;
|
||||
}
|
||||
else {
|
||||
return i.id;
|
||||
}
|
||||
return $scope.model.config.idType === "udi" ? i.udi : i.id;
|
||||
});
|
||||
$scope.model.value = trim(currIds.join(), ",");
|
||||
});
|
||||
@@ -264,12 +246,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper
|
||||
|
||||
_.each(modelIds, function (id, i) {
|
||||
var entity = _.find(data, function (d) {
|
||||
if ($scope.model.config.idType === "udi") {
|
||||
return d.udi == id;
|
||||
}
|
||||
else {
|
||||
return d.id == id;
|
||||
}
|
||||
return $scope.model.config.idType === "udi" ? (d.udi == id) : (d.id == id);
|
||||
});
|
||||
|
||||
if (entity) {
|
||||
|
||||
@@ -68,12 +68,19 @@ function memberPickerController($scope, dialogService, entityResource, $log, ico
|
||||
|
||||
$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) {
|
||||
var itemId = $scope.model.config.idType === "udi" ? item.udi : item.id;
|
||||
|
||||
if (currIds.indexOf(itemId) < 0) {
|
||||
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
|
||||
$scope.renderModel.push({name: item.name, id: item.id, icon: item.icon});
|
||||
$scope.renderModel.push({ name: item.name, id: item.id, udi: item.udi, icon: item.icon});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,7 +90,12 @@ function memberPickerController($scope, dialogService, entityResource, $log, ico
|
||||
|
||||
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(), ",");
|
||||
});
|
||||
@@ -99,7 +111,7 @@ function memberPickerController($scope, dialogService, entityResource, $log, ico
|
||||
_.each(data, function (item, i) {
|
||||
// set default icon if it's missing
|
||||
item.icon = (item.icon) ? iconHelper.convertFromLegacyIcon(item.icon) : "icon-user";
|
||||
$scope.renderModel.push({ name: item.name, id: item.id, icon: item.icon });
|
||||
$scope.renderModel.push({ name: item.name, id: item.id, udi: item.udi, icon: item.icon });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Examine;
|
||||
using Examine.LuceneEngine.Providers;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Mapping;
|
||||
@@ -94,21 +95,40 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dto => dto.Trashed, expression => expression.Ignore())
|
||||
.ForMember(x => x.AdditionalData, expression => expression.Ignore())
|
||||
.AfterMap((result, basic) =>
|
||||
{
|
||||
{
|
||||
|
||||
//get the icon if there is one
|
||||
basic.Icon = result.Fields.ContainsKey(UmbracoContentIndexer.IconFieldName)
|
||||
? result.Fields[UmbracoContentIndexer.IconFieldName]
|
||||
: "icon-document";
|
||||
|
||||
basic.Name = result.Fields.ContainsKey("nodeName") ? result.Fields["nodeName"] : "[no name]";
|
||||
if (result.Fields.ContainsKey("__NodeKey"))
|
||||
if (result.Fields.ContainsKey(UmbracoContentIndexer.NodeKeyFieldName))
|
||||
{
|
||||
Guid key;
|
||||
if (Guid.TryParse(result.Fields["__NodeKey"], out key))
|
||||
if (Guid.TryParse(result.Fields[UmbracoContentIndexer.NodeKeyFieldName], out key))
|
||||
{
|
||||
basic.Key = key;
|
||||
|
||||
//need to set the UDI
|
||||
if (result.Fields.ContainsKey(LuceneIndexer.IndexTypeFieldName))
|
||||
{
|
||||
switch (result.Fields[LuceneIndexer.IndexTypeFieldName])
|
||||
{
|
||||
case IndexTypes.Member:
|
||||
basic.Udi = new GuidUdi(Constants.UdiEntityType.Member, basic.Key);
|
||||
break;
|
||||
case IndexTypes.Content:
|
||||
basic.Udi = new GuidUdi(Constants.UdiEntityType.Document, basic.Key);
|
||||
break;
|
||||
case IndexTypes.Media:
|
||||
basic.Udi = new GuidUdi(Constants.UdiEntityType.Media, basic.Key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result.Fields.ContainsKey("parentID"))
|
||||
{
|
||||
int parentId;
|
||||
@@ -121,7 +141,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
basic.ParentId = -1;
|
||||
}
|
||||
}
|
||||
basic.Path = result.Fields.ContainsKey("__Path") ? result.Fields["__Path"] : "";
|
||||
basic.Path = result.Fields.ContainsKey(UmbracoContentIndexer.IndexPathFieldName) ? result.Fields[UmbracoContentIndexer.IndexPathFieldName] : "";
|
||||
|
||||
if (result.Fields.ContainsKey(UmbracoContentIndexer.NodeTypeAliasFieldName))
|
||||
{
|
||||
|
||||
@@ -13,10 +13,28 @@ namespace Umbraco.Web.PropertyEditors
|
||||
[PropertyEditor(Constants.PropertyEditors.MemberPickerAlias, "(Obsolete) Member Picker", PropertyEditorValueTypes.Integer, "memberpicker", Group = "People", Icon = "icon-user", IsDeprecated = true)]
|
||||
public class MemberPickerPropertyEditor : MemberPickerPropertyEditor2
|
||||
{
|
||||
public MemberPickerPropertyEditor()
|
||||
{
|
||||
InternalPreValues["idType"] = "int";
|
||||
}
|
||||
}
|
||||
|
||||
[PropertyEditor(Constants.PropertyEditors.MemberPicker2Alias, "Member Picker", PropertyEditorValueTypes.String, "memberpicker", Group = "People", Icon = "icon-user")]
|
||||
public class MemberPickerPropertyEditor2 : PropertyEditor
|
||||
{
|
||||
public MemberPickerPropertyEditor2()
|
||||
{
|
||||
InternalPreValues = new Dictionary<string, object>
|
||||
{
|
||||
{"idType", "udi"}
|
||||
};
|
||||
}
|
||||
|
||||
internal IDictionary<string, object> InternalPreValues;
|
||||
public override IDictionary<string, object> DefaultPreValues
|
||||
{
|
||||
get { return InternalPreValues; }
|
||||
set { InternalPreValues = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ namespace UmbracoExamine
|
||||
/// Used to store the path of a content object
|
||||
/// </summary>
|
||||
public const string IndexPathFieldName = "__Path";
|
||||
public const string NodeKeyFieldName = "__Key";
|
||||
public const string NodeTypeAliasFieldName = "__NodeTypeAlias";
|
||||
public const string IconFieldName = "__Icon";
|
||||
|
||||
@@ -726,18 +727,23 @@ namespace UmbracoExamine
|
||||
|
||||
//ensure the special path and node type alias fields is added to the dictionary to be saved to file
|
||||
var path = e.Node.Attribute("path").Value;
|
||||
if (!e.Fields.ContainsKey(IndexPathFieldName))
|
||||
if (e.Fields.ContainsKey(IndexPathFieldName) == false)
|
||||
e.Fields.Add(IndexPathFieldName, path);
|
||||
|
||||
//this needs to support both schema's so get the nodeTypeAlias if it exists, otherwise the name
|
||||
var nodeTypeAlias = e.Node.Attribute("nodeTypeAlias") == null ? e.Node.Name.LocalName : e.Node.Attribute("nodeTypeAlias").Value;
|
||||
if (!e.Fields.ContainsKey(NodeTypeAliasFieldName))
|
||||
if (e.Fields.ContainsKey(NodeTypeAliasFieldName) == false)
|
||||
e.Fields.Add(NodeTypeAliasFieldName, nodeTypeAlias);
|
||||
|
||||
//add icon
|
||||
var icon = (string)e.Node.Attribute("icon");
|
||||
if (!e.Fields.ContainsKey(IconFieldName))
|
||||
e.Fields.Add(IconFieldName, icon);
|
||||
if (e.Fields.ContainsKey(IconFieldName) == false)
|
||||
e.Fields.Add(IconFieldName, icon);
|
||||
|
||||
//add guid
|
||||
var guid = (string)e.Node.Attribute("key");
|
||||
if (e.Fields.ContainsKey(NodeKeyFieldName) == false)
|
||||
e.Fields.Add(NodeKeyFieldName, guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -768,6 +774,12 @@ namespace UmbracoExamine
|
||||
//adds the special node type alias property to the index
|
||||
fields.Add(NodeTypeAliasFieldName, allValuesForIndexing[NodeTypeAliasFieldName]);
|
||||
|
||||
//guid
|
||||
if (allValuesForIndexing[IconFieldName].IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
fields.Add(NodeKeyFieldName, allValuesForIndexing[NodeKeyFieldName]);
|
||||
}
|
||||
|
||||
//icon
|
||||
if (allValuesForIndexing[IconFieldName].IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
|
||||
@@ -231,20 +231,7 @@ namespace UmbracoExamine
|
||||
protected override XDocument GetXDocument(string xPath, string type)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSpecialFieldsToIndex(Dictionary<string, string> allValuesForIndexing)
|
||||
{
|
||||
var fields = base.GetSpecialFieldsToIndex(allValuesForIndexing);
|
||||
|
||||
//adds the special path property to the index
|
||||
string valuesForIndexing;
|
||||
if (allValuesForIndexing.TryGetValue("__key", out valuesForIndexing))
|
||||
fields.Add("__key", valuesForIndexing);
|
||||
|
||||
return fields;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the special __key and _searchEmail fields
|
||||
@@ -256,8 +243,8 @@ namespace UmbracoExamine
|
||||
|
||||
if (e.Node.Attribute("key") != null)
|
||||
{
|
||||
if (e.Fields.ContainsKey("__key") == false)
|
||||
e.Fields.Add("__key", e.Node.Attribute("key").Value);
|
||||
if (e.Fields.ContainsKey(NodeKeyFieldName) == false)
|
||||
e.Fields.Add(NodeKeyFieldName, e.Node.Attribute("key").Value);
|
||||
}
|
||||
|
||||
if (e.Node.Attribute("email") != null)
|
||||
|
||||
Reference in New Issue
Block a user