Move IEntrySource to workshop

This commit is contained in:
Robert committed 2023-11-01 20:19:00 +01:00
1 parent c1e0dadce8
commit 59fe1df40f
13 files changed
+63 -34

No files matched your search

@@ -1,6 +0,0 @@
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Models;
public interface IEntrySource
{
}
@@ -1,29 +0,0 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Core;
using Artemis.UI.Screens.Workshop.Layout;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Models;
public class LayoutEntrySource : IEntrySource
{
public LayoutEntrySource(ArtemisLayout layout)
{
Layout = layout;
}
public ArtemisLayout Layout { get; set; }
public ObservableCollection<LayoutInfoViewModel> LayoutInfo { get; } = new();
public KeyboardLayoutType PhysicalLayout { get; set; }
private List<LayoutCustomLedDataLogicalLayout> GetLogicalLayouts()
{
return Layout.Leds
.Where(l => l.LayoutCustomLedData.LogicalLayouts != null)
.SelectMany(l => l.LayoutCustomLedData.LogicalLayouts!)
.Where(l => !string.IsNullOrWhiteSpace(l.Name))
.DistinctBy(l => l.Name)
.ToList();
}
}
@@ -1,13 +0,0 @@
using Artemis.Core;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Models;
public class ProfileEntrySource : IEntrySource
{
public ProfileEntrySource(ProfileConfiguration profileConfiguration)
{
ProfileConfiguration = profileConfiguration;
}
public ProfileConfiguration ProfileConfiguration { get; set; }
}
@@ -5,6 +5,7 @@ using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Layout;
using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
using Artemis.UI.Shared.Services;
using Artemis.WebClient.Workshop;
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
using DryIoc;
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Models;
@@ -6,7 +6,7 @@ using System.Reactive.Disposables;
using System.Reactive.Linq;
using Artemis.Core;
using Artemis.UI.Screens.Workshop.Layout;
using Artemis.UI.Screens.Workshop.SubmissionWizard.Models;
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
using PropertyChanged.SourceGenerator;
using ReactiveUI;
using ReactiveUI.Validation.Extensions;
@@ -26,7 +26,7 @@ public partial class LayoutInfoStepViewModel : SubmissionViewModel
public LayoutInfoStepViewModel(Func<ArtemisLayout, LayoutInfoViewModel> getLayoutInfoViewModel)
{
_getLayoutInfoViewModel = getLayoutInfoViewModel;
GoBack = ReactiveCommand.Create(() => State.ChangeScreen<LayoutSelectionStepViewModel>());
Continue = ReactiveCommand.Create(ExecuteContinue, ValidationContext.Valid);
Secondary = ReactiveCommand.Create(ExecuteAddLayoutInfo);
@@ -40,11 +40,11 @@ public partial class LayoutInfoStepViewModel : SubmissionViewModel
_layout = layoutEntrySource.Layout;
IsKeyboardLayout = _layout.RgbLayout.Type == RGBDeviceType.Keyboard;
PhysicalLayout = layoutEntrySource.PhysicalLayout;
LayoutInfo = layoutEntrySource.LayoutInfo;
LayoutInfo = new ObservableCollection<LayoutInfoViewModel>(layoutEntrySource.LayoutInfo.Select(CreateLayoutInfoViewModel));
if (!LayoutInfo.Any())
ExecuteAddLayoutInfo();
this.ValidationRule(
vm => vm.PhysicalLayout,
this.WhenAnyValue(vm => vm.IsKeyboardLayout, vm => vm.PhysicalLayout, (isKeyboard, layout) => !isKeyboard || layout != KeyboardLayoutType.Unknown),
@@ -58,6 +58,17 @@ public partial class LayoutInfoStepViewModel : SubmissionViewModel
});
}
private LayoutInfoViewModel CreateLayoutInfoViewModel(LayoutInfo layoutInfo)
{
LayoutInfoViewModel vm = _getLayoutInfoViewModel(_layout ?? throw new InvalidOperationException());
vm.Model = layoutInfo.Model;
vm.Vendor = layoutInfo.Vendor;
vm.DeviceProviderId = layoutInfo.DeviceProviderId;
vm.Remove = ReactiveCommand.Create(() => LayoutInfo.Remove(vm));
return vm;
}
private void ExecuteAddLayoutInfo()
{
if (_layout == null)
@@ -74,8 +85,9 @@ public partial class LayoutInfoStepViewModel : SubmissionViewModel
return;
layoutEntrySource.PhysicalLayout = PhysicalLayout;
if (string.IsNullOrWhiteSpace(State.Name))
// layoutEntrySource.LayoutInfo = new List<LayoutInfo>(LayoutInfo.Select(i => i.ToLayoutInfo()));
if (string.IsNullOrWhiteSpace(State.Name))
State.Name = layoutEntrySource.Layout.RgbLayout.Name ?? "";
if (string.IsNullOrWhiteSpace(State.Summary))
{
@@ -108,7 +120,6 @@ public partial class LayoutInfoStepViewModel : SubmissionViewModel
}
State.Categories = new List<long> {8}; // Device category, yes this could change but why would it
if (State.EntryId == null)
State.ChangeScreen<SpecificationsStepViewModel>();
else
@@ -12,6 +12,7 @@ using System.Threading.Tasks;
using Artemis.UI.Screens.Workshop.SubmissionWizard.Models;
using Artemis.UI.Shared.Extensions;
using Artemis.UI.Shared.Services;
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
using Avalonia.Media.Imaging;
using Avalonia.Threading;
using SkiaSharp;
@@ -9,6 +9,7 @@ using Artemis.Core.Services;
using Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs;
using Artemis.UI.Screens.Workshop.SubmissionWizard.Models;
using Artemis.UI.Shared.Services;
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
using DynamicData;
using DynamicData.Aggregation;
using ReactiveUI;
@@ -8,6 +8,7 @@ using Artemis.Core.Services;
using Artemis.UI.Extensions;
using Artemis.UI.Screens.Workshop.Profile;
using Artemis.UI.Screens.Workshop.SubmissionWizard.Models;
using Artemis.WebClient.Workshop.Handlers.UploadHandlers;
using Material.Icons;
using PropertyChanged.SourceGenerator;
using ReactiveUI;