This commit is contained in:
@@ -48,7 +48,7 @@ namespace AyaNova.DataList
|
|||||||
//Hard coded extra criteria from server end
|
//Hard coded extra criteria from server end
|
||||||
if (DataList is IAyaDataListViewServerCriteria)
|
if (DataList is IAyaDataListViewServerCriteria)
|
||||||
{
|
{
|
||||||
var ServerCriteriaListView = JArray.Parse(((IAyaDataListViewServerCriteria)DataList).ListViewServerCriteria(userId));
|
var ServerCriteriaListView = JArray.Parse(((IAyaDataListViewServerCriteria)DataList).ListViewServerCriteria(await ct.User.AsNoTracking().FirstOrDefaultAsync(z => z.Id == userId), ct));
|
||||||
foreach (JToken jt in ServerCriteriaListView)
|
foreach (JToken jt in ServerCriteriaListView)
|
||||||
InternalListViewArray.Add(jt);
|
InternalListViewArray.Add(jt);
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ namespace AyaNova.DataList
|
|||||||
//Hard coded extra criteria from server end
|
//Hard coded extra criteria from server end
|
||||||
if (DataList is IAyaDataListViewServerCriteria)
|
if (DataList is IAyaDataListViewServerCriteria)
|
||||||
{
|
{
|
||||||
var ServerCriteriaListView = JArray.Parse(((IAyaDataListViewServerCriteria)DataList).ListViewServerCriteria(userId));
|
var ServerCriteriaListView = JArray.Parse(((IAyaDataListViewServerCriteria)DataList).ListViewServerCriteria(await ct.User.AsNoTracking().FirstOrDefaultAsync(z => z.Id == userId), ct));
|
||||||
foreach (JToken jt in ServerCriteriaListView)
|
foreach (JToken jt in ServerCriteriaListView)
|
||||||
ListViewArray.Add(jt);
|
ListViewArray.Add(jt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
namespace AyaNova.DataList
|
namespace AyaNova.DataList
|
||||||
{
|
{
|
||||||
internal interface IAyaDataListViewServerCriteria
|
internal interface IAyaDataListViewServerCriteria
|
||||||
{
|
{
|
||||||
//Additional criteria for security or other reasons
|
//Additional criteria for security or other reasons
|
||||||
//hard coded into some lists (e.g. MemoDataList so users can't get other people's memos)
|
//hard coded into some lists (e.g. MemoDataList so users can't get other people's memos)
|
||||||
string ListViewServerCriteria (long userId);
|
string ListViewServerCriteria(AyaNova.Models.User user, AyaNova.Models.AyContext ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using AyaNova.Models;
|
||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
namespace AyaNova.DataList
|
namespace AyaNova.DataList
|
||||||
{
|
{
|
||||||
@@ -137,9 +138,9 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
string IAyaDataListViewServerCriteria.ListViewServerCriteria(long userId)
|
string IAyaDataListViewServerCriteria.ListViewServerCriteria(User user, AyaNova.Models.AyContext ct)
|
||||||
{
|
{
|
||||||
return "[{\"fld\":\"metamemoto\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + userId.ToString() + "}]}}]";
|
return "[{\"fld\":\"metamemoto\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + user.Id.ToString() + "}]}}]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using AyaNova.Models;
|
||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
namespace AyaNova.DataList
|
namespace AyaNova.DataList
|
||||||
{
|
{
|
||||||
@@ -17,7 +18,7 @@ namespace AyaNova.DataList
|
|||||||
//######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############
|
//######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############
|
||||||
|
|
||||||
dynamic dlistView = new JArray();
|
dynamic dlistView = new JArray();
|
||||||
|
|
||||||
dynamic cm = new JObject();
|
dynamic cm = new JObject();
|
||||||
cm.fld = "ReminderName";
|
cm.fld = "ReminderName";
|
||||||
dlistView.Add(cm);
|
dlistView.Add(cm);
|
||||||
@@ -113,9 +114,9 @@ namespace AyaNova.DataList
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Ensure only current user can fetch their reminders
|
//Ensure only current user can fetch their reminders
|
||||||
string IAyaDataListViewServerCriteria.ListViewServerCriteria(long userId)
|
string IAyaDataListViewServerCriteria.ListViewServerCriteria(User user, AyContext ct)
|
||||||
{
|
{
|
||||||
return "[{\"fld\":\"metareminderuser\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + userId.ToString() + "}]}}]";
|
return "[{\"fld\":\"metareminderuser\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + user.Id.ToString() + "}]}}]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using AyaNova.Models;
|
||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
namespace AyaNova.DataList
|
namespace AyaNova.DataList
|
||||||
{
|
{
|
||||||
@@ -184,9 +185,18 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
string IAyaDataListViewServerCriteria.ListViewServerCriteria(long userId)
|
string IAyaDataListViewServerCriteria.ListViewServerCriteria(User user, AyaNova.Models.AyContext ct)
|
||||||
{
|
{
|
||||||
return "[{\"fld\":\"metareviewuser\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + userId.ToString() + "}]}}]";
|
var CurrentUserRoles = user.Roles;
|
||||||
|
bool HasSupervisorRole =
|
||||||
|
CurrentUserRoles.HasFlag(AuthorizationRoles.BizAdminFull) ||
|
||||||
|
CurrentUserRoles.HasFlag(AuthorizationRoles.DispatchFull) ||
|
||||||
|
CurrentUserRoles.HasFlag(AuthorizationRoles.InventoryFull) ||
|
||||||
|
CurrentUserRoles.HasFlag(AuthorizationRoles.SalesFull) ||
|
||||||
|
CurrentUserRoles.HasFlag(AuthorizationRoles.AccountingFull);
|
||||||
|
if (!HasSupervisorRole)
|
||||||
|
return "[{\"fld\":\"metareviewuser\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + user.Id.ToString() + "}]}}]";
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|||||||
Reference in New Issue
Block a user