Skip to content

Commit

Permalink
Update Scheduler Title when StartMonth changes in Year Views (#1873)
Browse files Browse the repository at this point in the history
* Update Scheduler Title when StartMonth changes in Year Views

* Update to the Demo page

* Slight update to XML comment on SchedulerYearViewBase->StartMonth
  • Loading branch information
paulo-rico authored Dec 27, 2024
1 parent 153e9e0 commit 749c2cf
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Radzen.Blazor/RadzenYearPlannerView.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@using Radzen.Blazor
@using Radzen.Blazor.Rendering

@inherits SchedulerViewBase
@inherits SchedulerYearViewBase

@code {
public override RenderFragment Render()
Expand Down
4 changes: 2 additions & 2 deletions Radzen.Blazor/RadzenYearPlannerView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Radzen.Blazor
/// </RadzenScheduler>
/// </code>
/// </example>
public partial class RadzenYearPlannerView : SchedulerViewBase
public partial class RadzenYearPlannerView : SchedulerYearViewBase
{
/// <inheritdoc />
public override string Icon => "view_list";
Expand Down Expand Up @@ -91,7 +91,7 @@ public override DateTime EndDate
/// </summary>
/// <value>The start month.</value>
[Parameter]
public Month StartMonth { get; set; } = Month.January;
public override Month StartMonth { get; set; } = Month.January;

/// <inheritdoc />
public override DateTime Next()
Expand Down
2 changes: 1 addition & 1 deletion Radzen.Blazor/RadzenYearTimelineView.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@using Radzen.Blazor
@using Radzen.Blazor.Rendering

@inherits SchedulerViewBase
@inherits SchedulerYearViewBase

@code {
public override RenderFragment Render()
Expand Down
4 changes: 2 additions & 2 deletions Radzen.Blazor/RadzenYearTimelineView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Radzen.Blazor
/// &lt;/RadzenScheduler&gt;
/// </code>
/// </example>
public partial class RadzenYearTimelineView : SchedulerViewBase
public partial class RadzenYearTimelineView : SchedulerYearViewBase
{
/// <inheritdoc />
public override string Icon => "view_timeline";
Expand Down Expand Up @@ -91,7 +91,7 @@ public override DateTime EndDate
/// </summary>
/// <value>The start month.</value>
[Parameter]
public Month StartMonth { get; set; } = Month.January;
public override Month StartMonth { get; set; } = Month.January;

/// <inheritdoc />
public override DateTime Next()
Expand Down
2 changes: 1 addition & 1 deletion Radzen.Blazor/RadzenYearView.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@using Radzen.Blazor
@using Radzen.Blazor.Rendering

@inherits SchedulerViewBase
@inherits SchedulerYearViewBase

@code {
public override RenderFragment Render()
Expand Down
4 changes: 2 additions & 2 deletions Radzen.Blazor/RadzenYearView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Radzen.Blazor
/// &lt;/RadzenScheduler&gt;
/// </code>
/// </example>
public partial class RadzenYearView : SchedulerViewBase
public partial class RadzenYearView : SchedulerYearViewBase
{
/// <inheritdoc />
public override string Icon => "calendar_month";
Expand Down Expand Up @@ -89,7 +89,7 @@ public override DateTime EndDate
/// </summary>
/// <value>The start month.</value>
[Parameter]
public Month StartMonth { get; set; } = Month.January;
public override Month StartMonth { get; set; } = Month.January;

/// <inheritdoc />
public override DateTime Next()
Expand Down
36 changes: 36 additions & 0 deletions Radzen.Blazor/SchedulerYearViewBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using Radzen;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;

namespace Radzen.Blazor
{
/// <summary>
/// A base class for <see cref="RadzenScheduler{TItem}" /> views.
/// </summary>
public abstract class SchedulerYearViewBase : SchedulerViewBase
{
/// <summary>
/// Gets the StartMonth of the view.
/// </summary>
/// <value>The start month.</value>
public abstract Month StartMonth { get; set; }

/// <summary>
/// Called by the Blazor runtime when parameters are set.
/// </summary>
/// <param name="parameters">The parameters.</param>
public override async Task SetParametersAsync(ParameterView parameters)
{
if (parameters.DidParameterChange(nameof(StartMonth), StartMonth))
{
if (Scheduler != null)
{
await Scheduler.Reload();
}
}

await base.SetParametersAsync(parameters);
}
}
}
8 changes: 1 addition & 7 deletions RadzenBlazorDemos/Pages/SchedulerPlannerTimeline.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Gap="0.5rem" class="rz-p-4 rz-mb-6 rz-border-radius-1" Style="border: var(--rz-grid-cell-border);">
<RadzenLabel Text="Schedule Start Month:" />
<RadzenSelectBar @bind-Value="@startMonth" TextProperty="Text" ValueProperty="Value" Data="@(Enum.GetValues(typeof(Month)).Cast<Month>().Select(t => new { Text = $"{t}", Value = t }))" Size="ButtonSize.Small" class="rz-display-none rz-display-xl-flex" />
<RadzenDropDown @bind-Value="@startMonth" Change="StartMonthChange" TextProperty="Text" ValueProperty="Value" Data="@(Enum.GetValues(typeof(Month)).Cast<Month>().Select(t => new { Text = $"{t}", Value = t }))" class="rz-display-inline-flex rz-display-xl-none" />
<RadzenSelectBar @bind-Value="@startMonth" TextProperty="Text" ValueProperty="Value" Data="@(Enum.GetValues(typeof(Month)).Cast<Month>().Select(t => new { Text = $"{t}", Value = t }))" Size="ButtonSize.Small" class="rz-display-xl-flex" />
</RadzenStack>

<RadzenScheduler @ref=@scheduler SlotRender=@OnSlotRender style="height: 768px;" TItem="Appointment" Data=@appointments StartProperty="Start" EndProperty="End"
Expand Down Expand Up @@ -34,11 +33,6 @@
new Appointment { Start = DateTime.Today.AddDays(1), End = DateTime.Today.AddDays(12), Text = "Vacation" },
};

async Task StartMonthChange()
{
await scheduler.Reload();
}

void OnSlotRender(SchedulerSlotRenderEventArgs args)
{
// Highlight today in month view
Expand Down

0 comments on commit 749c2cf

Please sign in to comment.