-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from Kibnet/feat/Duration-filter
Feat/duration filter
- Loading branch information
Showing
5 changed files
with
156 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using DynamicData.Binding; | ||
using PropertyChanged; | ||
|
||
namespace Unlimotion.ViewModel; | ||
|
||
[AddINotifyPropertyChangedInterface] | ||
public class DurationFilter | ||
{ | ||
public string Title { get; set; } | ||
public bool ShowTasks { get; set; } | ||
public Func<TaskItemViewModel, bool> Predicate { get; set; } | ||
|
||
public static ReadOnlyObservableCollection<DurationFilter> GetDefinitions() | ||
{ | ||
return new ReadOnlyObservableCollection<DurationFilter>(new ObservableCollectionExtended<DurationFilter> | ||
{ | ||
new() | ||
{ | ||
Title = "No duration", | ||
Predicate = e => e.PlannedDuration == null | ||
}, | ||
new() | ||
{ | ||
Title = "<=5m", | ||
Predicate = e => e.PlannedDuration <= TimeSpan.FromMinutes(5) | ||
}, | ||
new() | ||
{ | ||
Title = "5m< & <=30m", | ||
Predicate = e => TimeSpan.FromMinutes(5) < e.PlannedDuration && e.PlannedDuration <= TimeSpan.FromMinutes(30) | ||
}, | ||
new() | ||
{ | ||
Title = "30m< & <=2h", | ||
Predicate = e => TimeSpan.FromMinutes(30) < e.PlannedDuration && e.PlannedDuration <= TimeSpan.FromHours(2) | ||
}, | ||
new() | ||
{ | ||
Title = "2h< & <=1d", | ||
Predicate = e => TimeSpan.FromHours(2) < e.PlannedDuration && e.PlannedDuration <= TimeSpan.FromDays(1) | ||
}, | ||
new() | ||
{ | ||
Title = "1d<", | ||
Predicate = e => TimeSpan.FromDays(1) < e.PlannedDuration | ||
} | ||
}); | ||
} | ||
} |
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,47 @@ | ||
using System; | ||
using System.Windows.Input; | ||
using PropertyChanged; | ||
using ReactiveUI; | ||
|
||
namespace Unlimotion.ViewModel; | ||
|
||
[AddINotifyPropertyChangedInterface] | ||
public class SetDurationCommands | ||
{ | ||
TaskItemViewModel taskItemViewModel; | ||
|
||
public SetDurationCommands(TaskItemViewModel item) | ||
{ | ||
taskItemViewModel = item; | ||
var hasDuration = taskItemViewModel.WhenAny(m => m.PlannedDuration, (time) => time.Value != null); | ||
var any = taskItemViewModel.WhenAny(m => m.PlannedDuration, (time) => true); | ||
|
||
OneMinCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromMinutes(1), any); | ||
FiveMinutesCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromMinutes(5), any); | ||
TenMinutesCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromMinutes(10), any); | ||
TwentyMinutesCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromMinutes(20), any); | ||
FortyMinutesCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromMinutes(40), any); | ||
OneHourCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromHours(1), any); | ||
TwoHoursCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromHours(2), any); | ||
FourHoursCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromHours(4), any); | ||
OneDayCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromDays(1), any); | ||
TwoDaysCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromDays(2), any); | ||
FourDaysCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromDays(4), any); | ||
EightDaysCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = TimeSpan.FromDays(8), any); | ||
NoneCommand = ReactiveCommand.Create(() => taskItemViewModel.PlannedDuration = null, hasDuration); | ||
} | ||
|
||
public ICommand OneMinCommand { get; set; } | ||
public ICommand FiveMinutesCommand { get; set; } | ||
public ICommand TenMinutesCommand { get; set; } | ||
public ICommand TwentyMinutesCommand { get; set; } | ||
public ICommand FortyMinutesCommand { get; set; } | ||
public ICommand OneHourCommand { get; set; } | ||
public ICommand TwoHoursCommand { get; set; } | ||
public ICommand FourHoursCommand { get; set; } | ||
public ICommand OneDayCommand { get; set; } | ||
public ICommand TwoDaysCommand { get; set; } | ||
public ICommand FourDaysCommand { get; set; } | ||
public ICommand EightDaysCommand { get; set; } | ||
public ICommand NoneCommand { get; set; } | ||
} |
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