Browse Source

Fixed error in License Screen
Implemented BaseEntityForm to allow for "Fixed" and "Movable" entity forms

frogsoftware 1 month ago
parent
commit
caf00dada9

+ 7 - 7
InABox.Core/DigitalForms/DFUtils.cs

@@ -15,7 +15,7 @@ namespace InABox.Core
     }
 
     public abstract class EntityFormUtils<TForm, TEntity, TEntityLink> : IEntityFormUtils
-        where TForm : EntityForm<TEntity, TEntityLink, TForm>
+        where TForm : BaseEntityForm<TEntity, TEntityLink, TForm>
         where TEntity : Entity, new()
         where TEntityLink : EntityLink<TEntity>, new()
     {
@@ -31,7 +31,7 @@ namespace InABox.Core
     }
 
     public class DelegateEntityFormUtils<TForm, TEntity, TEntityLink> : EntityFormUtils<TForm, TEntity, TEntityLink>
-        where TForm : EntityForm<TEntity, TEntityLink, TForm>
+        where TForm : BaseEntityForm<TEntity, TEntityLink, TForm>
         where TEntity : Entity, new()
         where TEntityLink : EntityLink<TEntity>, new()
     {
@@ -152,7 +152,7 @@ namespace InABox.Core
             DelegateEntityFormUtils<TForm, TEntity, TEntityLink>.CanEditEvent editFormFunc,
             DelegateEntityFormUtils<TForm, TEntity, TEntityLink>.NewEntityEvent? newEntityFunc = null,
             DelegateEntityFormUtils<TForm, TEntity, TEntityLink>.OnSaveEvent? beforeSaveFunc = null)
-            where TForm : EntityForm<TEntity, TEntityLink, TForm>
+            where TForm : BaseEntityForm<TEntity, TEntityLink, TForm>
             where TEntity : Entity, new()
             where TEntityLink : EntityLink<TEntity>, new()
         {
@@ -160,7 +160,7 @@ namespace InABox.Core
         }
         
         public static void AddFormUtils<TForm, TEntity, TEntityLink>(EntityFormUtils<TForm, TEntity, TEntityLink> formUtils)
-            where TForm : EntityForm<TEntity, TEntityLink, TForm>
+            where TForm : BaseEntityForm<TEntity, TEntityLink, TForm>
             where TEntity : Entity, new()
             where TEntityLink : EntityLink<TEntity>, new()
         {
@@ -177,7 +177,7 @@ namespace InABox.Core
         }
         
         public static bool CanEditForm<TForm, TEntity, TEntityLink>(TForm Form, TEntity Entity)
-            where TForm : EntityForm<TEntity, TEntityLink, TForm>
+            where TForm : BaseEntityForm<TEntity, TEntityLink, TForm>
             where TEntity : Entity, new()
             where TEntityLink : EntityLink<TEntity>, new()
         {
@@ -194,7 +194,7 @@ namespace InABox.Core
         }
 
         public static TEntity NewEntity<TForm, TEntity, TEntityLink>(DigitalForm form)
-            where TForm : EntityForm<TEntity, TEntityLink, TForm>
+            where TForm : BaseEntityForm<TEntity, TEntityLink, TForm>
             where TEntity : Entity, new()
             where TEntityLink : EntityLink<TEntity>, new()
         {
@@ -210,7 +210,7 @@ namespace InABox.Core
         }
         
         public static void OnSave<TForm, TEntity, TEntityLink>(TForm form, TEntity entity)
-            where TForm : EntityForm<TEntity, TEntityLink, TForm>
+            where TForm : BaseEntityForm<TEntity, TEntityLink, TForm>
             where TEntity : Entity, new()
             where TEntityLink : EntityLink<TEntity>, new()
         {

+ 27 - 6
InABox.Core/DigitalForms/Forms/EntityForm.cs → InABox.Core/DigitalForms/Forms/BaseEntityForm.cs

@@ -11,10 +11,10 @@ namespace InABox.Core
     }
 
     [Caption("Digital Forms")]
-    public abstract class EntityForm<TParent, TParentLink, TThis> : Entity, IRemotable, IPersistent, ISequenceable, IStringAutoIncrement<TThis>,
+    public abstract class BaseEntityForm<TParent, TParentLink, TThis> : Entity, IRemotable, IPersistent, ISequenceable, IStringAutoIncrement<TThis>,
         IEntityForm,
         IDigitalFormInstance<TParentLink>, ILicense<DigitalFormsLicense>
-        where TThis : EntityForm<TParent,TParentLink, TThis>
+        where TThis : BaseEntityForm<TParent,TParentLink, TThis>
         where TParent : Entity
         where TParentLink : BaseObject, IEntityLink<TParent>, new()
     {
@@ -32,10 +32,7 @@ namespace InABox.Core
         [EditorSequence(2)]
         public string Description { get; set; } = "";
 
-        [NullEditor]
-        [EntityRelationship(DeleteAction.Cascade)]
-        public virtual TParentLink Parent => InitializeField(ref _tParentLink, nameof(TParentLink));
-        private TParentLink _tParentLink;
+        public abstract TParentLink Parent { get; }
 
         [NullEditor]
         [Obsolete("Being Replaced by Form")]
@@ -120,4 +117,28 @@ namespace InABox.Core
         [NullEditor]
         public long Sequence { get; set; }
     }
