-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,599 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.5" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.5" PrivateAssets="all" /> | ||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" /> | ||
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" /> | ||
</ItemGroup> | ||
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> | ||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Sample.Core\Sample.Core.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.5" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.5" PrivateAssets="all" /> | ||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" /> | ||
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Sample.Core\Sample.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
samples/Sample.Core/Pages/QueryBuilder/Examples/Basic.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@using LoreSoft.Blazor.Controls.Utilities | ||
@using Sample.Core.Models | ||
@using System.Text.Json | ||
|
||
<h3 class="m-2">Basic</h3> | ||
|
||
<QueryBuilder TItem="Bank" @bind-Query="Query"> | ||
<QueryFields> | ||
<QueryBuilderField Field="p => p.Id" /> | ||
<QueryBuilderField Field="p => p.AccountNumber" /> | ||
<QueryBuilderField Field="p => p.IBAN" /> | ||
<QueryBuilderField Field="p => p.BankName" /> | ||
<QueryBuilderField Field="p => p.RoutingNumber" /> | ||
<QueryBuilderField Field="p => p.SwiftBIC" /> | ||
<QueryBuilderField Field="p => p.IsActive" /> | ||
<QueryBuilderField Field="p => p.Created" /> | ||
</QueryFields> | ||
</QueryBuilder> | ||
<h4 class="m-2">Query JSON</h4> | ||
<pre style="max-height: 400px; max-width: calc(100vw - 4em);"><code class="language-json">@Serialize(Query)</code></pre> | ||
@code { | ||
protected QueryGroup Query { get; set; } = new() | ||
{ | ||
Filters = new List<QueryRule> | ||
{ | ||
new QueryFilter{ Field = nameof(Bank.BankName), Operator = QueryOperators.Contains, Value = "Wells Fargo" }, | ||
new QueryFilter{ Field = nameof(Bank.IsActive), Operator = QueryOperators.Equal, Value = true }, | ||
} | ||
}; | ||
|
||
protected string Serialize(QueryGroup query) | ||
{ | ||
var options = new JsonSerializerOptions(JsonSerializerDefaults.Web); | ||
options.WriteIndented = true; | ||
return JsonSerializer.Serialize(query, options); | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
samples/Sample.Core/Pages/QueryBuilder/Examples/Templates.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@using LoreSoft.Blazor.Controls.Utilities | ||
@using Sample.Core.Models | ||
@using System.Text.Json | ||
|
||
<h3 class="m-2">Using Templates</h3> | ||
|
||
<QueryBuilder TItem="Bank" @bind-Query="Query"> | ||
<QueryFields> | ||
<QueryBuilderField Field="p => p.Id" /> | ||
<QueryBuilderField Field="p => p.AccountNumber" /> | ||
<QueryBuilderField Field="p => p.IBAN" /> | ||
<QueryBuilderField Field="p => p.BankName"> | ||
<ValueTemplate Context="filter"> | ||
<select value="@Binding.Format(filter.Value)" | ||
@onchange="e => filter.Value = Binding.Convert<string>(e.Value)"> | ||
<option>- Select Bank -</option> | ||
<option value="Chase Bank">Chase Bank</option> | ||
<option value="Bank of America">Bank of America</option> | ||
<option value="Wells Fargo">Wells Fargo</option> | ||
<option value="Citibank">Citibank</option> | ||
<option value="U.S. Bank">U.S. Bank</option> | ||
<option value="PNC Bank">PNC Bank</option> | ||
<option value="Goldman Sachs Bank">Goldman Sachs Bank</option> | ||
<option value="Truist Bank">Truist Bank</option> | ||
<option value="Capital One">Capital One</option> | ||
<option value="TD Bank">TD Bank</option> | ||
</select> | ||
</ValueTemplate> | ||
</QueryBuilderField> | ||
<QueryBuilderField Field="p => p.RoutingNumber" /> | ||
<QueryBuilderField Field="p => p.SwiftBIC" /> | ||
<QueryBuilderField Field="p => p.IsActive" /> | ||
<QueryBuilderField Field="p => p.Created" /> | ||
</QueryFields> | ||
</QueryBuilder> | ||
<h4 class="m-2">Query JSON</h4> | ||
<pre style="max-height: 400px; max-width: calc(100vw - 4em);"><code class="language-json">@Serialize(Query)</code></pre> | ||
@code { | ||
protected QueryGroup Query { get; set; } = new() | ||
{ | ||
Filters = new List<QueryRule> | ||
{ | ||
new QueryFilter{ Field = nameof(Bank.BankName), Operator = QueryOperators.Contains, Value = "Wells Fargo" }, | ||
new QueryFilter{ Field = nameof(Bank.IsActive), Operator = QueryOperators.Equal, Value = true }, | ||
new QueryGroup { | ||
Logic = QueryLogic.Or, | ||
Filters = new List<QueryRule> | ||
{ | ||
new QueryFilter{ Field = nameof(Bank.AccountNumber), Operator = QueryOperators.Equal, Value = "88888" }, | ||
new QueryFilter{ Field = nameof(Bank.AccountNumber), Operator = QueryOperators.Equal, Value = "99999" }, | ||
} | ||
} | ||
} | ||
}; | ||
|
||
protected string Serialize(QueryGroup query) | ||
{ | ||
var options = new JsonSerializerOptions(JsonSerializerDefaults.Web); | ||
options.WriteIndented = true; | ||
return JsonSerializer.Serialize(query, options); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@page "/query/index" | ||
@using Sample.Core.Models | ||
@using System.Text.Json | ||
@using Sample.Core.Pages.QueryBuilder.Examples | ||
|
||
@inject IJSRuntime JsRuntime; | ||
|
||
<h1>Query Builder</h1> | ||
|
||
<p>Query Builder Control</p> | ||
|
||
<Instructions></Instructions> | ||
|
||
<h2 class="m-3">Examples</h2> | ||
|
||
<Basic /> | ||
|
||
<Templates /> | ||
|
||
@code { | ||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
Check warning on line 21 in samples/Sample.Core/Pages/QueryBuilder/Index.razor GitHub Actions / build
Check warning on line 21 in samples/Sample.Core/Pages/QueryBuilder/Index.razor GitHub Actions / build
|
||
{ | ||
base.OnAfterRender(firstRender); | ||
//TODO fix highlight, breaks data binding | ||
//await JsRuntime.InvokeAsync<object>("Prism.highlightAll"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.