diff --git a/view/view_table_renderer.anubis b/view/view_table_renderer.anubis index 1fc5e0b..ebed24d 100644 --- a/view/view_table_renderer.anubis +++ b/view/view_table_renderer.anubis @@ -33,6 +33,7 @@ read calexium_lib/web/jQuery/CXM_jquery_datatable.anubis read calexium_lib/web/jQuery/CXM_jquery_datatable_types.anubis read calexium_lib/web/jQuery/CXM_jquery_dialog.anubis read calexium_lib/web/jQuery/CXM_jquery_button.anubis +read calexium_lib/web/jQuery/CXM_jq_form.anubis read calexium_lib/web/jQuery/ui-addon/datetimepicker.anubis read calexium_lib/web/jQuery/jqgrid.anubis read calexium_lib/web/CXM_form.anubis @@ -462,7 +463,7 @@ public define HTML_Partial_Content [html_wave_box_wide(_T(to_upper(current_view.table_name)), sequence([ //create the dialog - 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)))), + 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)))), div([class("inline")], sequence([ // (+) icon for adding new entry 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 jq_dialog_init + jq_datetimepicker_init(lang), [ - 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)))), + 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)))), partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+action_name+"_dlg_ajax")))], "", [])), //table_view_selector(_T, vtm_v, view_name), 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) ], foreign_text(s_name, c_name, value, foreign_table_name, select, help) then - with uid = generate_random_string(20)+"_", - - [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), + with uid = generate_random_string(20)+"_", + [ + 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)))), + one_line_fields([ + 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), + partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), + ]) + ], - 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)))), - partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), - ], foreign_text_search(s_name, c_name, select, foreign_table_name, fields, help) then - with uid = generate_random_string(20)+"_", - [ - raw_in_form(sequence([ - literal(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+ + with uid = generate_random_string(20)+"_", + [ + 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)))), + one_line_fields([ + message(to_String(format_label(label(_T(s_name), no_help), html_Id("")))+ ""), - 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)))), partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), - ]) - ), - help_line(help, _T)] + ]), + help_line(help, _T) + ] choices_text(s_name, c_name, value, select, help) then [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 List(HK_Form_Entry) list_entries, List(HK_Form_Tab) list_tabs, List(Web_arg) lwa, + //String dialog_id, //HK_Form edit_form, VTM vtm, String clause, @@ -861,10 +865,12 @@ public define HTML_Partial_Content with create = if get_String(lwa, "id","none") = "none" then true else false, with id = get_String(lwa, "id","none"), with sub_dialog = get_String(lwa, "sub_dialog", "false"), - - with button_name = if create then _T("CREATE") else _T("UPDATE"), + with dialog_id = get_String(lwa, "dialog_id", ""), + with button_label = if create then _T("CREATE") else _T("UPDATE"), + with button_name = if create then "create" else "update", with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), + println("renderer_edit_list_form dialog_id ["+dialog_id+"]"); partial_content( [ js(js_file("js/jscolor.min.js")), js(js_file("js/dropzone.js")), @@ -879,14 +885,20 @@ public define HTML_Partial_Content get_editor_header(list_entries)+ //add editor header if need. Like init ck_editor get_combo_header(table_name, list_entries), sequence([ - cxm_form( table_name, lwa, - [ one_line_fields([ - submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name), ("sub_dialog", sub_dialog)]), - 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)]), - submit(hkc_cancel, failure, _T("CANCEL"), [("sub_dialog", sub_dialog)]) - ]), - hr - ]+edit_form_lines(db, "", table_referer, _T, list_entries, create, []) + cxm_form( table_name, lwa, + (if length(list_entries) > 19 then + [ + one_line_fields([ + 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)])))))), + partial(jquery_button(jQuery_button(button, dialog_id+"cancel", "cancel", _T("CANCEL"), jQuery_actioner(same, jqscript("$('#"+dialog_id+"').dialog('close')"))))), + ]), + hr + ] + else + [] + ) + + + edit_form_lines(db, "", table_referer, _T, list_entries, create, []) + (if id = "none" then [] @@ -902,16 +914,20 @@ public define HTML_Partial_Content } //text("Foreign Key from table ["+fk_table_name+"] columns ["+fk_col_name+"] view to use ["+list_view_name+"]") ,list_tabs))+ + [ hr, one_line_fields([ - submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name), ("sub_dialog", sub_dialog)]), - 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)]), - submit(hkc_cancel, failure, _T("CANCEL"), [("sub_dialog", sub_dialog)]) - ]) + 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)])))))), + partial(jquery_button(jQuery_button(button, dialog_id+"cancel", "cancel", _T("CANCEL"), jQuery_actioner(same, jqscript("$('#"+dialog_id+"').dialog('close')"))))), + ]) ] - ), - ] - )). +// submit(if create then hkc_save_row else hkc_update_row, failure, button_name, [("table_name", table_name), ("sub_dialog", sub_dialog)]), +// 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)]), +// submit(hkc_cancel, failure, _T("CANCEL"), [("sub_dialog", sub_dialog)]) + + + ) //end of the form + ])). //Edit table part public define List(CXM_Form_Field) @@ -1117,6 +1133,7 @@ public define Maybe(HTML_Partial_Content) String lang, String web_site_directory, List(Web_arg) lwa, + String dialog_id, String table, //table name String view_name, //view name to use HK_Form_action action, //new_entry or edit an existing record @@ -1147,11 +1164,12 @@ public define Maybe(HTML_Partial_Content) String lang, String web_site_directory, List(Web_arg) lwa, + String dialog_id, String table, //table name String view_name, //view name to use HK_Form_action action, //new_entry or edit an existing record VTM vtm ) = - edit_table_content(db, _T, lang, web_site_directory, lwa, table, view_name, action, vtm, "", "", no_referer) + edit_table_content(db, _T, lang, web_site_directory, lwa, dialog_id, table, view_name, action, vtm, "", "", no_referer) . -- libgit2 0.21.4