Commit 228502569ce21c09630057afe9516682ae7602a1

Authored by totoro
1 parent 3e2e9b57

[!] Update CXM_form according to MailFountain form

[+] Add img_submit_button
Showing 2 changed files with 47 additions and 25 deletions   Show diff stats
web/CXM_form.anubis
@@ -113,7 +113,8 @@ public type CXM_FormField: @@ -113,7 +113,8 @@ public type CXM_FormField:
113 WebArgName web_arg_name, 113 WebArgName web_arg_name,
114 WebArgValue web_arg_value, 114 WebArgValue web_arg_value,
115 Bool checked, 115 Bool checked,
116 - Mandatory mandatory), 116 + Mandatory mandatory),
  117 +
117 // the same one, but with the tag on the right of the checkbox 118 // the same one, but with the tag on the right of the checkbox
118 checkboxr (List(InputAttrs) options, 119 checkboxr (List(InputAttrs) options,
119 String label, 120 String label,
@@ -121,8 +122,16 @@ public type CXM_FormField: @@ -121,8 +122,16 @@ public type CXM_FormField:
121 WebArgName web_arg_name, 122 WebArgName web_arg_name,
122 WebArgValue web_arg_value, 123 WebArgValue web_arg_value,
123 Bool checked, 124 Bool checked,
124 - Mandatory mandatory),  
125 - 125 + Mandatory mandatory),
  126 +
  127 + //checkbox_hide_show
  128 + checkbox_hide_show( List(InputAttrs) options,
  129 + String label,
  130 + WebArgName web_arg_name,
  131 + WebArgValue web_arg_value,
  132 + Bool checked,
  133 + List(CXM_FormField) fields),
  134 +
126 //--- radio-button field -------------------------------------------------------------- 135 //--- radio-button field --------------------------------------------------------------
127 radio_button (List(InputAttrs) options, 136 radio_button (List(InputAttrs) options,
128 String label, 137 String label,
@@ -163,24 +172,25 @@ public type CXM_FormField: @@ -163,24 +172,25 @@ public type CXM_FormField:
163 // preview (String html_text), 172 // preview (String html_text),
164 173
165 //--- upload field ------------------------------------------------------------------- 174 //--- upload field -------------------------------------------------------------------
166 - upload (List(InputAttrs) options, 175 + upload (List(InputAttrs) options,
167 String label, 176 String label,
168 HtmlId id, 177 HtmlId id,
169 WebArgName name, 178 WebArgName name,
170 Width width, 179 Width width,
171 Mandatory mandatory), 180 Mandatory mandatory),
172 181
173 - raw_in_form (HTML_In_Form html),  
174 - raw_in_form (String label, 182 + raw_in_form (HTML_In_Form html),
  183 + raw_in_form (String label,
175 HtmlId id, 184 HtmlId id,
176 HTML_In_Form input), 185 HTML_In_Form input),
177 - partial (HTML_Partial_Content p_content),  
178 - input_with_help (CXM_FormField field, 186 + div (List(CoreAttrs), HTML_In_Form content),
  187 + partial (HTML_Partial_Content p_content),
  188 + input_with_help (CXM_FormField field,
179 Maybe(String) help_title, 189 Maybe(String) help_title,
180 String help_text, 190 String help_text,
181 Int width), 191 Int width),
182 192
183 - sub_fieldset (HTML_In_Form fieldset), 193 + sub_fieldset (HTML_In_Form fieldset),
184 194
185 blank_space, 195 blank_space,
186 blank_space (HtmlClass class), 196 blank_space (HtmlClass class),
@@ -391,7 +401,14 @@ public define HTML_In_Form @@ -391,7 +401,14 @@ public define HTML_In_Form
391 401
392 checkboxr(options, label, id, name, val, checked, mand) then 402 checkboxr(options, label, id, name, val, checked, mand) then
393 check_box_r(options, label + star(mand), id, name, val, checked), 403 check_box_r(options, label + star(mand), id, name, val, checked),
394 - 404 +
  405 + checkbox_hide_show(options, label, name, val, checked, fields) then
  406 + with div_id = generate_random_string(15),
  407 + sequence([
  408 + check_box([event(onclick, "checkbox_hide_show_element('"+div_id+"', this);")], label, htmlId(""), name, val, checked),
  409 + div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_FormField ff2) |-> div([class("form_field")], cxm_format_form_field(ff2)),fields)))
  410 + ]),
  411 +
395 radio_button(options, label, id, name, val, checked, mand) then 412 radio_button(options, label, id, name, val, checked, mand) then
396 radio_button(options, label + star(mand), id, name, val, checked), 413 radio_button(options, label + star(mand), id, name, val, checked),
397 414
@@ -417,29 +434,26 @@ public define HTML_In_Form @@ -417,29 +434,26 @@ public define HTML_In_Form
417 table([nude],[row([], 434 table([nude],[row([],
418 map((CXM_FormField ff2) |-> cell([],cxm_format_form_field(ff2)),fields))]) 435 map((CXM_FormField ff2) |-> cell([],cxm_format_form_field(ff2)),fields))])
419 , 436 ,
420 -  
421 437
422 upload(options, label, id, name, w, mand) then 438 upload(options, label, id, name, w, mand) then
423 file_upload(options, label + star(mand), id, name, pixels(w)), 439 file_upload(options, label + star(mand), id, name, pixels(w)),
424 440
425 - raw_in_form(html) then  
426 - html, 441 + raw_in_form(html) then html,
427 // div([class("in")], html), 442 // div([class("in")], html),
428 raw_in_form(label, id, input) then 443 raw_in_form(label, id, input) then
429 sequence([ 444 sequence([
430 if id is htmlId(id) then 445 if id is htmlId(id) then
431 literal("<label for=\"" + id + "\">" + label + "</label>"), 446 literal("<label for=\"" + id + "\">" + label + "</label>"),
432 input]), 447 input]),
433 - partial(p_content) then  
434 - partial(p_content), 448 + div(options, e) then div(options, e),
  449 + partial(p_content) then partial(p_content),
