From a8e062d5842b19e2b2226fe7dd3b7bf10a5dd9d7 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 16 Sep 2017 11:07:44 +0900 Subject: [PATCH] manage the __HK_SHOW_STRING__ in ajax_combo. When search field has that name "__HK_SHOW_STRING__" this is means, we want ajax combo only show the Show_String instead of other search fields --- view/view_table_renderer.anubis | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/view/view_table_renderer.anubis b/view/view_table_renderer.anubis index 6e88521..0da7f46 100644 --- a/view/view_table_renderer.anubis +++ b/view/view_table_renderer.anubis @@ -118,9 +118,9 @@ define String ajax_combo_init_parameter ( String combo_uid, - String f_table, //db table name - String c_name, //column name in the table - List(String) s_fields //search fields + String f_table, //db table name + String c_name, //column name in the table + List(String) s_fields //search fields )= "$('#"+combo_uid+"').ajaxComboBox( '?aws_controller=hk_c&aws_action=combo_search', { @@ -131,8 +131,12 @@ define String field: '"+force_nth(0, s_fields, "name")+"', search_field: '"+join(", ", s_fields)+"', hidden_name: '"+c_name+"', - show_string: '"+join(", ", s_fields)+"', - and_or: 'OR' +"+(if "__HK_SHOW_STRING__":s_fields then +" show_string: '__HK_SHOW_STRING__',\n" + else +" show_string: '"+join(", ", s_fields)+"',\n") ++ +" and_or: 'OR' });" . @@ -611,6 +615,7 @@ public define List(CXM_Form_Field) SQLite3DataBase db, String fk_clause, HK_Referer table_referer, + List(Web_arg) lwa, //web arguments of the request (String) -> String _T, List(HK_Form_Entry) list, Bool new_entry, @@ -652,9 +657,12 @@ public define List(CXM_Form_Field) password_entries ], - foreign_text(s_name, c_name, value, foreign_table_name, select, help) then + foreign_text(s_name, c_name, _value, foreign_table_name, select, help) then with uid = "_"+generate_random_string(20)+"_", with refresh_func = uid+foreign_table_name+"_"+c_name+"_selector_refresh", + //Get the priority of the web argument content for the value, this means the value already set by the user or called with programmaticaly with it + with value = get_DB_id(lwa, c_name, _value), + //create refresh function and call it first to construct the dropdown with load_script = script("text/javascript","function "+refresh_func+"() { CalexiumToolBox.ajax_load_content('"+uid+foreign_table_name+"_"+c_name+"_selector', '?aws_controller=hk_c&aws_action=selector&table_name="+foreign_table_name+"&fk_filter="+fk_clause+"&selected="+value+"&"+to_Web_arg(table_referer, "")+"');} "+refresh_func+"(); "), [ 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+"&after_close_cb="+refresh_func)))), @@ -666,8 +674,10 @@ public define List(CXM_Form_Field) ], - foreign_text_search(s_name, c_name, select, foreign_table_name, s_fields, help) then + foreign_text_search(s_name, c_name, _select, foreign_table_name, s_fields, help) then with uid = "_"+generate_random_string(20)+"_", + //Get the priority of the web argument content for the select, this means the value already set by the user or called with programmaticaly with it + with select = get_DB_id(lwa, c_name, _select), with combo_init = ajax_combo_init_parameter(uid, foreign_table_name, c_name, s_fields), [ @@ -724,7 +734,7 @@ public define List(CXM_Form_Field) email( s_name, c_name, value, help) then [email_input([event(onclick, "hk_send_email(this)")], [class("hk_input_email")], label(_T(s_name), no_help), html_Id(c_name), wan(c_name), init(not_null_String(value)), narrow, mandatory), help_line(help, _T)], }, - edit_form_lines(db, fk_clause, table_referer, _T, t, new_entry, reverse(line)+so_far) + edit_form_lines(db, fk_clause, table_referer, lwa, _T, t, new_entry, reverse(line)+so_far) }. @@ -774,7 +784,7 @@ public define HTML_Partial_Content //get_combo_header(table_name, list_entries), sequence([ cxm_form( form_id, lwa, - (if length(list_entries) > 19 then + (if length(list_entries) > 5 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, form_id, hkc_update_row, [("table_name", table_name), ("sub_dialog", sub_dialog)], after_close_cb)))))), @@ -786,7 +796,7 @@ public define HTML_Partial_Content [] ) + - edit_form_lines(db, "", table_referer, _T, list_entries, create, []) + edit_form_lines(db, "", table_referer, lwa, _T, list_entries, create, []) + (if id = "none" then [] -- libgit2 0.21.4