Mini-list view search by id,name & key is fixed. (#13735)
* Mini-list view search by id,name & key is fixed. Added multiple conditions in the query to consider id or name or key from the filter param(search bar from minilistview) * make it more simple ,now using || instead of clause conditions. --------- Co-authored-by: Dhanesh Kumar <dhanesh.kumar@phases.dk> Co-authored-by: Michael <michael@crossingpaths.be>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Dynamic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using Examine.Search;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||
@@ -15,6 +18,7 @@ using Umbraco.Cms.Core.Models.Entities;
|
||||
using Umbraco.Cms.Core.Models.Membership;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Cms.Core.Models.TemplateQuery;
|
||||
using Umbraco.Cms.Core.Persistence;
|
||||
using Umbraco.Cms.Core.Routing;
|
||||
using Umbraco.Cms.Core.Security;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
@@ -745,7 +749,11 @@ public class EntityController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
return new PagedResult<EntityBasic>(0, 0, 0);
|
||||
}
|
||||
|
||||
//adding multiple conditions ,considering id,key & name as filter param
|
||||
//for id as int
|
||||
int.TryParse(filter, out int filterAsIntId);
|
||||
//for key as Guid
|
||||
Guid.TryParse(filter, out Guid filterAsGuid);
|
||||
// else proceed as usual
|
||||
entities = _entityService.GetPagedChildren(
|
||||
id,
|
||||
@@ -755,7 +763,9 @@ public class EntityController : UmbracoAuthorizedJsonController
|
||||
out long totalRecords,
|
||||
filter.IsNullOrWhiteSpace()
|
||||
? null
|
||||
: _sqlContext.Query<IUmbracoEntity>().Where(x => x.Name!.Contains(filter)),
|
||||
: _sqlContext.Query<IUmbracoEntity>().Where(x => x.Name!.Contains(filter)
|
||||
|| x.Id == filterAsIntId
|
||||
|| x.Key == filterAsGuid),
|
||||
Ordering.By(orderBy, orderDirection));
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user