Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
<PackageReference Include="System.Linq.Async" Version="7.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="10.0.0">
<PackageReference Include="coverlet.collector" Version="10.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion Mimeo.DynamicUI.Blazor/Controls/CustomRadzenDataGrid.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@typeparam TItem
@typeparam TItem where TItem : notnull
@inherits RadzenDataGrid<TItem>

@inject TaskRunningService taskRunningService
Expand Down
20 changes: 20 additions & 0 deletions Mimeo.DynamicUI.Blazor/Extensions/RadzenLoadDataArgsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public static DataQuery ToODataQuery(this LoadDataArgs args, ViewModel viewModel
};
foreach (var filter in args.Filters ?? [])
{
if (string.IsNullOrEmpty(filter.Property))
{
continue;
}

var formFieldDefinition = viewModel.GetListForm().Values.SingleOrDefault(f => f.PropertyName == filter.Property);
if (formFieldDefinition == null)
{
Expand All @@ -32,6 +37,11 @@ public static DataQuery ToODataQuery(this LoadDataArgs args, ViewModel viewModel
}
foreach (var sort in args.Sorts ?? [])
{
if (string.IsNullOrEmpty(sort.Property))
{
continue;
}

var formFieldDefinition = viewModel.GetListForm().Values.SingleOrDefault(f => f.PropertyName == sort.Property);
if (formFieldDefinition == null)
{
Expand Down Expand Up @@ -69,6 +79,11 @@ FormFieldDefinition getFormField(string propertyName, object? filterValue)
};
foreach (var filter in args.Filters ?? [])
{
if (string.IsNullOrEmpty(filter.Property))
{
continue;
}

if (filter.FilterValue != null)
{
query.Filters.Add(new DataQueryFilter(new DataFieldDefinition(getFormField(filter.Property, filter.FilterValue)), ToDataFilterOperator(filter.FilterOperator), filter.FilterValue));
Expand All @@ -81,6 +96,11 @@ FormFieldDefinition getFormField(string propertyName, object? filterValue)

foreach (var sort in args.Sorts ?? [])
{
if (string.IsNullOrEmpty(sort.Property))
{
continue;
}

query.Sorts.Add(new DataQuerySort(new DataFieldDefinition(getFormField(sort.Property, null)), sort.SortOrder == SortOrder.Descending));
}
return query;
Expand Down
4 changes: 2 additions & 2 deletions Mimeo.DynamicUI.Blazor/Forms/CustomRadzenDataGridColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Mimeo.DynamicUI.Blazor.Forms;

public class CustomRadzenDataGridColumn<TItem> : RadzenDataGridColumn<TItem>
public class CustomRadzenDataGridColumn<TItem> : RadzenDataGridColumn<TItem> where TItem : notnull
{
private static readonly IReadOnlyDictionary<FilterOperator, string> DataFilterOperators = new Dictionary<FilterOperator, string>
{
Expand All @@ -23,7 +23,7 @@ public class CustomRadzenDataGridColumn<TItem> : RadzenDataGridColumn<TItem>
{FilterOperator.IsNotEmpty, "ne"}
};

protected override string GetColumnODataFilter(object filterValue, FilterOperator filterOperator)
protected override string GetColumnODataFilter(object? filterValue, FilterOperator filterOperator)
{
var odataOperator = DataFilterOperators[filterOperator];
var property = GetFilterProperty().Replace('.', '/');
Expand Down
5 changes: 2 additions & 3 deletions Mimeo.DynamicUI.Blazor/Forms/DataFilter/DataFilterField.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@using Mimeo.DynamicUI.Blazor.Extensions
@using Radzen.Blazor.Rendering

<div @ref=_customSplitButton class="data-filter-field">
<button class="data-filter-field-primary" @onclick="@(() => _popup!.ToggleAsync(_customSplitButton))">
Expand All @@ -12,10 +11,10 @@
</button>
</div>

<Popup @ref=_popup class="data-field-popup" Style="display:none;position:absolute;width:300px;padding:5px;border:var(--rz-panel-border);background-color:var(--rz-panel-background-color);">
<RadzenPopup @ref=_popup class="data-field-popup" Style="display:none;position:absolute;width:300px;padding:5px;border:var(--rz-panel-border);background-color:var(--rz-panel-background-color);">
<div class="data-field-popup-content">
<RadzenDropDown TValue="FilterOperatorItem" Data="_filterOperators" @bind-Value=SelectedFilterOperator TextProperty="Label" />
<DynamicField FormField="@Filter.FilterDefinition.FormFieldDefinition" ViewModel="@Filter" For="@(() => Filter.Value)" />
<RadzenButton Text="@lang.GetValueOrDefault("save")" Click="@OnSave" />
</div>
</Popup>
</RadzenPopup>
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
using Mimeo.DynamicUI.Blazor.Extensions;
using Mimeo.DynamicUI.Data;
using Mimeo.DynamicUI.Data.OData;
using Radzen.Blazor.Rendering;
using Radzen.Blazor;

namespace Mimeo.DynamicUI.Blazor.Forms.DataFilter
{
public partial class DataFilterField
{
private ElementReference _customSplitButton;
private Popup? _popup;
private RadzenPopup? _popup;
private IEnumerable<FilterOperatorItem>? _filterOperators;

[Parameter]
Expand Down
9 changes: 8 additions & 1 deletion Mimeo.DynamicUI.Blazor/Forms/ODataGrid.razor
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@

@if (SupportsSearchText)
{
<RadzenAutoComplete @bind-Value="@filterViewModel.SearchText" Data="@searchSuggestions" Placeholder="@lang.GetValueOrDefault("datafilter_searchtextplaceholder")" LoadData="@LoadSearchSuggestions" Change="@OnSearchChanged" Style="flex:1" InputType="search" />
@if (SupportsSearchAutoComplete)
{
<RadzenAutoComplete @bind-Value="@filterViewModel.SearchText" Data="@searchSuggestions" Placeholder="@lang.GetValueOrDefault("datafilter_searchtextplaceholder")" LoadData="@LoadSearchSuggestions" Change="@OnSearchChanged" Style="flex:1" InputType="search" />
}
else
{
<RadzenTextBox @bind-Value="@filterViewModel.SearchText" Change="OnSearchChanged" Placeholder="@lang.GetValueOrDefault("datafilter_searchtextplaceholder")" Style="flex:1" />
}
}

<RadzenDropDown @ref="addFilterDropdown"
Expand Down
15 changes: 13 additions & 2 deletions Mimeo.DynamicUI.Blazor/Forms/ODataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public partial class ODataGrid
private bool CanDelete => (Service?.SupportsDelete ?? false) && AllowDelete;
private bool CanView => (Service?.SupportsView ?? false) && AllowView;
private bool SupportsSearchText => Service?.SupportsSearchText ?? false;
private bool SupportsSearchAutoComplete => Service?.SupportsSearchAutoComplete ?? false;

private RadzenDataGrid<GridItem>? gridRef;
private bool IsSmall;
Expand Down Expand Up @@ -213,18 +214,28 @@ private async Task LoadData(LoadDataArgs args)
}

// Work around Radzen bug where it's not thread safe
args.Filters = args.Filters.ToList();
args.Sorts = args.Sorts.ToList();
args.Filters = args.Filters?.ToList() ?? [];
args.Sorts = args.Sorts?.ToList() ?? [];

// The GridItem class is private to this control
// Filters and sorts will be on a GridItem property,
// but we need to feed the actual property to ListMethod()
foreach (var filter in args.Filters)
{
if (string.IsNullOrEmpty(filter.Property))
{
continue;
}

filter.Property = filter.Property.Replace($"{nameof(GridItem.ListModel)}.", "").Replace($"{nameof(GridItem.ListModel)}/", "");
}
foreach (var orderBy in args.Sorts)
{
if (string.IsNullOrEmpty(orderBy.Property))
{
continue;
}

orderBy.Property = orderBy.Property.Replace($"{nameof(GridItem.ListModel)}.", "").Replace($"{nameof(GridItem.ListModel)}/", "");
}
searchModel ??= await taskRunningService.Run(() => Service.GetSearchModel());
Expand Down
26 changes: 8 additions & 18 deletions Mimeo.DynamicUI.Blazor/Mimeo.DynamicUI.Blazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<TargetFrameworks>net10.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand All @@ -20,25 +20,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BlazorMonaco" Version="3.4.0" />
<PackageReference Include="BlazorMonaco" Version="3.5.0" />
<PackageReference Include="CsvHelper" Version="33.1.0" />
<PackageReference Include="DecimalMath.DecimalEx" Version="1.0.2" />
<PackageReference Include="NodaTime" Version="3.3.2" />
<PackageReference Include="Radzen.Blazor" Version="10.3.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.26" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.26" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.26" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.26" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="10.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="10.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="10.0.7" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="10.0.7" />
<PackageReference Include="NodaTime" Version="3.3.3" />
<PackageReference Include="Radzen.Blazor" Version="11.1.7" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="10.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="10.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="10.0.10" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="10.0.10" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.10" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.10" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.10" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public TestDataService(HttpClient httpClient, ODataExpressionGenerator oDataExpr

public bool SupportsSearchText => true;

public bool SupportsSearchAutoComplete => true;

public async Task<DataResponse<TestViewModel>> GetModels(DataQuery args)
{
var apiUrl = $"{this.apiUrl}/Test";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<ItemGroup>
<ProjectReference Include="..\Mimeo.DynamicUI.Demo.Client\Mimeo.DynamicUI.Demo.Client.csproj" />
<ProjectReference Include="..\Mimeo.DynamicUI.Demo.Shared\Mimeo.DynamicUI.Demo.Shared.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.7" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.4.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.10" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.5.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions Mimeo.DynamicUI.Tests/Mimeo.DynamicUI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AwesomeAssertions" Version="9.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
<PackageReference Include="AwesomeAssertions" Version="9.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="System.Linq.Async" Version="7.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="10.0.0">
<PackageReference Include="coverlet.collector" Version="10.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 2 additions & 0 deletions Mimeo.DynamicUI/Data/IDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ public interface IReadOnlyDataService
{
bool SupportsView { get; }
bool SupportsSearchText { get; }
public bool SupportsSearchAutoComplete => SupportsSearchText;

Task<DataResponse<ViewModel>> GetModels(DataQuery args);
Task<ViewModel> GetNewListModel();

Expand Down
2 changes: 1 addition & 1 deletion Mimeo.DynamicUI/Mimeo.DynamicUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<PackageReference Include="CsvHelper" Version="33.1.0" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="10.0.7" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="10.0.10" />
<PackageReference Include="System.Linq.Async" Version="7.0.1" />
</ItemGroup>

Expand Down
Loading