Commit 97ee784a25934d3e6407d84b2b9574d4ae33ec14

Authored by Cédric RICARD
1 parent 42149afb

Adding checkbox to DojoDialog

Showing 1 changed file with 48 additions and 13 deletions   Show diff stats
calexium_lib/web/CXM_dojo.anubis
@@ -73,9 +73,10 @@ public type Input_Type: @@ -73,9 +73,10 @@ public type Input_Type:
73 password. 73 password.
74 74
75 public type InputDial: 75 public type InputDial:
76 - input_dial(String id, Input_Type input_type, String label, Maybe(String) class),  
77 - input_date(String id, String label),  
78 - input_combo(String label, HtmlId id, WebArgName name, List((WebArgValue,String)) list_data). 76 + input_dial(HtmlId id, Input_Type input_type, String label, Maybe(String) class),
  77 + input_date(HtmlId id, String label),
  78 + input_combo(HtmlId id, String label, List((WebArgValue,String)) list_data),
  79 + input_check(HtmlId id, String label, Bool checked).
79 80
80 81
81 define List(HTML_Off_Form) 82 define List(HTML_Off_Form)
@@ -111,20 +112,45 @@ public define HTML_Off_Form @@ -111,20 +112,45 @@ public define HTML_Off_Form
111 ]). 112 ]).
112 113
113 define HTML_Off_Form 114 define HTML_Off_Form
  115 + _maybe_label
  116 + (
  117 + String label_text,
  118 + HtmlId html_id
  119 + ) =
  120 + if length(label_text) > 0 then literal("<label for=\"" + html_id.id + "\">" + label_text + "</label>")
  121 + else literal("").
  122 +
  123 +public define HTML_Off_Form
  124 + dojo_checkbox
  125 + (
  126 + WebArgName the_name,
  127 + HtmlId the_id,
  128 + String label,
  129 + WebArgValue val,
  130 + Bool checked,
  131 + )=
  132 + sequence([
  133 + _maybe_label(label, the_id),
  134 + literal("<input type=\"checkbox\" name=\"" + the_name.name + "\" id=\"" + the_id.id + "\" value=\"" + val.value + "\""
  135 + + (if checked then " checked=\"checked\" " else "") + " dojoType=\"dijit.form.CheckBox\" />"),
  136 + ]).
  137 +
  138 +
  139 +define HTML_Off_Form
114 input_in_dialog 140 input_in_dialog
115 ( 141 (
116 InputDial input_data 142 InputDial input_data
117 )= 143 )=
118 if input_data is 144 if input_data is
119 { 145 {
120 - input_dial(id, input, label, class) then 146 + input_dial(html_id, input, label, class) then
121 sequence([ 147 sequence([
122 - literal("<div id=\"" + id +"_block\"" + 148 + literal("<div id=\"" + html_id.id +"_block\"" +
123 if class is 149 if class is
124 { 150 {
125 failure then "", 151 failure then "",
126 success(class_name) then " class=\"block_"+ class_name +"\"" 152 success(class_name) then " class=\"block_"+ class_name +"\""
127 - }+"><label for=\"" + id + "\" id=\"label_" + id + "\"" + 153 + }+"><label for=\"" + html_id.id + "\" id=\"label_" + html_id.id + "\"" +
128 if class is 154 if class is
129 { 155 {
130 failure then "", 156 failure then "",
@@ -137,22 +163,31 @@ define HTML_Off_Form @@ -137,22 +163,31 @@ define HTML_Off_Form
137 text then "type=\"text\"", 163 text then "type=\"text\"",
138 password then "type=\"password\"" 164 password then "type=\"password\""
139 } + 165 } +
140 - " name=\""+id+"\" id=\""+id+"\" /></div>") 166 + " name=\""+html_id.id+"\" id=\""+html_id.id+"\" /></div>")
141 ]), 167 ]),
142 - input_date(id, label) then 168 +
  169 + input_date(html_id, label) then
143 sequence([ 170 sequence([
144 - literal("<div id=\"" + id +"_block\"><label for=\"" + id + "\"> " + label + "</label>"),  
145 - literal("<div id=\""+id+"\" type=\"text\" name=\"date1\" 171 + literal("<div id=\"" + html_id.id +"_block\"><label for=\"" + html_id.id + "\"> " + label + "</label>"),
  172 + literal("<div id=\""+html_id.id+"\" type=\"text\" name=\"date1\"
146 dojoType=\"dijit.form.DateTextBox\"> 173 dojoType=\"dijit.form.DateTextBox\">
147 </div></div>" 174 </div></div>"
148 ) 175 )
149 ]), 176 ]),
150 - input_combo(label, the_id, name, list_data) then 177 +
  178 + input_combo(the_id, label, list_data) then
151 sequence([ 179 sequence([
152 literal("<div id=\"" + the_id.id +"_block\">"), 180 literal("<div id=\"" + the_id.id +"_block\">"),
153 - dojo_combobox(name, the_id, label, list_data), 181 + dojo_combobox(wan(the_id.id), the_id, label, list_data),
154 literal("</div>") 182 literal("</div>")
155 - ]) 183 + ]),
  184 +
  185 + input_check(the_id, label, checked) then
  186 + sequence([
  187 + literal("<div id=\"" + the_id.id +"_block\">"),
  188 + dojo_checkbox(wan(the_id.id), the_id, label, wav("1"), checked),
  189 + literal("</div>"),
  190 + ]),
156 } 191 }
157 . 192 .
158 193