danheron / Heron.MudCalendar

Calendar component for MudBlazor
MIT License
149 stars 30 forks source link

Added CalendarTimeInterval.Minutes5 #151

Closed Jeroen-VdB closed 1 month ago

Jeroen-VdB commented 1 month ago

First of all, thanks for this awesome component! It is already very useful for my small personal project. In my use case it would be very helpful to quickly edit the calendar items via drag & drop. The smallest timeframe needed is 5 minutes. Currently the smallest is 10. I added a 5 Minutes option to the CalendarTimeInterval enum.

I was able to successfully run all unit tests as well as the unit tests viewer: image

However, I was not able to test the Docs, even after cloning the MudBlazor/mudcalendar repo into the same parent folder and building it in release. I got:

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Object of type 'MudBlazor.Docs.Components.SectionContent' does not have a property matching the name 'Assembly'.
System.InvalidOperationException: Object of type 'MudBlazor.Docs.Components.SectionContent' does not have a property matching the name 'Assembly'.
   at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.ThrowForUnknownIncomingParameterName(Type targetType, String parameterName)
   at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.SetProperties(ParameterView& parameters, Object target)
   at Microsoft.AspNetCore.Components.ParameterView.SetParameterProperties(Object target)
   at Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(ParameterView parameters)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)
Dt @ blazor.webassembly.js:1
carbon.js:1 

       Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
digitaldirk commented 1 month ago

Hi,

I wonder if it would be worth re-implementing this feature as a user specifiable list? Instead of static enums there could be a default list (5,10,15,...,180), then it could be overridden to suite your needs.

Simple mockup:

[Parameter]
public int[] CalendarMinuteIntervals { get; set; } = new[] { 5, 10, 15, 20, 30, 60, 120, 180 };
<MudCalendar CalendarMinuteIntervals="new int[] { 1, 5, 60, 180, 360}" />

MudBlazor TablePager as an example: https://mudblazor.com/components/table#tablepager-customization

Willing to make a PR if wanted

Jeroen-VdB commented 1 month ago

I initially thought the same but this was already asked in #56 with a reply

It's difficult to change it to an arbitrary amount now as it would break backwards compatibility. However I will add some more options to the enum including an option for 3 hours.

Therefore I simply added a time interval suited for my use case.

Perhaps a conversion from the enum value to int to keep it backwards compatible and adding a new property that accepts a list of arbitrary values could be an options? Although I am not sure how this would impact the UI, I haven't gone into detail enough in this project.

danheron commented 1 month ago

Changing it to an arbitrary value might be a good idea. For the moment we will just add the 5 minute option.