Properties added

This commit is contained in:
retr0volkov
2025-07-09 14:27:45 +03:00 Unverified
parent 72dc9b6874
commit 2a8f8d2714
10 changed files with 272 additions and 22 deletions
+24 -2
View File
@@ -115,6 +115,26 @@ public partial class EditEquipmentDialogViewModel : ViewModelBase
{
Inspections.Remove(inspection);
}
public ObservableCollection<PropertyViewModel> Properties { get; set; }
[RelayCommand]
private void AddPropertySimple() => Properties.Add(new PropertyViewModel());
[RelayCommand]
private static void AddProperty(PropertyViewModel property) => property.Properties.Add(new PropertyViewModel(property));
[RelayCommand]
private static void EditProperty(PropertyViewModel property) => property.IsEditing = !property.IsEditing;
[RelayCommand]
private void DeleteProperty(PropertyViewModel property)
{
if (property.Parent is null)
Properties.Remove(property);
else
property.Parent?.Properties.Remove(property);
}
private bool CanCompleteEdit() => !string.IsNullOrWhiteSpace(Name);
@@ -122,13 +142,13 @@ public partial class EditEquipmentDialogViewModel : ViewModelBase
private void CompleteEdit()
{
IsClosed = true;
Equipment equipment = new Equipment()
Equipment equipment = new Equipment
{
Name = Name,
Description = Description,
Image = Image?.GetImage(),
Inspections = Inspections.Select(e => e.GetInspection()).ToList(),
Properties = [],
Properties = Properties.Select(e => e.GetProperty()).ToList(),
};
WeakReferenceMessenger.Default.Send(new EditEquipmentDone(new EquipmentViewModel(equipment)));
}
@@ -160,6 +180,7 @@ public partial class EditEquipmentDialogViewModel : ViewModelBase
Description = "Testing";
Image = null;
Inspections = [];
Properties = [];
IsImageSelected = false;
@@ -172,6 +193,7 @@ public partial class EditEquipmentDialogViewModel : ViewModelBase
Description = equipment.Description;
Image = equipment.Image;
Inspections = new ObservableCollection<InspectionViewModel>(equipment.Inspections.Select(e => e));
Properties = new ObservableCollection<PropertyViewModel>(equipment.Properties.Select(e => e));
IsImageSelected = equipment.Image is { Bytes.Length: > 0 };