|
@@ -14,18 +14,22 @@ using InABox.DynamicGrid;
|
|
|
using InABox.WPF;
|
|
|
using Syncfusion.Pdf.Graphics;
|
|
|
using Syncfusion.Pdf;
|
|
|
-using gnu.java.awt.color;
|
|
|
using System.Windows.Data;
|
|
|
using System.Windows.Media;
|
|
|
using System.Drawing;
|
|
|
-using static com.sun.tools.javac.code.Symbol;
|
|
|
|
|
|
namespace PRSDesktop
|
|
|
{
|
|
|
+ public class TaskPanelProperties : BaseObject, GlobalConfigurationSettings
|
|
|
+ {
|
|
|
+ [CheckBoxEditor(ToolTip = "Require that all tasks are given a task type.")]
|
|
|
+ public bool RequireTaskTypes { get; set; } = false;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Interaction logic for TaskPanel.xaml
|
|
|
/// </summary>
|
|
|
- public partial class TaskPanel : UserControl, IPanel<Kanban>, ITaskHost, IJobControl
|
|
|
+ public partial class TaskPanel : UserControl, IPanel<Kanban>, ITaskHost, IJobControl, IPropertiesPanel<TaskPanelProperties>
|
|
|
{
|
|
|
private bool _bTabChanging;
|
|
|
public Guid MyID { get; set; } = CoreUtils.FullGuid;
|
|
@@ -826,7 +830,9 @@ namespace PRSDesktop
|
|
|
GetCurrentPanel()?.Refresh(false);
|
|
|
}
|
|
|
|
|
|
- public string? SectionName => GetCurrentPanel().SectionName;
|
|
|
+ public string SectionName => GetCurrentPanel().SectionName;
|
|
|
+
|
|
|
+ public TaskPanelProperties Properties { get; set; }
|
|
|
|
|
|
public DataModel DataModel(Selection selection)
|
|
|
{
|
|
@@ -838,26 +844,33 @@ namespace PRSDesktop
|
|
|
|
|
|
#region CRUD Functionality
|
|
|
|
|
|
- private TEntity? DoCreate<TEntity>(Action<TEntity> customise) where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
+ private TEntity? DoCreate<TEntity>(Action<TEntity> customise)
|
|
|
+ where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
{
|
|
|
var result = new TEntity();
|
|
|
customise?.Invoke(result);
|
|
|
- if (DoEdit(new[] { result }))
|
|
|
+ if (DoEdit(new[] { result }, null))
|
|
|
return result;
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private static readonly Dictionary<Type, IDynamicGrid> _grids = new();
|
|
|
+ private readonly Dictionary<Type, IDynamicGrid> _grids = new();
|
|
|
|
|
|
private readonly List<Tuple<Guid, Entity>> _entitycache = new();
|
|
|
|
|
|
- private static DynamicDataGrid<TEntity> GetGrid<TEntity>() where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
+ private DynamicDataGrid<TEntity> GetGrid<TEntity>() where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
{
|
|
|
if(!_grids.TryGetValue(typeof(TEntity), out var grid))
|
|
|
{
|
|
|
grid = (DynamicGridUtils.CreateDynamicGrid(typeof(DynamicDataGrid<>), typeof(TEntity)) as DynamicDataGrid<TEntity>)!;
|
|
|
_grids[typeof(TEntity)] = grid;
|
|
|
+
|
|
|
+ if (typeof(TEntity) == typeof(Kanban))
|
|
|
+ {
|
|
|
+ CustomiseKanbanGrid((grid as DynamicDataGrid<Kanban>)!);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
return (grid as DynamicDataGrid<TEntity>)!;
|
|
|
}
|
|
|
|
|
@@ -915,7 +928,7 @@ namespace PRSDesktop
|
|
|
_entitycache.Add(new Tuple<Guid, Entity>(kanbanid, entity));
|
|
|
}
|
|
|
|
|
|
- private static bool DoEdit<TEntity>(IEnumerable<TEntity> entities, Action<TEntity>? action = null)
|
|
|
+ private bool DoEdit<TEntity>(IEnumerable<TEntity> entities, Action<TEntity>? action = null)
|
|
|
where TEntity : Entity, IRemotable, IPersistent, new()
|
|
|
{
|
|
|
if (entities == null || !entities.Any())
|
|
@@ -991,6 +1004,19 @@ namespace PRSDesktop
|
|
|
return DoLoad(models, columns);
|
|
|
}
|
|
|
|
|
|
+ public void OnValidateKanban(object sender, Kanban[] items, List<string> errors)
|
|
|
+ {
|
|
|
+ if (Properties.RequireTaskTypes && items.Any(x => x.Type.ID == Guid.Empty))
|
|
|
+ {
|
|
|
+ errors.Add("[Task Type] may not be blank!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void CustomiseKanbanGrid(DynamicDataGrid<Kanban> grid)
|
|
|
+ {
|
|
|
+ grid.OnValidate += OnValidateKanban;
|
|
|
+ }
|
|
|
+
|
|
|
public bool EditKanbans(IEnumerable<TaskModel> models, Action<Kanban>? customise = null)
|
|
|
{
|
|
|
var entities = LoadKanbans(models, GetGrid<Kanban>().LoadEditorColumns());
|