Commit cd8a0a45283d63e8a75a1fd799b6af3eea579d21
1 parent
99a54291
add float_field. Now must be generated by hk_generator
move web_action_name definition into file view/web_action.anubis Add view/view_apps_renderer.anubis, which constructs html table with all applications and their tables
Showing
4 changed files
with
101 additions
and
11 deletions
Show diff stats
types/model/fields.anubis
| @@ -26,6 +26,7 @@ transmit calexium_lib/web/CXM_json.anubis | @@ -26,6 +26,7 @@ transmit calexium_lib/web/CXM_json.anubis | ||
| 26 | datetime_field | DB_datetime | text (date in ISO-8601 format: yyyy-mm-dd hh:mm:ss) | 26 | datetime_field | DB_datetime | text (date in ISO-8601 format: yyyy-mm-dd hh:mm:ss) |
| 27 | foreign_key | Int | integer | 27 | foreign_key | Int | integer |
| 28 | integer_field | Int | arbitrary size integer (numeric) | 28 | integer_field | Int | arbitrary size integer (numeric) |
| 29 | + float_field | Float | | ||
| 29 | char_field | String | max size text | 30 | char_field | String | max size text |
| 30 | text_field | String | arbitrary size text | 31 | text_field | String | arbitrary size text |
| 31 | 32 | ||
| @@ -196,6 +197,7 @@ public type HK_Model_Field: | @@ -196,6 +197,7 @@ public type HK_Model_Field: | ||
| 196 | datetime_field(HK_Datetime_Field_Attr), // datetime with the precision of the second | 197 | datetime_field(HK_Datetime_Field_Attr), // datetime with the precision of the second |
| 197 | foreign_key (HK_App_Name app_name, String table_name), // foreign key to 'id' in another (or same) table and column_name for choice selector. | 198 | foreign_key (HK_App_Name app_name, String table_name), // foreign key to 'id' in another (or same) table and column_name for choice selector. |
| 198 | integer_field (HK_Int_Choices choices), // integer of arbitrary size | 199 | integer_field (HK_Int_Choices choices), // integer of arbitrary size |
| 200 | + float_field , | ||
| 199 | char_field (HK_Text_Choices choices, Int size), // text of maximal size 'size' (number of characters) | 201 | char_field (HK_Text_Choices choices, Int size), // text of maximal size 'size' (number of characters) |
| 200 | password_field(Int min_size), // the password field doesn't show the password string or store it in hashed version into database | 202 | password_field(Int min_size), // the password field doesn't show the password string or store it in hashed version into database |
| 201 | text_field (HK_Text_Field_Attr). // text of variable size | 203 | text_field (HK_Text_Field_Attr). // text of variable size |
| @@ -287,7 +289,10 @@ public define Message | @@ -287,7 +289,10 @@ public define Message | ||
| 287 | integer_field(choices) then // integer of arbitrary size | 289 | integer_field(choices) then // integer of arbitrary size |
| 288 | //TODO add choices if need | 290 | //TODO add choices if need |
| 289 | forget(add_string(hk_model_field_message, "type", "integer_field")), | 291 | forget(add_string(hk_model_field_message, "type", "integer_field")), |
| 290 | - | 292 | + |
| 293 | + float_field then | ||
| 294 | + forget(add_string(hk_model_field_message, "type", "float_field")), | ||
| 295 | + | ||
| 291 | char_field (choices, size) then // text of maximal size 'size' (number of characters) | 296 | char_field (choices, size) then // text of maximal size 'size' (number of characters) |
| 292 | //TODO add choices if need | 297 | //TODO add choices if need |
| 293 | forget(add_string(hk_model_field_message, "type", "char_field")); | 298 | forget(add_string(hk_model_field_message, "type", "char_field")); |
| @@ -343,7 +348,10 @@ public define JsonValue | @@ -343,7 +348,10 @@ public define JsonValue | ||
| 343 | integer_field(choices) then // integer of arbitrary size | 348 | integer_field(choices) then // integer of arbitrary size |
| 344 | //TODO add choices if need | 349 | //TODO add choices if need |
| 345 | [ json_member("type", json_string("integer_field")) ], | 350 | [ json_member("type", json_string("integer_field")) ], |
| 346 | - | 351 | + |
| 352 | + float_field then //float | ||
| 353 | + [ json_member("type", json_string("float_field"))], | ||
| 354 | + | ||
| 347 | char_field (choices, size) then // text of maximal size 'size' (number of characters) | 355 | char_field (choices, size) then // text of maximal size 'size' (number of characters) |
| 348 | //TODO add choices if need | 356 | //TODO add choices if need |
| 349 | [ json_member("type", json_string("char_field")), | 357 | [ json_member("type", json_string("char_field")), |
| @@ -380,14 +388,15 @@ define Maybe(HK_Model_Field) | @@ -380,14 +388,15 @@ define Maybe(HK_Model_Field) | ||
| 380 | if from_Message(msg_app_name) is {failure then failure, success(app_name) then | 388 | if from_Message(msg_app_name) is {failure then failure, success(app_name) then |
| 381 | success(foreign_key(app_name, table_name)) | 389 | success(foreign_key(app_name, table_name)) |
| 382 | }}} | 390 | }}} |
| 383 | - else if type = "integer_field" then success(integer_field) | 391 | + else if type = "integer_field" then success(integer_field) |
| 392 | + else if type = "float_field" then success(float_field) | ||
| 384 | else if type = "char_field" then | 393 | else if type = "char_field" then |
| 385 | if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then | 394 | if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then |
| 386 | success(char_field(to_Int(w32_size)))} | 395 | success(char_field(to_Int(w32_size)))} |
| 387 | else if type = "password_field" then | 396 | else if type = "password_field" then |
| 388 | if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then | 397 | if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then |
| 389 | success(password_field(to_Int(w32_size)))} | 398 | success(password_field(to_Int(w32_size)))} |
| 390 | - else if type = "text_field" then success(text_field(get_text_attribute(hk_model_field_message))) | 399 | + else if type = "text_field" then success(text_field(get_text_attribute(hk_model_field_message))) |
| 391 | else failure | 400 | else failure |
| 392 | . | 401 | . |
| 393 | 402 |
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: フランスのトトロ aka (David RENÉ) | ||
| 4 | + * Date: 11/03/2017 | ||
| 5 | + * Time: 19:12 | ||
| 6 | + * © Calexium | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +read hayamiki_lib/types/hayamiki.anubis | ||
| 10 | +read hayamiki_lib/view/web_action.anubis | ||
| 11 | + | ||
| 12 | +read calexium_lib/web/CXM_making_a_web_site.anubis | ||
| 13 | + | ||
| 14 | +read calexium_lib/web/jQuery/CXM_jquery_dialog.anubis | ||
| 15 | +read calexium_lib/web/jQuery/CXM_jquery_button.anubis | ||
| 16 | +read calexium_lib/web/jQuery/ui-addon/datetimepicker.anubis | ||
| 17 | +read calexium_lib/web/widgets/button.anubis | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +define List(HTML_Row(HTML_Off_Form)) | ||
| 21 | + generate_apps | ||
| 22 | + ( | ||
| 23 | + List(HK_App) apps, | ||
| 24 | + (String) -> String _T, | ||
| 25 | + )= | ||
| 26 | + map_append((HK_App app) |-> since app is hk_app(app_name, icon, help, tables), | ||
| 27 | + [ (HTML_Row(HTML_Off_Form))row([core_attrs([class("hk_app_title")])],cell([columns(2)],text(app_name)))]+ //APP name line | ||
| 28 | + //here map for each table | ||
| 29 | + map((HK_Table table) |-> since table is hk_table(_table_name, short_name, model, display), | ||
| 30 | + //construct the real name of the table (app + table_name) | ||
| 31 | + with table_name = if length(app_name) > 0 then app_name +"_"+_table_name else _table_name, | ||
| 32 | + (HTML_Row(HTML_Off_Form))row([core_attrs([class("hk_table_line")])], | ||
| 33 | + [ cell(text(_table_name)), | ||
| 34 | + cell( | ||
| 35 | + sequence([ | ||
| 36 | + partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id("edit_table_dlg_ajax"), "'table_name="+table_name+"'"))], "", [])), | ||
| 37 | + partial(img_button(icn16_view_list, view_table, [("table_name",table_name)])) | ||
| 38 | + ]) | ||
| 39 | + ) | ||
| 40 | + ]) | ||
| 41 | + ,tables) | ||
| 42 | + | ||
| 43 | + ,apps | ||
| 44 | + ) | ||
| 45 | +. | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + | ||
| 49 | +public define Maybe(HTML_Partial_Content) | ||
| 50 | + show_apps_content | ||
| 51 | + ( | ||
| 52 | + SQLite3DataBase db, | ||
| 53 | + HK_Database hk_db, | ||
| 54 | + (String) -> String _T, | ||
| 55 | + String lang, | ||
| 56 | + String web_site_directory | ||
| 57 | + ) = | ||
| 58 | + success(partial_content([css(css_file("hayamiki/hayamiki.css")),]+ | ||
| 59 | + jq_dialog_init + jq_datetimepicker_init(lang), | ||
| 60 | + sequence([ | ||
| 61 | + partial(jq_dialog_create(dialog_id("edit_table_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table")))), /*&table_name="+rows.table_name*/ | ||
| 62 | + table([class("hk_table_apps")], generate_apps(hk_db.apps, _T)) | ||
| 63 | + ]) | ||
| 64 | + )) | ||
| 65 | +. |
view/view_table_renderer.anubis
| @@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
| 9 | read hayamiki_lib/view/view_table_types.anubis | 9 | read hayamiki_lib/view/view_table_types.anubis |
| 10 | read hayamiki_lib/view/view_table_manager_types.anubis | 10 | read hayamiki_lib/view/view_table_manager_types.anubis |
| 11 | read hayamiki_lib/view/view_table_manager.anubis | 11 | read hayamiki_lib/view/view_table_manager.anubis |
| 12 | +read hayamiki_lib/view/web_action.anubis | ||
| 12 | read hayamiki_lib/types/hayamiki.anubis | 13 | read hayamiki_lib/types/hayamiki.anubis |
| 13 | read system/string.anubis | 14 | read system/string.anubis |
| 14 | read locale/L3.anubis | 15 | read locale/L3.anubis |
| @@ -32,12 +33,7 @@ read calexium_lib/web/CXM_form.anubis | @@ -32,12 +33,7 @@ read calexium_lib/web/CXM_form.anubis | ||
| 32 | read calexium_lib/web/widgets/css_helper.anubis | 33 | read calexium_lib/web/widgets/css_helper.anubis |
| 33 | read calexium_lib/web/widgets/button.anubis | 34 | read calexium_lib/web/widgets/button.anubis |
| 34 | 35 | ||
| 35 | -public define WEB_Action_Name edit_table = controller_action("hk_c", "edit_table"). | ||
| 36 | -public define WEB_Action_Name view_table = controller_action("hk_c", "view_table"). | ||
| 37 | -public define WEB_Action_Name save_row = controller_action("hk_c", "save_row"). | ||
| 38 | -public define WEB_Action_Name delete_row = controller_action("hk_c", "delete_row"). | ||
| 39 | -public define WEB_Action_Name hk_cancel = controller_action("hk_c", "cancel"). | ||
| 40 | -public define WEB_Action_Name ajax_edit_table = controller_action("hk_c", "ajax_edit_table"). | 36 | + |
| 41 | 37 | ||
| 42 | 38 | ||
| 43 | define CXM_Form_Field | 39 | define CXM_Form_Field |
| @@ -116,7 +112,7 @@ define HTML_Head_Tag | @@ -116,7 +112,7 @@ define HTML_Head_Tag | ||
| 116 | join("",map_select((VT_edit_entry entry) |-> | 112 | join("",map_select((VT_edit_entry entry) |-> |
| 117 | if entry is text_area(s_name, c_name, value, txt_editor, help) then | 113 | if entry is text_area(s_name, c_name, value, txt_editor, help) then |
| 118 | if txt_editor is { none then failure, | 114 | if txt_editor is { none then failure, |
| 119 | - rich_editor then success("CKEDITOR.on( 'loaded', function(){\n CKEDITOR.replace( '"+c_name+"_editor' );});") | 115 | + rich_editor then success(" CKEDITOR.replace( '"+c_name+"_editor' );") |
| 120 | } | 116 | } |
| 121 | else | 117 | else |
| 122 | failure, list)) | 118 | failure, list)) |
| @@ -144,6 +140,7 @@ public define HTML_Partial_Content | @@ -144,6 +140,7 @@ public define HTML_Partial_Content | ||
| 144 | ) = | 140 | ) = |
| 145 | with table_name = vt_elist.table_name, | 141 | with table_name = vt_elist.table_name, |
| 146 | with button_name = if get_String(lwa, "id","none") = "none" then _T("CREATE") else _T("UPDATE"), | 142 | with button_name = if get_String(lwa, "id","none") = "none" then _T("CREATE") else _T("UPDATE"), |
| 143 | + with button_name_and_new = if get_String(lwa, "id","none") = "none" then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), | ||
| 147 | 144 | ||
| 148 | 145 | ||
| 149 | partial_content( | 146 | partial_content( |
| @@ -153,6 +150,7 @@ public define HTML_Partial_Content | @@ -153,6 +150,7 @@ public define HTML_Partial_Content | ||
| 153 | edit_form_lines(db, _T, vt_elist.list, [])+ | 150 | edit_form_lines(db, _T, vt_elist.list, [])+ |
| 154 | [ one_line_fields([ | 151 | [ one_line_fields([ |
| 155 | submit(save_row, failure, button_name, [("table_name", table_name)]), | 152 | submit(save_row, failure, button_name, [("table_name", table_name)]), |
| 153 | + submit(save_row_and_new, failure, button_name_and_new, [("table_name", table_name)]), | ||
| 156 | submit(hk_cancel, failure, _T("CANCEL")) | 154 | submit(hk_cancel, failure, _T("CANCEL")) |
| 157 | ]) | 155 | ]) |
| 158 | ] | 156 | ] |
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: フランスのトトロ aka (David RENÉ) | ||
| 4 | + * Date: 11/03/2017 | ||
| 5 | + * Time: 21:55 | ||
| 6 | + * © Calexium | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +read calexium_lib/web/CXM_making_a_web_site.anubis | ||
| 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"). |