Commit 30bcc5df0059c30590abb340fa7fb69b563a6e63

Authored by totoro
1 parent 8116ce4b

add "+" icon near the selector to be able to create a new entry if needs

Showing 1 changed file with 52 additions and 34 deletions   Show diff stats
view/view_table_renderer.anubis
@@ -33,6 +33,7 @@ read calexium_lib/web/jQuery/CXM_jquery_datatable.anubis @@ -33,6 +33,7 @@ read calexium_lib/web/jQuery/CXM_jquery_datatable.anubis
33 read calexium_lib/web/jQuery/CXM_jquery_datatable_types.anubis 33 read calexium_lib/web/jQuery/CXM_jquery_datatable_types.anubis
34 read calexium_lib/web/jQuery/CXM_jquery_dialog.anubis 34 read calexium_lib/web/jQuery/CXM_jquery_dialog.anubis
35 read calexium_lib/web/jQuery/CXM_jquery_button.anubis 35 read calexium_lib/web/jQuery/CXM_jquery_button.anubis
  36 +read calexium_lib/web/jQuery/CXM_jq_form.anubis
36 read calexium_lib/web/jQuery/ui-addon/datetimepicker.anubis 37 read calexium_lib/web/jQuery/ui-addon/datetimepicker.anubis
37 read calexium_lib/web/jQuery/jqgrid.anubis 38 read calexium_lib/web/jQuery/jqgrid.anubis
38 read calexium_lib/web/CXM_form.anubis 39 read calexium_lib/web/CXM_form.anubis
@@ -462,7 +463,7 @@ public define HTML_Partial_Content @@ -462,7 +463,7 @@ public define HTML_Partial_Content
462 [html_wave_box_wide(_T(to_upper(current_view.table_name)), 463 [html_wave_box_wide(_T(to_upper(current_view.table_name)),
463 sequence([ 464 sequence([
464 //create the dialog 465 //create the dialog
465 - partial(jq_dialog_create(dialog_id(uid+action_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&table_name="+current_view.table_name+filter_clause+referer_arg)))), 466 + partial(jq_dialog_create(dialog_id(uid+action_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+action_name+"_dlg_ajax&table_name="+current_view.table_name+filter_clause+referer_arg)))),
466 div([class("inline")], sequence([ 467 div([class("inline")], sequence([
467 // (+) icon for adding new entry 468 // (+) icon for adding new entry
468 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+action_name+"_dlg_ajax")))], "", [])), 469 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+action_name+"_dlg_ajax")))], "", [])),
@@ -499,7 +500,7 @@ public define HTML_Partial_Content @@ -499,7 +500,7 @@ public define HTML_Partial_Content
499 jq_dialog_init + 500 jq_dialog_init +
500 jq_datetimepicker_init(lang), 501 jq_datetimepicker_init(lang),
501 [ 502 [
502 - partial(jq_dialog_create(dialog_id(uid+action_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&table_name="+current_view.table_name+filter_clause+referer_arg)))), 503 + partial(jq_dialog_create(dialog_id(uid+action_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+action_name+"_dlg_ajax&table_name="+current_view.table_name+filter_clause+referer_arg)))),
503 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+action_name+"_dlg_ajax")))], "", [])), 504 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+action_name+"_dlg_ajax")))], "", [])),
504 //table_view_selector(_T, vtm_v, view_name), 505 //table_view_selector(_T, vtm_v, view_name),
505 partial(jqGrid_table(db, uid, current_view, filter_name, _T, lang, fk_clause, table_referer)), 506 partial(jqGrid_table(db, uid, current_view, filter_name, _T, lang, fk_clause, table_referer)),
@@ -629,24 +630,26 @@ public define List(CXM_Form_Field) @@ -629,24 +630,26 @@ public define List(CXM_Form_Field)
629 ], 630 ],
630 631
631 foreign_text(s_name, c_name, value, foreign_table_name, select, help) then 632 foreign_text(s_name, c_name, value, foreign_table_name, select, help) then
632 - with uid = generate_random_string(20)+"_",  
633 -  
634 - [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db, table_referer, fk_clause), success(init(to_String(value))), mandatory), help_line(help, _T), 633 + with uid = generate_random_string(20)+"_",
  634 + [
  635 + partial(jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name)))),
  636 + one_line_fields([
  637 + selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db, table_referer, fk_clause), success(init(to_String(value))), mandatory), help_line(help, _T),
  638 + partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
  639 + ])
  640 + ],
