diff --git a/OpenIZAdmin.Services/Entities/EntityService.cs b/OpenIZAdmin.Services/Entities/EntityService.cs index 2655dfd7..fa80f8dc 100644 --- a/OpenIZAdmin.Services/Entities/EntityService.cs +++ b/OpenIZAdmin.Services/Entities/EntityService.cs @@ -546,6 +546,22 @@ public IEnumerable Search(string searchTerm, string[] expandProperties) wh /// if set to true [invert class concept filter check]. /// Returns a list of entities which match the given search term and class concept key filter. public IEnumerable Search(string searchTerm, Guid classConceptFilterKey, string[] expandProperties, bool invertClassConceptFilterCheck = false) where T : Entity + { + return this.Search(searchTerm, classConceptFilterKey, 0, null, expandProperties, invertClassConceptFilterCheck); + } + + /// + /// Searches the specified search term. + /// + /// + /// The search term. + /// The class concept filter key. + /// The offset. + /// The count. + /// The expand properties. + /// if set to true [invert class concept filter check]. + /// Returns a list of entities which match the given search term and class concept key filter. + public IEnumerable Search(string searchTerm, Guid classConceptFilterKey, int offset, int? count, string[] expandProperties, bool invertClassConceptFilterCheck = false) where T : Entity { var results = new List(); @@ -560,7 +576,7 @@ public IEnumerable Search(string searchTerm, Guid classConceptFilterKey, s queryExpression = p => p.Names.Any(n => n.Component.Any(c => c.Value.Contains(searchTerm))) && p.ClassConceptKey != classConceptFilterKey; } - var bundle = this.Client.Query(queryExpression, 0, null, expandProperties); + var bundle = this.Client.Query(queryExpression, offset, count, expandProperties); foreach (var item in bundle.Item.OfType().LatestVersionOnly().Where(queryExpression.Compile())) { @@ -576,6 +592,7 @@ public IEnumerable Search(string searchTerm, Guid classConceptFilterKey, s coreAuditService.AuditGenericError(OutcomeIndicator.EpicFail, this.entityAuditService.QueryEntityAuditCode, EventIdentifierType.ApplicationActivity, e); throw; } + return results; } diff --git a/OpenIZAdmin.Services/Entities/IEntityService.cs b/OpenIZAdmin.Services/Entities/IEntityService.cs index 99db7f67..6a4d14b4 100644 --- a/OpenIZAdmin.Services/Entities/IEntityService.cs +++ b/OpenIZAdmin.Services/Entities/IEntityService.cs @@ -176,6 +176,19 @@ public interface IEntityService /// Returns a list of entities which match the given search term and class concept key filter. IEnumerable Search(string searchTerm, Guid classConceptFilterKey, string[] expandProperties, bool invertClassConceptFilterCheck = false) where T : Entity; + /// + /// Searches the specified search term. + /// + /// + /// The search term. + /// The class concept filter key. + /// The offset. + /// The count. + /// The expand properties. + /// if set to true [invert class concept filter check]. + /// Returns a list of entities which match the given search term and class concept key filter. + IEnumerable Search(string searchTerm, Guid classConceptFilterKey, int offset, int? count, string[] expandProperties, bool invertClassConceptFilterCheck = false) where T : Entity; + /// /// Searches for a specific entity by search term. /// diff --git a/OpenIZAdmin/Controllers/PlaceController.cs b/OpenIZAdmin/Controllers/PlaceController.cs index b4cc8165..92294913 100644 --- a/OpenIZAdmin/Controllers/PlaceController.cs +++ b/OpenIZAdmin/Controllers/PlaceController.cs @@ -928,7 +928,7 @@ public ActionResult SearchAddressAjax(string searchTerm, string classConcept) if (Guid.TryParse(classConcept, out classConceptKey)) { - var places = this.entityService.Query(p => p.Names.Any(n => n.Component.Any(c => c.Value.Contains(searchTerm))) && p.ObsoletionTime == null && p.ClassConceptKey == classConceptKey, 0, 15, new string[] { "typeConcept", "address.use" }); + var places = this.entityService.Search(searchTerm, classConceptKey, 0, 15, new []{ "typeConcept", "address.use" }); results = places.Select(p => new PlaceViewModel(p)).OrderBy(p => p.Name).ToList(); } diff --git a/OpenIZAdmin/Scripts/address-search.js b/OpenIZAdmin/Scripts/address-search.js index f267e0c7..c52da09d 100644 --- a/OpenIZAdmin/Scripts/address-search.js +++ b/OpenIZAdmin/Scripts/address-search.js @@ -28,7 +28,7 @@ maximumSelectionLength: 1, keepSearchResults: true, escapeMarkup: function (markup) { return markup; }, - minimumInputLength: 4, + minimumInputLength: 3, templateResult: function (data) { var retVal = ""; if (data.data) {