1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Comal.Classes;
- using InABox.Core;
- namespace comal.timesheets
- {
- public class EquipmentDetailsDataModel : ListDataModel<Equipment, EquipmentDetailsDataModelItem>
- {
- private IList<EquipmentKanbanDataModelItem> _openKanbans = new List<EquipmentKanbanDataModelItem>();
- public IList<EquipmentKanbanDataModelItem> OpenKanbans
- {
- get { return _openKanbans; }
- set { SetProperty(ref _openKanbans, value); }
- }
- private bool _openKanbansVisible = false;
- public bool OpenKanbansVisible
- {
- get { return _openKanbansVisible; }
- set { SetProperty(ref _openKanbansVisible, value); }
- }
-
- public override Columns<Equipment> Columns => new Columns<Equipment>(x => x.ID)
- .Add(x => x.Description)
- .Add(x => x.GroupLink.Description)
- .Add(x => x.DigitalKey.ID)
- .Add(x => x.Notes)
- .Add(x => x.SpecificationSheet.ID)
- .Add(x => x.Documents);
- //.Add(x => x.Kanbans);
- public override void BeforeLoad(MultiQuery query, Filter<Equipment> filter)
- {
- base.BeforeLoad(query, filter);
- query.Add(
- new Filter<Kanban>(x => x.Equipment.ID).InQuery(filter, x => x.ID)
- .And(x=>x.Completed).IsEqualTo(DateTime.MinValue),
- new Columns<Kanban>(x=>x.ID)
- .Add(x=>x.Title)
- );
- }
-
- public override void AfterLoad(MultiQuery query, Filter<Equipment> filter)
- {
- OpenKanbans = new List<EquipmentKanbanDataModelItem>(
- query.Get<Kanban>().Rows.Select(row => new EquipmentKanbanDataModelItem() { Row = row, Parent = this })
- );
- OpenKanbansVisible = OpenKanbans.Any();
- base.AfterLoad(query, filter);
- }
-
- }
-
- public class EquipmentKanbanDataModelItem : CoreDataModelItem
- {
- public Guid ID => Row.Get<Kanban, Guid>(c => c.ID);
- public String Title => Row.Get<Kanban, String>(c => c.Title);
- }
- public class EquipmentDetailsDataModelItem : CoreDataModelItem
- {
- public Guid ID => Row.Get<Equipment, Guid>(c => c.ID);
- public String Description => Row.Get<Equipment, String>(c => c.Description);
- public String GroupName => Row.Get<Equipment, String>(c => c.GroupLink.Description);
- public String Notes => Row.Get<Equipment, String>(c => c.Notes);
-
- public bool DigitalKeyVisible => Row.Get<Equipment, Guid>(c => c.DigitalKey.ID) != Guid.Empty;
-
- public Guid SpecificationSheetID => Row.Get<Equipment, Guid>(c => c.SpecificationSheet.ID);
- public bool SpecificationSheetVisible => SpecificationSheetID != Guid.Empty;
-
- public bool DocumentsVisible => Row.Get<Equipment, int>(c => c.Documents) > 0;
- public String DocumentsDescription => $"Documents ({Row.Get<Equipment, int>(c => c.Documents)})";
- public bool KanbansVisible => false; //Row.Get<Equipment, int>(c => c.Kanbans) > 0;
- public String KanbansDescription => $"View Tasks / History (0)"; //{Row.Get<Equipment, int>(c => c.Kanbans)})";
- }
- }
|