Forráskód Böngészése

Improvements to Digital Forms

Frank van den Bos 1 éve
szülő
commit
99e5c69287

+ 13 - 0
InABox.Core/DigitalForms/Layouts/Fields/DFStorage.cs

@@ -2,6 +2,7 @@
 using System;
 using System.Collections.Generic;
 using System.Diagnostics.CodeAnalysis;
+using System.Linq;
 
 namespace InABox.Core
 {
@@ -19,6 +20,9 @@ namespace InABox.Core
             FormData = new Dictionary<string, object?>();
             BlobData = new Dictionary<string, object?>();
         }
+        
+        public int Count() => FormData.Count();
+        
 
         public void AddValue(string key, object? value)
         {
@@ -88,6 +92,11 @@ namespace InABox.Core
     {
         public Dictionary<string, object?> FormData { get; private set; } = new Dictionary<string, object?>();
 
+        public DFLoadStorage() : this(new Dictionary<string, object?>(), null)
+        {
+            
+        }
+        
         public DFLoadStorage(Dictionary<string, object?> formData, Dictionary<string, object?>? blobData)
         {
             Load(formData, blobData);
@@ -115,6 +124,10 @@ namespace InABox.Core
                 }
             }
         }
+        
+        public void Clear() => FormData.Clear();
+
+        public int Count() => FormData.Count();
 
         /// <summary>
         /// Get a value from the storage, returning <see langword="null"/> if the key does not exist.

+ 14 - 10
InABox.Core/DigitalForms/Layouts/Values/DFLayoutEmbeddedMediaValues.cs

@@ -32,26 +32,30 @@ namespace InABox.Core
             var results = new List<string>();
             foreach (var value in _values)
                 results.Add(Serialization.Serialize((value.ID, value.Thumbnail)));
-            storage.SetBlobValue(results);
+            if (results.Any())
+                storage.SetBlobValue(results);
         }
 
         public void Deserialize(DFLoadStorageEntry storage)
         {
             _values.Clear();
             Present = storage.HasValue();
-            var values = storage.GetValue<string[]>() ?? Array.Empty<string>();
-            foreach (string s in values)
+            if (Present)
             {
-                if (!s.IsNullOrWhiteSpace())
+                var values = storage.GetValue<string[]>() ?? Array.Empty<string>();
+                foreach (string s in values)
                 {
-                    var externaldata = Serialization.Deserialize<(Guid, byte[])>(s);
-                    if (externaldata.Item1 != Guid.Empty)
+                    if (!s.IsNullOrWhiteSpace())
                     {
-                        _values.Add(new DFLayoutEmbeddedMediaValue()
+                        var externaldata = Serialization.Deserialize<(Guid, byte[])>(s);
+                        if (externaldata.Item1 != Guid.Empty)
                         {
-                            ID = externaldata.Item1,
-                            Thumbnail = externaldata.Item2
-                        });
+                            _values.Add(new DFLayoutEmbeddedMediaValue()
+                            {
+                                ID = externaldata.Item1,
+                                Thumbnail = externaldata.Item2
+                            });
+                        }
                     }
                 }
             }

+ 3 - 5
InABox.Core/DigitalForms/Layouts/Values/DFLayoutLookupValue.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using InABox.Core;
 
 namespace InABox.Core
@@ -51,16 +52,13 @@ namespace InABox.Core
         {
             storage.SetValue(Text);
             storage.AddValue("ID", ID);
-            foreach(var (key, value) in Values)
+            var valuesExcludingID = Values.Where(x => !String.Equals(x.Key, "ID")).ToArray();
+            foreach(var (key, value) in valuesExcludingID)
             {
                 if(value is byte[] bArr)
-                {
                     storage.AddBlobValue(key, bArr);
-                }
                 else
-                {
                     storage.AddValue(key, value);
-                }
             }
         }
 

+ 1 - 0
InABox.Mobile/InABox.Mobile.Shared/Components/MobileDateSelector/MobileDateButton.xaml

@@ -17,6 +17,7 @@
                 IsEnabled="True"
                 BackgroundColor="{TemplateBinding ButtonColor}"
                 BorderColor="{TemplateBinding BorderColor}"
+                IsClickable="True"
                 Clicked="_frame_OnClicked">
                 <local:MobileCard.Triggers>
                     <DataTrigger TargetType="local:MobileCard" Binding="{TemplateBinding IsEnabled}" Value="False">

+ 9 - 1
InABox.Mobile/InABox.Mobile.Shared/Components/MobileDateSelector/MobileDateButton.xaml.cs

@@ -150,12 +150,15 @@ namespace InABox.Mobile
             popup.PopupView.HeightRequest = 500;
             popup.PopupView.ShowHeader = false;
             popup.PopupView.ShowFooter = false;
+            //popup.PopupView.PopupStyle.HasShadow = false;
+            popup.PopupView.PopupStyle.CornerRadius = 5;
+            //popup.PopupView.Background = new SolidColorBrush(Color.White);
             MobileDateSelector popupContent = new MobileDateSelector();
             popupContent.Date = Date;
             popupContent.Changed += (o, args) =>
             {
                 Date = args.Date;
-                Changed?.Invoke(this,new DateButtonChangedArgs(Date));
+                DoChanged();
                 popup.Closing -= RestrictClose;
                 popup.Dismiss();
             };
@@ -172,6 +175,11 @@ namespace InABox.Mobile
             popup.Show();
         }
 
+        protected virtual void DoChanged()
+        {
+            Changed?.Invoke(this,new DateButtonChangedArgs(Date));
+        }
+
         private void RestrictClose(object sender, CancelEventArgs e)
         {
             e.Cancel = true;

+ 1 - 0
InABox.Mobile/InABox.Mobile.Shared/Components/MobileTimeSelector/MobileTimeButton.xaml

@@ -20,6 +20,7 @@
                 IsEnabled="True"
                 BackgroundColor="{TemplateBinding ButtonColor}"
                 BorderColor="{TemplateBinding BorderColor}"
+                IsClickable="True"
                 Clicked="_frame_OnClicked">
                 <local:MobileCard.Triggers>
                     <DataTrigger TargetType="local:MobileCard" Binding="{TemplateBinding IsEnabled}" Value="False">

+ 10 - 1
InABox.Mobile/InABox.Mobile.Shared/Components/MobileTimeSelector/MobileTimeButton.xaml.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Globalization;
+using System.Net;
 using Syncfusion.XForms.Core;
 using Syncfusion.XForms.PopupLayout;
 
@@ -128,12 +129,15 @@ namespace InABox.Mobile
             popup.PopupView.HeightRequest = 500;
             popup.PopupView.ShowHeader = false;
             popup.PopupView.ShowFooter = false;
+            //popup.PopupView.PopupStyle.HasShadow = false;
+            popup.PopupView.PopupStyle.CornerRadius = 5;
+            //popup.PopupView.Background = new SolidColorBrush(Color.White);
             MobileTimeSelector popupContent = new MobileTimeSelector();
             popupContent.Time = Time;
             popupContent.Changed += (o, args) =>
             {
                 Time = args.Time;
-                Changed?.Invoke(this,new TimeButtonChangedArgs(Time));
+                DoChanged();
                 popup.Closing -= RestrictClose;
                 popup.Dismiss();
             };
@@ -151,6 +155,11 @@ namespace InABox.Mobile
             popup.Show();
         }
 
+        protected virtual void DoChanged()
+        {
+            Changed?.Invoke(this,new TimeButtonChangedArgs(Time));
+        }
+
         private void RestrictClose(object sender, CancelEventArgs e)
         {
             e.Cancel = true;