Skip to content

Commit

Permalink
Update package version 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavnavar committed Feb 2, 2022
1 parent 9545a55 commit a15fdfe
Show file tree
Hide file tree
Showing 33 changed files with 290 additions and 104 deletions.
4 changes: 2 additions & 2 deletions GridBlazor.Tests/Client/ClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public void TestMainMethods()
Assert.IsTrue(_client.Grid.ComponentOptions.AllowMultipleFilters);

_client.Searchable();
Assert.IsTrue(_client.Grid.SearchingEnabled);
Assert.IsTrue(_client.Grid.SearchingOnlyTextColumns);
Assert.IsTrue(_client.Grid.SearchOptions.Enabled);
Assert.IsTrue(_client.Grid.SearchOptions.OnlyTextColumns);

_client.Named("test");
Assert.AreEqual(_client.Grid.ComponentOptions.GridName, "test");
Expand Down
4 changes: 2 additions & 2 deletions GridBlazor.Tests/Client/ODataClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void TestMainMethods()
Assert.IsTrue(_client.Grid.ComponentOptions.AllowMultipleFilters);

_client.Searchable();
Assert.IsTrue(_client.Grid.SearchingEnabled);
Assert.IsTrue(_client.Grid.SearchingOnlyTextColumns);
Assert.IsTrue(_client.Grid.SearchOptions.Enabled);
Assert.IsTrue(_client.Grid.SearchOptions.OnlyTextColumns);

