From fdf01819d4dcfcb26d4b885adbae0650abbbb6f2 Mon Sep 17 00:00:00 2001 From: Santiago Dubois Date: Mon, 14 Mar 2022 18:22:03 -0300 Subject: [PATCH 01/31] Fixing server issues --- .../Pages/ServerSideData.razor | 30 +++++++-- src/BlazorTable/BlazorTable.csproj | 1 + src/BlazorTable/Components/Column.razor.cs | 9 ++- .../Components/FilterManager.razor.cs | 1 + src/BlazorTable/Components/Pager.razor | 22 +++++++ src/BlazorTable/Components/Pager.razor.cs | 33 ++++++++++ .../Components/ServerSide/FilterData.cs | 12 +++- .../Components/ServerSide/FilterString.cs | 11 ++++ src/BlazorTable/Components/Table.razor | 2 +- src/BlazorTable/Components/Table.razor.cs | 62 ++++++++++++++----- .../Filters/BooleanFilter.razor.cs | 13 +++- src/BlazorTable/Filters/CustomSelect.razor.cs | 13 +++- src/BlazorTable/Filters/DateFilter.razor.cs | 13 +++- src/BlazorTable/Filters/EnumFilter.razor.cs | 11 ++++ src/BlazorTable/Filters/NumberFilter.razor.cs | 14 ++++- src/BlazorTable/Filters/StringFilter.razor.cs | 15 ++++- src/BlazorTable/Interfaces/IColumn.cs | 8 ++- src/BlazorTable/Interfaces/IDataLoader.cs | 6 +- src/BlazorTable/Interfaces/IFilter.cs | 9 ++- src/BlazorTable/Interfaces/ITable.cs | 9 ++- src/BlazorTable/Utillities.cs | 13 ++++ 21 files changed, 272 insertions(+), 35 deletions(-) create mode 100644 src/BlazorTable/Components/ServerSide/FilterString.cs diff --git a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor index 929403e9..78cd8ef0 100644 --- a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor +++ b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor @@ -6,9 +6,11 @@

Server side data

