This commit is contained in:
@@ -16,7 +16,7 @@ namespace AyaNova.DataList
|
||||
//CoreBizObject add here
|
||||
//well, not here exactly but add a new DATALIST class if it will be displayed as a list anywhere in the UI or reported on
|
||||
public AyaDataList()
|
||||
{
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace AyaNova.DataList
|
||||
public AyaType DefaultListObjectType { get; set; }
|
||||
|
||||
public string DefaultListView { get; set; }
|
||||
public string AdditionalCriteriaInternalListView { get; set; }
|
||||
public long CurrentUserId { get; set; }
|
||||
|
||||
|
||||
//return array of field keys in list view
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace AyaNova.DataList
|
||||
// Get the data list data requested
|
||||
//
|
||||
//
|
||||
internal static async Task<ApiDataListResponse> GetResponseAsync(string DataListKey, AyContext ct, ListOptions listOptions, AuthorizationRoles UserRoles, ILogger log)
|
||||
internal static async Task<ApiDataListResponse> GetResponseAsync(string DataListKey, AyContext ct, ListOptions listOptions, AuthorizationRoles UserRoles, ILogger log, long userId)
|
||||
{
|
||||
|
||||
var DataList = DataListFactory.GetAyaDataList(DataListKey);
|
||||
@@ -27,6 +27,7 @@ namespace AyaNova.DataList
|
||||
if (DataList == null)
|
||||
throw new System.ArgumentOutOfRangeException($"DataList \"{DataListKey}\" specified does not exist");
|
||||
|
||||
|
||||
//check rights
|
||||
if (!UserRoles.HasAnyFlags(DataList.AllowedRoles))
|
||||
throw new System.UnauthorizedAccessException("User roles insufficient for this datalist");
|
||||
@@ -39,8 +40,20 @@ namespace AyaNova.DataList
|
||||
//This one is for the return list to the Client for grid column display
|
||||
var PublicListViewArray = JArray.Parse(listOptions.ListView);
|
||||
|
||||
|
||||
|
||||
//this one is for internal use here to build the filter and sort etc
|
||||
var InternalListViewArray = JArray.Parse(listOptions.ListView);
|
||||
|
||||
//Hard coded extra criteria from server end
|
||||
if (DataList is IAyaDataListViewServerCriteria)
|
||||
{
|
||||
var ServerCriteriaListView = ((IAyaDataListViewServerCriteria)DataList).ListViewServerCriteria(userId);
|
||||
foreach (JToken jt in ServerCriteriaListView)
|
||||
InternalListViewArray.Add(jt);
|
||||
}
|
||||
|
||||
//Hard coded extra criteria from Client end
|
||||
var MetaListViewArray = JArray.Parse(listOptions.MetaView ?? "[]");
|
||||
foreach (JToken jt in MetaListViewArray)
|
||||
InternalListViewArray.Add(jt);
|
||||
@@ -216,13 +229,15 @@ namespace AyaNova.DataList
|
||||
// Get a list of id's of the datalist results for reporting
|
||||
//
|
||||
//
|
||||
internal static async Task<long[]> GetIdListResponseAsync(string dataListKey, string listView, string metaListView, AyContext ct, AuthorizationRoles userRoles, ILogger log)
|
||||
internal static async Task<long[]> GetIdListResponseAsync(string dataListKey, string listView, string metaListView, AyContext ct, AuthorizationRoles userRoles, ILogger log, long userId)
|
||||
{
|
||||
var DataList = DataListFactory.GetAyaDataList(dataListKey);
|
||||
//was the name not found as a list?
|
||||
if (DataList == null)
|
||||
throw new System.ArgumentOutOfRangeException($"DataList \"{dataListKey}\" specified does not exist");
|
||||
|
||||
|
||||
|
||||
//check rights
|
||||
if (!userRoles.HasAnyFlags(DataList.AllowedRoles))
|
||||
throw new System.UnauthorizedAccessException("User roles insufficient for this datalist");
|
||||
@@ -234,6 +249,17 @@ namespace AyaNova.DataList
|
||||
//parse the list view
|
||||
var ListViewArray = JArray.Parse(listView);
|
||||
|
||||
|
||||
//Hard coded extra criteria from server end
|
||||
if (DataList is IAyaDataListViewServerCriteria)
|
||||
{
|
||||
var ServerCriteriaListView = ((IAyaDataListViewServerCriteria)DataList).ListViewServerCriteria(userId);
|
||||
foreach (JToken jt in ServerCriteriaListView)
|
||||
ListViewArray.Add(jt);
|
||||
}
|
||||
|
||||
//Hard coded extra criteria from Client end
|
||||
//parse and combine any additional listview hard coded from Client UI
|
||||
var MetaListViewArray = JArray.Parse(metaListView ?? "[]");
|
||||
foreach (JToken jt in MetaListViewArray)
|
||||
ListViewArray.Add(jt);
|
||||
|
||||
@@ -21,6 +21,12 @@ namespace AyaNova.DataList
|
||||
//Default / STOCK DataListView when none is specified
|
||||
string DefaultListView { get; set; }
|
||||
|
||||
//Additional criteria for security or other reasons
|
||||
//hard coded into some lists (e.g. MemoDataList so users can't get other people's memos)
|
||||
// string AdditionalCriteriaInternalListView (long userId);
|
||||
|
||||
|
||||
|
||||
Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromListView(JArray listViewArray);
|
||||
List<string> GetFieldListFromListView(JArray listViewArray);
|
||||
|
||||
|
||||
9
server/AyaNova/DataList/IAyaDataListExtraCriteria.cs
Normal file
9
server/AyaNova/DataList/IAyaDataListExtraCriteria.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace AyaNova.DataList
|
||||
{
|
||||
internal interface IAyaDataListViewServerCriteria
|
||||
{
|
||||
//Additional criteria for security or other reasons
|
||||
//hard coded into some lists (e.g. MemoDataList so users can't get other people's memos)
|
||||
string ListViewServerCriteria (long userId);
|
||||
}
|
||||
}
|
||||
89
server/AyaNova/DataList/MemoDataList.cs
Normal file
89
server/AyaNova/DataList/MemoDataList.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using AyaNova.Biz;
|
||||
namespace AyaNova.DataList
|
||||
{
|
||||
internal class MemoDataList : AyaDataList,IAyaDataListViewServerCriteria
|
||||
{
|
||||
public MemoDataList()
|
||||
{
|
||||
|
||||
DefaultListObjectType = AyaType.Memo;
|
||||
SQLFrom = "from amemo left outer 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);
|
||||
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 = "User",
|
||||
FieldKey = "username",
|
||||
AyaObjectType = (int)AyaType.User,
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlIdColumnName = "auser.id",
|
||||
SqlValueColumnName = "auser.name",
|
||||
IsRowId = false
|
||||
});
|
||||
|
||||
|
||||
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
TKey = "MemoNotes",
|
||||
FieldKey = "notes",
|
||||
AyaObjectType = (int)AyaType.Memo,
|
||||
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||
SqlIdColumnName = "amemo.id",
|
||||
SqlValueColumnName = "amemo.notes",
|
||||
IsRowId = true
|
||||
});
|
||||
|
||||
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
TKey = "MemoNoteDate",
|
||||
FieldKey = "notedate",
|
||||
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
||||
SqlValueColumnName = "amemo.notedate"
|
||||
});
|
||||
|
||||
//META column
|
||||
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
FieldKey = "metacustomer",
|
||||
SqlIdColumnName = "amemo.customerid",
|
||||
SqlValueColumnName = "amemo.customerid",
|
||||
IsMeta = true
|
||||
});
|
||||
}
|
||||
|
||||
string IAyaDataListViewServerCriteria.ListViewServerCriteria(long userId)
|
||||
{
|
||||
//todo: take user id here and return additional criteria listview
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user