_client.Named("test");
Assert.AreEqual(_client.Grid.ComponentOptions.GridName, "test");
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor.Tests/GridBlazor.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>3.0.4</Version>
<Version>3.2.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 1 addition & 7 deletions GridBlazor/CGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,7 @@ private CGrid(HttpClient httpClient, string url,
/// </summary>
public int ItemsCount { get { return _pager.ItemsCount; } }

public bool SearchingEnabled { get; set; }

public bool SearchingOnlyTextColumns { get; set; }

public bool SearchingHiddenColumns { get; set; }

public bool SearchingSplittedWords { get; set; }
public SearchOptions SearchOptions { get; set; } = new SearchOptions() { Enabled = false };

public bool ExtSortingEnabled { get; set; }

Expand Down
18 changes: 12 additions & 6 deletions GridBlazor/Client/GridClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,21 @@ public IGridClient<T> Searchable(bool enable, bool onlyTextColumns)

public IGridClient<T> Searchable(bool enable, bool onlyTextColumns, bool hiddenColumns)
{
return Searchable(enable, onlyTextColumns, false, false);
return Searchable(o =>
{
o.Enabled = enable;
o.OnlyTextColumns = onlyTextColumns;
o.HiddenColumns = hiddenColumns;
o.SplittedWords = false;
});
}

public IGridClient<T> Searchable(bool enable, bool onlyTextColumns, bool hiddenColumns, bool splittedWords)
public IGridClient<T> Searchable(Action<SearchOptions> searchOptions)
{
_source.SearchingEnabled = enable;
_source.SearchingOnlyTextColumns = onlyTextColumns;
_source.SearchingHiddenColumns = hiddenColumns;
_source.SearchingSplittedWords = splittedWords;
var options = new SearchOptions();
searchOptions?.Invoke(options);

_source.SearchOptions = options;
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/Client/IGridClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public interface IGridClient<T>
/// <summary>
/// Enable or disable searching for all columns
/// </summary>
IGridClient<T> Searchable(bool enable, bool onlyTextColumns, bool hiddenColumns, bool splittedWords);
IGridClient<T> Searchable(Action<SearchOptions> searchOptions);

/// <summary>
/// Enable extended sorting
Expand Down
6 changes: 3 additions & 3 deletions GridBlazor/Filtering/FilterGridODataProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ public string Process()

// workaround for lack of $search OData support
var search = new List<string>();
if (_grid.SearchingEnabled && !string.IsNullOrWhiteSpace(_searchSettings.SearchValue))
if (_grid.SearchOptions.Enabled && !string.IsNullOrWhiteSpace(_searchSettings.SearchValue))
{
foreach (IGridColumn column in _grid.Columns)
{
var gridColumn = column as IGridColumn<T>;
if (gridColumn == null) continue;
if (!_grid.SearchingHiddenColumns && gridColumn.Hidden) continue;
if (!_grid.SearchOptions.HiddenColumns && gridColumn.Hidden) continue;
if (gridColumn.Filter == null) continue;
if (!gridColumn.Filter.IsTextColumn()) continue;

List<ColumnFilterValue> options = new List<ColumnFilterValue>();
if (_grid.SearchingSplittedWords)
if (_grid.SearchOptions.SplittedWords)
{
var searchWords = _searchSettings.SearchValue.Split(' ');
foreach (var searchWord in searchWords)
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/GridBlazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<LangVersion>8.0</LangVersion>
<GenerateEmbeddedFilesManifest>True</GenerateEmbeddedFilesManifest>
<EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
<Version>3.1.1</Version>
<Version>3.2.0</Version>
<Title>GridBlazor</Title>
<Description>Grid components for Blazor</Description>
<Summary>Grid components for Blazor</Summary>
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/Pages/GridComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
</div>
}
</div>
@if (Grid.SearchingEnabled)
@if (Grid.SearchOptions.Enabled)
{
<CascadingValue Value=@this Name="GridComponent">
<GridSearchComponent @ref="SearchComponent" T="@T" Grid="@Grid"></GridSearchComponent>
Expand Down
2 changes: 1 addition & 1 deletion GridBlazor/Searching/SearchGridODataProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void UpdateSettings(IGridSearchSettings settings)
public string Process()
{
string result = "";
if (_grid.SearchingEnabled && !string.IsNullOrWhiteSpace(_settings.SearchValue))
if (_grid.SearchOptions.Enabled && !string.IsNullOrWhiteSpace(_settings.SearchValue))
{
result = "$search='" + WebUtility.UrlEncode(_settings.SearchValue.Replace("'", "''")) + "'";
}
Expand Down
2 changes: 1 addition & 1 deletion GridCore/GridCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
<Product>GridCore</Product>
<PackageId>GridCore</PackageId>
<Version>5.1.1</Version>
<Version>5.2.0</Version>
<Title>GridCore</Title>
<Description>Grid core component</Description>
<Summary>Grid core component</Summary>
Expand Down
8 changes: 1 addition & 7 deletions GridCore/SGridCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,7 @@ public IGridColumnCollection<T> Columns
get { return _columnsCollection; }
}

public bool SearchingEnabled { get; set; }

public bool SearchingOnlyTextColumns { get; set; }

public bool SearchingHiddenColumns { get; set; }

public bool SearchingSplittedWords { get; set; }
public SearchOptions SearchOptions { get; set; } = new SearchOptions() { Enabled = false };

public bool ExtSortingEnabled { get; set; }

Expand Down
10 changes: 5 additions & 5 deletions GridCore/Searching/SearchGridItemsProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public void UpdateSettings(IGridSearchSettings settings)

public IQueryable<T> Process(IQueryable<T> items)
{
if (_grid.SearchingEnabled && !string.IsNullOrWhiteSpace(_settings.SearchValue))
if (_grid.SearchOptions.Enabled && !string.IsNullOrWhiteSpace(_settings.SearchValue))
{
ParameterExpression parameter = Expression.Parameter(typeof(T), "x");
Expression binaryExpression = null;

if (_grid.SearchingSplittedWords)
if (_grid.SearchOptions.SplittedWords)
{
var searchWords = _settings.SearchValue.Split(' ');
foreach (var searchWord in searchWords)
Expand All @@ -66,17 +66,17 @@ private Expression GetExpression(ISGrid grid, Expression binaryExpression, Param
IGridColumn<T> gridColumn = column as IGridColumn<T>;
if (gridColumn == null) continue;
if (gridColumn.Search == null) continue;
if (!grid.SearchingHiddenColumns && gridColumn.Hidden) continue;
if (!grid.SearchOptions.HiddenColumns && gridColumn.Hidden) continue;

if (binaryExpression == null)
{
binaryExpression = gridColumn.Search.GetExpression(searchValue,
grid.SearchingOnlyTextColumns, parameter, grid.RemoveDiacritics);
grid.SearchOptions.OnlyTextColumns, parameter, grid.RemoveDiacritics);
}
else
{
Expression expression = gridColumn.Search.GetExpression(searchValue,
grid.SearchingOnlyTextColumns, parameter, grid.RemoveDiacritics);
grid.SearchOptions.OnlyTextColumns, parameter, grid.RemoveDiacritics);
if (expression != null)
{
binaryExpression = Expression.OrElse(binaryExpression, expression);
Expand Down
18 changes: 12 additions & 6 deletions GridCore/Server/GridCoreServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,21 @@ public IGridServer<T> Searchable(bool enable, bool onlyTextColumns)

public IGridServer<T> Searchable(bool enable, bool onlyTextColumns, bool hiddenColumns)
{
return Searchable(enable, onlyTextColumns, false, false);
return Searchable(o =>
{
o.Enabled = enable;
o.OnlyTextColumns = onlyTextColumns;
o.HiddenColumns = hiddenColumns;
o.SplittedWords = false;
});
}

public IGridServer<T> Searchable(bool enable, bool onlyTextColumns, bool hiddenColumns, bool splittedWords)
public IGridServer<T> Searchable(Action<SearchOptions> searchOptions)
{
_source.SearchingEnabled = enable;
_source.SearchingOnlyTextColumns = onlyTextColumns;
_source.SearchingHiddenColumns = hiddenColumns;
_source.SearchingSplittedWords = splittedWords;
var options = new SearchOptions();
searchOptions?.Invoke(options);

_source.SearchOptions = options;
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion GridCore/Server/IGridServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public interface IGridServer<T>
/// <summary>
/// Enable or disable searching for all columns
/// </summary>
IGridServer<T> Searchable(bool enable, bool onlyTextColumns, bool hiddenColumns, bool splittedWords);
IGridServer<T> Searchable(Action<SearchOptions> searchOptions);

/// <summary>
/// Enable extended sorting
Expand Down
2 changes: 1 addition & 1 deletion GridMvc.Tests/GridMvc.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>5.0.3</Version>
<Version>5.2.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions GridMvc.Tests/Html/HtmlOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public void TestMainMethods()
Assert.IsTrue(_grid.RenderOptions.AllowMultipleFilters);

_opt.Searchable();
Assert.IsTrue(_grid.SearchingEnabled);
Assert.IsTrue(_grid.SearchingOnlyTextColumns);
Assert.IsTrue(_grid.SearchOptions.Enabled);
Assert.IsTrue(_grid.SearchOptions.OnlyTextColumns);

_opt.Named("test");
Assert.AreEqual(_grid.RenderOptions.GridName, "test");
Expand Down
8 changes: 4 additions & 4 deletions GridMvc.Tests/Searching/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void TestTextColumnsSearch()
store.Add("grid-search", "TEST");
QueryCollection query = new QueryCollection(store);
_grid = new TestGrid(_repo.GetAll(), query);
_grid.SearchingEnabled = true;
_grid.SearchingOnlyTextColumns = true;
_grid.SearchOptions.Enabled = true;
_grid.SearchOptions.OnlyTextColumns = true;

Action<IGridColumnCollection<TestModel>> columns = c =>
{
Expand Down Expand Up @@ -61,8 +61,8 @@ public void TestAllColumnsSearch()
store.Add("grid-search", "3");
QueryCollection query = new QueryCollection(store);
_grid = new TestGrid(_repo.GetAll(), query);
_grid.SearchingEnabled = true;
_grid.SearchingOnlyTextColumns = false;
_grid.SearchOptions.Enabled = true;
_grid.SearchOptions.OnlyTextColumns = false;

Action<IGridColumnCollection<TestModel>> columns = c =>
{
Expand Down
4 changes: 2 additions & 2 deletions GridMvc.Tests/Server/ServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void TestMainMethods()
Assert.IsTrue(_server.Grid.RenderOptions.AllowMultipleFilters);

_server.Searchable();
Assert.IsTrue(_server.Grid.SearchingEnabled);
Assert.IsTrue(_server.Grid.SearchingOnlyTextColumns);
Assert.IsTrue(_server.Grid.SearchOptions.Enabled);
Assert.IsTrue(_server.Grid.SearchOptions.OnlyTextColumns);

_server.Named("test");
Assert.AreEqual(_server.Grid.RenderOptions.GridName, "test");
Expand Down
2 changes: 1 addition & 1 deletion GridMvc/GridMvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<EnableDefaultEmbeddedResourceItems>False</EnableDefaultEmbeddedResourceItems>
<Product>GridMvc</Product>
<PackageId>GridMvcCore</PackageId>
<Version>5.1.1</Version>
<Version>5.2.0</Version>
<Title>GridMvc</Title>
<Description>ASP.NET MVC Grid component</Description>
<Summary>ASP.NET MVC Grid component</Summary>
Expand Down
18 changes: 15 additions & 3 deletions GridMvc/Html/GridHtmlOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,21 @@ public IGridHtmlOptions<T> Searchable(bool enable, bool onlyTextColumns)

public IGridHtmlOptions<T> Searchable(bool enable, bool onlyTextColumns, bool hiddenColumns)
{
_source.SearchingEnabled = enable;
_source.SearchingOnlyTextColumns = onlyTextColumns;
_source.SearchingHiddenColumns = hiddenColumns;
return Searchable(o =>
{
o.Enabled = enable;
o.OnlyTextColumns = onlyTextColumns;
o.HiddenColumns = hiddenColumns;
o.SplittedWords = false;
});
}

public IGridHtmlOptions<T> Searchable(Action<SearchOptions> searchOptions)
{
var options = new SearchOptions();
searchOptions?.Invoke(options);

_source.SearchOptions = options;
return this;
}

Expand Down
23 changes: 3 additions & 20 deletions GridMvc/Html/HtmlGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,9 @@ public bool EnablePaging
set { _source.EnablePaging = value; }
}

bool IGrid.SearchingEnabled {
get { return _source.SearchingEnabled; }
set { _source.SearchingEnabled = value; }
}

public bool SearchingOnlyTextColumns {
get { return _source.SearchingOnlyTextColumns; }
set { _source.SearchingOnlyTextColumns = value; }
}

public bool SearchingHiddenColumns
{
get { return _source.SearchingHiddenColumns; }
set { _source.SearchingHiddenColumns = value; }
}

public bool SearchingSplittedWords
{
get { return _source.SearchingSplittedWords; }
set { _source.SearchingSplittedWords = value; }
SearchOptions IGrid.SearchOptions {
get { return _source.SearchOptions; }
set { _source.SearchOptions = value; }
}

public bool ExtSortingEnabled
Expand Down
5 changes: 5 additions & 0 deletions GridMvc/Html/IGridHtmlOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public interface IGridHtmlOptions<T> : IHtmlContent
/// </summary>
IGridHtmlOptions<T> Searchable(bool enable, bool onlyTextColumns, bool hiddenColumns);

/// <summary>
/// Enable or disable searching for all columns
/// </summary>
IGridHtmlOptions<T> Searchable(Action<SearchOptions> searchOptions);

/// <summary>
/// Enable extended sorting
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion GridMvc/Views/Shared/_Grid.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ else
</div>
}
</div>
@if (Model.SearchingEnabled)
@if (Model.SearchOptions.Enabled)
{
@await Html.PartialAsync("_GridSearch", Model)
}
Expand Down
2 changes: 1 addition & 1 deletion GridShared/GridShared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<Version>5.1.1</Version>
<Version>5.2.0</Version>
<Title>GridShared</Title>
<Description>Support library for GridBlazor and GridMvcCore component libraries</Description>
<Summary>Support library for GridBlazor and GridMvcCore component libraries</Summary>
Expand Down
Loading

0 comments on commit a15fdfe

Please sign in to comment.