using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Sockeye.Biz;
namespace Sockeye.PickList
{
    internal class HeadOfficePickList : AyaPickList
    {
        public HeadOfficePickList()
        {

            DefaultListAType = SockType.HeadOffice;
            SQLFrom = "from aheadoffice";
            AllowedRoles = BizRoles.GetRoleSet(DefaultListAType).Select;
            dynamic dTemplate = new JArray();

            dynamic cm = new JObject();
            cm.fld = "headofficename";
            dTemplate.Add(cm);

            cm = new JObject();
            cm.fld = "headofficetags";
            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 = "headofficeactive",
                ColumnDataType = UiFieldDataType.Bool,
                SqlValueColumnName = "aheadoffice.active",
                IsActiveColumn = true
            });
            ColumnDefinitions.Add(new AyaPickListFieldDefinition
            {
                TKey = "Name",
                FieldKey = "headofficename",
                ColumnDataType = UiFieldDataType.Text,
                SqlIdColumnName = "aheadoffice.id",
                SqlValueColumnName = "aheadoffice.name",
                IsRowId = true
            });

             ColumnDefinitions.Add(new AyaPickListFieldDefinition
            {
                TKey = "Tags",
                FieldKey = "headofficetags",
                ColumnDataType = UiFieldDataType.Tags,
                SqlValueColumnName = "aheadoffice.tags"
            });
           
        }
    }//eoc
}//eons