Browse Source

Improved Digital Forms Save / Load

Frank van den Bos 1 year ago
parent
commit
43bd52f139

+ 2 - 4
prs.mobile.new/PRS.Mobile/Components/DigitalForms/Editor/DataModels/DigitalFormHostModel.cs

@@ -92,11 +92,9 @@ namespace PRS.Mobile
 
         private IDigitalFormInstance GetInstance(Guid iD)
         {
-            return new Client<TInstance>().Query
-                (
+            return new Client<TInstance>().Query(
                 new Filter<TInstance>(x => x.ID).IsEqualTo(iD)
-                )
-                .Rows.FirstOrDefault().ToObject<TInstance>();
+            ).Rows.FirstOrDefault().ToObject<TInstance>();
         }
 
         public DigitalFormLayout QueryDigitalFormLayout(Entity form)

+ 11 - 2
prs.mobile.new/PRS.Mobile/Components/DigitalForms/Editor/Views/DigitalFormDoubleEntry.cs

@@ -27,9 +27,18 @@ namespace PRS.Mobile
         public double Value
         {
             get => _value;
-            set => _value = value;
+            set 
+            { 
+                _value = value;
+                UpdateUI();
+            }
         }
-        
+
+        private void UpdateUI()
+        {
+            _entry.Text = Definition.Properties.FormatValue(_value);
+        }
+
         public bool IsEmpty => Math.Abs(Value).Equals(0F);
         
         public void Deserialize(string serialized)

+ 4 - 2
prs.mobile.new/PRS.Mobile/Components/DigitalForms/Editor/Views/DigitalFormEmbeddedMedia.cs

@@ -48,7 +48,7 @@ namespace PRS.Mobile
 
         private void UpdateUI()
         {
-            if ((_value?.Thumbnail?.Any() == false) && (_value?.Data?.Any() != true))
+            if ((_value?.Thumbnail?.Any() != true) && (_value?.Data?.Any() == true))
                 _value.Thumbnail = CreateThumbnail(_value.Data);
 
             _image.Source = _value?.Thumbnail?.Any() == true 
@@ -103,8 +103,10 @@ namespace PRS.Mobile
 
             _card = new MobileCard()
             {
-                Padding = 5
+                Padding = 5,
+                IsClickable = true,
             };
+            _card.Clicked += ((o,e) => Image_Tapped());
             SetRow(_card, 0);
             SetColumn(_card, 0);
             SetRowSpan(_card, 4);

+ 10 - 1
prs.mobile.new/PRS.Mobile/Components/DigitalForms/Editor/Views/DigitalFormIntegerEntry.cs

@@ -25,7 +25,16 @@ namespace PRS.Mobile
         public int Value
         {
             get => _value;
-            set => _value = value;
+            set
+            {
+                _value = value;
+                UpdateUI();
+            }
+        }
+
+        private void UpdateUI()
+        {
+            _entry.Text = _value.ToString();
         }
 
         public bool IsEmpty => Value.Equals(0);

+ 6 - 0
prs.mobile.new/PRS.Mobile/Components/DigitalForms/Editor/Views/MobileDigitalFormDocumentHandler.cs

@@ -1,4 +1,6 @@
+using System;
 using InABox.Mobile;
+using JetBrains.Annotations;
 
 namespace PRS.Mobile
 {
@@ -6,5 +8,9 @@ namespace PRS.Mobile
     {
         protected override string CachePath => CoreRepository.CacheFolder();
         protected override bool IsConnected => App.Data.IsConnected();
+
+        public MobileDigitalFormDocumentHandler([NotNull] Action<bool> status) : base(status)
+        {
+        }
     }
 }

+ 4 - 3
prs.mobile.new/PRS.Mobile/Components/DigitalForms/ExistingForms/ExistingForms.xaml.cs

@@ -260,9 +260,10 @@ namespace PRS.Mobile
             where TForm : Entity, IRemotable, IPersistent, IDigitalFormInstance<TParentLink>, new()
         {
             
-            var form = new Client<TForm>()
-                .Query(new Filter<TForm>(x => x.ID).IsEqualTo(shell.ID))
-                .Rows
+            var table = new Client<TForm>()
+                .Query(new Filter<TForm>(x => x.ID).IsEqualTo(shell.ID)
+            );
+            var form = table.Rows
                 .Select(x => x.ToObject<TForm>())
                 .FirstOrDefault();
             

+ 7 - 5
prs.mobile.new/PRS.Mobile/Main/DataModel.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Threading;
 using System.Threading.Tasks;
 using Comal.Classes;
 using InABox.Clients;
@@ -361,17 +360,18 @@ namespace PRS.Mobile
             App.Transport.OnOpen += OnTransportConnected;
             App.Transport.OnClose += OnTransportDisconnected;
             
-
-            DigitalFormDocumentFactory.Run<MobileDigitalFormDocumentHandler>(
+            DigitalFormDocumentFactory.Init(
+                new MobileDigitalFormDocumentHandler(
                 b =>
                 {
                     IsBackgroundUpdateStatusActive = b;
                     BackgroundUpdateStatusChanged?.Invoke(this, EventArgs.Empty);
-                }
+                })
             );
-            
+            DigitalFormDocumentFactory.Run();
         }
         
+
         public bool IsBackgroundUpdateStatusActive { get; private set; }
 
         public event BackgroundUpdateStatusEvent BackgroundUpdateStatusChanged;
@@ -384,12 +384,14 @@ namespace PRS.Mobile
         
         private void OnTransportDisconnected(IRpcTransport transport, RpcTransportCloseArgs e)
         {
+            DigitalFormDocumentFactory.Stop();
             TransportDisconnected?.Invoke(new TransportDisconnectedEventArgs());
             Task.Run(() =>
             {
                 while (!IsConnected())
                     App.Transport.Connect();
                 ClientFactory.Validate(ClientFactory.SessionID);
+                DigitalFormDocumentFactory.Run();
             });
         }