private static string processAdvancedTips_Columns(Serenity.CodeGenerator.EntityField x) { if (x.DataType == "Decimal") { return("DisplayFormat(\"#,##0.00\"), AlignRight"); } return(""); }
//ROLEMBERG - process Advanced Tips private static string processAdvancedTips(Serenity.CodeGenerator.EntityField x) { string DateTimeField = ""; if (x.DataType == "Date") { DateTimeField = "DateEditor"; } if (x.DataType == "Time") { DateTimeField = "TimeEditor"; } if (x.DataType == "DateTime") { DateTimeField = "DateTimeEditor"; } if ((x.DataType == "DateTime") || (x.DataType == "Date")) { if ((x.Ident.ToUpper().Contains("CADASTRO")) || (x.Ident.ToUpper().Contains("INSERT"))) { DateTimeField = "ReadOnly(true), DefaultValue(\"now\"), Updatable(false), " + DateTimeField; } if ((x.Ident.ToUpper().Contains("ATUALIZACAO")) || (x.Ident.ToUpper().Contains("UPDATE"))) { DateTimeField = "ReadOnly(true), " + DateTimeField; } } if (!string.IsNullOrEmpty(DateTimeField)) { return(DateTimeField); } if ((x.DataType == "String") && ((x.Size ?? 0) >= 200) && ((!x.Ident.ToUpper().Contains("ARQUIVO")) || (!x.Ident.ToUpper().Contains("FOTO")))) { return("TextAreaEditor(Rows = 4)"); } return(""); }
private static string processAdvancedTips_Forms(Serenity.CodeGenerator.EntityField x) { //if (x.DataType == "Decimal") // return "DisplayFormat(\"#,##0.00\"), AlignRight"; if ((x.DataType == "String") && (x.Ident.ToUpper().Contains("MAIL"))) { return("EmailEditor"); } if ((x.DataType == "String") && (x.Ident.ToUpper().Contains("TELEFONE"))) { return("MaskedEditor(Mask = \"(99)9999-9999\")"); } if ((x.DataType == "String") && (x.Ident.ToUpper().Contains("CPF"))) { return("MaskedEditor(Mask = \"999.999.999-99\")"); } if ((x.DataType == "String") && (x.Ident.ToUpper().Contains("CNPJ"))) { return("MaskedEditor(Mask = \"99.999.999/9999-99\")"); } return(""); }
private static string processAdvancedTips_Image_File(Serenity.CodeGenerator.EntityField x, string tableName) { if ((x.DataType == "String") && (x.Ident.ToUpper().Contains("FOTO"))) { string strMultiple = ""; if (x.Ident.ToUpper().Contains("FOTOS")) { strMultiple = "Multiple"; } return("[" + strMultiple + "ImageUploadEditor(AllowNonImage = true, FilenameFormat = \"" + tableName + "/" + x.Ident + "/~\")]"); } if ((x.DataType == "String") && (x.Ident.ToUpper().Contains("ARQUIVO"))) { string strMultiple = ""; if (x.Ident.ToUpper().Contains("ARQUIVOS")) { strMultiple = "Multiple"; } return("[" + strMultiple + "FileUploadEditor(AllowNonImage = true, FilenameFormat = \"" + tableName + "/" + x.Ident + "/~\")] //, OriginalNameProperty = \"" + x.Ident + "Nome\")]"); } return(""); }
private static DialogAttributes processAdvancedTips_Dialog(Serenity.CodeGenerator.EntityField x, ref EntityModel m) { //DialogAttributes m.DialogAttributes = new DialogAttributes(); //m.DialogAttributes.Attrs01 = new List<string>(); //m.DialogAttributes.Attrs02 = new List<string>(); //m.DialogAttributes.AttrsConstructor = new List<string>(); //m.DialogAttributes.AttrsValidacao = new List<string>(); //m.DialogAttributes.AttrsConfirmSave = new List<string>(); #region // *** DIALOG PARA CONFIRMAR SE VAI SALVAR OU NÃO *** //m.DialogAttributes.AttrsConfirmSave.Add(" // *** DIALOG PARA CONFIRMAR SE VAI SALVAR OU NÃO ***"); //m.DialogAttributes.AttrsConfirmSave.Add(" " + (m.RootNamespace) + "DialogUtils.pendingChangesConfirmation(this.element, () => this.getSaveState() != this.loadedState);"); //m.DialogAttributes.AttrsConfirmSave.Add(" }"); //m.DialogAttributes.AttrsConfirmSave.Add(""); //m.DialogAttributes.AttrsConfirmSave.Add("//INICIO - PROCESSA O CONFIRM SAVE"); //m.DialogAttributes.AttrsConfirmSave.Add(" getSaveState() {"); //m.DialogAttributes.AttrsConfirmSave.Add(" try { return $.toJSON(this.getSaveEntity()); }"); //m.DialogAttributes.AttrsConfirmSave.Add(" catch (e) { return null; }"); //m.DialogAttributes.AttrsConfirmSave.Add(" }"); //m.DialogAttributes.AttrsConfirmSave.Add(""); //m.DialogAttributes.AttrsConfirmSave.Add(" loadResponse(data) {"); //m.DialogAttributes.AttrsConfirmSave.Add(" super.loadResponse(data);"); //m.DialogAttributes.AttrsConfirmSave.Add(" this.loadedState = this.getSaveState();"); //m.DialogAttributes.AttrsConfirmSave.Add(" }"); //m.DialogAttributes.AttrsConfirmSave.Add("//FIM - PROCESSA O CONFIRM SAVE"); #endregion #region MyRegion if ((x.DataType == "DateTime") && ((x.Ident.ToUpper().Contains("ATUALIZACAO")) || (x.Ident.ToUpper().Contains("UPDATE")))) { m.DialogAttributes.Attrs01.Add("this.form." + x.Ident + ".valueAsDate = new Date();"); } if ((x.DataType == "Boolean") && ((x.Ident.ToUpper().Contains("ATIVO")))) { m.DialogAttributes.Attrs02.Add("//if (this.form." + x.Ident + ".value == true)"); m.DialogAttributes.Attrs02.Add("//{"); m.DialogAttributes.Attrs02.Add("// this.form.ALGUMCAMPO.getGridField().toggle(true);"); m.DialogAttributes.Attrs02.Add("//}"); } if ((x.DataType == "Boolean") && ((x.Ident.ToUpper().Contains("ATIVO")))) { m.DialogAttributes.AttrsConstructor.Add("//// *** INICIO - CHECKBOX CHANGE - " + x.Ident + " ***"); m.DialogAttributes.AttrsConstructor.Add("//this.form." + x.Ident + ".change(e => {"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// if (this.form." + x.Ident + ".value == true) {"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// var isChecked = false;"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// Q.confirm(\"Confirma a seleção ?\", "); m.DialogAttributes.AttrsConstructor.Add("// () => {"); m.DialogAttributes.AttrsConstructor.Add("// isChecked = true;"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// //var texto = this.form.ALGUMCAMPO.getGridField().find('.caption').prop('outerHTML').split('Nome').join('TEXTO NOVO');"); m.DialogAttributes.AttrsConstructor.Add("// //this.form.ALGUMCAMPO.getGridField().find('.caption').prop('outerHTML', texto);"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// this.form." + x.Ident + ".value = isChecked;"); m.DialogAttributes.AttrsConstructor.Add("// this.form.ALGUMCAMPO.getGridField().toggle(true);"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// this.form.ALGUMCAMPO.value = null;"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// }"); m.DialogAttributes.AttrsConstructor.Add("// );"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// this.form." + x.Ident + ".value = isChecked;"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// }"); m.DialogAttributes.AttrsConstructor.Add("// else {"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// var isChecked = true;"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// Q.confirm(\"Confirma a exclusão ?\\nOs dados existentes serão descartados.\", "); m.DialogAttributes.AttrsConstructor.Add("// () => {"); m.DialogAttributes.AttrsConstructor.Add("// isChecked = false;"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// this.form." + x.Ident + ".value = isChecked;"); m.DialogAttributes.AttrsConstructor.Add("// this.form.ALGUMCAMPO.getGridField().toggle(false);"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// }"); m.DialogAttributes.AttrsConstructor.Add("// );"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// this.form." + x.Ident + ".value = isChecked;"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add("// }"); m.DialogAttributes.AttrsConstructor.Add("//});"); m.DialogAttributes.AttrsConstructor.Add("//// *** FIM - CHECKBOX CHANGE - NotaFiscalTerceiro ***"); m.DialogAttributes.AttrsConstructor.Add("//"); m.DialogAttributes.AttrsConstructor.Add(""); m.DialogAttributes.AttrsConstructor.Add(""); } if ((x.DataType == "String") && ((x.Ident.ToUpper().Contains("CNPJ")))) { m.DialogAttributes.AttrsValidacao.Add(m.RootNamespace + ".addValidationRule_CNPJ(this.form." + x.Ident + ");"); } if ((x.DataType == "String") && ((x.Ident.ToUpper().Contains("CPF")))) { m.DialogAttributes.AttrsValidacao.Add(m.RootNamespace + ".addValidationRule_CPF(this.form." + x.Ident + ");"); } #endregion return(m.DialogAttributes); }