Made search suggestions togglable
This commit is contained in:
@@ -15,6 +15,7 @@ public class TableConfig {
|
||||
public bool Ignored { get; set; }
|
||||
public int Order { get; set; }
|
||||
internal bool Seeded { get; set; }
|
||||
public bool ShowSearchSuggestions { get; set; } = true;
|
||||
|
||||
public string? ViewPolicy { get; set; }
|
||||
public string? CreatePolicy { get; set; }
|
||||
@@ -66,6 +67,13 @@ public sealed class TableConfigurator<TModel>(TableConfig config) {
|
||||
InnerConfig.Ignored = ignore;
|
||||
return this;
|
||||
}
|
||||
/// <summary>
|
||||
/// Determines if search suggestions should be displayed in the ui (Advanced Search)
|
||||
/// </summary>
|
||||
public TableConfigurator<TModel> ShowSearchSuggestions(bool show = true) {
|
||||
InnerConfig.ShowSearchSuggestions = show;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the property of the table
|
||||
|
||||
@@ -314,7 +314,7 @@
|
||||
}
|
||||
|
||||
private void UpdateSearchSuggestions() {
|
||||
if (_config is null) return;
|
||||
if (_config is null || !_config.ShowSearchSuggestions) return;
|
||||
_searchSuggestions = SearchSuggestions.GenerateSearchSuggestions(_config, _searchTerm ?? string.Empty).ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ namespace HopFrame.Web.Services.Implementation;
|
||||
public sealed class SearchSuggestionProvider : ISearchSuggestionProvider {
|
||||
|
||||
public IEnumerable<string> GenerateSearchSuggestions(TableConfig table, string searchText) {
|
||||
if (table.ContextConfig is not DbContextConfig) return [];
|
||||
|
||||
var searchParts = searchText.Trim().Split(' ');
|
||||
if (searchParts.Length != 0 && searchParts.Last().EndsWith('=') && !searchText.EndsWith(' ')) {
|
||||
var part = searchParts.Last()[..^1];
|
||||
|
||||
Reference in New Issue
Block a user