Commit c6fff2c0fe605fb6e10c2ba38844a19af49c0b83
1 parent
6ad846b4
the tm_writer has now 2 functions for writing row.
One with complete Type given from web args and one with list of available fields of that type. This make update or insert with only available columns from web args. Manage that previous behavior by adding new controller action "update_row" and "update_row_and_new" but the last one is not already managed
Showing
4 changed files
with
24 additions
and
16 deletions
Show diff stats
view/view_table_manager.anubis
| @@ -70,7 +70,7 @@ public define Maybe(TM_writer) | @@ -70,7 +70,7 @@ public define Maybe(TM_writer) | ||
| 70 | { | 70 | { |
| 71 | [] then failure, | 71 | [] then failure, |
| 72 | [ h . t ] then | 72 | [ h . t ] then |
| 73 | - if h is tm_writer(tb_name, get_writer) then | 73 | + if h is tm_writer(tb_name, get_writer_from_type, get_writer_from_fields) then |
| 74 | if tb_name = table_name then | 74 | if tb_name = table_name then |
| 75 | success(h) | 75 | success(h) |
| 76 | else | 76 | else |
view/view_table_manager_types.anubis
| @@ -16,7 +16,12 @@ public type VTM_edit_list: | @@ -16,7 +16,12 @@ public type VTM_edit_list: | ||
| 16 | vtm_edit_list(List(VTM_edit) list). | 16 | vtm_edit_list(List(VTM_edit) list). |
| 17 | 17 | ||
| 18 | public type TM_writer: | 18 | public type TM_writer: |
| 19 | - tm_writer(String table_name, (SQLite3DataBase db, List(Web_arg) lwa) -> Maybe(One) write). | 19 | + tm_writer( |
| 20 | + String table_name, | ||
| 21 | + (SQLite3DataBase db, List(Web_arg) lwa) -> Maybe(One) write_from_type, | ||
| 22 | + (SQLite3DataBase db, List(Web_arg) lwa) -> Maybe(One) write_from_fields | ||
| 23 | + ) | ||
| 24 | +. | ||
| 20 | 25 | ||
| 21 | public type TM_writer_list: | 26 | public type TM_writer_list: |
| 22 | tm_writer_list(List(TM_writer) list). | 27 | tm_writer_list(List(TM_writer) list). |
view/view_table_renderer.anubis
| @@ -154,18 +154,19 @@ public define HTML_Partial_Content | @@ -154,18 +154,19 @@ public define HTML_Partial_Content | ||
| 154 | VT_edit vt_elist | 154 | VT_edit vt_elist |
| 155 | ) = | 155 | ) = |
| 156 | with table_name = vt_elist.table_name, | 156 | with table_name = vt_elist.table_name, |
| 157 | - with button_name = if get_String(lwa, "id","none") = "none" then _T("CREATE") else _T("UPDATE"), | ||
| 158 | - with button_name_and_new = if get_String(lwa, "id","none") = "none" then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), | ||
| 159 | - with new_entry = if get_String(lwa, "id", "none") = "none" then true else false, | 157 | + //true if need to create row or false for updating |
| 158 | + with create = if get_String(lwa, "id","none") = "none" then true else false, | ||
| 159 | + with button_name = if create then _T("CREATE") else _T("UPDATE"), | ||
| 160 | + with button_name_and_new = if create then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), | ||
| 160 | 161 | ||
| 161 | partial_content( | 162 | partial_content( |
| 162 | jq_datetimepicker_init(lang) + | 163 | jq_datetimepicker_init(lang) + |
| 163 | get_editor_header(vt_elist.list), //add editor header if need. Like init ck_editor | 164 | get_editor_header(vt_elist.list), //add editor header if need. Like init ck_editor |
| 164 | cxm_form( table_name, lwa, | 165 | cxm_form( table_name, lwa, |
| 165 | - edit_form_lines(db, _T, vt_elist.list, new_entry, [])+ | 166 | + edit_form_lines(db, _T, vt_elist.list, create, [])+ |
| 166 | [ one_line_fields([ | 167 | [ one_line_fields([ |
| 167 | - submit(save_row, failure, button_name, [("table_name", table_name)]), | ||
| 168 | - submit(save_row_and_new, failure, button_name_and_new, [("table_name", table_name)]), | 168 | + submit(if create then save_row else update_row, failure, button_name, [("table_name", table_name)]), |
| 169 | + submit(if create then save_row_and_new else update_row_and_new, failure, button_name_and_new, [("table_name", table_name)]), | ||
| 169 | submit(hk_cancel, failure, _T("CANCEL")) | 170 | submit(hk_cancel, failure, _T("CANCEL")) |
| 170 | ]) | 171 | ]) |
| 171 | ] | 172 | ] |
view/web_action.anubis
| @@ -8,11 +8,13 @@ | @@ -8,11 +8,13 @@ | ||
| 8 | 8 | ||
| 9 | read calexium_lib/web/CXM_making_a_web_site.anubis | 9 | read calexium_lib/web/CXM_making_a_web_site.anubis |
| 10 | 10 | ||
| 11 | -public define WEB_Action_Name edit_table = controller_action("hk_c", "edit_table"). | ||
| 12 | -public define WEB_Action_Name view_table = controller_action("hk_c", "view_table"). | ||
| 13 | -public define WEB_Action_Name save_row = controller_action("hk_c", "save_row"). | ||
| 14 | -public define WEB_Action_Name save_row_and_new = controller_action("hk_c", "save_row_and_new"). | ||
| 15 | -public define WEB_Action_Name delete_row = controller_action("hk_c", "delete_row"). | ||
| 16 | -public define WEB_Action_Name hk_cancel = controller_action("hk_c", "cancel"). | ||
| 17 | -public define WEB_Action_Name ajax_edit_table = controller_action("hk_c", "ajax_edit_table"). | ||
| 18 | -public define WEB_Action_Name show_apps = controller_action("hk_c", "show_apps"). | 11 | +public define WEB_Action_Name edit_table = controller_action("hk_c", "edit_table"). |
| 12 | +public define WEB_Action_Name view_table = controller_action("hk_c", "view_table"). | ||
| 13 | +public define WEB_Action_Name save_row = controller_action("hk_c", "save_row"). | ||
| 14 | +public define WEB_Action_Name save_row_and_new = controller_action("hk_c", "save_row_and_new"). | ||
| 15 | +public define WEB_Action_Name update_row = controller_action("hk_c", "update_row"). | ||
| 16 | +public define WEB_Action_Name update_row_and_new = controller_action("hk_c", "update_row_and_new"). | ||
| 17 | +public define WEB_Action_Name delete_row = controller_action("hk_c", "delete_row"). | ||
| 18 | +public define WEB_Action_Name hk_cancel = controller_action("hk_c", "cancel"). | ||
| 19 | +public define WEB_Action_Name ajax_edit_table = controller_action("hk_c", "ajax_edit_table"). | ||
| 20 | +public define WEB_Action_Name show_apps = controller_action("hk_c", "show_apps"). |