JobForm.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. using InABox.Core;
  2. namespace Comal.Classes
  3. {
  4. public class JobForm : EntityForm<Job, JobLink, JobForm>, IDigitalForm<Job>, ILicense<ProjectManagementLicense>
  5. {
  6. [EditorSequence(998)]
  7. [EntityRelationship(DeleteAction.Cascade)]
  8. public override JobLink Parent { get; set; }
  9. private class JobScopeLookup : LookupDefinitionGenerator<JobScope, JobForm>
  10. {
  11. public override Filter<JobScope> DefineFilter(JobForm[] items)
  12. {
  13. var item = items?.Length == 1 ? items[0] : null;
  14. if (item != null)
  15. return new Filter<JobScope>(x => x.Job.ID).IsEqualTo(item.Parent.ID).And(x => x.Status.Approved).IsEqualTo(true);
  16. return new Filter<JobScope>(x => x.ID).None();
  17. }
  18. public override Columns<JobForm> DefineFilterColumns()
  19. => new Columns<JobForm>(x => x.Parent.ID);
  20. }
  21. [LookupDefinition(typeof(JobScopeLookup))]
  22. [EditorSequence(999)]
  23. public JobScopeLink JobScope { get; set; }
  24. public override string AutoIncrementPrefix() => "JF";
  25. }
  26. }