using System.Collections.Generic;
using AyaNova.Biz;
namespace AyaNova.DataList
{
    internal class UserDataList : AyaDataList
    {

        public UserDataList()
        {
            DefaultListObjectType = AyaType.User;
            ListKey = nameof(UserDataList);
            SQLFrom = "from auser";
            FullListAllowedRoles = BizRoles.GetRoleSet(DefaultListObjectType).ReadFullRecord;
            MiniListAllowedRoles = AuthorizationRoles.All;//anyone (so can select on forms)            
            DefaultDataListDisplayTemplate = @"
            {
                ""full"":[""username"",""useremployeenumber"",""useractive"",""usernotes"",""userroles""],
                ""mini"":[""username""]
            }
            ";

            //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined (in this case User) table need to be specified completely
            FieldDefinitions = new List<AyaDataListFieldDefinition>();
            FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.User, SqlIdColumnName = "auser.id" });
            FieldDefinitions.Add(new AyaDataListFieldDefinition
            {
                LtKey = "User",
                FieldKey = "username",
                AyaObjectType = (int)AyaType.User,
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlIdColumnName = "auser.id",
                SqlValueColumnName = "auser.name"
            });

            FieldDefinitions.Add(new AyaDataListFieldDefinition
            {
                LtKey = "Active",
                FieldKey = "useractive",
                UiFieldDataType = (int)UiFieldDataType.Bool,
                SqlValueColumnName = "auser.active"
            });

            FieldDefinitions.Add(new AyaDataListFieldDefinition
            {
                LtKey = "AuthorizationRoles",
                FieldKey = "userroles",
                UiFieldDataType = (int)UiFieldDataType.Enum,
                EnumType = typeof(AuthorizationRoles).ToString(),
                SqlValueColumnName = "auser.roles"
            });

            FieldDefinitions.Add(new AyaDataListFieldDefinition
            {
                LtKey = "UserType",
                FieldKey = "usertype",
                UiFieldDataType = (int)UiFieldDataType.Enum,
                EnumType = typeof(UserType).ToString(),
                SqlValueColumnName = "auser.usertype"
            });

            FieldDefinitions.Add(new AyaDataListFieldDefinition
            {
                LtKey = "UserEmployeeNumber",
                FieldKey = "useremployeenumber",
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlValueColumnName = "auser.employeenumber"
            });

            FieldDefinitions.Add(new AyaDataListFieldDefinition
            {
                LtKey = "UserNotes",
                FieldKey = "usernotes",
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlValueColumnName = "auser.notes"
            });


            // //-------------------------
            //NOT SURE ABOUT CUSTOM FIELDS
            //NEED TO COME BACK TO THIS ONCE CLIENT IS CONSUMING THESE LISTS
            //WIDGETLIST has custom fields so good test before doing here

            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom1", FieldKey = "widgetcustom1", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom2", FieldKey = "widgetcustom2", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom3", FieldKey = "widgetcustom3", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom4", FieldKey = "widgetcustom4", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom5", FieldKey = "widgetcustom5", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom6", FieldKey = "widgetcustom6", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom7", FieldKey = "widgetcustom7", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom8", FieldKey = "widgetcustom8", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom9", FieldKey = "widgetcustom9", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom10", FieldKey = "widgetcustom10", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom11", FieldKey = "widgetcustom11", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom12", FieldKey = "widgetcustom12", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom13", FieldKey = "widgetcustom13", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom14", FieldKey = "widgetcustom14", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom15", FieldKey = "widgetcustom15", IsCustomField = true });
            // FieldDefinitions.Add(new AyaDataListFieldDefinition { LtKey = "WidgetCustom16", FieldKey = "widgetcustom16", IsCustomField = true });
        }
    }//eoc
}//eons