This commit is contained in:
80
server/PickList/UserPickList.cs
Normal file
80
server/PickList/UserPickList.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Sockeye.Biz;
|
||||
namespace Sockeye.PickList
|
||||
{
|
||||
internal class UserPickList : AyaPickList, IAyaPickListVariant
|
||||
{
|
||||
public UserPickList()
|
||||
{
|
||||
|
||||
DefaultListAType = SockType.User;
|
||||
SQLFrom = "from auser";
|
||||
AllowedRoles = BizRoles.GetRoleSet(DefaultListAType).Select;
|
||||
dynamic dTemplate = new JArray();
|
||||
|
||||
dynamic cm = new JObject();
|
||||
cm.fld = "username";
|
||||
dTemplate.Add(cm);
|
||||
|
||||
cm = new JObject();
|
||||
cm.fld = "useremployeenumber";
|
||||
dTemplate.Add(cm);
|
||||
|
||||
cm = new JObject();
|
||||
cm.fld = "usertags";
|
||||
dTemplate.Add(cm);
|
||||
|
||||
base.DefaultTemplate = dTemplate.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
|
||||
ColumnDefinitions = new List<AyaPickListFieldDefinition>();
|
||||
ColumnDefinitions.Add(new AyaPickListFieldDefinition
|
||||
{
|
||||
TKey = "Active",
|
||||
FieldKey = "useractive",
|
||||
ColumnDataType = UiFieldDataType.Bool,
|
||||
SqlValueColumnName = "auser.active",
|
||||
IsActiveColumn = true
|
||||
});
|
||||
ColumnDefinitions.Add(new AyaPickListFieldDefinition
|
||||
{
|
||||
TKey = "Name",
|
||||
FieldKey = "username",
|
||||
ColumnDataType = UiFieldDataType.Text,
|
||||
SqlIdColumnName = "auser.id",
|
||||
SqlValueColumnName = "auser.name",
|
||||
IsRowId = true
|
||||
});
|
||||
ColumnDefinitions.Add(new AyaPickListFieldDefinition
|
||||
{
|
||||
TKey = "UserEmployeeNumber",
|
||||
FieldKey = "useremployeenumber",
|
||||
ColumnDataType = UiFieldDataType.Text,
|
||||
SqlValueColumnName = "auser.employeenumber"
|
||||
});
|
||||
|
||||
ColumnDefinitions.Add(new AyaPickListFieldDefinition
|
||||
{
|
||||
TKey = "Tags",
|
||||
FieldKey = "usertags",
|
||||
ColumnDataType = UiFieldDataType.Tags,
|
||||
SqlValueColumnName = "auser.tags"
|
||||
});
|
||||
}
|
||||
|
||||
public string GetVariantCriteria(string variant)
|
||||
{
|
||||
switch (variant)
|
||||
{
|
||||
case "inside":
|
||||
return $"auser.usertype!={(int)UserType.Customer} and auser.usertype!={(int)UserType.HeadOffice}";
|
||||
case "outside":
|
||||
return $"auser.usertype={(int)UserType.Customer} or auser.usertype={(int)UserType.HeadOffice}";
|
||||
case "tech":
|
||||
return $"auser.usertype={(int)UserType.Service} or auser.usertype={(int)UserType.ServiceContractor}";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user