Skip to content

Commit 1443813

Browse files
committed
improve multiselection properties
1 parent 9b77a23 commit 1443813

19 files changed

Lines changed: 446 additions & 139 deletions

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerCheckboxProperty.razor

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
<Field Horizontal Margin="MarginIs0FromBottomIs0OnX">
55
<FieldLabel ColumnSize="ColumnSizeIs4" TextSize="TextSizeSmall" Padding="PaddingIs1FromEnd" TextOverflow="TextOverflowTruncate">@Label</FieldLabel>
66
<FieldBody ColumnSize="ColumnSizeIs8">
7-
<Select TValue="bool" Value="@Value" ValueChanged="@Changed" Size="Size.Small">
8-
<SelectItem TValue="bool" Value="@true">True</SelectItem>
9-
<SelectItem TValue="bool" Value="@false">False</SelectItem>
7+
<Select TValue="bool?" Value="@DisplayValue" ValueChanged="@OnValueChanged" Size="Size.Small">
8+
@if ( Mixed )
9+
{
10+
<SelectItem TValue="bool?" Value="@((bool?)null)" Hidden></SelectItem>
11+
}
12+
<SelectItem TValue="bool?" Value="@true">True</SelectItem>
13+
<SelectItem TValue="bool?" Value="@false">False</SelectItem>
1014
</Select>
1115
</FieldBody>
1216
</Field>

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerCheckboxProperty.razor.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#region Using directives
2+
using System.Threading.Tasks;
23
using Microsoft.AspNetCore.Components;
34
#endregion
45

