147 lines
7.8 KiB
C#
147 lines
7.8 KiB
C#
using System.Collections.Generic;
|
|
using Newtonsoft.Json.Linq;
|
|
using AyaNova.Models;
|
|
using AyaNova.Biz;
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class MemoDataList : AyaDataList, IAyaDataListViewServerCriteria
|
|
{
|
|
public MemoDataList()
|
|
{
|
|
|
|
DefaultListObjectType = AyaType.Memo;
|
|
SQLFrom = "from amemo left join auser on (amemo.fromid=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 = "MemoSubject";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "MemoFromID";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "MemoSent";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "MemoViewed";
|
|
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 = "MemoSubject",
|
|
FieldKey = "MemoSubject",
|
|
AyaObjectType = (int)AyaType.Memo,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "amemo.id",
|
|
SqlValueColumnName = "amemo.name",
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "MemoMessage",
|
|
FieldKey = "MemoMessage",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "amemo.notes"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "MemoFromID",
|
|
FieldKey = "MemoFromID",
|
|
AyaObjectType = (int)AyaType.User,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "auser.id",
|
|
SqlValueColumnName = "auser.name",
|
|
IsRowId = false
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "MemoSent",
|
|
FieldKey = "MemoSent",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "amemo.sent"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "MemoReplied",
|
|
FieldKey = "MemoReplied",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "amemo.replied"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "MemoViewed",
|
|
FieldKey = "MemoViewed",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "amemo.viewed"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "Tags",
|
|
FieldKey = "MemoTags",
|
|
UiFieldDataType = (int)UiFieldDataType.Tags,
|
|
SqlValueColumnName = "amemo.tags"
|
|
});
|
|
|
|
//META column
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
FieldKey = "metamemoto",
|
|
SqlIdColumnName = "amemo.toid",
|
|
SqlValueColumnName = "amemo.toid",
|
|
IsMeta = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom1", FieldKey = "MemoCustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom2", FieldKey = "MemoCustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom3", FieldKey = "MemoCustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom4", FieldKey = "MemoCustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom5", FieldKey = "MemoCustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom6", FieldKey = "MemoCustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom7", FieldKey = "MemoCustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom8", FieldKey = "MemoCustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom9", FieldKey = "MemoCustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom10", FieldKey = "MemoCustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom11", FieldKey = "MemoCustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom12", FieldKey = "MemoCustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom13", FieldKey = "MemoCustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom14", FieldKey = "MemoCustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom15", FieldKey = "MemoCustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "MemoCustom16", FieldKey = "MemoCustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amemo.customfields" });
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string IAyaDataListViewServerCriteria.ListViewServerCriteria(User user, AyaNova.Models.AyContext ct)
|
|
{
|
|
return "[{\"fld\":\"metamemoto\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + user.Id.ToString() + "}]}}]";
|
|
}
|
|
|
|
}//eoc
|
|
}//eons |