diff --git a/WatchList.MudBlazors/Model/FilterModel.cs b/WatchList.MudBlazors/Model/FilterModel.cs new file mode 100644 index 0000000..2f926ee --- /dev/null +++ b/WatchList.MudBlazors/Model/FilterModel.cs @@ -0,0 +1,28 @@ +using System.Collections.ObjectModel; +using Microsoft.AspNetCore.Components; +using WatchList.Core.Model.Filter; +using WatchList.Core.Model.Filter.Components; + +namespace WatchList.MudBlazors.Model +{ + public class FilterModel + { + public ObservableCollection TypeItem { get; set; } = new ObservableCollection(TypeFilter.List); + + public ObservableCollection StatusItem { get; set; } = new ObservableCollection(StatusFilter.List); + + [Parameter] + public TypeFilter Type { get; set; } = TypeFilter.AllCinema; + + [Parameter] + public StatusFilter Status { get; set; } = StatusFilter.AllCinema; + + public FilterItem GetFilter() => new FilterItem(Type, Status); + + public void Clear() + { + Type = TypeFilter.AllCinema; + Status = StatusFilter.AllCinema; + } + } +} diff --git a/WatchList.MudBlazors/Model/SortModel.cs b/WatchList.MudBlazors/Model/SortModel.cs new file mode 100644 index 0000000..405cfe1 --- /dev/null +++ b/WatchList.MudBlazors/Model/SortModel.cs @@ -0,0 +1,16 @@ +using System.Collections.ObjectModel; +using WatchList.Core.Model.Sorting; + +namespace WatchList.MudBlazors.Model +{ + public class SortModel + { + public ObservableCollection Items { get; set; } = new ObservableCollection(SortField.List); + + public SortField Type { get; set; } = SortField.Title; + + public SortField GetSortItem() => Type; + + public void Clear() => Type = SortField.Title; + } +} diff --git a/WatchList.MudBlazors/Pages/WatchCinemaTable.razor b/WatchList.MudBlazors/Pages/WatchCinemaTable.razor index b534805..cd9151e 100644 --- a/WatchList.MudBlazors/Pages/WatchCinemaTable.razor +++ b/WatchList.MudBlazors/Pages/WatchCinemaTable.razor @@ -1,4 +1,6 @@ -@using WatchList.Core.Model.ItemCinema +@using Bromix.MudBlazor.MaterialDesignIcons +@using WatchList.Core.Model.Filter.Components +@using WatchList.Core.Model.ItemCinema @page "/watchlist" @@ -6,6 +8,37 @@ + + + + +
+ + @foreach (var item in Filter.TypeItem.ToList()) + { + + } + +
+ +
+ + @foreach (var item in Filter.StatusItem.ToList()) + { + + } + +
+ + + + + + + + +
+ diff --git a/WatchList.MudBlazors/Pages/WatchCinemaTable.razor.cs b/WatchList.MudBlazors/Pages/WatchCinemaTable.razor.cs index 9093f25..95ae72f 100644 --- a/WatchList.MudBlazors/Pages/WatchCinemaTable.razor.cs +++ b/WatchList.MudBlazors/Pages/WatchCinemaTable.razor.cs @@ -30,6 +30,9 @@ public partial class WatchCinemaTable private WatchItemSearchRequest _itemsSearchRequest = new WatchItemSearchRequest(); private PagedList? _pagedList = null; + private FilterModel Filter { get; set; } = new FilterModel(); + private SortModel Sort { get; set; } = new SortModel(); + protected override void OnInitialized() { _itemsSearchRequest = new WatchItemSearchRequest(new FilterItem(), SortField.Title, _pageModel); @@ -81,6 +84,8 @@ private async Task RemoveItemDialog(Guid id) private void LoadData() { + _itemsSearchRequest.Filter = Filter.GetFilter(); + _itemsSearchRequest.Sort = Sort.GetSortItem(); _pagedList = WatchItemService.GetPage(_itemsSearchRequest); _items = _pagedList.Items; StateHasChanged(); @@ -91,5 +96,12 @@ private void OnSelectItems(HashSet items) _selectedItems = items; _isSelectItems = _selectedItems.Count <= 0; } + + private void ClearFilter() + { + Filter.Clear(); + Sort.Clear(); + LoadData(); + } } } diff --git a/WatchList.MudBlazors/app.db-shm b/WatchList.MudBlazors/app.db-shm index d8fd19a..02ded72 100644 Binary files a/WatchList.MudBlazors/app.db-shm and b/WatchList.MudBlazors/app.db-shm differ diff --git a/WatchList.MudBlazors/app.db-wal b/WatchList.MudBlazors/app.db-wal index bcee2e6..a27bf39 100644 Binary files a/WatchList.MudBlazors/app.db-wal and b/WatchList.MudBlazors/app.db-wal differ