Commit 23bb1d768dc99cf190ce4da83e1f9b6cf1f40b63
1 parent
ac7be478
add new way to load selector by ajax call
remove writer_list and move the writer into hk_controller call_back collection
Showing
4 changed files
with
73 additions
and
45 deletions
Show diff stats
view/view_table_manager.anubis
| @@ -59,30 +59,30 @@ public define Maybe(VTM_edit) | @@ -59,30 +59,30 @@ public define Maybe(VTM_edit) | ||
| 59 | ) = | 59 | ) = |
| 60 | _vtm_get_edit(table_name, vtm_vlist.list). | 60 | _vtm_get_edit(table_name, vtm_vlist.list). |
| 61 | 61 | ||
| 62 | -public define Maybe(TM_writer) | ||
| 63 | - _tm_get_writer | ||
| 64 | - ( | ||
| 65 | - String table_name, | ||
| 66 | - List(TM_writer) list | ||
| 67 | - ) = | ||
| 68 | - if list is | ||
| 69 | - { | ||
| 70 | - [] then failure, | ||
| 71 | - [ h . t ] then | ||
| 72 | - if h is tm_writer(tb_name, get_writer_from_type, get_writer_from_fields) then | ||
| 73 | - if tb_name = table_name then | ||
| 74 | - success(h) | ||
| 75 | - else | ||
| 76 | - _tm_get_writer(table_name, t) | ||
| 77 | - }. | 62 | +//public define Maybe(TM_writer) |
| 63 | +// _tm_get_writer | ||
| 64 | +// ( | ||
| 65 | +// String table_name, | ||
| 66 | +// List(TM_writer) list | ||
| 67 | +// ) = | ||
| 68 | +// if list is | ||
| 69 | +// { | ||
| 70 | +// [] then failure, | ||
| 71 | +// [ h . t ] then | ||
| 72 | +// if h is tm_writer(tb_name, get_writer_from_type, get_writer_from_fields) then | ||
| 73 | +// if tb_name = table_name then | ||
| 74 | +// success(h) | ||
| 75 | +// else | ||
| 76 | +// _tm_get_writer(table_name, t) | ||
| 77 | +// }. | ||
| 78 | 78 | ||
| 79 | -public define Maybe(TM_writer) | ||
| 80 | - tm_get_writer | ||
| 81 | - ( | ||
| 82 | - String table_name, | ||
| 83 | - TM_writer_list tm_wlist | ||
| 84 | - ) = | ||
| 85 | - _tm_get_writer(table_name, tm_wlist.list). | 79 | +//public define Maybe(TM_writer) |
| 80 | +// tm_get_writer | ||
| 81 | +// ( | ||
| 82 | +// String table_name, | ||
| 83 | +// TM_writer_list tm_wlist | ||
| 84 | +// ) = | ||
| 85 | +// _tm_get_writer(table_name, tm_wlist.list). | ||
| 86 | 86 | ||
| 87 | public define Maybe((SQLite3DataBase db, List(Int) l_int) -> Maybe(One)) | 87 | public define Maybe((SQLite3DataBase db, List(Int) l_int) -> Maybe(One)) |
| 88 | _tm_get_delete | 88 | _tm_get_delete |
view/view_table_manager_types.anubis
| @@ -14,6 +14,7 @@ read hayamiki_lib/types/hayamiki.anubis | @@ -14,6 +14,7 @@ read hayamiki_lib/types/hayamiki.anubis | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | read calexium_lib/web/CXM_common.anubis | 16 | read calexium_lib/web/CXM_common.anubis |
| 17 | +read calexium_lib/web/CXM_making_a_web_site.anubis | ||
| 17 | read calexium_lib/database/db_types.anubis | 18 | read calexium_lib/database/db_types.anubis |
| 18 | 19 | ||
| 19 | public type VTM_edit: | 20 | public type VTM_edit: |
| @@ -22,13 +23,13 @@ public type VTM_edit: | @@ -22,13 +23,13 @@ public type VTM_edit: | ||
| 22 | public type VTM_edit_list: | 23 | public type VTM_edit_list: |
| 23 | vtm_edit_list(List(VTM_edit) list). | 24 | vtm_edit_list(List(VTM_edit) list). |
| 24 | 25 | ||
| 25 | -public type TM_writer: | ||
| 26 | - tm_writer( | ||
| 27 | - String table_name, | ||
| 28 | - (SQLite3DataBase db, List(Web_arg) lwa) -> Maybe(One) write_from_type, | ||
| 29 | - (SQLite3DataBase db, List(Web_arg) lwa) -> Maybe(One) write_from_fields | ||
| 30 | - ) | ||
| 31 | -. | 26 | +//public type TM_writer: |
| 27 | +// tm_writer( | ||
| 28 | +// String table_name, | ||
| 29 | +// (SQLite3DataBase db, List(Web_arg) lwa) -> Maybe(One) write_from_type, | ||
| 30 | +// (SQLite3DataBase db, List(Web_arg) lwa) -> Maybe(One) write_from_fields | ||
| 31 | +// ) | ||
| 32 | +//. | ||
| 32 | 33 | ||
| 33 | //CRUD basis function + | 34 | //CRUD basis function + |
| 34 | //Create | 35 | //Create |
| @@ -48,12 +49,16 @@ public type HK_Table_controller: | @@ -48,12 +49,16 @@ public type HK_Table_controller: | ||
| 48 | (SQLite3DataBase db, List(String) columns, HK_Referer referer, String clause, String order_by) -> JsonValue get_rows_json, | 49 | (SQLite3DataBase db, List(String) columns, HK_Referer referer, String clause, String order_by) -> JsonValue get_rows_json, |
| 49 | //Update | 50 | //Update |
| 50 | //Delete | 51 | //Delete |
| 51 | - (SQLite3DataBase db, List(Int) l_int) -> Maybe(One) delete | 52 | + (SQLite3DataBase db, List(Int) l_int) -> Maybe(One) delete, |
| 53 | + | ||
| 54 | + //view interface | ||
| 55 | + //selector | ||
| 56 | + (SQLite3DataBase db, HK_Referer referer, String filter) -> List((List(CoreAttrs), WebArgValue, String)) get_selector | ||
| 52 | ) | 57 | ) |
| 53 | . | 58 | . |
| 54 | 59 | ||
| 55 | -public type TM_writer_list: | ||
| 56 | - tm_writer_list(List(TM_writer) list). | 60 | +//public type TM_writer_list: |
| 61 | +// tm_writer_list(List(TM_writer) list). | ||
| 57 | 62 | ||
| 58 | public type TM_delete: | 63 | public type TM_delete: |
| 59 | tm_delete(String table_name, (SQLite3DataBase db, List(Int) l_int) -> Maybe(One) delete). | 64 | tm_delete(String table_name, (SQLite3DataBase db, List(Int) l_int) -> Maybe(One) delete). |
| @@ -70,6 +75,6 @@ public type VTM_view_list: | @@ -70,6 +75,6 @@ public type VTM_view_list: | ||
| 70 | public type VTM: | 75 | public type VTM: |
| 71 | vtm(VTM_view_list view_list, | 76 | vtm(VTM_view_list view_list, |
| 72 | VTM_edit_list edit_list, | 77 | VTM_edit_list edit_list, |
| 73 | - TM_writer_list writer_list, | 78 | + //TM_writer_list writer_list, |
| 74 | TM_delete_list delete_list, | 79 | TM_delete_list delete_list, |
| 75 | List(HK_Table_controller) hk_controllers). | 80 | List(HK_Table_controller) hk_controllers). |
view/view_table_renderer.anubis
| @@ -17,6 +17,7 @@ read hayamiki_lib/types/hayamiki.anubis | @@ -17,6 +17,7 @@ read hayamiki_lib/types/hayamiki.anubis | ||
| 17 | read system/string.anubis | 17 | read system/string.anubis |
| 18 | read locale/L3.anubis | 18 | read locale/L3.anubis |
| 19 | read tools/basis.anubis | 19 | read tools/basis.anubis |
| 20 | +read tools/base64.anubis | ||
| 20 | read tools/list.anubis | 21 | read tools/list.anubis |
| 21 | read tools/printable_tree.anubis | 22 | read tools/printable_tree.anubis |
| 22 | read data_base/sqlite.anubis | 23 | read data_base/sqlite.anubis |
| @@ -630,17 +631,32 @@ public define List(CXM_Form_Field) | @@ -630,17 +631,32 @@ public define List(CXM_Form_Field) | ||
| 630 | ], | 631 | ], |
| 631 | 632 | ||
| 632 | foreign_text(s_name, c_name, value, foreign_table_name, select, help) then | 633 | foreign_text(s_name, c_name, value, foreign_table_name, select, help) then |
| 633 | - with uid = generate_random_string(20)+"_", | 634 | + with uid = "_"+generate_random_string(20)+"_", |
| 635 | + with refresh_func = uid+foreign_table_name+"_"+c_name+"_selector_refresh", | ||
| 636 | + 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+"');} "+refresh_func+"(); "), | ||
| 637 | + //with load_script_b64 = base64_encode(load_script, false), | ||
| 634 | [ | 638 | [ |
| 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)))), | 639 | + 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)))), |
| 636 | one_line_fields([ | 640 | 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), | 641 | + partial(partial_content([js_inline(load_script)],empty)), |
| 642 | + selector_c([],label(_T(s_name), no_help), html_Id(uid+foreign_table_name+"_"+c_name+"_selector"), wan(c_name), 1, [],/*select.get(db, table_referer, fk_clause), */ success(init("")), mandatory), help_line(help, _T), | ||
| 638 | partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), | 643 | partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), |
| 639 | ]) | 644 | ]) |
| 640 | ], | 645 | ], |
| 646 | + | ||
| 647 | +// with uid = generate_random_string(20)+"_", | ||
| 648 | +// with load_script = "CalexiumToolBox.ajax_load_content('"+uid+foreign_table_name+c_name+"_selector', '?aws_controller=hkc&aws_action=selector&table_name="+foreign_table_name+"&fk_filter="+fk_clause+"');", | ||
| 649 | +// [ | ||
| 650 | +// 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)))), | ||
| 651 | +// one_line_fields([ | ||
| 652 | +// partial(partial_content([js_inline(jquery_ready(load_script))],empty)), | ||
| 653 | +// selector_c([],label(_T(s_name), no_help), html_Id(uid+foreign_table_name+c_name+"_selector"), wan(c_name), 1, select.get(db, table_referer, fk_clause), success(init(to_String(value))), mandatory), help_line(help, _T), | ||
| 654 | +// partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), | ||
| 655 | +// ]) | ||
| 656 | +// ], | ||
| 641 | 657 | ||
| 642 | foreign_text_search(s_name, c_name, select, foreign_table_name, fields, help) then | 658 | foreign_text_search(s_name, c_name, select, foreign_table_name, fields, help) then |
| 643 | - with uid = generate_random_string(20)+"_", | 659 | + with uid = "_"+generate_random_string(20)+"_", |
| 644 | [ | 660 | [ |
| 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)))), | 661 | 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([ | 662 | one_line_fields([ |
| @@ -866,8 +882,9 @@ public define HTML_Partial_Content | @@ -866,8 +882,9 @@ public define HTML_Partial_Content | ||
| 866 | with id = get_String(lwa, "id","none"), | 882 | with id = get_String(lwa, "id","none"), |
| 867 | with sub_dialog = get_String(lwa, "sub_dialog", "false"), | 883 | with sub_dialog = get_String(lwa, "sub_dialog", "false"), |
| 868 | with dialog_id = get_String(lwa, "dialog_id", ""), | 884 | 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", | 885 | + with after_close_cb = get_String(lwa, "after_close_cb", ""), //call back |
| 886 | + with button_label = if create then _T("CREATE") else _T("UPDATE"), | ||
| 887 | + with button_name = if create then "create" else "update", | ||
| 871 | with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), | 888 | with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), |
| 872 | 889 | ||
| 873 | println("renderer_edit_list_form dialog_id ["+dialog_id+"]"); | 890 | println("renderer_edit_list_form dialog_id ["+dialog_id+"]"); |
| @@ -889,7 +906,7 @@ public define HTML_Partial_Content | @@ -889,7 +906,7 @@ public define HTML_Partial_Content | ||
| 889 | (if length(list_entries) > 19 then | 906 | (if length(list_entries) > 19 then |
| 890 | [ | 907 | [ |
| 891 | one_line_fields([ | 908 | 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)])))))), | 909 | + 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)], after_close_cb)))))), |
| 893 | partial(jquery_button(jQuery_button(button, dialog_id+"cancel", "cancel", _T("CANCEL"), jQuery_actioner(same, jqscript("$('#"+dialog_id+"').dialog('close')"))))), | 910 | partial(jquery_button(jQuery_button(button, dialog_id+"cancel", "cancel", _T("CANCEL"), jQuery_actioner(same, jqscript("$('#"+dialog_id+"').dialog('close')"))))), |
| 894 | ]), | 911 | ]), |
| 895 | hr | 912 | hr |
| @@ -917,7 +934,7 @@ public define HTML_Partial_Content | @@ -917,7 +934,7 @@ public define HTML_Partial_Content | ||
| 917 | 934 | ||
| 918 | [ hr, | 935 | [ hr, |
| 919 | one_line_fields([ | 936 | one_line_fields([ |
| 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)])))))), | 937 | + 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)], after_close_cb)))))), |
| 921 | partial(jquery_button(jQuery_button(button, dialog_id+"cancel", "cancel", _T("CANCEL"), jQuery_actioner(same, jqscript("$('#"+dialog_id+"').dialog('close')"))))), | 938 | partial(jquery_button(jQuery_button(button, dialog_id+"cancel", "cancel", _T("CANCEL"), jQuery_actioner(same, jqscript("$('#"+dialog_id+"').dialog('close')"))))), |
| 922 | ]) | 939 | ]) |
| 923 | ] | 940 | ] |
| @@ -975,18 +992,22 @@ public define List(CXM_Form_Field) | @@ -975,18 +992,22 @@ public define List(CXM_Form_Field) | ||
| 975 | 992 | ||
| 976 | foreign_text(s_name, c_name, value, foreign_table_name, select, help) then | 993 | foreign_text(s_name, c_name, value, foreign_table_name, select, help) then |
| 977 | //[selector_c([],no_label, html_Id(""), wan(c_name), 1, select.get(db, table_referer, fk_clause), success(init(to_String(value))), mandatory), help_line(help, _T)], | 994 | //[selector_c([],no_label, html_Id(""), wan(c_name), 1, select.get(db, table_referer, fk_clause), success(init(to_String(value))), mandatory), help_line(help, _T)], |
| 978 | - with uid = generate_random_string(20)+"_", | 995 | + with uid = "_"+generate_random_string(20)+"_", |
| 996 | + with refresh_func = uid+foreign_table_name+"_"+c_name+"_selector_refresh", | ||
| 997 | + //with load_script = "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+"');", | ||
| 998 | + 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+"');} "+refresh_func+"(); "), | ||
| 979 | [ | 999 | [ |
| 980 | 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)))), | 1000 | 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)))), |
| 981 | one_line_fields([ | 1001 | one_line_fields([ |
| 982 | - 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), | 1002 | + partial(partial_content([js_inline(load_script)],empty)), |
| 1003 | + selector_c([],label(_T(s_name), no_help), html_Id(uid+foreign_table_name+"_"+c_name+"_selector"), wan(c_name), 1, select.get(db, table_referer, fk_clause), success(init(to_String(value))), mandatory), help_line(help, _T), | ||
| 983 | partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), | 1004 | partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id(uid+foreign_table_name+"_dlg_ajax")))], "", [])), |
| 984 | ]) | 1005 | ]) |
| 985 | ], | 1006 | ], |
| 986 | 1007 | ||
| 987 | foreign_text_search(s_name, c_name, select, foreign_table_name, s_fields, help) then | 1008 | foreign_text_search(s_name, c_name, select, foreign_table_name, s_fields, help) then |
| 988 | //[raw_in_form(literal("<input class=\"in\" id=\"acb_"+c_name+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"))] | 1009 | //[raw_in_form(literal("<input class=\"in\" id=\"acb_"+c_name+"\" data-init_record=\""+select+"\" size=\"50\" type=\"text\">"))] |
| 989 | - with uid = generate_random_string(20)+"_", | 1010 | + with uid = "_"+generate_random_string(20)+"_", |
| 990 | [ | 1011 | [ |
| 991 | 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)))), | 1012 | 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)))), |
| 992 | one_line_fields([ | 1013 | one_line_fields([ |
view/web_action.anubis
| @@ -15,6 +15,8 @@ public define WEB_Action_Name hkc_view_editor = controller_action("hk_c" | @@ -15,6 +15,8 @@ public define WEB_Action_Name hkc_view_editor = controller_action("hk_c" | ||
| 15 | public define WEB_Action_Name hkc_grid_view = controller_action("hk_c", "grid_view"). | 15 | public define WEB_Action_Name hkc_grid_view = controller_action("hk_c", "grid_view"). |
| 16 | public define WEB_Action_Name hkc_grid_action = controller_action("hk_c", "grid_action"). | 16 | public define WEB_Action_Name hkc_grid_action = controller_action("hk_c", "grid_action"). |
| 17 | public define WEB_Action_Name hkc_combo_search = controller_action("hk_c", "combo_search"). | 17 | public define WEB_Action_Name hkc_combo_search = controller_action("hk_c", "combo_search"). |
| 18 | +public define WEB_Action_Name hkc_selector = controller_action("hk_c", "selector"). //get dropdown HMTL content | ||
| 19 | + | ||
| 18 | public define WEB_Action_Name hkc_list_view = controller_action("hk_c", "view_table"). | 20 | public define WEB_Action_Name hkc_list_view = controller_action("hk_c", "view_table"). |
| 19 | public define WEB_Action_Name hkc_list_view_name = controller_action("hk_c", "hkc_list_view_name"). | 21 | public define WEB_Action_Name hkc_list_view_name = controller_action("hk_c", "hkc_list_view_name"). |
| 20 | public define WEB_Action_Name hkc_list_view_filter = controller_action("hk_c", "hkc_list_view_filter"). | 22 | public define WEB_Action_Name hkc_list_view_filter = controller_action("hk_c", "hkc_list_view_filter"). |