Commit a8e062d5842b19e2b2226fe7dd3b7bf10a5dd9d7

Authored by totoro
1 parent c6986bdf

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
Showing 1 changed file with 20 additions and 10 deletions   Show diff stats
view/view_table_renderer.anubis
... ... @@ -118,9 +118,9 @@ define String
118 118 ajax_combo_init_parameter
119 119 (
120 120 String combo_uid,
121   - String f_table, //db table name
122   - String c_name, //column name in the table
123   - List(String) s_fields //search fields
  121 + String f_table, //db table name
  122 + String c_name, //column name in the table
  123 + List(String) s_fields //search fields
124 124 )=
125 125 "$('#"+combo_uid+"').ajaxComboBox( '?aws_controller=hk_c&aws_action=combo_search',
126 126 {
... ... @@ -131,8 +131,12 @@ define String
131 131 field: '"+force_nth(0, s_fields, "name")+"',
132 132 search_field: '"+join(", ", s_fields)+"',
133 133 hidden_name: '"+c_name+"',
134   - show_string: '"+join(", ", s_fields)+"',
135   - and_or: 'OR'
  134 +"+(if "__HK_SHOW_STRING__":s_fields then
  135 +" show_string: '__HK_SHOW_STRING__',\n"
  136 + else
  137 +" show_string: '"+join(", ", s_fields)+"',\n")
  138 ++
  139 +" and_or: 'OR'
136 140 });"
137 141 .
138 142  
... ... @@ -611,6 +615,7 @@ public define List(CXM_Form_Field)
611 615 SQLite3DataBase db,
612 616 String fk_clause,
613 617 HK_Referer table_referer,
  618 + List(Web_arg) lwa, //web arguments of the request
614 619 (String) -> String _T,
615 620 List(HK_Form_Entry) list,
616 621 Bool new_entry,
... ... @@ -652,9 +657,12 @@ public define List(CXM_Form_Field)
652 657 password_entries
653 658 ],
654 659  
655   - foreign_text(s_name, c_name, value, foreign_table_name, select, help) then
  660 + foreign_text(s_name, c_name, _value, foreign_table_name, select, help) then
656 661 with uid = "_"+generate_random_string(20)+"_",
657 662 with refresh_func = uid+foreign_table_name+"_"+c_name+"_selector_refresh",
  663 + //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
  664 + with value = get_DB_id(lwa, c_name, _value),
  665 + //create refresh function and call it first to construct the dropdown
658 666 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+"(); "),
659 667 [
660 668 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)
666 674 ],
667 675  
668 676  
669   - foreign_text_search(s_name, c_name, select, foreign_table_name, s_fields, help) then
  677 + foreign_text_search(s_name, c_name, _select, foreign_table_name, s_fields, help) then
670 678 with uid = "_"+generate_random_string(20)+"_",
  679 + //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
  680 + with select = get_DB_id(lwa, c_name, _select),
671 681 with combo_init = ajax_combo_init_parameter(uid, foreign_table_name, c_name, s_fields),
672 682 [
673 683  
... ... @@ -724,7 +734,7 @@ public define List(CXM_Form_Field)
724 734 email( s_name, c_name, value, help) then
725 735 [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)],
726 736 },
727   - edit_form_lines(db, fk_clause, table_referer, _T, t, new_entry, reverse(line)+so_far)
  737 + edit_form_lines(db, fk_clause, table_referer, lwa, _T, t, new_entry, reverse(line)+so_far)
728 738 }.
729 739  
730 740  
... ... @@ -774,7 +784,7 @@ public define HTML_Partial_Content
774 784 //get_combo_header(table_name, list_entries),
775 785 sequence([
776 786 cxm_form( form_id, lwa,
777   - (if length(list_entries) > 19 then
  787 + (if length(list_entries) > 5 then
778 788 [
779 789 one_line_fields([
780 790 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
786 796 []
787 797 )
788 798 +
789   - edit_form_lines(db, "", table_referer, _T, list_entries, create, [])
  799 + edit_form_lines(db, "", table_referer, lwa, _T, list_entries, create, [])
790 800 +
791 801 (if id = "none" then
792 802 []
... ...