Removed dialogs for editing equipment and points, and their related resources

This commit is contained in:
retr0volkov
2025-07-30 09:08:22 +03:00 Unverified
parent edae732fac
commit 08eaa30209
77 changed files with 1498 additions and 1543 deletions
+34 -3
View File
@@ -1,6 +1,10 @@
using System.Collections.ObjectModel;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using GazpromApp.Messages;
using GazpromApp.Models;
namespace GazpromApp.ViewModels;
@@ -8,6 +12,8 @@ namespace GazpromApp.ViewModels;
public partial class PropertyViewModel : ViewModelBase
{
public ViewModelBase? Parent { get; init; }
private Property Property { get; }
[ObservableProperty]
@@ -16,19 +22,36 @@ public partial class PropertyViewModel : ViewModelBase
[ObservableProperty]
private string _value;
[ObservableProperty]
private DateTime _creationDate;
public ObservableCollection<PropertyViewModel> Properties { get; set; }
// Visual and other properties
public PropertyViewModel? Parent { get; init; }
[ObservableProperty]
private bool _isEditing;
[RelayCommand]
private void AddProperty() => Properties.Add(new PropertyViewModel() {Parent = this});
[RelayCommand]
private void RemoveProperty() => WeakReferenceMessenger.Default.Send(new RemovePropertyMessage(this));
[RelayCommand]
private void EditProperty() => IsEditing = !IsEditing;
private void RemoveProperty(object sender, RemovePropertyMessage msg)
{
if (Properties.Contains(msg.Property))
Properties.Remove(msg.Property);
}
public Property GetProperty(Property? parent = null)
{
Property.Name = Name;
Property.Value = Value;
Property.CreationDate = CreationDate;
Property.Parent = parent;
Property.Properties = Properties.Select(e => e.GetProperty(Property)).ToList();
return Property;
@@ -38,19 +61,25 @@ public partial class PropertyViewModel : ViewModelBase
{
Name = "Имя свойства";
Value = "Значение свойства";
CreationDate = DateTime.Now;
Properties = [];
Parent = null;
Property = new Property();
WeakReferenceMessenger.Default.Register<RemovePropertyMessage>(this, RemoveProperty);
}
public PropertyViewModel(Property property, PropertyViewModel? parent = null)
{
Name = property.Name;
Value = property.Value;
CreationDate = property.CreationDate;
Properties = new ObservableCollection<PropertyViewModel>(
property.Properties.Select(e => new PropertyViewModel(e, this)));
Parent = property.Parent is null ? null : parent;
Property = property;
WeakReferenceMessenger.Default.Register<RemovePropertyMessage>(this, RemoveProperty);
}
public PropertyViewModel(PropertyViewModel property)
@@ -60,5 +89,7 @@ public partial class PropertyViewModel : ViewModelBase
Properties = [];
Parent = property;
Property = new Property();
WeakReferenceMessenger.Default.Register<RemovePropertyMessage>(this, RemoveProperty);
}
}