635 641
636 - partial(jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&sub_dialog=true&table_name="+foreign_table_name)))),  
637 - partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),  
638 - ],  
639 foreign_text_search(s_name, c_name, select, foreign_table_name, fields, help) then 642 foreign_text_search(s_name, c_name, select, foreign_table_name, fields, help) then
640 - with uid = generate_random_string(20)+"_",  
641 - [  
642 - raw_in_form(sequence([  
643 - literal(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+ 643 + with uid = generate_random_string(20)+"_",
  644 + [
  645 + partial(jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&dialog_id="+uid+foreign_table_name+"_dlg_ajax&sub_dialog=true&table_name="+foreign_table_name)))),
  646 + one_line_fields([
  647 + message(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+
644 "<input class=\"in\" id=\"acb_"+c_name+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"), 648 "<input class=\"in\" id=\"acb_"+c_name+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"),
645 - partial(jq_dialog_create(dialog_id(uid+foreign_table_name+"_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table&sub_dialog=true&table_name="+foreign_table_name)))),  
646 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), 649 partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])),
647 - ])  
648 - ),  
649 - help_line(help, _T)] 650 + ]),
  651 + help_line(help, _T)
  652 + ]
650 653
651 choices_text(s_name, c_name, value, select, help) then 654 choices_text(s_name, c_name, value, select, help) then
652 [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db, no_referer, ""), success(init(value)), mandatory), help_line(help, _T)], 655 [selector_c([],label(_T(s_name), no_help), html_Id(""), wan(c_name), 1, select.get(db, no_referer, ""), success(init(value)), mandatory), help_line(help, _T)],
@@ -850,6 +853,7 @@ public define HTML_Partial_Content @@ -850,6 +853,7 @@ public define HTML_Partial_Content
850 List(HK_Form_Entry) list_entries, 853 List(HK_Form_Entry) list_entries,
851 List(HK_Form_Tab) list_tabs, 854 List(HK_Form_Tab) list_tabs,
852 List(Web_arg) lwa, 855 List(Web_arg) lwa,
  856 + //String dialog_id,
853 //HK_Form edit_form, 857 //HK_Form edit_form,
854 VTM vtm, 858 VTM vtm,
855 String clause, 859 String clause,
@@ -861,10 +865,12 @@ public define HTML_Partial_Content @@ -861,10 +865,12 @@ public define HTML_Partial_Content
861 with create = if get_String(lwa, "id","none") = "none" then true else false, 865 with create = if get_String(lwa, "id","none") = "none" then true else false,
862 with id = get_String(lwa, "id","none"), 866 with id = get_String(lwa, "id","none"),
863 with sub_dialog = get_String(lwa, "sub_dialog", "false"), 867 with sub_dialog = get_String(lwa, "sub_dialog", "false"),
864 -  
865 - with button_name = if create then _T("CREATE") else _T("UPDATE"), 868 + with dialog_id = get_String(lwa, "dialog_id", ""),
  869 + with button_label = if create then _T("CREATE") else _T("UPDATE"),
  870 + with button_name = if create then "create" else "update",
866 with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), 871 with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"),
867 872
  873 + println("renderer_edit_list_form dialog_id ["+dialog_id+"]");
868 partial_content( 874 partial_content(
869 [ js(js_file("js/jscolor.min.js")), 875 [ js(js_file("js/jscolor.min.js")),
870 js(js_file("js/dropzone.js")), 876 js(js_file("js/dropzone.js")),
@@ -879,14 +885,20 @@ public define HTML_Partial_Content @@ -879,14 +885,20 @@ public define HTML_Partial_Content
879 get_editor_header(list_entries)+ //add editor header if need. Like init ck_editor 885 get_editor_header(list_entries)+ //add editor header if need. Like init ck_editor
880 get_combo_header(table_name, list_entries), 886 get_combo_header(table_name, list_entries),
881 sequence([ 887 sequence([
882 - cxm_form( table_name, lwa,  
883 - [ one_line_fields([  
884 - submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name), ("sub_dialog", sub_dialog)]),  
885 - submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name), ("sub_dialog", sub_dialog)]),  
886 - submit(hkc_cancel, failure, _T("CANCEL"), [("sub_dialog", sub_dialog)])  
887 - ]),  
888 - hr  
889 - ]+edit_form_lines(db, "", table_referer, _T, list_entries, create, []) 888 + cxm_form( table_name, lwa,
  889 + (if length(list_entries) > 19 then
  890 + [
  891 + one_line_fields([
  892 + partial(jquery_button(jQuery_button(button, dialog_id+button_name, button_name, button_label, jQuery_actioner(same, jqscript(jq_form_submit_and_close(dialog_id, table_name, hkc_update_row, [("table_name", table_name), ("sub_dialog", sub_dialog)])))))),
  893 + partial(jquery_button(jQuery_button(button, dialog_id+"cancel", "cancel", _T("CANCEL"), jQuery_actioner(same, jqscript("$('#"+dialog_id+"').dialog('close')"))))),
  894 + ]),
  895 + hr
  896 + ]
  897 + else
  898 + []
  899 + )
  900 + +
  901 + edit_form_lines(db, "", table_referer, _T, list_entries, create, [])
890 + 902 +
891 (if id = "none" then 903 (if id = "none" then
892 [] 904 []
@@ -902,16 +914,20 @@ public define HTML_Partial_Content @@ -902,16 +914,20 @@ public define HTML_Partial_Content
902 } 914 }
903 //text("Foreign Key from table ["+fk_table_name+"] columns ["+fk_col_name+"] view to use ["+list_view_name+"]") 915 //text("Foreign Key from table ["+fk_table_name+"] columns ["+fk_col_name+"] view to use ["+list_view_name+"]")
904 ,list_tabs))+ 916 ,list_tabs))+
  917 +