435 input_with_help(input, help_title, help_text, width) then 450 input_with_help(input, help_title, help_text, width) then
436 sequence([ 451 sequence([
437 cxm_format_form_field(input), 452 cxm_format_form_field(input),
438 html_tooltip(force_String(help_title), help_text, width), 453 html_tooltip(force_String(help_title), help_text, width),
439 ]), 454 ]),
440 455
441 - sub_fieldset(fieldset) then  
442 - fieldset, 456 + sub_fieldset(fieldset) then fieldset,
443 457
444 blank_space then 458 blank_space then
445 div([class("blank_space")], literal("&nbsp")), 459 div([class("blank_space")], literal("&nbsp")),
@@ -478,7 +492,7 @@ public define HTML_In_Form @@ -478,7 +492,7 @@ public define HTML_In_Form
478 cxm_fieldset 492 cxm_fieldset
479 ( 493 (
480 HtmlId fieldSetId, 494 HtmlId fieldSetId,
481 - List(CXM_FormField) fields 495 + List(CXM_FormField) fields
482 ) = 496 ) =
483 cxm_fieldset([id(fieldSetId.id), class("aligned")], "", fields). 497 cxm_fieldset([id(fieldSetId.id), class("aligned")], "", fields).
484 498
@@ -517,11 +531,12 @@ public define HTML_Off_Form @@ -517,11 +531,12 @@ public define HTML_Off_Form
517 public define HTML_Off_Form 531 public define HTML_Off_Form
518 cxm_form 532 cxm_form
519 ( 533 (
520 - String form_name,  
521 - List(CoreAttrs) options,  
522 - String action_name, 534 + String form_name,
  535 + List(CoreAttrs) options,
  536 + HtmlId fieldSetId,
  537 + String action_name,
523 List((String,String)) extra_ops, 538 List((String,String)) extra_ops,
524 - HtmlId fieldSetId, 539 +
525 List(CXM_FormField) fields 540 List(CXM_FormField) fields
526 ) = 541 ) =
527 cxm_form(form_name, options, action_name, extra_ops, 542 cxm_form(form_name, options, action_name, extra_ops,
@@ -535,7 +550,7 @@ public define HTML_Off_Form @@ -535,7 +550,7 @@ public define HTML_Off_Form
535 String form_name, 550 String form_name,
536 List(CoreAttrs) options, 551 List(CoreAttrs) options,
537 HtmlId fieldSetId, 552 HtmlId fieldSetId,
538 - List(CXM_FormField) fields 553 + List(CXM_FormField) fields
539 ) = 554 ) =
540 cxm_form(form_name, options, 555 cxm_form(form_name, options,
541 [ 556 [
@@ -546,7 +561,7 @@ public define HTML_Off_Form @@ -546,7 +561,7 @@ public define HTML_Off_Form
546 cxm_form 561 cxm_form
547 ( 562 (
548 String form_name, 563 String form_name,
549 - List(HTML_In_Form) fieldSets 564 + List(HTML_In_Form) fieldSets
550 ) = 565 ) =
551 cxm_form(form_name, [], fieldSets). 566 cxm_form(form_name, [], fieldSets).
552 567
@@ -555,7 +570,7 @@ public define HTML_Off_Form @@ -555,7 +570,7 @@ public define HTML_Off_Form
555 ( 570 (
556 String form_name, 571 String form_name,
557 HtmlId fieldSetId, 572 HtmlId fieldSetId,
558 - List(CXM_FormField) fields 573 + List(CXM_FormField) fields
559 ) = 574 ) =
560 cxm_form(form_name, [], fieldSetId, fields). 575 cxm_form(form_name, [], fieldSetId, fields).
561 576
web/jQuery/CXM_jquery_button.anubis
@@ -353,3 +353,10 @@ public define HTML_Partial_Content @@ -353,3 +353,10 @@ public define HTML_Partial_Content
353 )= 353 )=
354 jq_button_confirm(button_label, dlg_title, dlg_text, dlg_ok, dlg_cancel, url, []). 354 jq_button_confirm(button_label, dlg_title, dlg_text, dlg_ok, dlg_cancel, url, []).
355 355
  356 +public define HTML_Partial_Content
  357 + img_submit_button
  358 + (
  359 + String label, //translated label of the button
  360 + String form_id //
  361 + )=
  362 + jquery_button(jquery_img_button("icons/16x16/check.png", label, "", jQuery_actioner(same, jqform, form_id), left)).