Properties added
This commit is contained in:
@@ -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 };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user