+
+    // The only difference between this "standard" EntityForm and the "MovableEntityForm" below is that the Parent
+    // here is disabled, effectively locking the digital form to its parent.  A MovableEntityForm (currently only used
+    // for Job Forms) allows the form to be swicthed between different parents.
+    public abstract class FixedEntityForm<TParent, TParentLink, TThis> : BaseEntityForm<TParent, TParentLink, TThis>
+        where TThis : BaseEntityForm<TParent,TParentLink, TThis>
+        where TParent : Entity
+        where TParentLink : BaseObject, IEntityLink<TParent>, new()
+    {
+        [NullEditor]
+        [EntityRelationship(DeleteAction.Cascade)]
+        public override TParentLink Parent => InitializeField(ref _tParentLink, nameof(TParentLink));
+        private TParentLink _tParentLink;
+    }
+    
+    public abstract class MovableEntityForm<TParent, TParentLink, TThis> : BaseEntityForm<TParent, TParentLink, TThis>
+        where TThis : BaseEntityForm<TParent,TParentLink, TThis>
+        where TParent : Entity
+        where TParentLink : BaseObject, IEntityLink<TParent>, new()
+    {
+        [EntityRelationship(DeleteAction.Cascade)]
+        public override TParentLink Parent => InitializeField(ref _tParentLink, nameof(TParentLink));
+        private TParentLink _tParentLink;
+    }
 }

+ 1 - 1
InABox.Core/DigitalForms/Forms/DigitalFormInstanceLookups.cs

@@ -3,7 +3,7 @@ namespace InABox.Core
     public abstract class DigitalFormInstanceLookups<TEntity,TLink,TForm> : EntityLookup<TForm> 
         where TEntity : Entity
         where TLink : BaseObject, IEntityLink<TEntity>, new()
-        where TForm : EntityForm<TEntity,TLink,TForm>, new()
+        where TForm : BaseEntityForm<TEntity,TLink,TForm>, new()
     {
         public override Filter<TForm>? DefineFilter() => null;
 

+ 1 - 1
InABox.Core/Licensing/LicenseUtils.cs

@@ -103,7 +103,7 @@ namespace InABox.Core
         /// </returns>
         public static string? EncryptLicense(LicenseData license)
         {
-            return Encryption.EncryptV2(Serialization.Serialize(license), LicenseKey);
+            return Encryption.EncryptV2(Serialization.Serialize(license,false), LicenseKey);
         }
         
         public static bool TryEncryptLicense(LicenseData license, [NotNullWhen(true)] out string? result, [NotNullWhen(false)] out string? error)

+ 2 - 2
inabox.wpf/DigitalForms/DigitalFormUtils.cs

@@ -616,10 +616,10 @@ namespace InABox.DynamicGrid
         public static DataModel? GetDataModel(String appliesto, IEnumerable<DigitalFormVariable> variables)
         {
             _entityForms ??= CoreUtils.Entities
-                .Where(x => x.IsSubclassOfRawGeneric(typeof(EntityForm<,,>)))
+                .Where(x => x.IsSubclassOfRawGeneric(typeof(BaseEntityForm<,,>)))
                 .ToList();
             var entityForm = _entityForms
-                .FirstOrDefault(x => x.GetSuperclassDefinition(typeof(EntityForm<,,>))
+                .FirstOrDefault(x => x.GetSuperclassDefinition(typeof(BaseEntityForm<,,>))
                     ?.GenericTypeArguments[0].Name == appliesto);
             if(entityForm is not null)
             {

+ 1 - 1
inabox.wpf/DynamicGrid/DynamicGridUtils.cs

@@ -767,7 +767,7 @@ public static class DynamicGridUtils
         Func<TEntity> loadEntity,
         bool editOnAdd = false,
         DynamicFormEditWindow.CustomiseDynamicFormEditWindow? customiseEditor = null)
-        where TEntityForm : EntityForm<TEntity, TEntityLink, TEntityForm>, new()
+        where TEntityForm : BaseEntityForm<TEntity, TEntityLink, TEntityForm>, new()
         where TEntity : Entity
         where TEntityLink : BaseObject, IEntityLink<TEntity>, new()
     {

+ 1 - 1
inabox.wpf/DynamicGrid/Grids/DynamicEntityFormGrid.cs

@@ -12,7 +12,7 @@ using System.Windows.Media.Imaging;
 namespace InABox.DynamicGrid;
 
 public class DynamicEntityFormGrid<TForm, TEntity, TEntityLink> : DynamicDataGrid<TForm>
-    where TForm : EntityForm<TEntity, TEntityLink, TForm>, new()
+    where TForm : BaseEntityForm<TEntity, TEntityLink, TForm>, new()
     where TEntity : Entity
     where TEntityLink : BaseObject, IEntityLink<TEntity>, new()
 {