Files
raven/server/AyaNova/DataList/ProjectDataList.cs
2020-12-16 18:17:01 +00:00

145 lines
8.1 KiB
C#

using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using AyaNova.Biz;
namespace AyaNova.DataList
{
internal class ProjectDataList : AyaDataList
{
public ProjectDataList()
{
DefaultListObjectType = AyaType.Project;
SQLFrom = "from aproject left outer join auser on (aproject.projectoverseerid=auser.id)";
var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType);
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
//######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############
//Default ListView
dynamic dlistView = new JArray();
dynamic cm = new JObject();
cm.fld = "projectname";
cm.sort = "+";
dlistView.Add(cm);
cm = new JObject();
cm.fld = "ProjectProjectOverseerID";
dlistView.Add(cm);
cm = new JObject();
cm.fld = "ProjectDateStarted";
dlistView.Add(cm);
cm = new JObject();
cm.fld = "ProjectDateCompleted";
dlistView.Add(cm);
cm = new JObject();
cm.fld = "ProjectAccountNumber";
dlistView.Add(cm);
cm = new JObject();
cm.fld = "projectactive";
dlistView.Add(cm);
cm = new JObject();
cm.fld = "projecttags";
dlistView.Add(cm);
DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely
FieldDefinitions = new List<AyaDataListFieldDefinition>();
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "ProjectName",
FieldKey = "projectname",
AyaObjectType = (int)AyaType.Project,
UiFieldDataType = (int)UiFieldDataType.Text,
SqlIdColumnName = "aproject.id",
SqlValueColumnName = "aproject.name",
IsRowId = true
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "ProjectNotes",
FieldKey = "projectnotes",
UiFieldDataType = (int)UiFieldDataType.Text,
SqlValueColumnName = "aproject.notes"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "Active",
FieldKey = "projectactive",
UiFieldDataType = (int)UiFieldDataType.Bool,
SqlValueColumnName = "aproject.active"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "Tags",
FieldKey = "projecttags",
UiFieldDataType = (int)UiFieldDataType.Tags,
SqlValueColumnName = "aproject.tags"
});
//------------
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "ProjectAccountNumber",
FieldKey = "ProjectAccountNumber",
UiFieldDataType = (int)UiFieldDataType.Text,
SqlValueColumnName = "aproject.accountnumber"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
FieldKey = "ProjectProjectOverseerID",
TKey = "ProjectProjectOverseerID",
UiFieldDataType = (int)UiFieldDataType.Text,
AyaObjectType = (int)AyaType.User,
SqlIdColumnName = "auser.id",
SqlValueColumnName = "auser.name"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "ProjectDateStarted",
FieldKey = "ProjectDateStarted",
UiFieldDataType = (int)UiFieldDataType.DateTime,
SqlValueColumnName = "aproject.datestarted"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "ProjectDateCompleted",
FieldKey = "ProjectDateCompleted",
UiFieldDataType = (int)UiFieldDataType.DateTime,
SqlValueColumnName = "aproject.datecompleted"
});
//-----------
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom1", FieldKey = "projectcustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom2", FieldKey = "projectcustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom3", FieldKey = "projectcustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom4", FieldKey = "projectcustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom5", FieldKey = "projectcustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom6", FieldKey = "projectcustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom7", FieldKey = "projectcustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom8", FieldKey = "projectcustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom9", FieldKey = "projectcustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom10", FieldKey = "projectcustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom11", FieldKey = "projectcustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom12", FieldKey = "projectcustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom13", FieldKey = "projectcustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom14", FieldKey = "projectcustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom15", FieldKey = "projectcustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ProjectCustom16", FieldKey = "projectcustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aproject.customfields" });
}
}//eoc
}//eons