using System.Collections.Generic;
using Sockeye.Biz;
namespace Sockeye.DataList
{
    internal class ReportDataList : DataListProcessingBase
    {
        public ReportDataList(long translationId)
        {
            DefaultListAType = SockType.Report;
            SQLFrom = "from aReport";
            var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
            AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
            DefaultColumns = new List<string>() { "name", "aType", "ReportNotes", "active" };
            DefaultSortBy = new Dictionary<string, string>() { { "name", "+" } };
            FieldDefinitions = new List<DataListFieldDefinition>();

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "Report",
                FieldKey = "name",
                SockType = (int)SockType.Report,
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlIdColumnName = "aReport.id",
                SqlValueColumnName = "aReport.name",
                IsRowId = true
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "SockType",
                FieldKey = "aType",
                UiFieldDataType = (int)UiFieldDataType.Enum,
                EnumType = Sockeye.Util.StringUtil.TrimTypeName(typeof(SockType).ToString()),
                SqlValueColumnName = "areport.SockType"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "ReportNotes",
                FieldKey = "ReportNotes",
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlValueColumnName = "areport.notes"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "Active",
                FieldKey = "active",
                UiFieldDataType = (int)UiFieldDataType.Bool,
                SqlValueColumnName = "aReport.active"
            });

            FieldDefinitions.Add(new DataListFieldDefinition
            {
                TKey = "SelectRoles",
                FieldKey = "roles",
                UiFieldDataType = (int)UiFieldDataType.Roles,
                //NOTE: not technically an enum list but this will trigger datagrid at client to fetch roles for special handling
                EnumType = Sockeye.Util.StringUtil.TrimTypeName(typeof(AuthorizationRoles).ToString()),
                SqlValueColumnName = "areport.roles"
            });

        }
    }//eoc
}//eons