Example #1
0
        public string GenerateJS(Type modelType, string host, List <string> readOnlyProperties, List <string> properties, List <string> viewIgnoreProperties, bool hasUpdate, bool hasAdd, bool hasDelete, bool minimize)
        {
            if (!hasUpdate)
            {
                return("");
            }
            else if (modelType.GetCustomAttributes(typeof(ModelBlockJavascriptGeneration), false).Length > 0)
            {
                if (((int)((ModelBlockJavascriptGeneration)modelType.GetCustomAttributes(typeof(ModelBlockJavascriptGeneration), false)[0]).BlockType & (int)ModelBlockJavascriptGenerations.EditForm) == (int)ModelBlockJavascriptGenerations.EditForm)
                {
                    return("");
                }
            }
            WrappedStringBuilder sb = new WrappedStringBuilder(minimize);

            sb.AppendFormat((minimize ?
                             "{0}=_.extend(true,{0},{{editModel:function(view){{"
                :@"//Org.Reddragonit.BackBoneDotNet.JSGenerators.EditAddFormGenerator
{0} = _.extend(true,{0},{{editModel : function(view){{"),
                            ModelNamespace.GetFullNameForModel(modelType, host));

            ModelEditAddTypes meat = ModelEditAddTypes.dialog;

            if (modelType.GetCustomAttributes(typeof(ModelEditAddType), false).Length > 0)
            {
                meat = ((ModelEditAddType)modelType.GetCustomAttributes(typeof(ModelEditAddType), false)[0]).Type;
            }
            switch (meat)
            {
            case ModelEditAddTypes.dialog:
                _RenderDialogCode(modelType, host, readOnlyProperties, properties, sb, minimize);
                break;

            case ModelEditAddTypes.inline:
                _RenderInlineCode(modelType, host, readOnlyProperties, properties, viewIgnoreProperties, sb, minimize);
                break;
            }

            sb.AppendLine("}});");
            return(sb.ToString());
        }
 public ModelEditAddType(ModelEditAddTypes type)
 {
     _type = type;
 }
 public ModelEditAddType(ModelEditAddTypes type)
 {
     _type = type;
 }