@@ -9,8 +10,17 @@ namespace Blazorise.Reporting.Internal;
910
/// </summary>
1011
public partial class _ReportDesignerCheckboxProperty
1112
{
13+
#region Methods
14+
15+
private Task OnValueChanged( bool? value )
16+
=> value.HasValue ? Changed.InvokeAsync( value.Value ) : Task.CompletedTask;
17+
18+
#endregion
19+
1220
#region Properties
1321

22+
private bool? DisplayValue => Mixed ? null : Value;
23+
1424
/// <summary>
1525
/// Property label.
1626
/// </summary>
@@ -21,6 +31,11 @@ public partial class _ReportDesignerCheckboxProperty
2131
/// </summary>
2232
[Parameter] public bool Value { get; set; }
2333

34+
/// <summary>
35+
/// Indicates that selected elements have different values.
36+
/// </summary>
37+
[Parameter] public bool Mixed { get; set; }
38+
2439
/// <summary>
2540
/// Raised when the checkbox value changes.
2641
/// </summary>

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerColorProperty.razor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
<Addons Size="Size.Small">
88
<Addon AddonType="AddonType.Body">
99
<Select TValue="string" Value="@SelectedName" ValueChanged="@OnNameChanged" Size="Size.Small">
10+
@if ( Mixed )
11+
{
12+
<SelectItem TValue="string" Value="@MixedValue" Hidden></SelectItem>
13+
}
1014
@foreach ( var option in DefaultNamedOptions )
1115
{
1216
<SelectItem TValue="string" Value="@option.Value">@option.Text</SelectItem>

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerColorProperty.razor.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public partial class _ReportDesignerColorProperty
1313
{
1414
#region Members
1515

16+
private const string MixedValue = "__b_report_mixed__";
17+
1618
private static readonly (string Value, string Text)[] DefaultNamedOptions =
1719
[
1820
( string.Empty, "Default" ),
@@ -48,9 +50,12 @@ private Task Clear()
4850

4951
private Task OnNameChanged( string value )
5052
{
53+
if ( value == MixedValue )
54+
return Task.CompletedTask;
55+
5156
ReportColor color = ReportColor.FromString( value );
5257

53-
return color.Equals( Value )
58+
return !Mixed && color.Equals( Value )
5459
? Task.CompletedTask
5560
: Changed.InvokeAsync( color );
5661
}
@@ -62,7 +67,7 @@ private Task OnCustomChanged( string value )
6267

6368
ReportColor color = ReportColor.FromString( value );
6469

65-
return string.Equals( color.ToCssString(), Value.ToCssString(), StringComparison.OrdinalIgnoreCase )
70+
return !Mixed && string.Equals( color.ToCssString(), Value.ToCssString(), StringComparison.OrdinalIgnoreCase )
6671
? Task.CompletedTask
6772
: Changed.InvokeAsync( color );
6873
}
@@ -71,11 +76,15 @@ private Task OnCustomChanged( string value )
7176

7277
#region Properties
7378

74-
private string SelectedName => Value.Kind == ReportColorKind.Named || Value.Kind == ReportColorKind.Transparent
79+
private string SelectedName => Mixed
80+
? MixedValue
81+
: Value.Kind == ReportColorKind.Named || Value.Kind == ReportColorKind.Transparent
7582
? Value.Name
7683
: string.Empty;
7784

78-
private string CustomValue => Value.Kind == ReportColorKind.Rgb
85+
private string CustomValue => Mixed
86+
? null
87+
: Value.Kind == ReportColorKind.Rgb
7988
? FormattableString.Invariant( $"#{Value.Red:X2}{Value.Green:X2}{Value.Blue:X2}" )
8089
: Value.Kind == ReportColorKind.Named
8190
? Value.ToCssString()
@@ -91,6 +100,11 @@ private Task OnCustomChanged( string value )
91100
/// </summary>
92101
[Parameter] public ReportColor Value { get; set; }
93102

103+
/// <summary>
104+
/// Indicates that selected elements have different values.
105+
/// </summary>
106+
[Parameter] public bool Mixed { get; set; }
107+
94108
/// <summary>
95109
/// Raised when the color value changes.
96110
/// </summary>

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerDataSourceProperty.razor.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ private Task OnClicked()
2525

2626
#region Properties
2727

28-
private string DisplayValue => string.IsNullOrWhiteSpace( DisplayText )
28+
private string DisplayValue => Mixed
29+
? null
30+
: string.IsNullOrWhiteSpace( DisplayText )
2931
? string.IsNullOrWhiteSpace( Value ) ? "None" : Value
3032
: DisplayText;
3133

@@ -39,6 +41,11 @@ private Task OnClicked()
3941
/// </summary>
4042
[Parameter] public string Value { get; set; }
4143

44+
/// <summary>
45+
/// Indicates that selected elements have different values.
46+
/// </summary>
47+
[Parameter] public bool Mixed { get; set; }
48+
4249
/// <summary>
4350
/// Friendly text shown for the selected data source.
4451
/// </summary>

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerFormulaBooleanProperty.razor

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
<FieldBody ColumnSize="ColumnSizeIs8">
77
<Addons Size="Size.Small">
88
<Addon AddonType="AddonType.Body">
9-
<Select TValue="bool" Value="@Value" ValueChanged="@Changed" Size="Size.Small">
10-
<SelectItem TValue="bool" Value="@true">True</SelectItem>
11-
<SelectItem TValue="bool" Value="@false">False</SelectItem>
9+
<Select TValue="bool?" Value="@DisplayValue" ValueChanged="@OnValueChanged" Size="Size.Small">
10+
@if ( Mixed )
11+
{
12+
<SelectItem TValue="bool?" Value="@((bool?)null)" Hidden></SelectItem>
13+
}
14+
<SelectItem TValue="bool?" Value="@true">True</SelectItem>
15+
<SelectItem TValue="bool?" Value="@false">False</SelectItem>
1216
</Select>
1317
</Addon>
1418
<Addon AddonType="AddonType.End">

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerFormulaBooleanProperty.razor.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#region Using directives
2+
using System.Threading.Tasks;
23
using Microsoft.AspNetCore.Components;
34
#endregion
45

@@ -9,8 +10,17 @@ namespace Blazorise.Reporting.Internal;
910
/// </summary>
1011
public partial class _ReportDesignerFormulaBooleanProperty
1112
{
13+
#region Methods
14+
15+
private Task OnValueChanged( bool? value )
16+
=> value.HasValue ? Changed.InvokeAsync( value.Value ) : Task.CompletedTask;
17+
18+
#endregion
19+
1220
#region Properties
1321

22+
private bool? DisplayValue => Mixed ? null : Value;
23+
1424
private Color FormulaButtonColor => string.IsNullOrWhiteSpace( Formula ) ? Color.Light : Color.Primary;
1525

1626
/// <summary>
@@ -23,6 +33,11 @@ public partial class _ReportDesignerFormulaBooleanProperty
2333
/// </summary>
2434
[Parameter] public bool Value { get; set; }
2535

36+
/// <summary>
37+
/// Indicates that selected elements have different fallback values.
38+
/// </summary>
39+
[Parameter] public bool Mixed { get; set; }
40+
2641
/// <summary>
2742
/// Current formula expression.
2843
/// </summary>

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerFormulaSelectProperty.razor

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
<FieldBody ColumnSize="ColumnSizeIs8">
77
<Addons Size="Size.Small">
88
<Addon AddonType="AddonType.Body">
9-
<Select TValue="string" Value="@Value" ValueChanged="@Changed" Size="Size.Small">
9+
<Select TValue="string" Value="@DisplayValue" ValueChanged="@OnValueChanged" Size="Size.Small">
10+
@if ( Mixed )
11+
{
12+
<SelectItem TValue="string" Value="@MixedValue" Hidden></SelectItem>
13+
}
1014
@foreach ( var option in ResolvedOptions )
1115
{
1216
<SelectItem TValue="string" Value="@option.Value">@option.Text</SelectItem>

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerFormulaSelectProperty.razor.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#region Using directives
22
using System.Collections.Generic;
3+
using System.Threading.Tasks;
34
using Microsoft.AspNetCore.Components;
45
#endregion
56

@@ -10,12 +11,27 @@ namespace Blazorise.Reporting.Internal;
1011
/// </summary>
1112
public partial class _ReportDesignerFormulaSelectProperty
1213
{
14+
#region Members
15+
16+
private const string MixedValue = "__b_report_mixed__";
17+
18+
#endregion
19+
20+
#region Methods
21+
22+
private Task OnValueChanged( string value )
23+
=> value == MixedValue ? Task.CompletedTask : Changed.InvokeAsync( value );
24+
25+
#endregion
26+
1327
#region Properties
1428

1529
private Color FormulaButtonColor => string.IsNullOrWhiteSpace( Formula ) ? Color.Light : Color.Primary;
1630

1731
private IReadOnlyList<(string Value, string Text)> ResolvedOptions => Options ?? [];
1832

33+
private string DisplayValue => Mixed ? MixedValue : Value;
34+
1935
/// <summary>
2036
/// Property label.
2137
/// </summary>
@@ -26,6 +42,11 @@ public partial class _ReportDesignerFormulaSelectProperty
2642
/// </summary>
2743
[Parameter] public string Value { get; set; }
2844

45+
/// <summary>
46+
/// Indicates that selected elements have different fallback values.
47+
/// </summary>
48+
[Parameter] public bool Mixed { get; set; }
49+
2950
/// <summary>
3051
/// Current formula expression.
3152
/// </summary>

Source/Extensions/Blazorise.Reporting/Internal/Components/_ReportDesignerImageSourceProperty.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<FieldBody ColumnSize="ColumnSizeIs8">
77
<Addons Size="Size.Small">
88
<Addon AddonType="AddonType.Body">
9-
<TextInput Value="@Value" ReadOnly="@ReadOnly" ValueChanged="@Changed" Immediate="@Changed.HasDelegate" Size="Size.Small" />
9+
<TextInput Value="@DisplayValue" ReadOnly="@ReadOnly" ValueChanged="@Changed" Immediate="@Changed.HasDelegate" Size="Size.Small" />
1010
</Addon>
1111
@if ( UploadVisible )
1212
{

0 commit comments

Comments
 (0)