This commit is contained in:
2021-01-27 22:36:47 +00:00
parent 67d89b1d32
commit 59537b6896

View File

@@ -1,8 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using AyaNova.Models; using AyaNova.Models;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using AyaNova.Biz; using AyaNova.Biz;
namespace AyaNova.DataList namespace AyaNova.DataList
{ {
@@ -12,47 +9,52 @@ namespace AyaNova.DataList
{ {
DefaultListObjectType = AyaType.Review; DefaultListObjectType = AyaType.Review;
SQLFrom = "from areview left join auser uassto on (areview.userid=uassto.id) left join auser uassby on (areview.assignedbyuserid=uassby.id)"; SQLFrom = "from areview "
+ "left join auser uassto on (areview.userid=uassto.id) "
+ "left join auser uassby on (areview.assignedbyuserid=uassby.id)";
var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType);
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
//######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############
//Default ListView // //Default ListView
dynamic dlistView = new JArray(); // dynamic dlistView = new JArray();
dynamic cm = null; // dynamic cm = null;
cm = new JObject(); // cm = new JObject();
cm.fld = "ReviewCompletedDate"; // cm.fld = "ReviewCompletedDate";
cm.sort = "-"; // cm.sort = "-";
dlistView.Add(cm); // dlistView.Add(cm);
cm = new JObject(); // cm = new JObject();
cm.fld = "ReviewDueDate"; // cm.fld = "ReviewDueDate";
cm.sort = "+"; // cm.sort = "+";
dlistView.Add(cm); // dlistView.Add(cm);
cm = new JObject(); // cm = new JObject();
cm.fld = "ReviewName"; // cm.fld = "ReviewName";
dlistView.Add(cm); // dlistView.Add(cm);
cm = new JObject();
cm.fld = "Object";
dlistView.Add(cm);
cm = new JObject(); // cm = new JObject();
cm.fld = "AyaType"; // cm.fld = "Object";
dlistView.Add(cm); // dlistView.Add(cm);
cm = new JObject(); // cm = new JObject();
cm.fld = "ReviewNotes"; // cm.fld = "AyaType";
dlistView.Add(cm); // dlistView.Add(cm);
cm = new JObject(); // cm = new JObject();
cm.fld = "ReviewUserId"; // cm.fld = "ReviewNotes";
dlistView.Add(cm); // dlistView.Add(cm);
DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); // cm = new JObject();
// cm.fld = "ReviewUserId";
// dlistView.Add(cm);
// DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);
DefaultColumns = new List<string>() { "ReviewCompletedDate", "ReviewDueDate", "ReviewName", "Object", "AyaType", "ReviewNotes", "ReviewUserId" };
DefaultSortBy = new Dictionary<string, string>() { { "ReviewCompletedDate", "-" }, { "ReviewDueDate", "+" } };
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely //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 = new List<AyaDataListFieldDefinition>();
@@ -189,19 +191,41 @@ namespace AyaNova.DataList
string IAyaDataListServerCriteria.DataListServerCriteria(long currentUserId, AyaNova.Biz.AuthorizationRoles userRoles, DataListOptions dataListOptions) // string IAyaDataListServerCriteria.DataListServerCriteria(long currentUserId, AyaNova.Biz.AuthorizationRoles userRoles, DataListOptions dataListOptions)
// {
// bool HasSupervisorRole =
// userRoles.HasFlag(AuthorizationRoles.BizAdminFull) ||
// userRoles.HasFlag(AuthorizationRoles.DispatchFull) ||
// userRoles.HasFlag(AuthorizationRoles.InventoryFull) ||
// userRoles.HasFlag(AuthorizationRoles.SalesFull) ||
// userRoles.HasFlag(AuthorizationRoles.AccountingFull);
// if (!HasSupervisorRole)
// return "[{\"fld\":\"metareviewuser\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + currentUserId.ToString() + "}]}}]";
// return "[]";//this means effectively don't process this at all
// }
public List<DataListFilterOption> DataListServerCriteria(long currentUserId, AuthorizationRoles userRoles, DataListBase dataListBase)
{ {
List<DataListFilterOption> ret = new List<DataListFilterOption>();
bool HasSupervisorRole = bool HasSupervisorRole =
userRoles.HasFlag(AuthorizationRoles.BizAdminFull) || userRoles.HasFlag(AuthorizationRoles.BizAdminFull)
userRoles.HasFlag(AuthorizationRoles.DispatchFull) || || userRoles.HasFlag(AuthorizationRoles.DispatchFull)
userRoles.HasFlag(AuthorizationRoles.InventoryFull) || || userRoles.HasFlag(AuthorizationRoles.InventoryFull)
userRoles.HasFlag(AuthorizationRoles.SalesFull) || || userRoles.HasFlag(AuthorizationRoles.SalesFull)
userRoles.HasFlag(AuthorizationRoles.AccountingFull); || userRoles.HasFlag(AuthorizationRoles.AccountingFull);
if (!HasSupervisorRole) if (!HasSupervisorRole)
return "[{\"fld\":\"metareviewuser\",\"filter\":{\"items\":[{\"op\":\"=\",\"value\":" + currentUserId.ToString() + "}]}}]"; {
return "[]";//this means effectively don't process this at all DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metareviewuser" };
FilterOption.items.Add(new DataListColumnFilter() { value = currentUserId.ToString(), op = DataListFilterComparisonOperator.Equality });
ret.Add(FilterOption);
}
return ret;
} }
}//eoc }//eoc
}//eons }//eons