Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
@@ -1,10 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

using BootstrapBlazor.Server.Components.Samples.Table;

namespace BootstrapBlazor.Server.Components.Components;

/// <summary>
Expand All @@ -14,7 +12,7 @@ public partial class CustomerFilter
{
[Inject]
[NotNull]
private IStringLocalizer<TablesFilter>? TableFilterLocalizer { get; set; }
private IStringLocalizer<CustomerFilter>? TableFilterLocalizer { get; set; }

private int? _value;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@using BootstrapBlazor.Server.Components.Samples.Table
@inject IStringLocalizer<Foo> LocalizerFoo
@using BootstrapBlazor.Server.Components.Samples.Table
@inject IStringLocalizer<Foo> FooLocalizer

<div class="col-12 col-sm-6">
<MultiSelect @bind-Value="Model.Hobby" Items="@Hobbies" />
Expand All @@ -17,6 +17,6 @@
/// </summary>
protected override void OnInitialized()
{
Hobbies = Foo.GenerateHobbies(LocalizerFoo);
Hobbies = Foo.GenerateHobbies(FooLocalizer);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

using BootstrapBlazor.Server.Components.Samples;

namespace BootstrapBlazor.Server.Components.Components;

/// <summary>
Expand All @@ -20,7 +18,7 @@ public partial class FormInlineSwitch

[Inject]
[NotNull]
private IStringLocalizer<Rows>? LocalizerRows { get; set; }
private IStringLocalizer<FormInlineSwitch>? Localizer { get; set; }

/// <summary>
///
Expand Down Expand Up @@ -53,10 +51,12 @@ private RowType FormRowType
}

/// <summary>
/// OnInitialized 方法
/// <inheritdoc/>
/// </summary>
protected override void OnInitialized()
{
Items = Enum.GetNames<RowType>().Select(i => new SelectedItem(i, LocalizerRows[i]));
base.OnInitialized();

Items = Enum.GetNames<RowType>().Select(i => new SelectedItem(i, Localizer[i]));
}
}
2 changes: 0 additions & 2 deletions src/BootstrapBlazor.Server/Components/Samples/Alerts.razor
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,3 @@
</DemoBlock>

<AttributeTable Type="typeof(Alert)" />

<EventTable Items="@GetEvents()" />
16 changes: 1 addition & 15 deletions src/BootstrapBlazor.Server/Components/Samples/Alerts.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand Down Expand Up @@ -102,18 +102,4 @@ private Task DismissClick()
Logger.Log("Alert Dismissed");
return Task.CompletedTask;
}

/// <summary>
/// 获得事件方法
/// </summary>
/// <returns></returns>
private static EventItem[] GetEvents() =>
[
new()
{
Name = "OnDismiss",
Description = "Close the alert box callback method",
Type = "EventCallback<MouseEventArgs>"
}
];
}
16 changes: 8 additions & 8 deletions src/BootstrapBlazor.Server/Components/Samples/AutoFills.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand Down Expand Up @@ -44,7 +44,7 @@ partial class AutoFills

[Inject]
[NotNull]
private IStringLocalizer<Foo>? LocalizerFoo { get; set; }
private IStringLocalizer<Foo>? FooLocalizer { get; set; }

private bool _isClearable = true;

Expand All @@ -53,19 +53,19 @@ protected override void OnInitialized()
{
base.OnInitialized();

Items1 = Foo.GenerateFoo(LocalizerFoo);
Items1 = Foo.GenerateFoo(FooLocalizer);
Model1 = Items1.First();

Items2 = Foo.GenerateFoo(LocalizerFoo);
Items2 = Foo.GenerateFoo(FooLocalizer);
Model2 = Items2.First();

Items3 = Foo.GenerateFoo(LocalizerFoo);
Items3 = Foo.GenerateFoo(FooLocalizer);
Model3 = Items3.First();

Items4 = Foo.GenerateFoo(LocalizerFoo);
Items4 = Foo.GenerateFoo(FooLocalizer);
Model4 = Items3.First();

Items5 = Foo.GenerateFoo(LocalizerFoo);
Items5 = Foo.GenerateFoo(FooLocalizer);
Comment thread
ArgoZhang marked this conversation as resolved.
Model5 = Items3.First();
}

