78 lines
2.8 KiB
C#
78 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using Newtonsoft.Json.Linq;
|
|
using AyaNova.Biz;
|
|
namespace AyaNova.PickList
|
|
{
|
|
internal class UserPickList : AyaPickList, IAyaPickListVariant
|
|
{
|
|
public UserPickList()
|
|
{
|
|
|
|
DefaultListAType = AyaType.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}";
|
|
}
|
|
return string.Empty;
|
|
}
|
|
}//eoc
|
|
}//eons |