Files
raven/server/AyaNova/PickList/ReportPickList.cs
2021-06-15 20:14:33 +00:00

56 lines
1.9 KiB
C#

using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using AyaNova.Biz;
namespace AyaNova.PickList
{
internal class ReportPickList : AyaPickList, IAyaPickListVariant
{
public ReportPickList()
{
DefaultListAType = AyaType.Report;
SQLFrom = "from areport";
AllowedRoles = BizRoles.GetRoleSet(DefaultListAType).Select;
dynamic dTemplate = new JArray();
dynamic cm = new JObject();
cm.fld = "reportname";
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 = "reportactive",
ColumnDataType = UiFieldDataType.Bool,
SqlValueColumnName = "areport.active",
IsActiveColumn = true
});
ColumnDefinitions.Add(new AyaPickListFieldDefinition
{
TKey = "Name",
FieldKey = "reportname",
ColumnDataType = UiFieldDataType.Text,
SqlIdColumnName = "areport.id",
SqlValueColumnName = "areport.name",
IsRowId = true
});
}
public string GetVariantCriteria(string variant)
{
//has for type variant
if (string.IsNullOrWhiteSpace(variant))
return string.Empty;
int forType;
if (!int.TryParse(variant, out forType))
return string.Empty;
return $"areport.atype={forType}";
}
}//eoc
}//eons