Fixing couple issues with context flyout and moving items.
This commit is contained in:
@@ -164,18 +164,17 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
|
|||||||
CurrentSettings = _preferencesService.GetCurrentCalendarSettings();
|
CurrentSettings = _preferencesService.GetCurrentCalendarSettings();
|
||||||
IsDarkWebviewRenderer = _underlyingThemeService.IsUnderlyingThemeDark();
|
IsDarkWebviewRenderer = _underlyingThemeService.IsUnderlyingThemeDark();
|
||||||
|
|
||||||
// Initialize Show As options
|
foreach (var showAs in CalendarItemActionOptions.ShowAsOptions)
|
||||||
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.Free));
|
{
|
||||||
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.Tentative));
|
ShowAsOptions.Add(new ShowAsOption(showAs));
|
||||||
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.Busy));
|
}
|
||||||
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.OutOfOffice));
|
|
||||||
ShowAsOptions.Add(new ShowAsOption(CalendarItemShowAs.WorkingElsewhere));
|
|
||||||
SelectedShowAsOption = ShowAsOptions[2]; // Default to Busy
|
|
||||||
|
|
||||||
// Initialize RSVP status options
|
SelectedShowAsOption = ShowAsOptions.FirstOrDefault(option => option.ShowAs == CalendarItemShowAs.Busy) ?? ShowAsOptions.FirstOrDefault();
|
||||||
RsvpStatusOptions.Add(new RsvpStatusOption(CalendarItemStatus.Accepted));
|
|
||||||
RsvpStatusOptions.Add(new RsvpStatusOption(CalendarItemStatus.Tentative));
|
foreach (var responseStatus in CalendarItemActionOptions.ResponseOptions)
|
||||||
RsvpStatusOptions.Add(new RsvpStatusOption(CalendarItemStatus.Cancelled));
|
{
|
||||||
|
RsvpStatusOptions.Add(new RsvpStatusOption(responseStatus));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
|
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Wino.Core.Domain.Enums;
|
||||||
|
|
||||||
|
namespace Wino.Core.Domain;
|
||||||
|
|
||||||
|
public static class CalendarItemActionOptions
|
||||||
|
{
|
||||||
|
public static IReadOnlyList<CalendarItemShowAs> ShowAsOptions { get; } =
|
||||||
|
[
|
||||||
|
CalendarItemShowAs.Free,
|
||||||
|
CalendarItemShowAs.Tentative,
|
||||||
|
CalendarItemShowAs.Busy,
|
||||||
|
CalendarItemShowAs.OutOfOffice,
|
||||||
|
CalendarItemShowAs.WorkingElsewhere
|
||||||
|
];
|
||||||
|
|
||||||
|
public static IReadOnlyList<CalendarItemStatus> ResponseOptions { get; } =
|
||||||
|
[
|
||||||
|
CalendarItemStatus.Accepted,
|
||||||
|
CalendarItemStatus.Tentative,
|
||||||
|
CalendarItemStatus.Cancelled
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Wino.Core.Domain;
|
||||||
using Wino.Core.Domain.Entities.Calendar;
|
using Wino.Core.Domain.Entities.Calendar;
|
||||||
using Wino.Core.Domain.Enums;
|
using Wino.Core.Domain.Enums;
|
||||||
using Wino.Services;
|
using Wino.Services;
|
||||||
@@ -30,15 +31,12 @@ public class CalendarContextMenuItemServiceTests
|
|||||||
items.Should().NotContain(item => item.Action.ActionType == CalendarContextMenuActionType.Respond);
|
items.Should().NotContain(item => item.Action.ActionType == CalendarContextMenuActionType.Respond);
|
||||||
|
|
||||||
var showAsItem = items.Single(item => item.Action.ActionType == CalendarContextMenuActionType.ShowAs);
|
var showAsItem = items.Single(item => item.Action.ActionType == CalendarContextMenuActionType.ShowAs);
|
||||||
showAsItem.Children.Should().HaveCount(5);
|
showAsItem.Children.Should().HaveCount(CalendarItemActionOptions.ShowAsOptions.Count);
|
||||||
showAsItem.Children.Select(child => child.Action.ShowAs).Should().BeEquivalentTo(
|
showAsItem.Children.Select(child => child.Action.ShowAs).Should().BeEquivalentTo(
|
||||||
[
|
CalendarItemActionOptions.ShowAsOptions);
|
||||||
CalendarItemShowAs.Free,
|
|
||||||
CalendarItemShowAs.Tentative,
|
var deleteItem = items.Single(item => item.Action.ActionType == CalendarContextMenuActionType.Delete);
|
||||||
CalendarItemShowAs.Busy,
|
deleteItem.Action.TargetType.Should().BeNull();
|
||||||
CalendarItemShowAs.OutOfOffice,
|
|
||||||
CalendarItemShowAs.WorkingElsewhere
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -30,8 +30,10 @@
|
|||||||
|
|
||||||
<Grid.ContextFlyout>
|
<Grid.ContextFlyout>
|
||||||
<local:CalendarItemCommandBarFlyout
|
<local:CalendarItemCommandBarFlyout
|
||||||
|
AlwaysExpanded="True"
|
||||||
Item="{x:Bind CalendarItem, Mode=OneWay}"
|
Item="{x:Bind CalendarItem, Mode=OneWay}"
|
||||||
Placement="Top" />
|
Placement="BottomEdgeAlignedLeft"
|
||||||
|
ShowMode="Transient" />
|
||||||
</Grid.ContextFlyout>
|
</Grid.ContextFlyout>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -845,13 +845,13 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void TimedViewportPointerMoved(object sender, PointerRoutedEventArgs e)
|
private void TimedViewportPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||||
=> SetHoverTarget(ResolveTimedDropTarget(e.GetCurrentPoint(TimedViewport).Position, _activeDragPackage?.CalendarItemViewModel));
|
=> UpdateHoverTargetForActiveDrag(() => ResolveTimedDropTarget(e.GetCurrentPoint(TimedViewport).Position, _activeDragPackage?.CalendarItemViewModel));
|
||||||
|
|
||||||
private void TimedAllDayHostPointerMoved(object sender, PointerRoutedEventArgs e)
|
private void TimedAllDayHostPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||||
=> SetHoverTarget(ResolveTimedAllDayDropTarget(e.GetCurrentPoint(TimedAllDayHost).Position, _activeDragPackage?.CalendarItemViewModel));
|
=> UpdateHoverTargetForActiveDrag(() => ResolveTimedAllDayDropTarget(e.GetCurrentPoint(TimedAllDayHost).Position, _activeDragPackage?.CalendarItemViewModel));
|
||||||
|
|
||||||
private void MonthViewportPointerMoved(object sender, PointerRoutedEventArgs e)
|
private void MonthViewportPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||||
=> SetHoverTarget(ResolveMonthDropTarget(e.GetCurrentPoint(MonthViewport).Position, _activeDragPackage?.CalendarItemViewModel));
|
=> UpdateHoverTargetForActiveDrag(() => ResolveMonthDropTarget(e.GetCurrentPoint(MonthViewport).Position, _activeDragPackage?.CalendarItemViewModel));
|
||||||
|
|
||||||
private void CalendarDropTargetPointerExited(object sender, PointerRoutedEventArgs e)
|
private void CalendarDropTargetPointerExited(object sender, PointerRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -861,6 +861,17 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateHoverTargetForActiveDrag(Func<CalendarDropTargetInfo?> resolveHoverTarget)
|
||||||
|
{
|
||||||
|
if (_activeDragPackage == null)
|
||||||
|
{
|
||||||
|
SetHoverTarget(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetHoverTarget(resolveHoverTarget());
|
||||||
|
}
|
||||||
|
|
||||||
private void TimedViewportDragOver(object sender, DragEventArgs e)
|
private void TimedViewportDragOver(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (!TryGetDragPackage(e, out var dragPackage))
|
if (!TryGetDragPackage(e, out var dragPackage))
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Wino.Core.Domain;
|
||||||
using Wino.Core.Domain.Entities.Calendar;
|
using Wino.Core.Domain.Entities.Calendar;
|
||||||
using Wino.Core.Domain.Enums;
|
using Wino.Core.Domain.Enums;
|
||||||
using Wino.Core.Domain.Interfaces;
|
using Wino.Core.Domain.Interfaces;
|
||||||
@@ -8,22 +9,6 @@ namespace Wino.Services;
|
|||||||
|
|
||||||
public class CalendarContextMenuItemService : ICalendarContextMenuItemService
|
public class CalendarContextMenuItemService : ICalendarContextMenuItemService
|
||||||
{
|
{
|
||||||
private static readonly IReadOnlyList<CalendarItemShowAs> ShowAsOptions =
|
|
||||||
[
|
|
||||||
CalendarItemShowAs.Free,
|
|
||||||
CalendarItemShowAs.Tentative,
|
|
||||||
CalendarItemShowAs.Busy,
|
|
||||||
CalendarItemShowAs.OutOfOffice,
|
|
||||||
CalendarItemShowAs.WorkingElsewhere
|
|
||||||
];
|
|
||||||
|
|
||||||
private static readonly IReadOnlyList<CalendarItemStatus> ResponseOptions =
|
|
||||||
[
|
|
||||||
CalendarItemStatus.Accepted,
|
|
||||||
CalendarItemStatus.Tentative,
|
|
||||||
CalendarItemStatus.Cancelled
|
|
||||||
];
|
|
||||||
|
|
||||||
public IReadOnlyList<CalendarContextMenuItem> GetContextMenuItems(CalendarItem calendarItem)
|
public IReadOnlyList<CalendarContextMenuItem> GetContextMenuItems(CalendarItem calendarItem)
|
||||||
{
|
{
|
||||||
if (calendarItem == null)
|
if (calendarItem == null)
|
||||||
@@ -71,7 +56,7 @@ public class CalendarContextMenuItemService : ICalendarContextMenuItemService
|
|||||||
CreateScopeLeaf(CalendarContextMenuActionType.Delete, CalendarEventTargetType.Series)
|
CreateScopeLeaf(CalendarContextMenuActionType.Delete, CalendarEventTargetType.Series)
|
||||||
])
|
])
|
||||||
: new CalendarContextMenuItem(
|
: new CalendarContextMenuItem(
|
||||||
new CalendarContextMenuAction(CalendarContextMenuActionType.Delete, CalendarEventTargetType.Single),
|
new CalendarContextMenuAction(CalendarContextMenuActionType.Delete),
|
||||||
IsPrimary: true);
|
IsPrimary: true);
|
||||||
|
|
||||||
private static CalendarContextMenuItem CreateShowAsItem(bool isRecurringChild)
|
private static CalendarContextMenuItem CreateShowAsItem(bool isRecurringChild)
|
||||||
@@ -102,9 +87,9 @@ public class CalendarContextMenuItemService : ICalendarContextMenuItemService
|
|||||||
|
|
||||||
private static IReadOnlyList<CalendarContextMenuItem> CreateShowAsLeaves(CalendarEventTargetType targetType)
|
private static IReadOnlyList<CalendarContextMenuItem> CreateShowAsLeaves(CalendarEventTargetType targetType)
|
||||||
{
|
{
|
||||||
var items = new List<CalendarContextMenuItem>(ShowAsOptions.Count);
|
var items = new List<CalendarContextMenuItem>(CalendarItemActionOptions.ShowAsOptions.Count);
|
||||||
|
|
||||||
foreach (var showAs in ShowAsOptions)
|
foreach (var showAs in CalendarItemActionOptions.ShowAsOptions)
|
||||||
{
|
{
|
||||||
items.Add(new CalendarContextMenuItem(
|
items.Add(new CalendarContextMenuItem(
|
||||||
new CalendarContextMenuAction(CalendarContextMenuActionType.ShowAs, targetType, showAs)));
|
new CalendarContextMenuAction(CalendarContextMenuActionType.ShowAs, targetType, showAs)));
|
||||||
@@ -115,9 +100,9 @@ public class CalendarContextMenuItemService : ICalendarContextMenuItemService
|
|||||||
|
|
||||||
private static IReadOnlyList<CalendarContextMenuItem> CreateResponseLeaves(CalendarEventTargetType targetType)
|
private static IReadOnlyList<CalendarContextMenuItem> CreateResponseLeaves(CalendarEventTargetType targetType)
|
||||||
{
|
{
|
||||||
var items = new List<CalendarContextMenuItem>(ResponseOptions.Count);
|
var items = new List<CalendarContextMenuItem>(CalendarItemActionOptions.ResponseOptions.Count);
|
||||||
|
|
||||||
foreach (var responseStatus in ResponseOptions)
|
foreach (var responseStatus in CalendarItemActionOptions.ResponseOptions)
|
||||||
{
|
{
|
||||||
items.Add(new CalendarContextMenuItem(
|
items.Add(new CalendarContextMenuItem(
|
||||||
new CalendarContextMenuAction(CalendarContextMenuActionType.Respond, targetType, ResponseStatus: responseStatus)));
|
new CalendarContextMenuAction(CalendarContextMenuActionType.Respond, targetType, ResponseStatus: responseStatus)));
|
||||||
|
|||||||
Reference in New Issue
Block a user