* use select instead of autocomplete for playout editor * use select instead of autocomplete for filler preset editor * reset selected collection when changing collection type * use select instead of autocomplete for multi collection editor * more select * more select controls
113 lines
3.3 KiB
C#
113 lines
3.3 KiB
C#
using System;
|
|
using ErsatzTV.Application.Filler.Commands;
|
|
using ErsatzTV.Application.MediaCollections;
|
|
using ErsatzTV.Application.MediaItems;
|
|
using ErsatzTV.Core;
|
|
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Core.Domain.Filler;
|
|
using LanguageExt;
|
|
using MediatR;
|
|
using Unit = LanguageExt.Unit;
|
|
|
|
namespace ErsatzTV.ViewModels
|
|
{
|
|
public class FillerPresetEditViewModel
|
|
{
|
|
private FillerKind _fillerKind;
|
|
private TimeSpan? _duration;
|
|
private FillerMode _fillerMode;
|
|
private int? _count;
|
|
private ProgramScheduleItemCollectionType _collectionType;
|
|
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
|
|
public FillerKind FillerKind
|
|
{
|
|
get => _fillerKind;
|
|
set
|
|
{
|
|
_fillerKind = value;
|
|
if (_fillerKind is FillerKind.Fallback or FillerKind.Tail)
|
|
{
|
|
FillerMode = FillerMode.None;
|
|
}
|
|
}
|
|
}
|
|
|
|
public FillerMode FillerMode
|
|
{
|
|
get => FillerKind is FillerKind.Fallback or FillerKind.Tail ? FillerMode.None : _fillerMode;
|
|
set => _fillerMode = value;
|
|
}
|
|
|
|
public TimeSpan? Duration
|
|
{
|
|
get => FillerMode == FillerMode.Duration ? _duration : null;
|
|
set => _duration = value;
|
|
}
|
|
|
|
public int? Count
|
|
{
|
|
get => FillerMode == FillerMode.Count ? _count : null;
|
|
set => _count = value;
|
|
}
|
|
|
|
public int? PadToNearestMinute { get; set; }
|
|
|
|
public ProgramScheduleItemCollectionType CollectionType
|
|
{
|
|
get => _collectionType;
|
|
set
|
|
{
|
|
if (_collectionType != value)
|
|
{
|
|
Collection = null;
|
|
MediaItem = null;
|
|
MultiCollection = null;
|
|
SmartCollection = null;
|
|
}
|
|
|
|
_collectionType = value;
|
|
}
|
|
}
|
|
|
|
public MediaCollectionViewModel Collection { get; set; }
|
|
public NamedMediaItemViewModel MediaItem { get; set; }
|
|
public MultiCollectionViewModel MultiCollection { get; set; }
|
|
public SmartCollectionViewModel SmartCollection { get; set; }
|
|
|
|
public IRequest<Either<BaseError, Unit>> ToEdit() =>
|
|
new UpdateFillerPreset(
|
|
Id,
|
|
Name,
|
|
FillerKind,
|
|
FillerMode,
|
|
Duration.Map(FixDuration),
|
|
Count,
|
|
PadToNearestMinute,
|
|
CollectionType,
|
|
Collection?.Id,
|
|
MediaItem?.MediaItemId,
|
|
MultiCollection?.Id,
|
|
SmartCollection?.Id);
|
|
|
|
public IRequest<Either<BaseError, Unit>> ToUpdate() =>
|
|
new CreateFillerPreset(
|
|
Name,
|
|
FillerKind,
|
|
FillerMode,
|
|
Duration.Map(FixDuration),
|
|
Count,
|
|
PadToNearestMinute,
|
|
CollectionType,
|
|
Collection?.Id,
|
|
MediaItem?.MediaItemId,
|
|
MultiCollection?.Id,
|
|
SmartCollection?.Id);
|
|
|
|
private static TimeSpan FixDuration(TimeSpan duration) =>
|
|
duration > TimeSpan.FromDays(1) ? duration.Subtract(TimeSpan.FromDays(1)) : duration;
|
|
}
|
|
}
|