Expand All @@ -84,7 +84,7 @@ private Task<IEnumerable<Foo>> OnCustomVirtulizeFilter(string searchText)
private async Task<QueryData<Foo>> OnQueryAsync(VirtualizeQueryOption option)
{
await Task.Delay(200);
var items = Foo.GenerateFoo(LocalizerFoo);
var items = Foo.GenerateFoo(FooLocalizer);
if (!string.IsNullOrEmpty(option.SearchText))
{
items = [.. items.Where(i => i.Name!.Contains(option.SearchText, StringComparison.OrdinalIgnoreCase))];
Expand Down
2 changes: 0 additions & 2 deletions src/BootstrapBlazor.Server/Components/Samples/Calendars.razor
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,3 @@
</DemoBlock>

<AttributeTable Type="typeof(BootstrapBlazor.Components.Calendar)" />

<EventTable Items="@GetEvents()" />
16 changes: 1 addition & 15 deletions src/BootstrapBlazor.Server/Components/Samples/Calendars.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand Down Expand Up @@ -33,18 +33,4 @@ private void OnValueChanged(DateTime ts)
private List<Crew> GetCrewsByDate(DateTime d) => Data.GetOrAdd(d, CalendarDemoDataHelper.GetCrewsByDate);

private int GetSumByName(string name) => Data.Where(d => d.Key.Month == CrewInfoValue.Month).Sum(d => d.Value.FirstOrDefault(v => v.Name == name)?.Value ?? 0);

/// <summary>
/// 获得事件方法
/// </summary>
/// <returns></returns>
private EventItem[] GetEvents() =>
[
new EventItem()
{
Name = "ValueChanged",
Description = Localizer["ValueChanged"],
Type ="EventCallback<DateTime>"
}
];
}
2 changes: 0 additions & 2 deletions src/BootstrapBlazor.Server/Components/Samples/Cascaders.razor
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,3 @@
</DemoBlock>

<AttributeTable Type="typeof(Cascader<>)" />

<EventTable Items="@GetEvents()" />
14 changes: 0 additions & 14 deletions src/BootstrapBlazor.Server/Components/Samples/Cascaders.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,6 @@ protected override void OnInitialized()
_items[2].AddItem(new CascaderItem("item3_child2", Localizer["item3_child2"]));
}

/// <summary>
/// 获得事件方法
/// </summary>
/// <returns></returns>
private EventItem[] GetEvents() =>
[
new()
{
Name = nameof(Cascader<string>.OnSelectedItemChanged),
Description = Localizer["Event1"],
Type ="Func<CascaderItem[], Task>"
}
];

private async Task OnValidate()
{
await ValidateForm1.ValidateAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,3 @@
</DemoBlock>

<AttributeTable Type="typeof(CheckboxList<>)" />

<EventTable Items="@GetEvents()" />
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand Down Expand Up @@ -95,8 +95,8 @@ protected override void OnInitialized()
};

Dummy = new Foo() { Name = Localizer["Foo"] };
Model = Foo.Generate(LocalizerFoo);
FooItems = Foo.GenerateHobbies(LocalizerFoo);
Model = Foo.Generate(FooLocalizer);
FooItems = Foo.GenerateHobbies(FooLocalizer);
}

/// <summary>
Expand All @@ -109,9 +109,9 @@ protected override async Task OnInitializedAsync()

GenericItems = new List<SelectedItem<Foo>>()
{
new() { Text = Localizer["item1"], Value = new Foo() { Name = LocalizerFoo["Foo.Name", "001"] } },
new() { Text = Localizer["item2"], Value = new Foo() { Name = LocalizerFoo["Foo.Name", "002"] } },
new() { Text = Localizer["item3"], Value = new Foo() { Name = LocalizerFoo["Foo.Name", "003"] } },
new() { Text = Localizer["item1"], Value = new Foo() { Name = FooLocalizer["Foo.Name", "001"] } },
new() { Text = Localizer["item2"], Value = new Foo() { Name = FooLocalizer["Foo.Name", "002"] } },
new() { Text = Localizer["item3"], Value = new Foo() { Name = FooLocalizer["Foo.Name", "003"] } },
};
}