- - - +Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggregate((c, n) => $"{c},{n}") : "None") + +
+ + - +
@code @@ -47,10 +49,17 @@ private IEnumerable data; + private List selectedItems = new List(); + protected override async Task OnInitializedAsync() { _loader = new PersonDataLoader(httpClient); - data = (await _loader.LoadDataAsync(null)).Records; + //data = (await _loader.LoadDataAsync(null)).Records; + } + + public void RowClick(PersonData data) + { + StateHasChanged(); } public class PersonDataLoader : IDataLoader @@ -60,7 +69,7 @@ { _client = client; } - public async Task> LoadDataAsync(FilterData parameters) + public async Task> LoadDataAsync(FilterData parameters) { var data = await _client.GetFromJsonAsync("sample-data/MOCK_DATA.json"); @@ -82,6 +91,13 @@ : query.OrderBy(x => prop.GetValue(x, null)); } } + if(parameters?.Filters != null) + { + foreach (var filter in parameters?.Filters) + { + query = query.Where(filter); + } + } var results = parameters?.Top.HasValue ?? false ? query.Skip(parameters.Skip.GetValueOrDefault()) .Take(parameters.Top.Value).ToArray() : @@ -97,4 +113,6 @@ } } + + } diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index 4d04d6e9..bd5e188e 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -35,6 +35,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/BlazorTable/Components/Column.razor.cs b/src/BlazorTable/Components/Column.razor.cs index dec41914..725f7002 100644 --- a/src/BlazorTable/Components/Column.razor.cs +++ b/src/BlazorTable/Components/Column.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using BlazorTable.Components.ServerSide; +using Microsoft.AspNetCore.Components; using System; using System.Globalization; using System.Linq; @@ -122,6 +123,11 @@ public string Title /// public Expression> Filter { get; set; } + /// + /// Filter as string + /// + public FilterString FilterString { get; set; } + /// /// True if this is the default Sort Column /// @@ -180,6 +186,7 @@ public bool Visible /// Currently applied Filter Control /// public IFilter FilterControl { get; set; } + protected override void OnInitialized() { diff --git a/src/BlazorTable/Components/FilterManager.razor.cs b/src/BlazorTable/Components/FilterManager.razor.cs index bb1f8285..73fd403c 100644 --- a/src/BlazorTable/Components/FilterManager.razor.cs +++ b/src/BlazorTable/Components/FilterManager.razor.cs @@ -27,6 +27,7 @@ private async Task ApplyFilterAsync() if (Column.FilterControl != null) { Column.Filter = Column.FilterControl.GetFilter(); + Column.FilterString = Column.FilterControl.GetFilterString(); await Column.Table.UpdateAsync().ConfigureAwait(false); await Column.Table.FirstPageAsync().ConfigureAwait(false); } diff --git a/src/BlazorTable/Components/Pager.razor b/src/BlazorTable/Components/Pager.razor index 8cd3332e..389c9e87 100644 --- a/src/BlazorTable/Components/Pager.razor +++ b/src/BlazorTable/Components/Pager.razor @@ -15,6 +15,13 @@ } + + @if (ShowPageNumberInput) + { +
  • + +
  • + } @if (ShowPageNumber) {
  • @@ -40,6 +47,21 @@
  • @Localization["PagerPrevious"]
  • + + @if(ShowPageNumberSelector) + { + for (var i = 0; i < 9; i++) + { + var page = Table.PageNumber < 5 ? i : Table.PageNumber + i - 4; + if(page <= Table.TotalPages - 1) + { +
  • + @(page + 1) +
  • + } + } + } +
  • @Localization["PagerNext"]
  • diff --git a/src/BlazorTable/Components/Pager.razor.cs b/src/BlazorTable/Components/Pager.razor.cs index d51bee2b..8660831b 100644 --- a/src/BlazorTable/Components/Pager.razor.cs +++ b/src/BlazorTable/Components/Pager.razor.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; using Microsoft.Extensions.Localization; using System.Collections.Generic; using System.Threading.Tasks; @@ -43,6 +44,18 @@ public partial class Pager [Parameter] public bool ShowPageSizes { get; set; } + /// + /// Show Pages Numbers + /// + [Parameter] + public bool ShowPageNumberSelector { get; set; } + + /// + /// Show Pages Number selector input + /// + [Parameter] + public bool ShowPageNumberInput { get; set; } + [Inject] IStringLocalizer Localization { get; set; } @@ -53,5 +66,25 @@ private async Task SetPageSizeAsync(ChangeEventArgs args) await Table.SetPageSizeAsync(result).ConfigureAwait(false); } } + + private int inputPage { get; set; } = 1; + + private async Task SetPageInput(KeyboardEventArgs e) + { + if (e.Code == "Enter" || e.Code == "NumpadEnter") + { + if (inputPage > Table.TotalPages) + { + inputPage = Table.TotalPages; + } + + if (inputPage < 1) + { + inputPage = 1; + } + + await Table.GoToPageAsync(inputPage - 1).ConfigureAwait(false); + } + } } } diff --git a/src/BlazorTable/Components/ServerSide/FilterData.cs b/src/BlazorTable/Components/ServerSide/FilterData.cs index b2dbf743..356b97c3 100644 --- a/src/BlazorTable/Components/ServerSide/FilterData.cs +++ b/src/BlazorTable/Components/ServerSide/FilterData.cs @@ -1,6 +1,10 @@ -namespace BlazorTable.Components.ServerSide +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +namespace BlazorTable.Components.ServerSide { - public class FilterData + public class FilterData { public string OrderBy { get; set; } @@ -9,6 +13,10 @@ public class FilterData public int? Top { get; set; } public int? Skip { get; set; } + + public List>> Filters { get; set; } + + public List FilterStrings { get; set; } } } diff --git a/src/BlazorTable/Components/ServerSide/FilterString.cs b/src/BlazorTable/Components/ServerSide/FilterString.cs new file mode 100644 index 00000000..871a07e7 --- /dev/null +++ b/src/BlazorTable/Components/ServerSide/FilterString.cs @@ -0,0 +1,11 @@ +namespace BlazorTable.Components.ServerSide +{ + public class FilterString + { + public string Field { get; set; } + + public string Condition { get; set; } + + public string FilterValue { get; set; } + } +} diff --git a/src/BlazorTable/Components/Table.razor b/src/BlazorTable/Components/Table.razor index f9411af2..634ff235 100644 --- a/src/BlazorTable/Components/Table.razor +++ b/src/BlazorTable/Components/Table.razor @@ -163,7 +163,7 @@ if (!rowDisplayed) { - + @{ int locali = i; diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index 57c959c3..3e453615 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -142,7 +142,7 @@ public partial class Table : ITable protected override async Task OnParametersSetAsync() { - await UpdateAsync().ConfigureAwait(false); + await UpdateAsync(true).ConfigureAwait(false); } private IEnumerable GetData() @@ -156,6 +156,11 @@ private IEnumerable GetData() ItemsQueryable = Items.AsQueryable(); } + if (DataLoader != null) + { + return ItemsQueryable.ToList(); + } + foreach (var item in Columns) { if (item.Filter != null) @@ -163,11 +168,7 @@ private IEnumerable GetData() ItemsQueryable = ItemsQueryable.Where(item.Filter); } } - - if (DataLoader != null) - { - return ItemsQueryable.ToList(); - } + // Global Search if (!string.IsNullOrEmpty(GlobalSearch)) { @@ -227,9 +228,10 @@ public void ToggleAllDetailsView(bool open) /// /// Gets Data and redraws the Table /// - public async Task UpdateAsync() + public async Task UpdateAsync(bool updateServerData = true) { - await LoadServerSideDataAsync().ConfigureAwait(false); + if(updateServerData) + await LoadServerSideDataAsync().ConfigureAwait(false); FilteredItems = GetData(); Refresh(); } @@ -248,12 +250,28 @@ private async Task LoadServerSideDataAsync() .Append(sortColumn.SortDescending ? "desc" : "asc"); } - var result = await DataLoader.LoadDataAsync(new FilterData + var filters = new List>>(); + var filterStrings = new List(); + if (Columns != null) + { + foreach (var item in Columns) + { + if (item.Filter != null) + { + filters.Add(item.Filter); + filterStrings.Add(item.FilterString); + } + } + } + + var result = await DataLoader.LoadDataAsync(new FilterData { Top = PageSize, Skip = PageNumber * PageSize, Query = GlobalSearch, - OrderBy = sortExpression.ToString() + OrderBy = sortExpression.ToString(), + Filters = filters, + FilterStrings = filterStrings }).ConfigureAwait(false); Items = result.Records; TotalCount = result.Total.GetValueOrDefault(1); @@ -336,6 +354,18 @@ public async Task LastPageAsync() await UpdateAsync().ConfigureAwait(false); } + /// + /// Go to specific page + /// + /// Page number to go + /// + public async Task GoToPageAsync(int pageNumber) + { + PageNumber = pageNumber; + detailsViewOpen.Clear(); + await UpdateAsync().ConfigureAwait(false); + } + /// /// Redraws the Table using EditTemplate instead of Template /// @@ -348,9 +378,9 @@ public void ToggleEditMode() /// /// Redraws Table without Getting Data /// - public void Refresh() + public async void Refresh() { - InvokeAsync(StateHasChanged); + await InvokeAsync(StateHasChanged); } /// @@ -468,7 +498,7 @@ public SelectionType SelectionType /// Handles the onclick action for table rows. /// This allows the RowClickAction to be optional. /// - private void OnRowClickHandler(TableItem tableItem) + private async void OnRowClickHandler(TableItem tableItem) { try { @@ -488,8 +518,8 @@ private void OnRowClickHandler(TableItem tableItem) SelectedItems.Add(tableItem); break; case SelectionType.Multiple: - if (SelectedItems.Contains(tableItem)) - SelectedItems.Remove(tableItem); + if (SelectedItems.Any(x=> x.CompareEx(tableItem))) + SelectedItems.RemoveAll(x=> x.CompareEx(tableItem)); else SelectedItems.Add(tableItem); break; @@ -560,6 +590,8 @@ private Expression> GlobalSearchQuery(string value) public async Task SetPageSizeAsync(int pageSize) { PageSize = pageSize; + PageNumber = 0; + detailsViewOpen.Clear(); await UpdateAsync().ConfigureAwait(false); } diff --git a/src/BlazorTable/Filters/BooleanFilter.razor.cs b/src/BlazorTable/Filters/BooleanFilter.razor.cs index 1b17aeca..bf0b5d07 100644 --- a/src/BlazorTable/Filters/BooleanFilter.razor.cs +++ b/src/BlazorTable/Filters/BooleanFilter.razor.cs @@ -1,4 +1,5 @@ -using BlazorTable.Localization; +using BlazorTable.Components.ServerSide; +using BlazorTable.Localization; using Microsoft.AspNetCore.Components; using System; using System.Collections.Generic; @@ -88,8 +89,18 @@ public Expression> GetFilter() _ => null, }; } + public FilterString GetFilterString() + { + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString() + }; + } } + + public enum BooleanCondition { [LocalizedDescription("BooleanConditionTrue", typeof(Localization.Localization))] diff --git a/src/BlazorTable/Filters/CustomSelect.razor.cs b/src/BlazorTable/Filters/CustomSelect.razor.cs index 9a0c5ca3..35eaf172 100644 --- a/src/BlazorTable/Filters/CustomSelect.razor.cs +++ b/src/BlazorTable/Filters/CustomSelect.razor.cs @@ -1,4 +1,5 @@ -using BlazorTable.Localization; +using BlazorTable.Components.ServerSide; +using BlazorTable.Localization; using Microsoft.AspNetCore.Components; using System; using System.Collections.Generic; @@ -83,6 +84,16 @@ public Expression> GetFilter() }; } + public FilterString GetFilterString() + { + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterValue.ToString() + }; + } + public void AddSelect(string key, object value) { Items.Add(new KeyValuePair(key, value)); diff --git a/src/BlazorTable/Filters/DateFilter.razor.cs b/src/BlazorTable/Filters/DateFilter.razor.cs index 52170959..e504f2dd 100644 --- a/src/BlazorTable/Filters/DateFilter.razor.cs +++ b/src/BlazorTable/Filters/DateFilter.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using BlazorTable.Components.ServerSide; +using Microsoft.AspNetCore.Components; using System; using System.Linq.Expressions; @@ -128,5 +129,15 @@ public Expression> GetFilter() _ => throw new ArgumentException(Condition + " is not defined!"), }; } + + public FilterString GetFilterString() + { + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterValue.ToString() + }; + } } } \ No newline at end of file diff --git a/src/BlazorTable/Filters/EnumFilter.razor.cs b/src/BlazorTable/Filters/EnumFilter.razor.cs index 29807eca..13d1ee1d 100644 --- a/src/BlazorTable/Filters/EnumFilter.razor.cs +++ b/src/BlazorTable/Filters/EnumFilter.razor.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Linq.Expressions; using Microsoft.Extensions.Localization; +using BlazorTable.Components.ServerSide; namespace BlazorTable { @@ -89,6 +90,16 @@ public Expression> GetFilter() }; } + public FilterString GetFilterString() + { + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterValue.ToString() + }; + } + public enum EnumCondition { [LocalizedDescription("EnumConditionIsEqualTo", typeof(Localization.Localization))] diff --git a/src/BlazorTable/Filters/NumberFilter.razor.cs b/src/BlazorTable/Filters/NumberFilter.razor.cs index d4131981..2cd0b61a 100644 --- a/src/BlazorTable/Filters/NumberFilter.razor.cs +++ b/src/BlazorTable/Filters/NumberFilter.razor.cs @@ -1,4 +1,5 @@ -using BlazorTable.Localization; +using BlazorTable.Components.ServerSide; +using BlazorTable.Localization; using Microsoft.AspNetCore.Components; using System; using System.Globalization; @@ -138,6 +139,17 @@ public Expression> GetFilter() _ => throw new ArgumentException(Condition + " is not defined!"), }; } + + public FilterString GetFilterString() + { + + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterValue + }; + } } public enum NumberCondition diff --git a/src/BlazorTable/Filters/StringFilter.razor.cs b/src/BlazorTable/Filters/StringFilter.razor.cs index d86440c6..43987031 100644 --- a/src/BlazorTable/Filters/StringFilter.razor.cs +++ b/src/BlazorTable/Filters/StringFilter.razor.cs @@ -1,4 +1,5 @@ -using BlazorTable.Localization; +using BlazorTable.Components.ServerSide; +using BlazorTable.Localization; using Microsoft.AspNetCore.Components; using System; using System.Linq.Expressions; @@ -183,6 +184,18 @@ public Expression> GetFilter() _ => throw new ArgumentException(Condition + " is not defined!"), }; } + + public FilterString GetFilterString() + { + FilterText = FilterText?.Trim(); + + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterText + }; + } } public enum StringCondition diff --git a/src/BlazorTable/Interfaces/IColumn.cs b/src/BlazorTable/Interfaces/IColumn.cs index d5d13ae3..bfadc7ba 100644 --- a/src/BlazorTable/Interfaces/IColumn.cs +++ b/src/BlazorTable/Interfaces/IColumn.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using BlazorTable.Components.ServerSide; +using Microsoft.AspNetCore.Components; using System; using System.Linq.Expressions; using System.Threading.Tasks; @@ -84,6 +85,11 @@ public interface IColumn /// Expression> Filter { get; set; } + /// + /// Filter as string + /// + FilterString FilterString { get; set; } + /// /// Edit Mode Item Template /// diff --git a/src/BlazorTable/Interfaces/IDataLoader.cs b/src/BlazorTable/Interfaces/IDataLoader.cs index c9d38047..6a1911d2 100644 --- a/src/BlazorTable/Interfaces/IDataLoader.cs +++ b/src/BlazorTable/Interfaces/IDataLoader.cs @@ -1,10 +1,12 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Threading.Tasks; using BlazorTable.Components.ServerSide; namespace BlazorTable.Interfaces { public interface IDataLoader { - public Task> LoadDataAsync(FilterData parameters); + public Task> LoadDataAsync(FilterData parameters); + } } diff --git a/src/BlazorTable/Interfaces/IFilter.cs b/src/BlazorTable/Interfaces/IFilter.cs index 77800215..917dd99c 100644 --- a/src/BlazorTable/Interfaces/IFilter.cs +++ b/src/BlazorTable/Interfaces/IFilter.cs @@ -1,4 +1,5 @@ -using System; +using BlazorTable.Components.ServerSide; +using System; using System.Linq.Expressions; namespace BlazorTable @@ -14,5 +15,11 @@ public interface IFilter /// /// Expression> GetFilter(); + + /// + /// Get filter as string object + /// + /// + FilterString GetFilterString(); } } diff --git a/src/BlazorTable/Interfaces/ITable.cs b/src/BlazorTable/Interfaces/ITable.cs index 7af8de02..c211cd66 100644 --- a/src/BlazorTable/Interfaces/ITable.cs +++ b/src/BlazorTable/Interfaces/ITable.cs @@ -58,6 +58,11 @@ public interface ITable /// Task LastPageAsync(); + /// + /// Go to Specific Page Async + /// + Task GoToPageAsync(int pageNumber); + /// /// Redraws the Table using EditTemplate instead of Template /// @@ -86,7 +91,9 @@ public interface ITable /// /// Gets Data and redraws the Table /// - Task UpdateAsync(); + /// false if it is not needed to update server data + /// + Task UpdateAsync(bool updateServerData = true); /// /// Open/Close detail view in specified row. /// diff --git a/src/BlazorTable/Utillities.cs b/src/BlazorTable/Utillities.cs index f7359284..0604a657 100644 --- a/src/BlazorTable/Utillities.cs +++ b/src/BlazorTable/Utillities.cs @@ -1,4 +1,5 @@ using LinqKit; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; @@ -229,5 +230,17 @@ public static BinaryExpression CreateNullChecks(this Expression expression, bool return newExpression; } + + public static bool CompareEx(this object obj, object another) + { + if (ReferenceEquals(obj, another)) return true; + if ((obj == null) || (another == null)) return false; + if (obj.GetType() != another.GetType()) return false; + + var objJson = JsonConvert.SerializeObject(obj); + var anotherJson = JsonConvert.SerializeObject(another); + + return objJson == anotherJson; + } } } From d8fb247b88b49d02cb1ab5c4e676db54c8018376 Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Tue, 15 Mar 2022 14:22:40 -0300 Subject: [PATCH 02/31] Initial filters --- .../Pages/ServerSideData.razor | 1 + src/BlazorTable/Components/Column.razor.cs | 5 +++++ src/BlazorTable/Components/Table.razor.cs | 19 +++++++++++++++++++ src/BlazorTable/Filters/StringFilter.razor.cs | 6 ++++++ src/BlazorTable/Interfaces/IColumn.cs | 5 +++++ src/BlazorTable/Utillities.cs | 5 +++++ 6 files changed, 41 insertions(+) diff --git a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor index 78cd8ef0..2d4f1e62 100644 --- a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor +++ b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor @@ -54,6 +54,7 @@ Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggrega protected override async Task OnInitializedAsync() { _loader = new PersonDataLoader(httpClient); + //data = (await _loader.LoadDataAsync(null)).Records; } diff --git a/src/BlazorTable/Components/Column.razor.cs b/src/BlazorTable/Components/Column.razor.cs index 725f7002..bd967ed5 100644 --- a/src/BlazorTable/Components/Column.razor.cs +++ b/src/BlazorTable/Components/Column.razor.cs @@ -128,6 +128,11 @@ public string Title /// public FilterString FilterString { get; set; } + /// + /// Initial filters + /// + public FilterString InitialFilterString { get; set; } + /// /// True if this is the default Sort Column /// diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index 3e453615..b26f659c 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -595,6 +595,25 @@ public async Task SetPageSizeAsync(int pageSize) await UpdateAsync().ConfigureAwait(false); } + /// + /// Set Table Page Size + /// + /// + public async Task SetFilterAsync(List filters) + { + foreach (var item in filters) + { + var column = Columns.FirstOrDefault(x => x.Field.GetPropertyMemberInfo().Name == item.Field); + if (column != null) + { + column.InitialFilterString = item; + } + } + PageNumber = 0; + detailsViewOpen.Clear(); + await UpdateAsync().ConfigureAwait(false); + } + /// /// Show table child content at the top of the table. /// diff --git a/src/BlazorTable/Filters/StringFilter.razor.cs b/src/BlazorTable/Filters/StringFilter.razor.cs index 43987031..bb2e8ff9 100644 --- a/src/BlazorTable/Filters/StringFilter.razor.cs +++ b/src/BlazorTable/Filters/StringFilter.razor.cs @@ -88,6 +88,12 @@ private StringCondition GetConditionFromMethod(string method, bool not) public Expression> GetFilter() { + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterText = Column.InitialFilterString.FilterValue; + } + FilterText = FilterText?.Trim(); if (Condition != StringCondition.IsNullOrEmpty && Condition != StringCondition.IsNotNulOrEmpty && string.IsNullOrEmpty(FilterText)) diff --git a/src/BlazorTable/Interfaces/IColumn.cs b/src/BlazorTable/Interfaces/IColumn.cs index bfadc7ba..adc01f3e 100644 --- a/src/BlazorTable/Interfaces/IColumn.cs +++ b/src/BlazorTable/Interfaces/IColumn.cs @@ -90,6 +90,11 @@ public interface IColumn /// FilterString FilterString { get; set; } + /// + /// Filter as string + /// + FilterString InitialFilterString { get; set; } + /// /// Edit Mode Item Template /// diff --git a/src/BlazorTable/Utillities.cs b/src/BlazorTable/Utillities.cs index 0604a657..09399f6f 100644 --- a/src/BlazorTable/Utillities.cs +++ b/src/BlazorTable/Utillities.cs @@ -182,6 +182,11 @@ public static string ToDescriptionString(this Enum val) return attributes.Length > 0 ? attributes[0].Description : string.Empty; } + public static T ParseEnum(string value) + { + return (T)Enum.Parse(typeof(T), value, true); + } + /// /// Recursively walks up the tree and adds null checks /// From 5a1a2d2fa06de0fd11ff4eff64a45f5df9bac92c Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Wed, 16 Mar 2022 15:07:23 -0300 Subject: [PATCH 03/31] Setting initial filters --- .../Pages/ServerSideData.razor | 35 ++++++++++++++++--- src/BlazorTable/Components/Column.razor.cs | 3 +- .../Components/FilterManager.razor.cs | 1 - src/BlazorTable/Components/Table.razor.cs | 28 +++++++++++---- .../Filters/BooleanFilter.razor.cs | 16 +++++++++ src/BlazorTable/Filters/CustomSelect.razor.cs | 17 +++++++++ src/BlazorTable/Filters/DateFilter.razor.cs | 20 +++++++++++ src/BlazorTable/Filters/EnumFilter.razor.cs | 16 +++++++++ src/BlazorTable/Filters/NumberFilter.razor.cs | 17 +++++++++ src/BlazorTable/Filters/StringFilter.razor.cs | 12 +++++++ src/BlazorTable/Interfaces/ITable.cs | 11 +++++- 11 files changed, 163 insertions(+), 13 deletions(-) diff --git a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor index 2d4f1e62..5ab2cfc6 100644 --- a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor +++ b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor @@ -8,15 +8,25 @@ Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggregate((c, n) => $"{c},{n}") : "None") - +
    - + + + + + + + + + + + - + @@ -35,6 +45,8 @@ Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggrega [Inject] private HttpClient httpClient { get; set; } + private ITable Table; + public class PersonData { public int? id { get; set; } @@ -54,8 +66,23 @@ Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggrega protected override async Task OnInitializedAsync() { _loader = new PersonDataLoader(httpClient); + data = (await _loader.LoadDataAsync(null)).Records; + + await Table.SetInitialFiltersAsync(new List() + { + new FilterString() + { + Condition = StringCondition.IsEqualTo.ToString(), + Field = "full_name", + FilterValue = "Marja Mustill" + }, + new FilterString() + { + Condition = BooleanCondition.True.ToString(), + Field = "paid" + } + }); - //data = (await _loader.LoadDataAsync(null)).Records; } public void RowClick(PersonData data) diff --git a/src/BlazorTable/Components/Column.razor.cs b/src/BlazorTable/Components/Column.razor.cs index bd967ed5..28b0d5f7 100644 --- a/src/BlazorTable/Components/Column.razor.cs +++ b/src/BlazorTable/Components/Column.razor.cs @@ -191,7 +191,6 @@ public bool Visible /// Currently applied Filter Control /// public IFilter FilterControl { get; set; } - protected override void OnInitialized() { @@ -306,5 +305,7 @@ public string Render(TableItem data) /// Save compiled renderCompiled property to avoid repeated Compile() calls /// private Func renderCompiled; + + public Func OnFilterChangedAsync { get; set; } } } \ No newline at end of file diff --git a/src/BlazorTable/Components/FilterManager.razor.cs b/src/BlazorTable/Components/FilterManager.razor.cs index 73fd403c..7fc24407 100644 --- a/src/BlazorTable/Components/FilterManager.razor.cs +++ b/src/BlazorTable/Components/FilterManager.razor.cs @@ -20,7 +20,6 @@ public partial class FilterManager IStringLocalizer Localization { get; set; } private async Task ApplyFilterAsync() - { Column.ToggleFilter(); diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index b26f659c..e19ad9b4 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -596,21 +596,37 @@ public async Task SetPageSizeAsync(int pageSize) } /// - /// Set Table Page Size + /// Set initial filters to grid /// - /// - public async Task SetFilterAsync(List filters) + /// + /// + public async Task SetInitialFiltersAsync(IEnumerable filters) { foreach (var item in filters) { var column = Columns.FirstOrDefault(x => x.Field.GetPropertyMemberInfo().Name == item.Field); - if (column != null) + if (column != null && column.Filterable) { column.InitialFilterString = item; + if (column.FilterControl == null) + { + if(column.Type == typeof(string)) + column.FilterControl = new StringFilter() { Column = column }; + if (column.Type.IsNumeric() && !column.Type.GetNonNullableType().IsEnum) + column.FilterControl = new NumberFilter() { Column = column }; + if (column.Type.GetNonNullableType().IsEnum) + column.FilterControl = new EnumFilter() { Column = column }; + if (column.Type.GetNonNullableType() == typeof(DateTime)) + column.FilterControl = new DateFilter() { Column = column }; + if (column.CustomIFilters != null) + column.FilterControl = new CustomSelect() { Column = column }; + if (new List() { typeof(bool) }.Contains(column.Type.GetNonNullableType())) + column.FilterControl = new BooleanFilter() { Column = column }; + } + column.Filter = column.FilterControl.GetFilter(); } } - PageNumber = 0; - detailsViewOpen.Clear(); + await FirstPageAsync().ConfigureAwait(false); await UpdateAsync().ConfigureAwait(false); } diff --git a/src/BlazorTable/Filters/BooleanFilter.razor.cs b/src/BlazorTable/Filters/BooleanFilter.razor.cs index bf0b5d07..3d8aa530 100644 --- a/src/BlazorTable/Filters/BooleanFilter.razor.cs +++ b/src/BlazorTable/Filters/BooleanFilter.razor.cs @@ -25,6 +25,15 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter != null) { var nodeType = Column.Filter.Body.NodeType; @@ -56,6 +65,13 @@ protected override void OnInitialized() public Expression> GetFilter() { + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + + Column.InitialFilterString = null; + } + return Condition switch { BooleanCondition.True => diff --git a/src/BlazorTable/Filters/CustomSelect.razor.cs b/src/BlazorTable/Filters/CustomSelect.razor.cs index 35eaf172..72a44666 100644 --- a/src/BlazorTable/Filters/CustomSelect.razor.cs +++ b/src/BlazorTable/Filters/CustomSelect.razor.cs @@ -27,6 +27,15 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter?.Body is BinaryExpression binaryExpression && binaryExpression.Right is BinaryExpression logicalBinary && logicalBinary.Right is ConstantExpression constant) @@ -47,6 +56,14 @@ protected override void OnInitialized() public Expression> GetFilter() { + + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + } + return Condition switch { CustomSelectCondition.IsEqualTo => diff --git a/src/BlazorTable/Filters/DateFilter.razor.cs b/src/BlazorTable/Filters/DateFilter.razor.cs index e504f2dd..5ae8864b 100644 --- a/src/BlazorTable/Filters/DateFilter.razor.cs +++ b/src/BlazorTable/Filters/DateFilter.razor.cs @@ -20,6 +20,17 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + if (DateTime.TryParse(Column.InitialFilterString.FilterValue, out DateTime filterValue)) + FilterValue = filterValue; + + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter?.Body is BinaryExpression binaryExpression && binaryExpression.Right is BinaryExpression logicalBinary && logicalBinary.Right is ConstantExpression constant) @@ -56,6 +67,15 @@ protected override void OnInitialized() public Expression> GetFilter() { + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + if (DateTime.TryParse(Column.InitialFilterString.FilterValue, out DateTime filterValue)) + FilterValue = filterValue; + + Column.InitialFilterString = null; + } + return Condition switch { NumberCondition.IsEqualTo => diff --git a/src/BlazorTable/Filters/EnumFilter.razor.cs b/src/BlazorTable/Filters/EnumFilter.razor.cs index 13d1ee1d..89c41069 100644 --- a/src/BlazorTable/Filters/EnumFilter.razor.cs +++ b/src/BlazorTable/Filters/EnumFilter.razor.cs @@ -26,6 +26,15 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter?.Body is BinaryExpression binaryExpression && binaryExpression.Right is BinaryExpression logicalBinary && logicalBinary.Right is ConstantExpression constant) @@ -52,6 +61,13 @@ protected override void OnInitialized() public Expression> GetFilter() { + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + } + return Condition switch { EnumCondition.IsEqualTo => diff --git a/src/BlazorTable/Filters/NumberFilter.razor.cs b/src/BlazorTable/Filters/NumberFilter.razor.cs index 2cd0b61a..00ed499d 100644 --- a/src/BlazorTable/Filters/NumberFilter.razor.cs +++ b/src/BlazorTable/Filters/NumberFilter.razor.cs @@ -25,6 +25,16 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + + if (Column.Filter?.Body is BinaryExpression binaryExpression && binaryExpression.Right is BinaryExpression logicalBinary && logicalBinary.Right is ConstantExpression constant) @@ -61,6 +71,13 @@ protected override void OnInitialized() public Expression> GetFilter() { + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + } + if (Condition != NumberCondition.IsNull && Condition != NumberCondition.IsNotNull && string.IsNullOrEmpty(FilterValue)) { return null; diff --git a/src/BlazorTable/Filters/StringFilter.razor.cs b/src/BlazorTable/Filters/StringFilter.razor.cs index bb2e8ff9..1f8a7cdb 100644 --- a/src/BlazorTable/Filters/StringFilter.razor.cs +++ b/src/BlazorTable/Filters/StringFilter.razor.cs @@ -26,6 +26,15 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterText = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter != null) { bool NotCondition = false; @@ -88,10 +97,13 @@ private StringCondition GetConditionFromMethod(string method, bool not) public Expression> GetFilter() { + if (Column.InitialFilterString != null) { Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); FilterText = Column.InitialFilterString.FilterValue; + + Column.InitialFilterString = null; } FilterText = FilterText?.Trim(); diff --git a/src/BlazorTable/Interfaces/ITable.cs b/src/BlazorTable/Interfaces/ITable.cs index c211cd66..8d57c0c6 100644 --- a/src/BlazorTable/Interfaces/ITable.cs +++ b/src/BlazorTable/Interfaces/ITable.cs @@ -1,4 +1,6 @@ -using System.Threading.Tasks; +using BlazorTable.Components.ServerSide; +using System.Collections.Generic; +using System.Threading.Tasks; namespace BlazorTable { @@ -145,5 +147,12 @@ public interface ITable /// /// Task SetPageSizeAsync(int pageSize); + + /// + /// Set initial filters + /// + /// + /// + Task SetInitialFiltersAsync(IEnumerable filters); } } From 6918ac894c7b2efeacf77643c3aa99b5387bc0bf Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Wed, 16 Mar 2022 16:00:14 -0300 Subject: [PATCH 04/31] Adding some comments --- .../Pages/ServerSideData.razor | 4 ++-- src/BlazorTable/Components/ServerSide/FilterString.cs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor index 5ab2cfc6..f256cf8d 100644 --- a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor +++ b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor @@ -73,13 +73,13 @@ Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggrega new FilterString() { Condition = StringCondition.IsEqualTo.ToString(), - Field = "full_name", + Field = nameof(PersonData.full_name), FilterValue = "Marja Mustill" }, new FilterString() { Condition = BooleanCondition.True.ToString(), - Field = "paid" + Field = nameof(PersonData.paid) } }); diff --git a/src/BlazorTable/Components/ServerSide/FilterString.cs b/src/BlazorTable/Components/ServerSide/FilterString.cs index 871a07e7..06c878b4 100644 --- a/src/BlazorTable/Components/ServerSide/FilterString.cs +++ b/src/BlazorTable/Components/ServerSide/FilterString.cs @@ -1,11 +1,21 @@ namespace BlazorTable.Components.ServerSide { + public class FilterString { + /// + /// Field name + /// public string Field { get; set; } + /// + /// it should be a enum converted to string according with field type. Available enums are StringCondition, NumberCondition, EnumCondition, CustomSelectCondition and BooleanCondition + /// public string Condition { get; set; } + /// + /// Value to filter + /// public string FilterValue { get; set; } } } From 9e563c016f483959ed871b121ef9fb85111d2a67 Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Wed, 16 Mar 2022 16:28:43 -0300 Subject: [PATCH 05/31] Removed unnecesary property --- src/BlazorTable/Components/Column.razor.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/BlazorTable/Components/Column.razor.cs b/src/BlazorTable/Components/Column.razor.cs index 28b0d5f7..638762da 100644 --- a/src/BlazorTable/Components/Column.razor.cs +++ b/src/BlazorTable/Components/Column.razor.cs @@ -305,7 +305,5 @@ public string Render(TableItem data) /// Save compiled renderCompiled property to avoid repeated Compile() calls /// private Func renderCompiled; - - public Func OnFilterChangedAsync { get; set; } } } \ No newline at end of file From 9f2b95f18a4e3e05aab6dd901a3cdaba4f83707a Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Thu, 17 Mar 2022 18:39:35 -0300 Subject: [PATCH 06/31] Changed the version --- src/BlazorTable/BlazorTable.csproj | 2 ++ .../Properties/PublishProfiles/FolderProfile.pubxml | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/BlazorTable/Properties/PublishProfiles/FolderProfile.pubxml diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index bd5e188e..750eb034 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -15,6 +15,8 @@ git MIT true + + 1.17.1-preview diff --git a/src/BlazorTable/Properties/PublishProfiles/FolderProfile.pubxml b/src/BlazorTable/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 00000000..6f5e1117 --- /dev/null +++ b/src/BlazorTable/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,12 @@ + + + + + Release + Any CPU + bin\Release\netstandard2.1\publish\ + FileSystem + + \ No newline at end of file From b1e4b1be02973beb1cf7de8e1025f982e23754f3 Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Fri, 18 Mar 2022 09:59:32 -0300 Subject: [PATCH 07/31] Fixing bug --- src/BlazorTable/BlazorTable.csproj | 2 +- src/BlazorTable/Components/Table.razor.cs | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index 750eb034..ef69dd1c 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -16,7 +16,7 @@ MIT true - 1.17.1-preview + 1.17.2-preview diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index e19ad9b4..84540356 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -610,20 +610,21 @@ public async Task SetInitialFiltersAsync(IEnumerable filters) column.InitialFilterString = item; if (column.FilterControl == null) { - if(column.Type == typeof(string)) + if (column.CustomIFilters != null) + column.FilterControl = new CustomSelect() { Column = column }; + else if (column.Type == typeof(string)) column.FilterControl = new StringFilter() { Column = column }; - if (column.Type.IsNumeric() && !column.Type.GetNonNullableType().IsEnum) + else if (column.Type.IsNumeric() && !column.Type.GetNonNullableType().IsEnum) column.FilterControl = new NumberFilter() { Column = column }; - if (column.Type.GetNonNullableType().IsEnum) + else if (column.Type.GetNonNullableType().IsEnum) column.FilterControl = new EnumFilter() { Column = column }; - if (column.Type.GetNonNullableType() == typeof(DateTime)) + else if (column.Type.GetNonNullableType() == typeof(DateTime)) column.FilterControl = new DateFilter() { Column = column }; - if (column.CustomIFilters != null) - column.FilterControl = new CustomSelect() { Column = column }; - if (new List() { typeof(bool) }.Contains(column.Type.GetNonNullableType())) + else if (new List() { typeof(bool) }.Contains(column.Type.GetNonNullableType())) column.FilterControl = new BooleanFilter() { Column = column }; } column.Filter = column.FilterControl.GetFilter(); + column.FilterString = column.FilterControl.GetFilterString(); } } await FirstPageAsync().ConfigureAwait(false); From df542b9014651e434c98b2f334084ae2cb0201e8 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 12:55:00 -0500 Subject: [PATCH 08/31] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..6d417832 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,34 @@ +# ASP.NET +# Build and test ASP.NET projects. +# Add steps that publish symbols, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4 + +trigger: +- master + +pool: + vmImage: 'windows-latest' + +variables: + solution: '**/*.sln' + buildPlatform: 'Any CPU' + buildConfiguration: 'Release' + +steps: +- task: NuGetToolInstaller@1 + +- task: NuGetCommand@2 + inputs: + restoreSolution: '$(solution)' + +- task: VSBuild@1 + inputs: + solution: '$(solution)' + msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"' + platform: '$(buildPlatform)' + configuration: '$(buildConfiguration)' + +- task: VSTest@2 + inputs: + platform: '$(buildPlatform)' + configuration: '$(buildConfiguration)' From a4a30186c592bfd64b4a5c158904fe49b93f2da6 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 14:44:15 -0500 Subject: [PATCH 09/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6d417832..e8f3ef5c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,8 +13,31 @@ variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' + Parameters.requestedMajorVersion: '1' + Parameters.requestedMinorVersion: '17' + Parameters.requestedPatchVersion: '3' steps: +- task: PowerShell@2 + inputs: + targetType: 'inline' + script: | + $tempdir = [IO.Path]::GetTempPath() + + $env:NUGET_PLUGIN_LOG_DIRECTORY_PATH = Join-Path $tempdir "pluginlog" + $env:NUGET_CREDENTIALPROVIDER_LOG_PATH = Join-Path $env:NUGET_PLUGIN_LOG_DIRECTORY_PATH "artifacts-credprovider.log" + $env:NUGET_PLUGIN_ENABLE_LOG = "true" + + if (Test-Path -LiteralPath $env:NUGET_PLUGIN_LOG_DIRECTORY_PATH) { + Remove-Item -Recurse -Force -LiteralPath $env:NUGET_PLUGIN_LOG_DIRECTORY_PATH + } + + [IO.Directory]::CreateDirectory($env:NUGET_PLUGIN_LOG_DIRECTORY_PATH) | Out-Null + + Write-Host "##vso[task.setvariable variable=NUGET_CREDENTIALPROVIDER_LOG_PATH]$env:NUGET_CREDENTIALPROVIDER_LOG_PATH" + Write-Host "##vso[task.setvariable variable=NUGET_PLUGIN_ENABLE_LOG]$env:NUGET_PLUGIN_ENABLE_LOG" + Write-Host "##vso[task.setvariable variable=NUGET_PLUGIN_LOG_DIRECTORY_PATH]$env:NUGET_PLUGIN_LOG_DIRECTORY_PATH" + - task: NuGetToolInstaller@1 - task: NuGetCommand@2 @@ -24,7 +47,6 @@ steps: - task: VSBuild@1 inputs: solution: '$(solution)' - msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' @@ -32,3 +54,23 @@ steps: inputs: platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' + +- task: NuGetCommand@2 + displayName: 'Nuget Pack' + inputs: + command: 'pack' + packagesToPack: '**/*.nuspec' + includeSymbols: true + configuration: '$(buildConfiguration)' + versioningScheme: byPrereleaseNumber + majorVersion: '$(Parameters.requestedMajorVersion)' + minorVersion: '$(Parameters.requestedMinorVersion)' + patchVersion: '$(Parameters.requestedPatchVersion)' + +- task: NuGetCommand@2 + displayName: 'Nuget Push' + inputs: + command: 'push' + packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' + nuGetFeedType: 'internal' + publishVstsFeed: '62fc85ae-4447-4b56-a2ea-c6ab74293507/dbfc01ad-afcb-448b-bda5-e0ef32ca9d70' \ No newline at end of file From bbe97abdccfb94f7735abec215c817e6e0d59b54 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 15:15:11 -0500 Subject: [PATCH 10/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e8f3ef5c..36b83afd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -55,6 +55,22 @@ steps: platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' +- task: PowerShell@2 + inputs: + targetType: 'inline' + script: | + Set-Content package.nuspec @" + + + BlazorTables$version$Octavian Technology Group + A fork of Blazor Tables + + + + + + "@ + - task: NuGetCommand@2 displayName: 'Nuget Pack' inputs: From 75f50f58764f65448cfdcb1cf8af7ccba9076f3d Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 15:42:22 -0500 Subject: [PATCH 11/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 36b83afd..a5dc4eee 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -62,7 +62,9 @@ steps: Set-Content package.nuspec @" - BlazorTables$version$Octavian Technology Group + BlazorTables + $version$ + Octavian Technology Group A fork of Blazor Tables From fc44cd8f0756f83d6dd51ee7bada804cc16a1a05 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 15:45:01 -0500 Subject: [PATCH 12/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a5dc4eee..18d92d8e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -4,7 +4,6 @@ # https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4 trigger: -- master pool: vmImage: 'windows-latest' @@ -13,9 +12,6 @@ variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' - Parameters.requestedMajorVersion: '1' - Parameters.requestedMinorVersion: '17' - Parameters.requestedPatchVersion: '3' steps: - task: PowerShell@2 @@ -63,7 +59,7 @@ steps: BlazorTables - $version$ + 1.17.3-preview Octavian Technology Group A fork of Blazor Tables From 07072252e4e82c855a6aaeb09ebc04ef867fbb29 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 15:48:23 -0500 Subject: [PATCH 13/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 18d92d8e..1f9f6e5b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,8 +3,6 @@ # Add steps that publish symbols, save build artifacts, deploy, and more: # https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4 -trigger: - pool: vmImage: 'windows-latest' From ee10160e25830effd4959ba3abb7b5bcbb9380bd Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 15:55:48 -0500 Subject: [PATCH 14/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1f9f6e5b..6e218891 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,7 +10,9 @@ variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' - + Parameters.requestedMajorVersion: '1' + Parameters.requestedMinorVersion: '17' + Parameters.requestedPatchVersion: '3' steps: - task: PowerShell@2 inputs: From 89c46e55b9e8ff8d3d489b275925169f68c2e811 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 16:04:51 -0500 Subject: [PATCH 15/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6e218891..70aa45b1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -64,7 +64,7 @@ steps: A fork of Blazor Tables - + "@ From d05e477895a39e72993dc458aed6b321bb89a425 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 16:44:16 -0500 Subject: [PATCH 16/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 70aa45b1..aae18dc2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -73,7 +73,7 @@ steps: displayName: 'Nuget Pack' inputs: command: 'pack' - packagesToPack: '**/*.nuspec' + packagesToPack: '**/BlazorTable.csproj' includeSymbols: true configuration: '$(buildConfiguration)' versioningScheme: byPrereleaseNumber From 9068f7ac7d79ba910b16ceb795d8549a7cf28b6b Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 16:57:42 -0500 Subject: [PATCH 17/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index aae18dc2..ce837d86 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -58,14 +58,19 @@ steps: Set-Content package.nuspec @" - BlazorTables + BlazorTable 1.17.3-preview Octavian Technology Group A fork of Blazor Tables - - - + + + + + + + + "@ From 6ed603d20d516d4652b8f90e784a92e1412cb148 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 16:58:03 -0500 Subject: [PATCH 18/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ce837d86..9941678c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -56,7 +56,7 @@ steps: targetType: 'inline' script: | Set-Content package.nuspec @" - + BlazorTable 1.17.3-preview From e4d6b5f72734c6a8a0a6b6a396d2d279be35c2e7 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Fri, 18 Mar 2022 17:13:56 -0500 Subject: [PATCH 19/31] Server side fixes (#1) * Fixing server issues * Initial filters * Setting initial filters * Adding some comments * Removed unnecesary property * Changed the version * Fixing bug Co-authored-by: Santiago Dubois Co-authored-by: sduboisOctaviantg --- .../Pages/ServerSideData.razor | 58 +++++++++-- src/BlazorTable/BlazorTable.csproj | 3 + src/BlazorTable/Components/Column.razor.cs | 13 ++- .../Components/FilterManager.razor.cs | 2 +- src/BlazorTable/Components/Pager.razor | 22 +++++ src/BlazorTable/Components/Pager.razor.cs | 33 +++++++ .../Components/ServerSide/FilterData.cs | 12 ++- .../Components/ServerSide/FilterString.cs | 21 ++++ src/BlazorTable/Components/Table.razor | 2 +- src/BlazorTable/Components/Table.razor.cs | 98 ++++++++++++++++--- .../Filters/BooleanFilter.razor.cs | 29 +++++- src/BlazorTable/Filters/CustomSelect.razor.cs | 30 +++++- src/BlazorTable/Filters/DateFilter.razor.cs | 33 ++++++- src/BlazorTable/Filters/EnumFilter.razor.cs | 27 +++++ src/BlazorTable/Filters/NumberFilter.razor.cs | 31 +++++- src/BlazorTable/Filters/StringFilter.razor.cs | 33 ++++++- src/BlazorTable/Interfaces/IColumn.cs | 13 ++- src/BlazorTable/Interfaces/IDataLoader.cs | 6 +- src/BlazorTable/Interfaces/IFilter.cs | 9 +- src/BlazorTable/Interfaces/ITable.cs | 20 +++- .../PublishProfiles/FolderProfile.pubxml | 12 +++ src/BlazorTable/Utillities.cs | 18 ++++ 22 files changed, 488 insertions(+), 37 deletions(-) create mode 100644 src/BlazorTable/Components/ServerSide/FilterString.cs create mode 100644 src/BlazorTable/Properties/PublishProfiles/FolderProfile.pubxml diff --git a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor index 929403e9..f256cf8d 100644 --- a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor +++ b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor @@ -6,15 +6,27 @@

    Server side data

    -
    - - +Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggregate((c, n) => $"{c},{n}") : "None") + +
    + + + + + + + + + + + + - + @@ -25,7 +37,7 @@ @(context.created_date.HasValue ? context.created_date.Value.ToShortDateString() : string.Empty) - +
    @code @@ -33,6 +45,8 @@ [Inject] private HttpClient httpClient { get; set; } + private ITable Table; + public class PersonData { public int? id { get; set; } @@ -47,10 +61,33 @@ private IEnumerable data; + private List selectedItems = new List(); + protected override async Task OnInitializedAsync() { _loader = new PersonDataLoader(httpClient); data = (await _loader.LoadDataAsync(null)).Records; + + await Table.SetInitialFiltersAsync(new List() + { + new FilterString() + { + Condition = StringCondition.IsEqualTo.ToString(), + Field = nameof(PersonData.full_name), + FilterValue = "Marja Mustill" + }, + new FilterString() + { + Condition = BooleanCondition.True.ToString(), + Field = nameof(PersonData.paid) + } + }); + + } + + public void RowClick(PersonData data) + { + StateHasChanged(); } public class PersonDataLoader : IDataLoader @@ -60,7 +97,7 @@ { _client = client; } - public async Task> LoadDataAsync(FilterData parameters) + public async Task> LoadDataAsync(FilterData parameters) { var data = await _client.GetFromJsonAsync("sample-data/MOCK_DATA.json"); @@ -82,6 +119,13 @@ : query.OrderBy(x => prop.GetValue(x, null)); } } + if(parameters?.Filters != null) + { + foreach (var filter in parameters?.Filters) + { + query = query.Where(filter); + } + } var results = parameters?.Top.HasValue ?? false ? query.Skip(parameters.Skip.GetValueOrDefault()) .Take(parameters.Top.Value).ToArray() : @@ -97,4 +141,6 @@ } } + + } diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index 4d04d6e9..ef69dd1c 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -15,6 +15,8 @@ git MIT true + + 1.17.2-preview @@ -35,6 +37,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive
    + diff --git a/src/BlazorTable/Components/Column.razor.cs b/src/BlazorTable/Components/Column.razor.cs index dec41914..638762da 100644 --- a/src/BlazorTable/Components/Column.razor.cs +++ b/src/BlazorTable/Components/Column.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using BlazorTable.Components.ServerSide; +using Microsoft.AspNetCore.Components; using System; using System.Globalization; using System.Linq; @@ -122,6 +123,16 @@ public string Title /// public Expression> Filter { get; set; } + /// + /// Filter as string + /// + public FilterString FilterString { get; set; } + + /// + /// Initial filters + /// + public FilterString InitialFilterString { get; set; } + /// /// True if this is the default Sort Column /// diff --git a/src/BlazorTable/Components/FilterManager.razor.cs b/src/BlazorTable/Components/FilterManager.razor.cs index bb1f8285..7fc24407 100644 --- a/src/BlazorTable/Components/FilterManager.razor.cs +++ b/src/BlazorTable/Components/FilterManager.razor.cs @@ -20,13 +20,13 @@ public partial class FilterManager IStringLocalizer Localization { get; set; } private async Task ApplyFilterAsync() - { Column.ToggleFilter(); if (Column.FilterControl != null) { Column.Filter = Column.FilterControl.GetFilter(); + Column.FilterString = Column.FilterControl.GetFilterString(); await Column.Table.UpdateAsync().ConfigureAwait(false); await Column.Table.FirstPageAsync().ConfigureAwait(false); } diff --git a/src/BlazorTable/Components/Pager.razor b/src/BlazorTable/Components/Pager.razor index 8cd3332e..389c9e87 100644 --- a/src/BlazorTable/Components/Pager.razor +++ b/src/BlazorTable/Components/Pager.razor @@ -15,6 +15,13 @@ } + + @if (ShowPageNumberInput) + { +
  • + +
  • + } @if (ShowPageNumber) {
  • @@ -40,6 +47,21 @@
  • @Localization["PagerPrevious"]
  • + + @if(ShowPageNumberSelector) + { + for (var i = 0; i < 9; i++) + { + var page = Table.PageNumber < 5 ? i : Table.PageNumber + i - 4; + if(page <= Table.TotalPages - 1) + { +
  • + @(page + 1) +
  • + } + } + } +
  • @Localization["PagerNext"]
  • diff --git a/src/BlazorTable/Components/Pager.razor.cs b/src/BlazorTable/Components/Pager.razor.cs index d51bee2b..8660831b 100644 --- a/src/BlazorTable/Components/Pager.razor.cs +++ b/src/BlazorTable/Components/Pager.razor.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; using Microsoft.Extensions.Localization; using System.Collections.Generic; using System.Threading.Tasks; @@ -43,6 +44,18 @@ public partial class Pager [Parameter] public bool ShowPageSizes { get; set; } + /// + /// Show Pages Numbers + /// + [Parameter] + public bool ShowPageNumberSelector { get; set; } + + /// + /// Show Pages Number selector input + /// + [Parameter] + public bool ShowPageNumberInput { get; set; } + [Inject] IStringLocalizer Localization { get; set; } @@ -53,5 +66,25 @@ private async Task SetPageSizeAsync(ChangeEventArgs args) await Table.SetPageSizeAsync(result).ConfigureAwait(false); } } + + private int inputPage { get; set; } = 1; + + private async Task SetPageInput(KeyboardEventArgs e) + { + if (e.Code == "Enter" || e.Code == "NumpadEnter") + { + if (inputPage > Table.TotalPages) + { + inputPage = Table.TotalPages; + } + + if (inputPage < 1) + { + inputPage = 1; + } + + await Table.GoToPageAsync(inputPage - 1).ConfigureAwait(false); + } + } } } diff --git a/src/BlazorTable/Components/ServerSide/FilterData.cs b/src/BlazorTable/Components/ServerSide/FilterData.cs index b2dbf743..356b97c3 100644 --- a/src/BlazorTable/Components/ServerSide/FilterData.cs +++ b/src/BlazorTable/Components/ServerSide/FilterData.cs @@ -1,6 +1,10 @@ -namespace BlazorTable.Components.ServerSide +using System; +using System.Collections.Generic; +using System.Linq.Expressions; + +namespace BlazorTable.Components.ServerSide { - public class FilterData + public class FilterData { public string OrderBy { get; set; } @@ -9,6 +13,10 @@ public class FilterData public int? Top { get; set; } public int? Skip { get; set; } + + public List>> Filters { get; set; } + + public List FilterStrings { get; set; } } } diff --git a/src/BlazorTable/Components/ServerSide/FilterString.cs b/src/BlazorTable/Components/ServerSide/FilterString.cs new file mode 100644 index 00000000..06c878b4 --- /dev/null +++ b/src/BlazorTable/Components/ServerSide/FilterString.cs @@ -0,0 +1,21 @@ +namespace BlazorTable.Components.ServerSide +{ + + public class FilterString + { + /// + /// Field name + /// + public string Field { get; set; } + + /// + /// it should be a enum converted to string according with field type. Available enums are StringCondition, NumberCondition, EnumCondition, CustomSelectCondition and BooleanCondition + /// + public string Condition { get; set; } + + /// + /// Value to filter + /// + public string FilterValue { get; set; } + } +} diff --git a/src/BlazorTable/Components/Table.razor b/src/BlazorTable/Components/Table.razor index f9411af2..634ff235 100644 --- a/src/BlazorTable/Components/Table.razor +++ b/src/BlazorTable/Components/Table.razor @@ -163,7 +163,7 @@ if (!rowDisplayed) { - + @{ int locali = i; diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index 57c959c3..84540356 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -142,7 +142,7 @@ public partial class Table : ITable protected override async Task OnParametersSetAsync() { - await UpdateAsync().ConfigureAwait(false); + await UpdateAsync(true).ConfigureAwait(false); } private IEnumerable GetData() @@ -156,6 +156,11 @@ private IEnumerable GetData() ItemsQueryable = Items.AsQueryable(); } + if (DataLoader != null) + { + return ItemsQueryable.ToList(); + } + foreach (var item in Columns) { if (item.Filter != null) @@ -163,11 +168,7 @@ private IEnumerable GetData() ItemsQueryable = ItemsQueryable.Where(item.Filter); } } - - if (DataLoader != null) - { - return ItemsQueryable.ToList(); - } + // Global Search if (!string.IsNullOrEmpty(GlobalSearch)) { @@ -227,9 +228,10 @@ public void ToggleAllDetailsView(bool open) /// /// Gets Data and redraws the Table /// - public async Task UpdateAsync() + public async Task UpdateAsync(bool updateServerData = true) { - await LoadServerSideDataAsync().ConfigureAwait(false); + if(updateServerData) + await LoadServerSideDataAsync().ConfigureAwait(false); FilteredItems = GetData(); Refresh(); } @@ -248,12 +250,28 @@ private async Task LoadServerSideDataAsync() .Append(sortColumn.SortDescending ? "desc" : "asc"); } - var result = await DataLoader.LoadDataAsync(new FilterData + var filters = new List>>(); + var filterStrings = new List(); + if (Columns != null) + { + foreach (var item in Columns) + { + if (item.Filter != null) + { + filters.Add(item.Filter); + filterStrings.Add(item.FilterString); + } + } + } + + var result = await DataLoader.LoadDataAsync(new FilterData { Top = PageSize, Skip = PageNumber * PageSize, Query = GlobalSearch, - OrderBy = sortExpression.ToString() + OrderBy = sortExpression.ToString(), + Filters = filters, + FilterStrings = filterStrings }).ConfigureAwait(false); Items = result.Records; TotalCount = result.Total.GetValueOrDefault(1); @@ -336,6 +354,18 @@ public async Task LastPageAsync() await UpdateAsync().ConfigureAwait(false); } + /// + /// Go to specific page + /// + /// Page number to go + /// + public async Task GoToPageAsync(int pageNumber) + { + PageNumber = pageNumber; + detailsViewOpen.Clear(); + await UpdateAsync().ConfigureAwait(false); + } + /// /// Redraws the Table using EditTemplate instead of Template /// @@ -348,9 +378,9 @@ public void ToggleEditMode() /// /// Redraws Table without Getting Data /// - public void Refresh() + public async void Refresh() { - InvokeAsync(StateHasChanged); + await InvokeAsync(StateHasChanged); } /// @@ -468,7 +498,7 @@ public SelectionType SelectionType /// Handles the onclick action for table rows. /// This allows the RowClickAction to be optional. /// - private void OnRowClickHandler(TableItem tableItem) + private async void OnRowClickHandler(TableItem tableItem) { try { @@ -488,8 +518,8 @@ private void OnRowClickHandler(TableItem tableItem) SelectedItems.Add(tableItem); break; case SelectionType.Multiple: - if (SelectedItems.Contains(tableItem)) - SelectedItems.Remove(tableItem); + if (SelectedItems.Any(x=> x.CompareEx(tableItem))) + SelectedItems.RemoveAll(x=> x.CompareEx(tableItem)); else SelectedItems.Add(tableItem); break; @@ -560,6 +590,44 @@ private Expression> GlobalSearchQuery(string value) public async Task SetPageSizeAsync(int pageSize) { PageSize = pageSize; + PageNumber = 0; + detailsViewOpen.Clear(); + await UpdateAsync().ConfigureAwait(false); + } + + /// + /// Set initial filters to grid + /// + /// + /// + public async Task SetInitialFiltersAsync(IEnumerable filters) + { + foreach (var item in filters) + { + var column = Columns.FirstOrDefault(x => x.Field.GetPropertyMemberInfo().Name == item.Field); + if (column != null && column.Filterable) + { + column.InitialFilterString = item; + if (column.FilterControl == null) + { + if (column.CustomIFilters != null) + column.FilterControl = new CustomSelect() { Column = column }; + else if (column.Type == typeof(string)) + column.FilterControl = new StringFilter() { Column = column }; + else if (column.Type.IsNumeric() && !column.Type.GetNonNullableType().IsEnum) + column.FilterControl = new NumberFilter() { Column = column }; + else if (column.Type.GetNonNullableType().IsEnum) + column.FilterControl = new EnumFilter() { Column = column }; + else if (column.Type.GetNonNullableType() == typeof(DateTime)) + column.FilterControl = new DateFilter() { Column = column }; + else if (new List() { typeof(bool) }.Contains(column.Type.GetNonNullableType())) + column.FilterControl = new BooleanFilter() { Column = column }; + } + column.Filter = column.FilterControl.GetFilter(); + column.FilterString = column.FilterControl.GetFilterString(); + } + } + await FirstPageAsync().ConfigureAwait(false); await UpdateAsync().ConfigureAwait(false); } diff --git a/src/BlazorTable/Filters/BooleanFilter.razor.cs b/src/BlazorTable/Filters/BooleanFilter.razor.cs index 1b17aeca..3d8aa530 100644 --- a/src/BlazorTable/Filters/BooleanFilter.razor.cs +++ b/src/BlazorTable/Filters/BooleanFilter.razor.cs @@ -1,4 +1,5 @@ -using BlazorTable.Localization; +using BlazorTable.Components.ServerSide; +using BlazorTable.Localization; using Microsoft.AspNetCore.Components; using System; using System.Collections.Generic; @@ -24,6 +25,15 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter != null) { var nodeType = Column.Filter.Body.NodeType; @@ -55,6 +65,13 @@ protected override void OnInitialized() public Expression> GetFilter() { + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + + Column.InitialFilterString = null; + } + return Condition switch { BooleanCondition.True => @@ -88,8 +105,18 @@ public Expression> GetFilter() _ => null, }; } + public FilterString GetFilterString() + { + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString() + }; + } } + + public enum BooleanCondition { [LocalizedDescription("BooleanConditionTrue", typeof(Localization.Localization))] diff --git a/src/BlazorTable/Filters/CustomSelect.razor.cs b/src/BlazorTable/Filters/CustomSelect.razor.cs index 9a0c5ca3..72a44666 100644 --- a/src/BlazorTable/Filters/CustomSelect.razor.cs +++ b/src/BlazorTable/Filters/CustomSelect.razor.cs @@ -1,4 +1,5 @@ -using BlazorTable.Localization; +using BlazorTable.Components.ServerSide; +using BlazorTable.Localization; using Microsoft.AspNetCore.Components; using System; using System.Collections.Generic; @@ -26,6 +27,15 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter?.Body is BinaryExpression binaryExpression && binaryExpression.Right is BinaryExpression logicalBinary && logicalBinary.Right is ConstantExpression constant) @@ -46,6 +56,14 @@ protected override void OnInitialized() public Expression> GetFilter() { + + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + } + return Condition switch { CustomSelectCondition.IsEqualTo => @@ -83,6 +101,16 @@ public Expression> GetFilter() }; } + public FilterString GetFilterString() + { + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterValue.ToString() + }; + } + public void AddSelect(string key, object value) { Items.Add(new KeyValuePair(key, value)); diff --git a/src/BlazorTable/Filters/DateFilter.razor.cs b/src/BlazorTable/Filters/DateFilter.razor.cs index 52170959..5ae8864b 100644 --- a/src/BlazorTable/Filters/DateFilter.razor.cs +++ b/src/BlazorTable/Filters/DateFilter.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using BlazorTable.Components.ServerSide; +using Microsoft.AspNetCore.Components; using System; using System.Linq.Expressions; @@ -19,6 +20,17 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + if (DateTime.TryParse(Column.InitialFilterString.FilterValue, out DateTime filterValue)) + FilterValue = filterValue; + + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter?.Body is BinaryExpression binaryExpression && binaryExpression.Right is BinaryExpression logicalBinary && logicalBinary.Right is ConstantExpression constant) @@ -55,6 +67,15 @@ protected override void OnInitialized() public Expression> GetFilter() { + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + if (DateTime.TryParse(Column.InitialFilterString.FilterValue, out DateTime filterValue)) + FilterValue = filterValue; + + Column.InitialFilterString = null; + } + return Condition switch { NumberCondition.IsEqualTo => @@ -128,5 +149,15 @@ public Expression> GetFilter() _ => throw new ArgumentException(Condition + " is not defined!"), }; } + + public FilterString GetFilterString() + { + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterValue.ToString() + }; + } } } \ No newline at end of file diff --git a/src/BlazorTable/Filters/EnumFilter.razor.cs b/src/BlazorTable/Filters/EnumFilter.razor.cs index 29807eca..89c41069 100644 --- a/src/BlazorTable/Filters/EnumFilter.razor.cs +++ b/src/BlazorTable/Filters/EnumFilter.razor.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Linq.Expressions; using Microsoft.Extensions.Localization; +using BlazorTable.Components.ServerSide; namespace BlazorTable { @@ -25,6 +26,15 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter?.Body is BinaryExpression binaryExpression && binaryExpression.Right is BinaryExpression logicalBinary && logicalBinary.Right is ConstantExpression constant) @@ -51,6 +61,13 @@ protected override void OnInitialized() public Expression> GetFilter() { + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + } + return Condition switch { EnumCondition.IsEqualTo => @@ -89,6 +106,16 @@ public Expression> GetFilter() }; } + public FilterString GetFilterString() + { + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterValue.ToString() + }; + } + public enum EnumCondition { [LocalizedDescription("EnumConditionIsEqualTo", typeof(Localization.Localization))] diff --git a/src/BlazorTable/Filters/NumberFilter.razor.cs b/src/BlazorTable/Filters/NumberFilter.razor.cs index d4131981..00ed499d 100644 --- a/src/BlazorTable/Filters/NumberFilter.razor.cs +++ b/src/BlazorTable/Filters/NumberFilter.razor.cs @@ -1,4 +1,5 @@ -using BlazorTable.Localization; +using BlazorTable.Components.ServerSide; +using BlazorTable.Localization; using Microsoft.AspNetCore.Components; using System; using System.Globalization; @@ -24,6 +25,16 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + + if (Column.Filter?.Body is BinaryExpression binaryExpression && binaryExpression.Right is BinaryExpression logicalBinary && logicalBinary.Right is ConstantExpression constant) @@ -60,6 +71,13 @@ protected override void OnInitialized() public Expression> GetFilter() { + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterValue = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + } + if (Condition != NumberCondition.IsNull && Condition != NumberCondition.IsNotNull && string.IsNullOrEmpty(FilterValue)) { return null; @@ -138,6 +156,17 @@ public Expression> GetFilter() _ => throw new ArgumentException(Condition + " is not defined!"), }; } + + public FilterString GetFilterString() + { + + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterValue + }; + } } public enum NumberCondition diff --git a/src/BlazorTable/Filters/StringFilter.razor.cs b/src/BlazorTable/Filters/StringFilter.razor.cs index d86440c6..1f8a7cdb 100644 --- a/src/BlazorTable/Filters/StringFilter.razor.cs +++ b/src/BlazorTable/Filters/StringFilter.razor.cs @@ -1,4 +1,5 @@ -using BlazorTable.Localization; +using BlazorTable.Components.ServerSide; +using BlazorTable.Localization; using Microsoft.AspNetCore.Components; using System; using System.Linq.Expressions; @@ -25,6 +26,15 @@ protected override void OnInitialized() { Column.FilterControl = this; + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterText = Column.InitialFilterString.FilterValue; + Column.InitialFilterString = null; + + Column.Filter = GetFilter(); + } + if (Column.Filter != null) { bool NotCondition = false; @@ -87,6 +97,15 @@ private StringCondition GetConditionFromMethod(string method, bool not) public Expression> GetFilter() { + + if (Column.InitialFilterString != null) + { + Condition = Utilities.ParseEnum(Column.InitialFilterString.Condition); + FilterText = Column.InitialFilterString.FilterValue; + + Column.InitialFilterString = null; + } + FilterText = FilterText?.Trim(); if (Condition != StringCondition.IsNullOrEmpty && Condition != StringCondition.IsNotNulOrEmpty && string.IsNullOrEmpty(FilterText)) @@ -183,6 +202,18 @@ public Expression> GetFilter() _ => throw new ArgumentException(Condition + " is not defined!"), }; } + + public FilterString GetFilterString() + { + FilterText = FilterText?.Trim(); + + return new FilterString() + { + Field = Column.Field.GetPropertyMemberInfo().Name, + Condition = Condition.ToString(), + FilterValue = FilterText + }; + } } public enum StringCondition diff --git a/src/BlazorTable/Interfaces/IColumn.cs b/src/BlazorTable/Interfaces/IColumn.cs index d5d13ae3..adc01f3e 100644 --- a/src/BlazorTable/Interfaces/IColumn.cs +++ b/src/BlazorTable/Interfaces/IColumn.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using BlazorTable.Components.ServerSide; +using Microsoft.AspNetCore.Components; using System; using System.Linq.Expressions; using System.Threading.Tasks; @@ -84,6 +85,16 @@ public interface IColumn /// Expression> Filter { get; set; } + /// + /// Filter as string + /// + FilterString FilterString { get; set; } + + /// + /// Filter as string + /// + FilterString InitialFilterString { get; set; } + /// /// Edit Mode Item Template /// diff --git a/src/BlazorTable/Interfaces/IDataLoader.cs b/src/BlazorTable/Interfaces/IDataLoader.cs index c9d38047..6a1911d2 100644 --- a/src/BlazorTable/Interfaces/IDataLoader.cs +++ b/src/BlazorTable/Interfaces/IDataLoader.cs @@ -1,10 +1,12 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Threading.Tasks; using BlazorTable.Components.ServerSide; namespace BlazorTable.Interfaces { public interface IDataLoader { - public Task> LoadDataAsync(FilterData parameters); + public Task> LoadDataAsync(FilterData parameters); + } } diff --git a/src/BlazorTable/Interfaces/IFilter.cs b/src/BlazorTable/Interfaces/IFilter.cs index 77800215..917dd99c 100644 --- a/src/BlazorTable/Interfaces/IFilter.cs +++ b/src/BlazorTable/Interfaces/IFilter.cs @@ -1,4 +1,5 @@ -using System; +using BlazorTable.Components.ServerSide; +using System; using System.Linq.Expressions; namespace BlazorTable @@ -14,5 +15,11 @@ public interface IFilter /// /// Expression> GetFilter(); + + /// + /// Get filter as string object + /// + /// + FilterString GetFilterString(); } } diff --git a/src/BlazorTable/Interfaces/ITable.cs b/src/BlazorTable/Interfaces/ITable.cs index 7af8de02..8d57c0c6 100644 --- a/src/BlazorTable/Interfaces/ITable.cs +++ b/src/BlazorTable/Interfaces/ITable.cs @@ -1,4 +1,6 @@ -using System.Threading.Tasks; +using BlazorTable.Components.ServerSide; +using System.Collections.Generic; +using System.Threading.Tasks; namespace BlazorTable { @@ -58,6 +60,11 @@ public interface ITable /// Task LastPageAsync(); + /// + /// Go to Specific Page Async + /// + Task GoToPageAsync(int pageNumber); + /// /// Redraws the Table using EditTemplate instead of Template /// @@ -86,7 +93,9 @@ public interface ITable /// /// Gets Data and redraws the Table /// - Task UpdateAsync(); + /// false if it is not needed to update server data + /// + Task UpdateAsync(bool updateServerData = true); /// /// Open/Close detail view in specified row. /// @@ -138,5 +147,12 @@ public interface ITable /// /// Task SetPageSizeAsync(int pageSize); + + /// + /// Set initial filters + /// + /// + /// + Task SetInitialFiltersAsync(IEnumerable filters); } } diff --git a/src/BlazorTable/Properties/PublishProfiles/FolderProfile.pubxml b/src/BlazorTable/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 00000000..6f5e1117 --- /dev/null +++ b/src/BlazorTable/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,12 @@ + + + + + Release + Any CPU + bin\Release\netstandard2.1\publish\ + FileSystem + + \ No newline at end of file diff --git a/src/BlazorTable/Utillities.cs b/src/BlazorTable/Utillities.cs index f7359284..09399f6f 100644 --- a/src/BlazorTable/Utillities.cs +++ b/src/BlazorTable/Utillities.cs @@ -1,4 +1,5 @@ using LinqKit; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; @@ -181,6 +182,11 @@ public static string ToDescriptionString(this Enum val) return attributes.Length > 0 ? attributes[0].Description : string.Empty; } + public static T ParseEnum(string value) + { + return (T)Enum.Parse(typeof(T), value, true); + } + /// /// Recursively walks up the tree and adds null checks /// @@ -229,5 +235,17 @@ public static BinaryExpression CreateNullChecks(this Expression expression, bool return newExpression; } + + public static bool CompareEx(this object obj, object another) + { + if (ReferenceEquals(obj, another)) return true; + if ((obj == null) || (another == null)) return false; + if (obj.GetType() != another.GetType()) return false; + + var objJson = JsonConvert.SerializeObject(obj); + var anotherJson = JsonConvert.SerializeObject(another); + + return objJson == anotherJson; + } } } From 31e3164ef67ef3f65d5e3a3d037799d2a3b35187 Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Mon, 21 Mar 2022 16:06:26 -0300 Subject: [PATCH 20/31] Added ClearFilterAsync for clearing filters --- src/BlazorTable/BlazorTable.csproj | 2 +- src/BlazorTable/Components/Table.razor.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index ef69dd1c..96504133 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -16,7 +16,7 @@ MIT true - 1.17.2-preview + 1.17.3-preview diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index 84540356..a796c24e 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -631,6 +631,24 @@ public async Task SetInitialFiltersAsync(IEnumerable filters) await UpdateAsync().ConfigureAwait(false); } + /// + /// Clear filter + /// + /// Column name + /// + public async Task ClearFilterAsync(string columnName) + { + var column = Columns.FirstOrDefault(x => x.Field.GetPropertyMemberInfo().Name == columnName); + if (column != null && column.Filterable) + { + column.Filter = null; + column.FilterString = null; + await FirstPageAsync().ConfigureAwait(false); + await UpdateAsync().ConfigureAwait(false); + } + } + + /// /// Show table child content at the top of the table. /// From 18166cb124b8d43c6e427c4c47769a0a24c321d9 Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Tue, 22 Mar 2022 17:27:44 -0300 Subject: [PATCH 21/31] Closing other popup filters if another is opened --- src/BlazorTable/BlazorTable.csproj | 2 +- src/BlazorTable/Components/Column.razor.cs | 6 +++++- src/BlazorTable/Interfaces/IColumn.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index 96504133..11e88688 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -16,7 +16,7 @@ MIT true - 1.17.3-preview + 1.17.4-preview diff --git a/src/BlazorTable/Components/Column.razor.cs b/src/BlazorTable/Components/Column.razor.cs index 638762da..52137011 100644 --- a/src/BlazorTable/Components/Column.razor.cs +++ b/src/BlazorTable/Components/Column.razor.cs @@ -158,7 +158,7 @@ public string Title /// /// Filter Panel is open /// - public bool FilterOpen { get; private set; } + public bool FilterOpen { get; set; } private bool _visible = true; @@ -231,6 +231,10 @@ protected override void OnParametersSet() public void ToggleFilter() { FilterOpen = !FilterOpen; + foreach (var column in Table.Columns.Where(x => x != this)) + { + column.FilterOpen = false; + } Table.Refresh(); } diff --git a/src/BlazorTable/Interfaces/IColumn.cs b/src/BlazorTable/Interfaces/IColumn.cs index adc01f3e..c6783d9c 100644 --- a/src/BlazorTable/Interfaces/IColumn.cs +++ b/src/BlazorTable/Interfaces/IColumn.cs @@ -50,7 +50,7 @@ public interface IColumn /// /// Filter Panel is open /// - bool FilterOpen { get; } + bool FilterOpen { get; set; } /// /// Column visibility From 94a79060f44b7d25f2be8145c4af22c8bad09be4 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Wed, 23 Mar 2022 09:10:45 -0500 Subject: [PATCH 22/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9941678c..424a38ee 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -74,18 +74,16 @@ steps: "@ -- task: NuGetCommand@2 - displayName: 'Nuget Pack' +- task: DotNetCoreCLI@2 inputs: command: 'pack' packagesToPack: '**/BlazorTable.csproj' - includeSymbols: true - configuration: '$(buildConfiguration)' - versioningScheme: byPrereleaseNumber - majorVersion: '$(Parameters.requestedMajorVersion)' - minorVersion: '$(Parameters.requestedMinorVersion)' - patchVersion: '$(Parameters.requestedPatchVersion)' - + includesymbols: true + versioningScheme: 'byPrereleaseNumber' + majorVersion: '1' + minorVersion: '17' + patchVersion: '3'' + - task: NuGetCommand@2 displayName: 'Nuget Push' inputs: From d251d91391dec8c0f222ca4df126d445664ef51b Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Wed, 23 Mar 2022 09:11:55 -0500 Subject: [PATCH 23/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 424a38ee..f993a03c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -82,10 +82,10 @@ steps: versioningScheme: 'byPrereleaseNumber' majorVersion: '1' minorVersion: '17' - patchVersion: '3'' - -- task: NuGetCommand@2 + patchVersion: 'Preview' displayName: 'Nuget Push' + +- task: NuGetCommand@2 inputs: command: 'push' packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' From a85c645ec08d67af4a236e0b6a67729e6cd94c0f Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Wed, 23 Mar 2022 09:28:20 -0500 Subject: [PATCH 24/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 47 +++------------------------------------------ 1 file changed, 3 insertions(+), 44 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f993a03c..d47ad603 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,31 +14,13 @@ variables: Parameters.requestedMinorVersion: '17' Parameters.requestedPatchVersion: '3' steps: -- task: PowerShell@2 - inputs: - targetType: 'inline' - script: | - $tempdir = [IO.Path]::GetTempPath() - - $env:NUGET_PLUGIN_LOG_DIRECTORY_PATH = Join-Path $tempdir "pluginlog" - $env:NUGET_CREDENTIALPROVIDER_LOG_PATH = Join-Path $env:NUGET_PLUGIN_LOG_DIRECTORY_PATH "artifacts-credprovider.log" - $env:NUGET_PLUGIN_ENABLE_LOG = "true" - - if (Test-Path -LiteralPath $env:NUGET_PLUGIN_LOG_DIRECTORY_PATH) { - Remove-Item -Recurse -Force -LiteralPath $env:NUGET_PLUGIN_LOG_DIRECTORY_PATH - } - - [IO.Directory]::CreateDirectory($env:NUGET_PLUGIN_LOG_DIRECTORY_PATH) | Out-Null - - Write-Host "##vso[task.setvariable variable=NUGET_CREDENTIALPROVIDER_LOG_PATH]$env:NUGET_CREDENTIALPROVIDER_LOG_PATH" - Write-Host "##vso[task.setvariable variable=NUGET_PLUGIN_ENABLE_LOG]$env:NUGET_PLUGIN_ENABLE_LOG" - Write-Host "##vso[task.setvariable variable=NUGET_PLUGIN_LOG_DIRECTORY_PATH]$env:NUGET_PLUGIN_LOG_DIRECTORY_PATH" - task: NuGetToolInstaller@1 -- task: NuGetCommand@2 +- task: DotNetCoreCLI@2 inputs: - restoreSolution: '$(solution)' + command: 'restore' + feedsToUse: 'select' - task: VSBuild@1 inputs: @@ -51,29 +33,6 @@ steps: platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' -- task: PowerShell@2 - inputs: - targetType: 'inline' - script: | - Set-Content package.nuspec @" - - - BlazorTable - 1.17.3-preview - Octavian Technology Group - A fork of Blazor Tables - - - - - - - - - - - "@ - - task: DotNetCoreCLI@2 inputs: command: 'pack' From 7573434809875aa3512ce3a54da141d1d6bf42a3 Mon Sep 17 00:00:00 2001 From: Cameron Vetter Date: Wed, 23 Mar 2022 09:40:00 -0500 Subject: [PATCH 25/31] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d47ad603..7c1f20b3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -41,7 +41,7 @@ steps: versioningScheme: 'byPrereleaseNumber' majorVersion: '1' minorVersion: '17' - patchVersion: 'Preview' + patchVersion: '3' displayName: 'Nuget Push' - task: NuGetCommand@2 From e036303279e716a4e56a296452ebe91d506c7259 Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Fri, 25 Mar 2022 11:28:29 -0300 Subject: [PATCH 26/31] Modified pager --- src/BlazorTable/Components/Pager.razor | 14 ++++- .../Localization/Localization.Designer.cs | 11 +++- .../Localization/Localization.da.resx | 3 + .../Localization/Localization.de.resx | 3 + .../Localization/Localization.es.resx | 59 ++++++++++--------- .../Localization/Localization.fr.resx | 4 ++ .../Localization/Localization.pt-BR.resx | 3 + .../Localization/Localization.resx | 3 + .../Localization/Localization.zh-CN.resx | 5 +- 9 files changed, 73 insertions(+), 32 deletions(-) diff --git a/src/BlazorTable/Components/Pager.razor b/src/BlazorTable/Components/Pager.razor index 389c9e87..f6396cbf 100644 --- a/src/BlazorTable/Components/Pager.razor +++ b/src/BlazorTable/Components/Pager.razor @@ -2,12 +2,19 @@ @if (AlwaysShow || (Table.TotalPages > 1)) { -
    +
    +
    + +
    +
    +
    +
      @if (ShowPageSizes) {
    • + @Localization["GoToPage"] 
    • } @if (ShowPageNumber) @@ -70,4 +77,7 @@
    +
    +
    + } diff --git a/src/BlazorTable/Localization/Localization.Designer.cs b/src/BlazorTable/Localization/Localization.Designer.cs index f5e12743..1b71d565 100644 --- a/src/BlazorTable/Localization/Localization.Designer.cs +++ b/src/BlazorTable/Localization/Localization.Designer.cs @@ -19,7 +19,7 @@ namespace BlazorTable.Localization { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Localization { @@ -195,6 +195,15 @@ internal static string FilterManagerClose { } } + /// + /// Looks up a localized string similar to Go to page:. + /// + internal static string GoToPage { + get { + return ResourceManager.GetString("GoToPage", resourceCulture); + } + } + /// /// Looks up a localized string similar to Is equal to. /// diff --git a/src/BlazorTable/Localization/Localization.da.resx b/src/BlazorTable/Localization/Localization.da.resx index dd9bd6d1..886a99a5 100644 --- a/src/BlazorTable/Localization/Localization.da.resx +++ b/src/BlazorTable/Localization/Localization.da.resx @@ -162,6 +162,9 @@ Luk + + Gå til side: + Er lig med diff --git a/src/BlazorTable/Localization/Localization.de.resx b/src/BlazorTable/Localization/Localization.de.resx index 05448a3d..0fc4cab1 100644 --- a/src/BlazorTable/Localization/Localization.de.resx +++ b/src/BlazorTable/Localization/Localization.de.resx @@ -162,6 +162,9 @@ Schließen + + Gehe zur seite: + Ist gleich diff --git a/src/BlazorTable/Localization/Localization.es.resx b/src/BlazorTable/Localization/Localization.es.resx index 7053e2f8..be0a2928 100644 --- a/src/BlazorTable/Localization/Localization.es.resx +++ b/src/BlazorTable/Localization/Localization.es.resx @@ -1,17 +1,17 @@  - @@ -231,4 +231,7 @@ Cargando... - + + Ir a página: + + \ No newline at end of file diff --git a/src/BlazorTable/Localization/Localization.fr.resx b/src/BlazorTable/Localization/Localization.fr.resx index adaa484b..4b5c2d2a 100644 --- a/src/BlazorTable/Localization/Localization.fr.resx +++ b/src/BlazorTable/Localization/Localization.fr.resx @@ -53,6 +53,7 @@ value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. + mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter @@ -161,6 +162,9 @@ Fermer + + Aller à la page: + Est égal à diff --git a/src/BlazorTable/Localization/Localization.pt-BR.resx b/src/BlazorTable/Localization/Localization.pt-BR.resx index 7c54a348..6dfa8f70 100644 --- a/src/BlazorTable/Localization/Localization.pt-BR.resx +++ b/src/BlazorTable/Localization/Localization.pt-BR.resx @@ -162,6 +162,9 @@ Fechar + + Vá para página: + É igual a diff --git a/src/BlazorTable/Localization/Localization.resx b/src/BlazorTable/Localization/Localization.resx index 8c94477f..73092e4d 100644 --- a/src/BlazorTable/Localization/Localization.resx +++ b/src/BlazorTable/Localization/Localization.resx @@ -162,6 +162,9 @@ Close + + Go to page: + Is equal to diff --git a/src/BlazorTable/Localization/Localization.zh-CN.resx b/src/BlazorTable/Localization/Localization.zh-CN.resx index 27f84536..847f9216 100644 --- a/src/BlazorTable/Localization/Localization.zh-CN.resx +++ b/src/BlazorTable/Localization/Localization.zh-CN.resx @@ -162,6 +162,9 @@ 关闭 + + 转到页面: + 等于 @@ -231,4 +234,4 @@ 加载中... - + \ No newline at end of file From abdf3ad316d1b49eb0089ed205611ebabdc5da7b Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Mon, 28 Mar 2022 16:58:23 -0300 Subject: [PATCH 27/31] Style of paginator modified --- .../Pages/ServerSideData.razor | 14 +-- .../wwwroot/css/site.css | 4 + .../wwwroot/index.html | 1 + src/BlazorTable/Components/Pager.razor | 116 +++++++++--------- src/BlazorTable/Components/Pager.razor.css | 3 + .../Localization/Localization.Designer.cs | 9 ++ .../Localization/Localization.resx | 3 + 7 files changed, 83 insertions(+), 67 deletions(-) create mode 100644 src/BlazorTable/Components/Pager.razor.css diff --git a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor index f256cf8d..c4e4a4a1 100644 --- a/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor +++ b/src/BlazorTable.Sample.Shared/Pages/ServerSideData.razor @@ -37,7 +37,7 @@ Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggrega @(context.created_date.HasValue ? context.created_date.Value.ToShortDateString() : string.Empty) - + @code @@ -70,12 +70,12 @@ Selected: @(selectedItems.Any() ? selectedItems.Select(x => x.full_name).Aggrega await Table.SetInitialFiltersAsync(new List() { - new FilterString() - { - Condition = StringCondition.IsEqualTo.ToString(), - Field = nameof(PersonData.full_name), - FilterValue = "Marja Mustill" - }, + //new FilterString() + //{ + // Condition = StringCondition.IsEqualTo.ToString(), + // Field = nameof(PersonData.full_name), + // FilterValue = "Marja Mustill" + //}, new FilterString() { Condition = BooleanCondition.True.ToString(), diff --git a/src/BlazorTable.Sample.Wasm/wwwroot/css/site.css b/src/BlazorTable.Sample.Wasm/wwwroot/css/site.css index aa02184c..bde68409 100644 --- a/src/BlazorTable.Sample.Wasm/wwwroot/css/site.css +++ b/src/BlazorTable.Sample.Wasm/wwwroot/css/site.css @@ -255,4 +255,8 @@ app { justify-content: center; flex-direction: column; --sk-color: white; +} + +.page-link { + border: none; } \ No newline at end of file diff --git a/src/BlazorTable.Sample.Wasm/wwwroot/index.html b/src/BlazorTable.Sample.Wasm/wwwroot/index.html index b8670c70..82cf2712 100644 --- a/src/BlazorTable.Sample.Wasm/wwwroot/index.html +++ b/src/BlazorTable.Sample.Wasm/wwwroot/index.html @@ -7,6 +7,7 @@ + diff --git a/src/BlazorTable/Components/Pager.razor b/src/BlazorTable/Components/Pager.razor index f6396cbf..30ac081d 100644 --- a/src/BlazorTable/Components/Pager.razor +++ b/src/BlazorTable/Components/Pager.razor @@ -3,81 +3,77 @@ @if (AlwaysShow || (Table.TotalPages > 1)) {
    -
    - -
    -
    -
    - - +
    - + } diff --git a/src/BlazorTable/Components/Pager.razor.css b/src/BlazorTable/Components/Pager.razor.css new file mode 100644 index 00000000..ef97bc6d --- /dev/null +++ b/src/BlazorTable/Components/Pager.razor.css @@ -0,0 +1,3 @@ +.page-link { + border: none; +} \ No newline at end of file diff --git a/src/BlazorTable/Localization/Localization.Designer.cs b/src/BlazorTable/Localization/Localization.Designer.cs index 1b71d565..51c77472 100644 --- a/src/BlazorTable/Localization/Localization.Designer.cs +++ b/src/BlazorTable/Localization/Localization.Designer.cs @@ -312,6 +312,15 @@ internal static string PagerPrevious { } } + /// + /// Looks up a localized string similar to Set Page Size. + /// + internal static string SetPageSize { + get { + return ResourceManager.GetString("SetPageSize", resourceCulture); + } + } + /// /// Looks up a localized string similar to Contains. /// diff --git a/src/BlazorTable/Localization/Localization.resx b/src/BlazorTable/Localization/Localization.resx index 73092e4d..1ebe5fb5 100644 --- a/src/BlazorTable/Localization/Localization.resx +++ b/src/BlazorTable/Localization/Localization.resx @@ -201,6 +201,9 @@ Previous + + Set Page Size + Contains From a6ea936479d28803a72018cfcacb1bd1963ae3b2 Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Mon, 28 Mar 2022 16:59:06 -0300 Subject: [PATCH 28/31] New version --- src/BlazorTable/BlazorTable.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index 11e88688..07a5b847 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -16,7 +16,7 @@ MIT true - 1.17.4-preview + 1.17.5-preview From 0ecfe9bbe1c1bf5988284b3584d15f2479b71d24 Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Fri, 1 Apr 2022 12:54:53 -0300 Subject: [PATCH 29/31] Fixing bug of select multiple then change the page size and select other items --- src/BlazorTable/BlazorTable.csproj | 2 +- src/BlazorTable/Components/Pager.razor | 2 +- src/BlazorTable/Components/Table.razor.cs | 5 ++++- src/BlazorTable/Interfaces/ITable.cs | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index 07a5b847..d6ea9986 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -16,7 +16,7 @@ MIT true - 1.17.5-preview + 1.17.6-preview diff --git a/src/BlazorTable/Components/Pager.razor b/src/BlazorTable/Components/Pager.razor index 30ac081d..a3c27f88 100644 --- a/src/BlazorTable/Components/Pager.razor +++ b/src/BlazorTable/Components/Pager.razor @@ -6,7 +6,7 @@
    @if (ShowPageSizes) { - @foreach (int option in PageSizes) { diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index a796c24e..f6c4df11 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -56,6 +56,8 @@ public partial class Table : ITable [Parameter] public int PageSize { get; set; } = DEFAULT_PAGE_SIZE; + public int? ServerPageSize { get; set; } + /// /// Allow Columns to be reordered /// @@ -266,7 +268,7 @@ private async Task LoadServerSideDataAsync() var result = await DataLoader.LoadDataAsync(new FilterData { - Top = PageSize, + Top = ServerPageSize.GetValueOrDefault(PageSize), Skip = PageNumber * PageSize, Query = GlobalSearch, OrderBy = sortExpression.ToString(), @@ -590,6 +592,7 @@ private Expression> GlobalSearchQuery(string value) public async Task SetPageSizeAsync(int pageSize) { PageSize = pageSize; + ServerPageSize = pageSize; PageNumber = 0; detailsViewOpen.Clear(); await UpdateAsync().ConfigureAwait(false); diff --git a/src/BlazorTable/Interfaces/ITable.cs b/src/BlazorTable/Interfaces/ITable.cs index 8d57c0c6..c5c203ca 100644 --- a/src/BlazorTable/Interfaces/ITable.cs +++ b/src/BlazorTable/Interfaces/ITable.cs @@ -14,6 +14,8 @@ public interface ITable ///
    int PageSize { get; } + int? ServerPageSize { get; } + /// /// Allow Columns to be reordered /// From c4134150a62baef4a054e3ce684317c5b9f96cfd Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Tue, 5 Apr 2022 17:25:17 -0300 Subject: [PATCH 30/31] Globar search on input key down and column with set --- src/BlazorTable/BlazorTable.csproj | 2 +- src/BlazorTable/Components/Pager.razor | 2 +- src/BlazorTable/Components/Pager.razor.cs | 25 ++++++++++++--------- src/BlazorTable/Components/Table.razor | 2 +- src/BlazorTable/Components/Table.razor.cs | 2 +- src/BlazorTable/Filters/DateFilter.razor.cs | 2 +- src/BlazorTable/Interfaces/ITableGen.cs | 2 +- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index d6ea9986..702d52f4 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -16,7 +16,7 @@ MIT true - 1.17.6-preview + 1.17.9-preview diff --git a/src/BlazorTable/Components/Pager.razor b/src/BlazorTable/Components/Pager.razor index a3c27f88..9e83ab82 100644 --- a/src/BlazorTable/Components/Pager.razor +++ b/src/BlazorTable/Components/Pager.razor @@ -18,7 +18,7 @@ @if (ShowPageNumberInput) {
    - @Localization["GoToPage"] + @Localization["GoToPage"]
    } diff --git a/src/BlazorTable/Components/Pager.razor.cs b/src/BlazorTable/Components/Pager.razor.cs index 8660831b..b6c40229 100644 --- a/src/BlazorTable/Components/Pager.razor.cs +++ b/src/BlazorTable/Components/Pager.razor.cs @@ -73,18 +73,23 @@ private async Task SetPageInput(KeyboardEventArgs e) { if (e.Code == "Enter" || e.Code == "NumpadEnter") { - if (inputPage > Table.TotalPages) - { - inputPage = Table.TotalPages; - } + await GoToPage().ConfigureAwait(false); + } + } + + private async Task GoToPage() + { + if (inputPage > Table.TotalPages) + { + inputPage = Table.TotalPages; + } - if (inputPage < 1) - { - inputPage = 1; - } - - await Table.GoToPageAsync(inputPage - 1).ConfigureAwait(false); + if (inputPage < 1) + { + inputPage = 1; } + + await Table.GoToPageAsync(inputPage - 1).ConfigureAwait(false); } } } diff --git a/src/BlazorTable/Components/Table.razor b/src/BlazorTable/Components/Table.razor index 634ff235..6eabc181 100644 --- a/src/BlazorTable/Components/Table.razor +++ b/src/BlazorTable/Components/Table.razor @@ -21,7 +21,7 @@ @if (ShowSearchBar) { - + } @if (Columns.Exists(column => !column.Visible)) { diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index f6c4df11..643455f6 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -115,7 +115,7 @@ public partial class Table : ITable /// /// List of All Available Columns /// - public List> Columns { get; } = new List>(); + public List> Columns { get; set; } = new List>(); /// /// Current Page Number diff --git a/src/BlazorTable/Filters/DateFilter.razor.cs b/src/BlazorTable/Filters/DateFilter.razor.cs index 5ae8864b..17bb6154 100644 --- a/src/BlazorTable/Filters/DateFilter.razor.cs +++ b/src/BlazorTable/Filters/DateFilter.razor.cs @@ -156,7 +156,7 @@ public FilterString GetFilterString() { Field = Column.Field.GetPropertyMemberInfo().Name, Condition = Condition.ToString(), - FilterValue = FilterValue.ToString() + FilterValue = FilterValue.ToString("MM-dd-yyyy") }; } } diff --git a/src/BlazorTable/Interfaces/ITableGen.cs b/src/BlazorTable/Interfaces/ITableGen.cs index 72eaa7ae..14a49b40 100644 --- a/src/BlazorTable/Interfaces/ITableGen.cs +++ b/src/BlazorTable/Interfaces/ITableGen.cs @@ -14,7 +14,7 @@ public interface ITable : ITable /// /// List of All Available Columns /// - List> Columns { get; } + List> Columns { get; set; } /// /// Adds a Column to the Table From 070cbebba1984a80b9e24d1f153c6834b0a0f098 Mon Sep 17 00:00:00 2001 From: sduboisOctaviantg Date: Thu, 14 Apr 2022 17:52:51 -0300 Subject: [PATCH 31/31] Adding a new th for using resize feacture --- src/BlazorTable/BlazorTable.csproj | 2 +- src/BlazorTable/Components/Table.razor | 18 ++++++++++++++++++ src/BlazorTable/Components/Table.razor.cs | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/BlazorTable/BlazorTable.csproj b/src/BlazorTable/BlazorTable.csproj index 702d52f4..37cf4d75 100644 --- a/src/BlazorTable/BlazorTable.csproj +++ b/src/BlazorTable/BlazorTable.csproj @@ -16,7 +16,7 @@ MIT true - 1.17.9-preview + 1.17.11-preview diff --git a/src/BlazorTable/Components/Table.razor b/src/BlazorTable/Components/Table.razor index 6eabc181..dd4e6dbc 100644 --- a/src/BlazorTable/Components/Table.razor +++ b/src/BlazorTable/Components/Table.razor @@ -139,6 +139,24 @@ } + @if(AddExtraTh) + { + + + @if (_detailTemplate != null) + { + + } + @foreach (IColumn column in Columns) + { + @if (column.Visible) + { + + } + } + + + } @if (FilteredItems != null) { diff --git a/src/BlazorTable/Components/Table.razor.cs b/src/BlazorTable/Components/Table.razor.cs index 643455f6..55e8fdcb 100644 --- a/src/BlazorTable/Components/Table.razor.cs +++ b/src/BlazorTable/Components/Table.razor.cs @@ -658,5 +658,11 @@ public async Task ClearFilterAsync(string columnName) [Parameter] public bool ShowChildContentAtTop { get; set; } + /// + /// Add a new th row + /// + [Parameter] + public bool AddExtraTh { get; set; } + } }