Skip to content

Commit

Permalink
#3242 - WIP of in-table filtering and sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Metal-Mighty committed Oct 28, 2024
1 parent cf7bbb2 commit 2ec4863
Show file tree
Hide file tree
Showing 30 changed files with 513 additions and 476 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@* <MudStack Spacing="0">
<MudCheckBox T="bool" Label="Select All"
Size="Size.Small"
Value="@selectAll" ValueChanged="@SelectAll" />
<MudStack Spacing="0">
@foreach (var item in @Items)
{
<MudStack Row="true" AlignItems="AlignItems.Center" Wrap="Wrap.NoWrap">
<MudCheckBox T="bool"
Size="Size.Small"
Value="@(selectedItems.Contains(item))"
ValueChanged="@((value) => SelectedChanged(value, item))" />
<img src="@(item.Image)" alt="@(item.Image) device model image" />
<MudText>@item.Name</MudText>
</MudStack>
}
</MudStack>
<MudStack Row="true">
<MudButton Color="@Color.Primary" OnClick="@(() => ApplyFilterAsync(Context))">Filter</MudButton>
</MudStack>
</MudStack>
*@
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//// Copyright (c) CGI France. All rights reserved.
//// Licensed under the MIT license. See LICENSE file in the project root for full license information.

//namespace IoTHub.Portal.Client.Components.Commons
//{
// using Enums;
// using MudBlazor;

// public partial class DeviceModelDataGridFilter
// {
// private bool filterOpen = false;
// private bool selectAll = true;
// private HashSet<DeviceModelDto> selectedItems = new();
// private HashSet<DeviceModelDto> filterItems = new();
// private FilterDefinition<DeviceModelDto> filterDefinition;


// [Parameter] public IEnumerable<DeviceModelDto> Items { get; set; }

// //[Parameter] public FilterContext<DeviceModelDto> Context {get;}

// protected override Task OnInitializedAsync()
// {
// this.selectedItems = Items.ToHashSet();
// this.filterItems = Items.ToHashSet();
// this.filterDefinition = new FilterDefinition<DeviceModelDto>
// {
// FilterFunction = x => this.filterItems.Contains(x)
// };

// return base.OnInitializedAsync();
// }

// //private void OpenFilter()
// //{
// // this.filterOpen = true;
// //}

// private void SelectedChanged(bool value, DeviceModelDto item)
// {
// _ = value ? this.selectedItems.Add(item) : this.selectedItems.Remove(item);

// this.selectAll = this.selectedItems.Count == Items.Count();
// }

// //private async Task ApplyFilterAsync(FilterContext<DeviceModelDto> context)
// //{
// // filterItems = selectedItems.ToHashSet();
// // //_icon = _filterItems.Count == Items.Count() ? Icons.Material.Outlined.FilterAlt : Icons.Material.Filled.FilterAlt;
// // await context.Actions.ApplyFilterAsync(filterDefinition);
// // filterOpen = false;
// //}

// private void SelectAll(bool value)
// {
// selectAll = value;

// if (value)
// {
// selectedItems = Items.ToHashSet();
// }
// else
// {
// selectedItems.Clear();
// }
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<MudExpansionPanel Text="Search panel">
<MudGrid>
<MudItem xs="12" md="6">
<MudTextField @bind-Value="searchKeyword" Placeholder="DeviceID / DeviceName" id="searchKeyword"></MudTextField>
<MudTextField @bind-Value="searchKeyword" Placeholder="DeviceID / Name" id="searchKeyword"></MudTextField>
</MudItem>
<MudGrid>
<MudItem sm="12" md="6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
T="DeviceListItem"
Label="Search a device to duplicate"
SearchFunc="@SearchDevicesToDuplicate"
ToStringFunc="@(x => x?.DeviceName)"
ToStringFunc="@(x => x?.Name)"
DebounceInterval="300"
ValueChanged="OnDeviceSelected"
Dense=true
Expand All @@ -23,7 +23,7 @@
Variant="Variant.Outlined"
Required="true">
<ItemTemplate>
@context.DeviceName
@context.Name
<MudText Typo="Typo.subtitle1" Class="mud-input-helper-text">
Id: @context.DeviceID
</MudText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</MudTd>
<MudTd DataLabel="Device">
<MudItem>
<MudText Typo="Typo.body1" Inline="true">@context.DeviceName</MudText>
<MudText Typo="Typo.body1" Inline="true">@context.Name</MudText>
</MudItem>
</MudTd>
<MudTd DataLabel="Delete" Style="text-align: center">
Expand Down Expand Up @@ -223,7 +223,7 @@
if (device == null) return deviceDetails;

deviceDetails.DeviceID = device.DeviceID;
deviceDetails.DeviceName = device.DeviceName;
deviceDetails.DeviceName = device.Name;
deviceDetails.ModelId = device.DeviceModelId;
deviceDetails.Image = device.Image;
deviceDetails.IsConnected = device.IsConnected;
Expand Down
5 changes: 5 additions & 0 deletions src/IoTHub.Portal.Client/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

global using Microsoft.AspNetCore.Components;
global using IoTHub.Portal.Models.v10;
1 change: 1 addition & 0 deletions src/IoTHub.Portal.Client/IoTHub.Portal.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
</PackageReference>
<PackageReference Include="MudBlazor" Version="6.21.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
<PackageReference Include="Tewr.Blazor.FileReader" Version="3.3.2.23201" />

Expand Down
Loading

0 comments on commit 2ec4863

Please sign in to comment.