Просмотр исходного кода

avalonia: Fixed ReadOnly for forms, and fixed DFOptionFieldControl Required

Kenric Nugteren 1 месяц назад
Родитель
Сommit
2d5484d27f

+ 5 - 1
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/DigitalFormViewer.axaml.cs

@@ -44,7 +44,11 @@ public partial class DigitalFormViewer : UserControl, IDFRenderer
         }
     }
 
-    public bool ReadOnly { get; set; }
+    public bool ReadOnly
+    {
+        get => GetValue(ReadOnlyProperty);
+        set => SetValue(ReadOnlyProperty, value);
+    }
 
     public bool IsChanged => _isChanged;
 

+ 2 - 1
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/DigitalFormsHostView.axaml

@@ -12,7 +12,8 @@
 				<forms:DigitalFormViewer Name="Viewer"
 										 Entity="{Binding Parent}"
 										 Form="{Binding Form}"
-										 FieldChanged="FormViewer_FieldChanged"/>
+										 FieldChanged="FormViewer_FieldChanged"
+										 ReadOnly="{Binding ReadOnly}"/>
 			</ScrollViewer>
 		</TabItem>
 		<TabItem Header="Documents"/>

+ 5 - 2
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/DigitalFormsHostViewModel.cs

@@ -44,6 +44,8 @@ public interface IDigitalFormsHostViewModel : INotifyPropertyChanged
 
     DFLayout Layout { get; }
 
+    bool ReadOnly { get; }
+
     Action<DFLoadStorage> LoadValues { set; }
 
     Func<DFSaveStorage> SaveValues { set; }
@@ -227,6 +229,9 @@ public partial class DigitalFormsHostViewModel<TModel, TShell, TParent, TParentL
             }
         }
 
+        NewForm = Form.FormData.IsNullOrWhiteSpace();
+        ReadOnly = Form.FormCompleted != DateTime.MinValue;
+
         var layout = new DFLayout();
         layout.LoadLayout(DigitalFormLayout.Layout);
         layout.LoadVariables(Variables);
@@ -238,8 +243,6 @@ public partial class DigitalFormsHostViewModel<TModel, TShell, TParent, TParentL
             LoadValues(DigitalForm.DeserializeFormData(Form) ?? new());
         });
 
-        NewForm = Form.FormData.IsNullOrWhiteSpace();
-        ReadOnly = Form.FormCompleted != DateTime.MinValue;
         _isChanged = NewForm;
 
         TimeStarted = DateTime.Now;

+ 1 - 1
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFOptionFieldControl.cs

@@ -184,7 +184,7 @@ public class ComboBoxOptionControl : ContentControl, IOptionControl
     {
         _comboBox.SelectedValue = value;
     }
-    public bool IsEmpty() => GetValue() == null;
+    public bool IsEmpty() => GetValue().IsNullOrWhiteSpace();
 }
 
 class DFOptionControl : DigitalFormFieldControl<DFLayoutOptionField, DFLayoutOptionFieldProperties, string, string?>