Expand Down Expand Up @@ -155,7 +155,7 @@ private Task OnSelectedChanged(IEnumerable<SelectedItem> items, string value)

[Inject]
[NotNull]
IStringLocalizer<Foo>? LocalizerFoo { get; set; }
IStringLocalizer<Foo>? FooLocalizer { get; set; }

[Inject, NotNull]
private ToastService? ToastService { get; set; }
Expand All @@ -169,24 +169,4 @@ class IconSelectedItem : SelectedItem
{
public string? Icon { get; init; }
}

/// <summary>
/// Get event method
/// </summary>
/// <returns></returns>
private EventItem[] GetEvents() =>
[
new()
{
Name = "OnSelectedChanged",
Description = Localizer["Event1"],
Type ="Func<IEnumerable<SelectedItem>, TValue, Task>"
},
new()
{
Name = nameof(CheckboxList<string>.OnMaxSelectedCountExceed),
Description = Localizer["AttributeOnMaxSelectedCountExceed"],
Type = "Func<Task>"
}
];
}
2 changes: 0 additions & 2 deletions src/BootstrapBlazor.Server/Components/Samples/Checkboxs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,3 @@
</DemoBlock>

<AttributeTable Type="typeof(Checkbox<>)" />

<EventTable Items="@GetEvents()" />
28 changes: 1 addition & 27 deletions src/BootstrapBlazor.Server/Components/Samples/Checkboxs.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand Down Expand Up @@ -64,30 +64,4 @@ private Task<bool> OnBeforeStateChanged(CheckboxState state) => SwalService.Show
Title = Localizer["OnBeforeStateChangedSwalTitle"],
Content = Localizer["OnBeforeStateChangedSwalContent"]
});

/// <summary>
/// 获得事件方法
/// </summary>
/// <returns></returns>
private EventItem[] GetEvents() =>
[
new()
{
Name = "OnBeforeStateChanged",
Description = Localizer["OnBeforeStateChanged"],
Type ="Action<CheckboxState, TItem>"
},
new()
{
Name = "OnStateChanged",
Description = Localizer["OnStateChanged"],
Type ="Action<CheckboxState, TItem>"
},
new()
{
Name = "StateChanged",
Description = Localizer["StateChanged"],
Type ="EventCallback<CheckboxState>"
}
];
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@page "/context-menu"
@page "/context-menu"
@inject IStringLocalizer<ContextMenus> Localizer
@inject IStringLocalizer<Foo> LocalizerFoo
@inject IStringLocalizer<Foo> FooLocalizer

<h3>@Localizer["ContextMenuTitle"]</h3>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand Down Expand Up @@ -37,8 +37,8 @@ private static Task OnPaste(ContextMenuItem item, object value)
/// </summary>
protected override void OnInitialized()
{
Foo = Foo.Generate(LocalizerFoo);
Items = Foo.GenerateFoo(LocalizerFoo);
Foo = Foo.Generate(FooLocalizer);
Items = Foo.GenerateFoo(FooLocalizer);
}

TreeFoo? SelectModel = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,3 @@
</DemoBlock>

<AttributeTable Type="typeof(DateTimePicker<>)" />

<EventTable Items="@GetEvents()" />
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
Expand Down Expand Up @@ -140,30 +140,4 @@ private Task OnDisabledDaysChanged(bool v)
_picker2.ClearDisabledDays();
return Task.CompletedTask;
}

/// <summary>
/// 获得事件方法
/// </summary>
/// <returns></returns>
private EventItem[] GetEvents() =>
[
new()
{
Name = "OnClickConfirm",
Description = Localizer["Event1"],
Type ="Action"
},
new()
{
Name = "ValueChanged",
Description = Localizer["Event2"],
Type ="EventCallback<DateTime?>"
},
new()
{
Name = "OnGetDisabledDaysCallback",
Description = Localizer["OnGetDisabledDaysCallbackEvent"],
Type ="Func<DateTime, DateTime, Task<List<DateTime>>>"
}
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,3 @@
</DemoBlock>

<AttributeTable Type="typeof(DateTimeRange)" />

<EventTable Items="@GetEvents()" />
Loading
Loading