From: Andrea Zagli Date: Sat, 7 Oct 2023 10:01:32 +0000 (+0200) Subject: c2rs: some adjustments based on branch validators. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=e111e22f1ee2cd3d950677aed23aeb4bc46c2455;p=rust%2Fzakform c2rs: some adjustments based on branch validators. --- diff --git a/src/bin/c2rs.rs b/src/bin/c2rs.rs index 1320b22..9f2f3fa 100644 --- a/src/bin/c2rs.rs +++ b/src/bin/c2rs.rs @@ -55,6 +55,8 @@ pub struct ZakFormElement { pub to_load: String, #[serde(rename = "to-save")] pub to_save: String, + pub accept: String, + pub inline: String, #[serde(rename = "option")] pub options: Vec, @@ -160,6 +162,7 @@ fn main() { "zak_form_cgi_form_element_select" => { writeln!(output, r#"let mut fi = zakform::fields::FieldSelect::new("{}")"#, e.id); }, "zak_form_cgi_form_element_check" => { writeln!(output, r#"let mut fi = zakform::fields::FieldCheck::new("{}")"#, e.id); }, "zak_form_cgi_form_element_submit" => { writeln!(output, r#"let mut fi = zakform::fields::FieldButton::new("{}")"#, e.id); }, + "zak_form_cgi_form_element_file" => { writeln!(output, r#"let mut fi = zakform::fields::FieldFile::new("{}")"#, e.id); }, _ => { continue; }, }; @@ -184,10 +187,10 @@ fn main() { }; if e.placeholder != "" { - writeln!(output, "fi.set_placeholder({})", e.placeholder); + writeln!(output, r#"fi.set_placeholder("{}")"#, e.placeholder); } if e.class != "" { - writeln!(output, "fi.set_class({})", e.class); + writeln!(output, r#"fi.set_class("{}")"#, e.class); } for option in e.options { @@ -203,14 +206,23 @@ fn main() { None => { }, } + if e.editable == "FALSE" { + writeln!(output, "fi.set_disabled(true)"); + } + if e.to_load == "FALSE" { writeln!(output, "fi.set_to_load(false)"); } if e.to_save == "FALSE" { writeln!(output, "fi.set_to_save(false)"); } - if e.editable == "FALSE" { - writeln!(output, "fi.set_disabled(true)"); + + if e.inline == "TRUE" { + writeln!(output, "fi.set_inline(true)"); + } + + if e.accept != "" { + writeln!(output, r#"fi.set_accept("{}")"#, e.accept); } for filter in e.filters { @@ -224,6 +236,11 @@ fn main() { _ => { }, }; }, + } + } + + for validator in e.validators { + match validator.vtype.as_str() { _ => { }, }; }