905 [ hr, 918 [ hr,
906 one_line_fields([ 919 one_line_fields([
907 - submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name), ("sub_dialog", sub_dialog)]),  
908 - submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name), ("sub_dialog", sub_dialog)]),  
909 - submit(hkc_cancel, failure, _T("CANCEL"), [("sub_dialog", sub_dialog)])  
910 - ]) 920 + partial(jquery_button(jQuery_button(button, dialog_id+button_name, button_name, button_label, jQuery_actioner(same, jqscript(jq_form_submit_and_close(dialog_id, table_name, hkc_update_row, [("table_name", table_name), ("sub_dialog", sub_dialog)])))))),
  921 + partial(jquery_button(jQuery_button(button, dialog_id+"cancel", "cancel", _T("CANCEL"), jQuery_actioner(same, jqscript("$('#"+dialog_id+"').dialog('close')"))))),
  922 + ])
911 ] 923 ]
912 - ),  
913 - ]  
914 - )). 924 +// submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name), ("sub_dialog", sub_dialog)]),
  925 +// submit(if create then hkc_save_row_and_new else hkc_update_row_and_new, failure, button_name_and_new, [("table_name", table_name), ("sub_dialog", sub_dialog)]),
  926 +// submit(hkc_cancel, failure, _T("CANCEL"), [("sub_dialog", sub_dialog)])
  927 +
  928 +
  929 + ) //end of the form
  930 + ])).
915 931
916 //Edit table part 932 //Edit table part
917 public define List(CXM_Form_Field) 933 public define List(CXM_Form_Field)
@@ -1117,6 +1133,7 @@ public define Maybe(HTML_Partial_Content) @@ -1117,6 +1133,7 @@ public define Maybe(HTML_Partial_Content)
1117 String lang, 1133 String lang,
1118 String web_site_directory, 1134 String web_site_directory,
1119 List(Web_arg) lwa, 1135 List(Web_arg) lwa,
  1136 + String dialog_id,
1120 String table, //table name 1137 String table, //table name
1121 String view_name, //view name to use 1138 String view_name, //view name to use
1122 HK_Form_action action, //new_entry or edit an existing record 1139 HK_Form_action action, //new_entry or edit an existing record
@@ -1147,11 +1164,12 @@ public define Maybe(HTML_Partial_Content) @@ -1147,11 +1164,12 @@ public define Maybe(HTML_Partial_Content)
1147 String lang, 1164 String lang,
1148 String web_site_directory, 1165 String web_site_directory,
1149 List(Web_arg) lwa, 1166 List(Web_arg) lwa,
  1167 + String dialog_id,
1150 String table, //table name 1168 String table, //table name
1151 String view_name, //view name to use 1169 String view_name, //view name to use
1152 HK_Form_action action, //new_entry or edit an existing record 1170 HK_Form_action action, //new_entry or edit an existing record
1153 VTM vtm 1171 VTM vtm
1154 ) = 1172 ) =
1155 - edit_table_content(db, _T, lang, web_site_directory, lwa, table, view_name, action, vtm, "", "", no_referer) 1173 + edit_table_content(db, _T, lang, web_site_directory, lwa, dialog_id, table, view_name, action, vtm, "", "", no_referer)
1156 . 1174 .
1157 1175