瀏覽代碼

DYNAMIC GRID - added parameter to DoAdd override to allow grids with direct edit to open a new entity editor when adding

Nick-PRSDigital@bitbucket.org 2 年之前
父節點
當前提交
dbeed2b2b2

+ 1 - 1
InABox.DynamicGrid/DynamicDocumentGrid.cs

@@ -177,7 +177,7 @@ namespace InABox.DynamicGrid
             }
         }
 
-        protected override void DoAdd()
+        protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
         {
             var dlg = new OpenFileDialog();
             dlg.Multiselect = true;

+ 1 - 1
InABox.DynamicGrid/DynamicEntityFormGrid.cs

@@ -39,7 +39,7 @@ namespace InABox.DynamicGrid
             }
         }
 
-        protected override void DoAdd()
+        protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
         {
             var filter = LookupFactory.DefineFilter<TEntity, DigitalForm>(new TEntity[] { Entity })
                 ?? LookupFactory.DefineFilter<TForm, DigitalForm>(Array.Empty<TForm>());

+ 17 - 17
InABox.DynamicGrid/DynamicGrid.cs

@@ -2417,42 +2417,42 @@ namespace InABox.DynamicGrid
             return false;
         }*/
 
-        protected virtual void DoAdd()
+        protected virtual void DoAdd(bool OpenEditorOnDirectEdit = false)
         {
             //CoreRow row = (SelectedRow > -1) && (SelectedRow < Data.Rows.Count) ?  Data.Rows[this.SelectedRow] : null;
-            if (AddEditClick(null))
-            {
-                Refresh(false, true);
-                OnChanged?.Invoke(this);
-            }
-        }
 
-        private void Add_Click(object sender, RoutedEventArgs e)
-        {
-            if (Options.Contains(DynamicGridOption.DirectEdit))
+            if (Options.Contains(DynamicGridOption.DirectEdit) && !OpenEditorOnDirectEdit)
             {
                 if (!CanCreateItems())
                     return;
-                
+
                 var item = CreateItem();
                 SaveItem(item);
-                
+
                 var datarow = Data.NewRow();
                 ObjectToRow(item, datarow);
                 Data.Rows.Add(datarow);
-                
+
                 var masterrow = MasterData.NewRow();
                 ObjectToRow(item, masterrow);
                 MasterData.Rows.Add(masterrow);
-                
+
                 _recordmap[datarow] = masterrow;
-                
+
                 InvalidateGrid();
                 SelectedRows = new[] { datarow };
                 OnChanged?.Invoke(this);
             }
-            else
-                DoAdd();
+            else if (AddEditClick(null))
+            {
+                Refresh(false, true);
+                OnChanged?.Invoke(this);
+            }
+        }
+
+        private void Add_Click(object sender, RoutedEventArgs e)
+        {    
+                DoAdd(OpenEditorOnDirectEdit: false);
         }
         public virtual DynamicEditorPages LoadEditorPages(T item)
         {

+ 2 - 2
InABox.DynamicGrid/DynamicManyToManyGrid.cs

@@ -211,7 +211,7 @@ namespace InABox.DynamicGrid
             return null;
         }
 
-        protected override void DoAdd()
+        protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
         {
             if (MultiSelect)
             {
@@ -241,7 +241,7 @@ namespace InABox.DynamicGrid
             }
             else
             {
-                base.DoAdd();
+                base.DoAdd(OpenEditorOnDirectEdit: false);
             }
         }
 

+ 1 - 1
InABox.DynamicGrid/FormDesigner/DynamicVariableGrid.cs

@@ -93,7 +93,7 @@ namespace InABox.DynamicGrid
             });
         }
 
-        protected override void DoAdd()
+        protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
         {
             var menu = new ContextMenu();