|
|
@@ -17,6 +17,7 @@ using System.Data;
|
|
|
using System.Windows.Media;
|
|
|
using AutoProperties;
|
|
|
using InABox.WPF;
|
|
|
+using System.Windows.Threading;
|
|
|
|
|
|
namespace InABox.DynamicGrid;
|
|
|
|
|
|
@@ -761,11 +762,21 @@ public static class DynamicGridUtils
|
|
|
bool editOnAdd = false,
|
|
|
DynamicFormEditWindow.CustomiseDynamicFormEditWindow? customiseEditor = null,
|
|
|
DynamicEntityFormGrid<TEntityForm, TEntity, TEntityLink>.CustomiseNewFormHandler? customiseNewForm = null,
|
|
|
- ISubPanelHost? nonModalHost = null)
|
|
|
+ ISubPanelHost? nonModalHost = null,
|
|
|
+ Action? onSaved = null)
|
|
|
where TEntityForm : BaseEntityForm<TEntity, TEntityLink, TEntityForm>, new()
|
|
|
where TEntity : Entity
|
|
|
where TEntityLink : BaseObject, IEntityLink<TEntity>, new()
|
|
|
{
|
|
|
+ if(onSaved is not null)
|
|
|
+ {
|
|
|
+ var oldOnSaved = onSaved;
|
|
|
+ onSaved = () =>
|
|
|
+ {
|
|
|
+ Application.Current.Dispatcher.BeginInvoke(oldOnSaved);
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
var task = Task.Run(() =>
|
|
|
{
|
|
|
return new Client<TEntityForm>().Query(
|
|
|
@@ -783,6 +794,7 @@ public static class DynamicGridUtils
|
|
|
if (task.Result.shouldSave)
|
|
|
{
|
|
|
task.Result.model!.Update(null);
|
|
|
+ onSaved?.Invoke();
|
|
|
}
|
|
|
}, TaskContinuationOptions.OnlyOnRanToCompletion);
|
|
|
}
|
|
|
@@ -791,6 +803,7 @@ public static class DynamicGridUtils
|
|
|
if (DynamicFormEditWindow.EditDigitalForm(form, out var dataModel, customise: customiseEditor))
|
|
|
{
|
|
|
dataModel.Update(null);
|
|
|
+ onSaved?.Invoke();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -801,9 +814,8 @@ public static class DynamicGridUtils
|
|
|
try
|
|
|
{
|
|
|
var entity = loadEntity();
|
|
|
- var filter = LookupFactory.DefineChildFilter<TEntity, DigitalForm>(new TEntity[] { entity });
|
|
|
- if (filter == null)
|
|
|
- filter = LookupFactory.DefineLookupFilter<TEntityForm, DigitalForm, DigitalFormLink>(x => x.Form, Array.Empty<TEntityForm>());
|
|
|
+ var filter = LookupFactory.DefineChildFilter<TEntity, DigitalForm>([entity])
|
|
|
+ ?? LookupFactory.DefineLookupFilter<TEntityForm, DigitalForm, DigitalFormLink>(x => x.Form, []);
|
|
|
|
|
|
var select = new MultiSelectDialog<DigitalForm>(
|
|
|
filter,
|
|
|
@@ -829,6 +841,7 @@ public static class DynamicGridUtils
|
|
|
else
|
|
|
{
|
|
|
Client.Save(form, "Added by user");
|
|
|
+ onSaved?.Invoke();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -846,6 +859,10 @@ public static class DynamicGridUtils
|
|
|
|
|
|
var grid = new DynamicEntityFormGrid<TEntityForm, TEntity, TEntityLink>(loadEntity());
|
|
|
grid.CustomiseNewForm = customiseNewForm;
|
|
|
+ grid.OnChanged += (o, e) =>
|
|
|
+ {
|
|
|
+ onSaved?.Invoke();
|
|
|
+ };
|
|
|
|
|
|
grid.Refresh(true, true);
|
|
|
grid.Margin = new Thickness(5);
|