Pārlūkot izejas kodu

Added Number field to IDigitalFormInstance implementations
KanbanFormShell is now a standard DifgitalFormInstance<> class
Corrected Loading & Saving of DigitalFormSignature Fields

Frank van den Bos 1 gadu atpakaļ
vecāks
revīzija
8ad180f8d6

+ 15 - 1
prs.classes/Entities/Manufacturing/ManufacturingPacket/ManufacturingPacketStage.cs

@@ -32,8 +32,18 @@ namespace Comal.Classes
     [Caption("Stages")]
     [UserTracking(typeof(ManufacturingPacket))]
     public class ManufacturingPacketStage : Entity, IRemotable, IPersistent, ISequenceable, IOneToMany<ManufacturingPacket>,
-        IDigitalForm<ManufacturingPacket>, IDigitalFormInstance<ManufacturingPacketLink>, ILicense<ManufacturingLicense>
+        IDigitalForm<ManufacturingPacket>, IDigitalFormInstance<ManufacturingPacketLink>, ILicense<ManufacturingLicense>,
+        IStringAutoIncrement<ManufacturingPacketStage>
     {
+        
+        public Expression<Func<ManufacturingPacketStage, String>> AutoIncrementField() => x => x.Number;
+
+        public String AutoIncrementPrefix() => "MS";
+
+        public virtual string AutoIncrementFormat() => "{0:D6}";
+        
+        public Filter<ManufacturingPacketStage> AutoIncrementFilter() => null;
+        
         public ManufacturingPacketStage()
         {
             QualityChecks = "";
@@ -57,6 +67,10 @@ namespace Comal.Classes
             get => Parent;
             set => Parent = value;
         }
+        
+        [EditorSequence(1)]
+        [CodeEditor(Editable = Editable.Disabled)]
+        public String Number { get; set; }
 
         [EntityRelationship(DeleteAction.Cascade)]
         public ManufacturingSectionLink ManufacturingSectionLink { get; set; }

+ 10 - 12
prs.mobile.new/PRS.Mobile/Components/DigitalForms/Editor/Views/DigitalFormSignature.cs

@@ -30,8 +30,6 @@ namespace PRS.Mobile
                 Initialize(value ??  new DFLayoutSignaturePad());
             } 
         }
-
-        private Guid _id;
         
         private byte[] _value;
         public byte[] Value
@@ -59,20 +57,20 @@ namespace PRS.Mobile
         
         public void Deserialize(string serialized)
         {
-            if (String.IsNullOrWhiteSpace(serialized))
-                return;
-            if (Guid.TryParse(serialized, out _id) && (_id != Guid.Empty))
-                DigitalFormDocumentFactory.LoadDocument(_id,
-                    v => Device.BeginInvokeOnMainThread(() => Value = v));
-            else if (serialized.IsBase64String())
+            if (!String.IsNullOrWhiteSpace(serialized) && serialized.IsBase64String())
                 Value = Convert.FromBase64String(serialized);
+            else
+                Value = null;
         }
 
         public string Serialize()
         {
-            if ((_id == Guid.Empty) && Value?.Any() == true)
-                _id = DigitalFormDocumentFactory.SaveDocument(Value);
-            return _id.ToString();
+            if (_value == null)
+            {
+                _pad.Save();
+                _value = GetSignature(_pad.ImageSource);
+            }
+            return Convert.ToBase64String(_value ?? new byte[] { });
         }
 
         public event DigitalFormViewChangedHandler ValueChanged;
@@ -194,7 +192,7 @@ namespace PRS.Mobile
             _apply.IsEnabled = enabled && (App.Data.Me.Signature?.Any() == true);
             _clear.IsEnabled = enabled && (Value?.Any() == true);
             
-            var colors = DigitalFormUtils.GetColors(!enabled, Definition.Properties.Required, false);
+            var colors = DigitalFormUtils.GetColors(!enabled || _value?.Any() == true, Definition.Properties.Required, false);
             BackgroundColor = colors.Background;
             BorderColor = colors.Border;
         }

+ 6 - 2
prs.mobile.new/PRS.Mobile/Data Models/Lists/DigitalFormInstance/DigitalFormInstanceShell.cs

@@ -25,8 +25,12 @@ namespace PRS.Mobile
                 .Map(nameof(Data), x=>x.FormData)
                 .Map(nameof(Created), x=>x.Created);
         }
-
-        public String Number => Get<String>();
+        
+        public String Number
+        {
+            get => Get<String>();
+            set => Set(value);
+        }
 
         public Guid ParentID
         {

+ 2 - 2
prs.mobile.new/PRS.Mobile/Data Models/Lists/DigitalFormInstance/IDigitalFormInstanceShell.cs

@@ -7,14 +7,14 @@ namespace PRS.Mobile
     public interface IDigitalFormInstanceShell : IShell
     {
         Guid ID { get; }
-        String Number { get; }
+        String Number { get; set; }
         Guid ParentID { get; set; }
         Guid FormID { get; set; }
         String FormCode { get; set; }
         String FormDescription { get; set; }
         String Data { get; set; }
         DateTime Created { get; }
-        DateTime Started { get; }
+        DateTime Started { get; set; }
         DateTime Completed { get; set; }
 
     }

+ 1 - 61
prs.mobile.new/PRS.Mobile/Data Models/Lists/KanbanForm/KanbanFormShell.cs

@@ -6,67 +6,7 @@ using Xamarin.Forms;
 
 namespace PRS.Mobile
 {
-    public class KanbanFormShell : Shell<KanbanFormModel, KanbanForm>, IDigitalFormInstanceShell
+    public class KanbanFormShell : DigitalFormInstanceShell<KanbanFormModel, Kanban, KanbanLink, KanbanForm>
     {
-        protected override void ConfigureColumns(ShellColumns<KanbanFormModel, KanbanForm> columns)
-        {
-            columns
-                .Map(nameof(Number), x=>x.Number)
-                .Map(nameof(ParentID), x => x.Parent.ID)
-                .Map(nameof(FormID), x=>x.Form.ID)
-                .Map(nameof(FormCode), x => x.Form.Code)
-                .Map(nameof(FormDescription), x => x.Form.Description)
-                .Map(nameof(Completed), x => x.FormCompleted)
-                .Map(nameof(Started), x=>x.FormStarted)
-                .Map(nameof(Data), x=>x.FormData)
-                .Map(nameof(Created), x=>x.Created);
-        }
-
-        public String Number => Get<String>();
-
-        public Guid ParentID
-        {
-            get => Get<Guid>();
-            set => Set(value);
-        }
-
-        public Guid FormID
-        {
-            get => Get<Guid>();
-            set => Set(value);
-        }
-
-        public String FormCode
-        {
-            get => Get<String>();
-            set => Set(value);
-        }
-
-        public String FormDescription 
-        {
-            get => Get<String>();
-            set => Set(value);
-        }
-        
-        public DateTime Created => Get<DateTime>();
-        
-        public DateTime Completed 
-        {
-            get => Get<DateTime>();
-            set => Set(value);
-        }
-        
-        public DateTime Started 
-        {
-            get => Get<DateTime>();
-            set => Set(value);
-        }
-        
-        public String Data         
-        {
-            get => Get<String>();
-            set => Set(value);
-        }
-
     }
 }