88 lines
1.8 KiB
C#
88 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Text;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using WinWARP.Core.Models.Entities;
|
|
|
|
namespace WinWARP.Core.ViewModels;
|
|
|
|
public abstract partial class ServerItemViewModel : ObservableObject
|
|
{
|
|
public ServerItemViewModel(Server server)
|
|
{
|
|
Id = server.Id;
|
|
DefaultTitle = server.DefaultTitle;
|
|
Title = server.Title;
|
|
Region = server.Region;
|
|
ConnectionString = server.ConnectionString;
|
|
IsDeleted = server.IsDeleted;
|
|
IsDisabled = server.IsDisabled;
|
|
Tags = new ObservableCollection<string>(server.Tags);
|
|
}
|
|
|
|
public int Id
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public partial string DefaultTitle
|
|
{
|
|
get; set;
|
|
} = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
public partial string Title
|
|
{
|
|
get; set;
|
|
} = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
public partial string ConnectionString
|
|
{
|
|
get; set;
|
|
} = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
public partial string Region
|
|
{
|
|
get; set;
|
|
} = string.Empty;
|
|
|
|
[RelayCommand]
|
|
public abstract Task DeleteAsync();
|
|
|
|
public abstract Task EditNameAsync();
|
|
|
|
[ObservableProperty]
|
|
public partial bool IsNameEditing
|
|
{
|
|
get; set;
|
|
} = false;
|
|
|
|
[RelayCommand]
|
|
public void EditName()
|
|
{
|
|
if (IsNameEditing)
|
|
EditNameAsync();
|
|
IsNameEditing = !IsNameEditing;
|
|
}
|
|
|
|
public ObservableCollection<string> Tags { get; } = [];
|
|
|
|
[ObservableProperty]
|
|
public partial bool IsDeleted
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public partial bool IsDisabled
|
|
{
|
|
get; set;
|
|
}
|
|
}
|