Fixes the tag editor and tag suggestions

This commit is contained in:
Shannon
2019-02-01 13:32:17 +11:00
parent d8fbbeccfe
commit 7614ba42df
3 changed files with 56 additions and 55 deletions

View File

@@ -259,7 +259,7 @@ namespace Umbraco.Web.Editors
},
{
"tagsDataBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<TagsDataController>(
controller => controller.GetTags("", ""))
controller => controller.GetTags("", "", null))
},
{
"examineMgmtBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl<ExamineManagementController>(

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
@@ -15,10 +17,28 @@ namespace Umbraco.Web.PropertyEditors
[PluginController("UmbracoApi")]
public class TagsDataController : UmbracoAuthorizedApiController
{
public IEnumerable<TagModel> GetTags(string tagGroup, string culture)
/// <summary>
/// Returns all tags matching tagGroup, culture and an optional query
/// </summary>
/// <param name="tagGroup"></param>
/// <param name="culture"></param>
/// <param name="query"></param>
/// <returns></returns>
public IEnumerable<TagModel> GetTags(string tagGroup, string culture, string query = null)
{
if (culture == string.Empty) culture = null;
return Umbraco.TagQuery.GetAllTags(tagGroup, culture);
var result = Umbraco.TagQuery.GetAllTags(tagGroup, culture);
if (!query.IsNullOrWhiteSpace())
{
//TODO: add the query to TagQuery + the tag service, this is ugly but all we can do for now.
//currently we are post filtering this :( but works for now
result = result.Where(x => x.Text.InvariantContains(query));
}
return result.OrderBy(x => x.Text);
}
}
}