1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Linq;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.WPF;
- namespace PRSDesktop
- {
- public class JobFormGrid : DynamicDataGrid<JobForm>, IJobControl, IDataModelSource
- {
- public event DataModelUpdateEvent? OnUpdateDataModel;
- public string SectionName => "Job Forms";
- public DataModel DataModel(Selection selection)
- {
- var ids = ExtractValues(x => x.ID, selection).ToArray();
- return new AutoDataModel<JobForm>(new Filter<JobForm>(x => x.ID).InList(ids));
- }
- public JobFormGrid()
- {
- ActionColumns.Add(new DynamicImageColumn(PRSDesktop.Resources.pencil.AsBitmapImage(), EditAction));
- }
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
- {
- base.DoReconfigure(options);
- options
- .BeginUpdate()
- .Add(DynamicGridOption.SelectColumns)
- .Add(DynamicGridOption.FilterRows)
- .EndUpdate();
- }
- public Job Job { get; set; }
-
- public JobPanelSettings Settings { get; set; }
- private bool EditAction(CoreRow? row)
- {
- if (row == null) return false;
- if(DynamicFormEditWindow.EditDigitalForm<JobForm>(row.Get<JobForm, Guid>(x => x.ID), out var dataModel))
- {
- dataModel.Update(null);
- return true;
- }
- return false;
- }
- protected override void Reload(Filters<JobForm> criteria, Columns<JobForm> columns, ref SortOrder<JobForm>? sort,
- Action<CoreTable?, Exception?> action)
- {
- criteria.Add(new Filter<JobForm>(x => x.Parent.ID).IsEqualTo(Job.ID));
- base.Reload(criteria, columns, ref sort, action);
- }
- protected override JobForm CreateItem()
- {
- var result = base.CreateItem();
- result.Parent.ID = Job.ID;
- result.Parent.Synchronise(Job.ID);
- return result;
- }
- }
- }
|