Skip to content

Commit

Permalink
All dates are stores in UTC time. TUI Calendar should recognize your …
Browse files Browse the repository at this point in the history
…timezone and adjust times automatically to UTC when making modifications
  • Loading branch information
gismofx committed Apr 19, 2021
1 parent 7f06458 commit 7805b69
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
9 changes: 1 addition & 8 deletions toast_ui.blazor_calendar/NpmJS/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ window.TUICalendar = {
TUICalendar.calendarRef.on('beforeUpdateSchedule', function (event) {
var schedule = event.schedule;
var changes = event.changes;
TUICalendar.dotNetRef.invokeMethodAsync('UpdateSchedule', schedule.id, changes);
TUICalendar.dotNetRef.invokeMethodAsync('UpdateSchedule', schedule, changes);
TUICalendar.calendarRef.updateSchedule(schedule.id, schedule.calendarId, changes);
});

Expand Down Expand Up @@ -82,13 +82,6 @@ window.TUICalendar = {

},

beforeUpdateSchedule2: function (event) {
var schedule = event.schedule;
var changes = event.changes;
TUICalendar.dotNetRef.invokeMethodAsync('UpdateSchedule', schedule.id, changes);
TUICalendar.calendarRef.updateSchedule(schedule.id, schedule.calendarId, changes);
},

createSchedules: function (schedules) {
TUICalendar.calendarRef.createSchedules(schedules);
},
Expand Down
8 changes: 5 additions & 3 deletions toast_ui.blazor_calendar/TUICalendar.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,20 @@ public TUICalendarViewName CalendarViewName
private Queue<ValueTask> _OnParameterChangeEvents = new Queue<ValueTask>();

[JSInvokable("UpdateSchedule")]
public async Task UpdateSchedule(string scheduleId, dynamic updatedScheduleFields)
public async Task UpdateSchedule(dynamic scheduleBeingModified, dynamic updatedScheduleFields)
{
var currentSchedule = Schedules.Where(x => x.id == scheduleId).FirstOrDefault();
//var currentSchedule = Schedules.Where(x => x.id == scheduleId).FirstOrDefault();
var currentSchedule = JsonSerializer.Deserialize<TUISchedule>(scheduleBeingModified.ToString());
var updatedSchedule = CalendarInterop.UpdateSchedule(currentSchedule, updatedScheduleFields); //Todo: Combine changes with actual schedule
await OnCalendarEventOrTaskChanged.InvokeAsync(updatedSchedule); //Todo: Test This callback!
Debug.WriteLine($"Schedule {scheduleId} Modified");
Debug.WriteLine($"Schedule {currentSchedule.Id} Modified");
}

[JSInvokable("CreateSchedule")]
public async Task CreateSchedule(JsonElement newSchedule)
{
var schedule = JsonSerializer.Deserialize<TUISchedule>(newSchedule.ToString());
Schedules.ToList().Add(schedule);
await OnCalendarEventOrTaskCreated.InvokeAsync(schedule);
Debug.WriteLine("New Schedule Created");
}
Expand Down
4 changes: 2 additions & 2 deletions toast_ui.blazor_calendar/toast_ui.blazor_calendar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<Copyright>MIT</Copyright>
<Description>Toast UI Calandar Wrapper For Blazor. A fully featured calendar component for blazor projects. Comes bundled with ToastUI Calendar JS and CSS files. visit github repo for examples on how to implement.</Description>
<Company></Company>
<Version>1.0.0-alpha2</Version>
<Version>1.0.0-alpha4</Version>
<PackageId>toast_ui.blazor_calendar</PackageId>
<PackageProjectUrl>https://github.com/gismofx/toast_ui.blazor_calendar</PackageProjectUrl>
<RepositoryUrl>https://github.com/gismofx/toast_ui.blazor_calendar</RepositoryUrl>
<PackageTags>blazor calendar jsinterop toastui c#</PackageTags>
<PackageReleaseNotes>Initial pre-release. Missing support for timezones in calendar</PackageReleaseNotes>
<PackageReleaseNotes>Initial pre-release. All dates are stores in UTC time. TUI Calendar should recognize your timezone and adjust times automatically to UTC when making modifications</PackageReleaseNotes>
<Product>toast_ui.blazor_calendar</Product>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>gismofx</Authors>
Expand Down

Large diffs are not rendered by default.

0 comments on commit 7805b69

Please sign in to comment.