-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scheduler drag and drop with mobile support (#1395)
* Appointment drag and drop functionality for Scheduler component. * Added drag support for mobile devices. * Remove DragDropTouch.js. * Remove touch events. Set ondragstart as an attribute (required for mobile support). * Remove some views. --------- Co-authored-by: Atanas Korchev <akorchev@gmail.com>
- Loading branch information
Showing
19 changed files
with
245 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace Radzen.Blazor.Rendering | ||
{ | ||
/// <summary> | ||
/// A base class for <see cref="MonthView" /> <see cref="DayView" /> <see cref="WeekView" /> <see cref="YearPlannerView" /> <see cref="YearTimelineView" /> views. | ||
/// </summary> | ||
public abstract class DropableViewBase : ComponentBase | ||
{ | ||
private bool dragStarted = false; | ||
private AppointmentData draggedAppointment; | ||
/// <summary> | ||
/// Gets or sets the appointment move event callback. | ||
/// </summary> | ||
/// <value>The appointment move event callback.</value> | ||
[Parameter] | ||
public EventCallback<SchedulerAppointmentMoveEventArgs> AppointmentMove { get; set; } | ||
|
||
/// <summary> | ||
/// Handles on slot drop. | ||
/// </summary> | ||
/// <param name="slotDate"></param> | ||
/// <returns>Task</returns> | ||
public async Task OnDrop(DateTime slotDate) | ||
{ | ||
if (draggedAppointment != null) | ||
{ | ||
TimeSpan timespan = slotDate - draggedAppointment.Start; | ||
|
||
await AppointmentMove.InvokeAsync(new SchedulerAppointmentMoveEventArgs { Appointment = draggedAppointment, TimeSpan = timespan }); | ||
|
||
draggedAppointment = null; | ||
} | ||
|
||
dragStarted = false; | ||
} | ||
|
||
/// <summary> | ||
/// Handles Appointment drag started. | ||
/// </summary> | ||
/// <param name="data"></param> | ||
/// <returns></returns> | ||
public void OnAppointmentDragStart(AppointmentData data) | ||
{ | ||
if (!dragStarted) | ||
{ | ||
dragStarted = true; | ||
draggedAppointment = data; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.