using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using AyaNova.Biz;
namespace AyaNova.DataList
{
    internal class TranslationDataList : AyaDataList
    {

        public TranslationDataList()
        {
            DefaultListObjectType = AyaType.Translation;
            SQLFrom = "from atranslation";
            var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType);
            AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;

            //Default ListView
            dynamic dlistView = new JArray();

            dynamic cm = new JObject();
            cm.fld = "name";
            dlistView.Add(cm);

            cm = new JObject();
            cm.fld = "stock";
            dlistView.Add(cm);

            cm = new JObject();
            cm.fld = "cjkindex";
            dlistView.Add(cm);

            DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);



            //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>();
            //DPRECATED FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.User, SqlIdColumnName = "auser.id" });
            FieldDefinitions.Add(new AyaDataListFieldDefinition
            {
                TKey = "Translation",
                FieldKey = "name",
                AyaObjectType = (int)AyaType.Translation,
                UiFieldDataType = (int)UiFieldDataType.Text,
                SqlIdColumnName = "atranslation.id",
                SqlValueColumnName = "atranslation.name",
                IsRowId = true
            });

            FieldDefinitions.Add(new AyaDataListFieldDefinition
            {
                TKey = "GlobalCJKIndex",
                FieldKey = "cjkindex",
                UiFieldDataType = (int)UiFieldDataType.Bool,
                SqlValueColumnName = "atranslation.cjkindex"
            });



            FieldDefinitions.Add(new AyaDataListFieldDefinition
            {
                TKey = "ReadOnly",
                FieldKey = "stock",
                UiFieldDataType = (int)UiFieldDataType.Bool,
                SqlValueColumnName = "atranslation.stock"
            });



        }
    }//eoc
}//eons