From cd8a0a45283d63e8a75a1fd799b6af3eea579d21 Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 12 Mar 2017 18:39:25 +0100 Subject: [PATCH] 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 --- types/model/fields.anubis | 17 +++++++++++++---- view/view_apps_renderer.anubis | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ view/view_table_renderer.anubis | 12 +++++------- view/web_action.anubis | 18 ++++++++++++++++++ 4 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 view/view_apps_renderer.anubis create mode 100644 view/web_action.anubis diff --git a/types/model/fields.anubis b/types/model/fields.anubis index 1cc9708..5a39d1d 100644 --- a/types/model/fields.anubis +++ b/types/model/fields.anubis @@ -26,6 +26,7 @@ transmit calexium_lib/web/CXM_json.anubis datetime_field | DB_datetime | text (date in ISO-8601 format: yyyy-mm-dd hh:mm:ss) foreign_key | Int | integer integer_field | Int | arbitrary size integer (numeric) + float_field | Float | char_field | String | max size text text_field | String | arbitrary size text @@ -196,6 +197,7 @@ public type HK_Model_Field: datetime_field(HK_Datetime_Field_Attr), // datetime with the precision of the second 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. integer_field (HK_Int_Choices choices), // integer of arbitrary size + float_field , char_field (HK_Text_Choices choices, Int size), // text of maximal size 'size' (number of characters) password_field(Int min_size), // the password field doesn't show the password string or store it in hashed version into database text_field (HK_Text_Field_Attr). // text of variable size @@ -287,7 +289,10 @@ public define Message integer_field(choices) then // integer of arbitrary size //TODO add choices if need forget(add_string(hk_model_field_message, "type", "integer_field")), - + + float_field then + forget(add_string(hk_model_field_message, "type", "float_field")), + char_field (choices, size) then // text of maximal size 'size' (number of characters) //TODO add choices if need forget(add_string(hk_model_field_message, "type", "char_field")); @@ -343,7 +348,10 @@ public define JsonValue integer_field(choices) then // integer of arbitrary size //TODO add choices if need [ json_member("type", json_string("integer_field")) ], - + + float_field then //float + [ json_member("type", json_string("float_field"))], + char_field (choices, size) then // text of maximal size 'size' (number of characters) //TODO add choices if need [ json_member("type", json_string("char_field")), @@ -380,14 +388,15 @@ define Maybe(HK_Model_Field) if from_Message(msg_app_name) is {failure then failure, success(app_name) then success(foreign_key(app_name, table_name)) }}} - else if type = "integer_field" then success(integer_field) + else if type = "integer_field" then success(integer_field) + else if type = "float_field" then success(float_field) else if type = "char_field" then if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then success(char_field(to_Int(w32_size)))} else if type = "password_field" then if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then success(password_field(to_Int(w32_size)))} - else if type = "text_field" then success(text_field(get_text_attribute(hk_model_field_message))) + else if type = "text_field" then success(text_field(get_text_attribute(hk_model_field_message))) else failure . diff --git a/view/view_apps_renderer.anubis b/view/view_apps_renderer.anubis new file mode 100644 index 0000000..6762086 --- /dev/null +++ b/view/view_apps_renderer.anubis @@ -0,0 +1,65 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 11/03/2017 + * Time: 19:12 + * © Calexium + */ + +read hayamiki_lib/types/hayamiki.anubis +read hayamiki_lib/view/web_action.anubis + +read calexium_lib/web/CXM_making_a_web_site.anubis + +read calexium_lib/web/jQuery/CXM_jquery_dialog.anubis +read calexium_lib/web/jQuery/CXM_jquery_button.anubis +read calexium_lib/web/jQuery/ui-addon/datetimepicker.anubis +read calexium_lib/web/widgets/button.anubis + + +define List(HTML_Row(HTML_Off_Form)) + generate_apps + ( + List(HK_App) apps, + (String) -> String _T, + )= + map_append((HK_App app) |-> since app is hk_app(app_name, icon, help, tables), + [ (HTML_Row(HTML_Off_Form))row([core_attrs([class("hk_app_title")])],cell([columns(2)],text(app_name)))]+ //APP name line + //here map for each table + map((HK_Table table) |-> since table is hk_table(_table_name, short_name, model, display), + //construct the real name of the table (app + table_name) + with table_name = if length(app_name) > 0 then app_name +"_"+_table_name else _table_name, + (HTML_Row(HTML_Off_Form))row([core_attrs([class("hk_table_line")])], + [ cell(text(_table_name)), + cell( + sequence([ + partial(img_button(icn16_add, [event(onclick, jq_dialog_open(dialog_id("edit_table_dlg_ajax"), "'table_name="+table_name+"'"))], "", [])), + partial(img_button(icn16_view_list, view_table, [("table_name",table_name)])) + ]) + ) + ]) + ,tables) + + ,apps + ) +. + + + +public define Maybe(HTML_Partial_Content) + show_apps_content + ( + SQLite3DataBase db, + HK_Database hk_db, + (String) -> String _T, + String lang, + String web_site_directory + ) = + success(partial_content([css(css_file("hayamiki/hayamiki.css")),]+ + jq_dialog_init + jq_datetimepicker_init(lang), + sequence([ + partial(jq_dialog_create(dialog_id("edit_table_dlg_ajax"), ajax(controller_action("hk_c", "ajax_edit_table")))), /*&table_name="+rows.table_name*/ + table([class("hk_table_apps")], generate_apps(hk_db.apps, _T)) + ]) + )) +. diff --git a/view/view_table_renderer.anubis b/view/view_table_renderer.anubis index 34478d8..27ae7ea 100644 --- a/view/view_table_renderer.anubis +++ b/view/view_table_renderer.anubis @@ -9,6 +9,7 @@ read hayamiki_lib/view/view_table_types.anubis read hayamiki_lib/view/view_table_manager_types.anubis read hayamiki_lib/view/view_table_manager.anubis +read hayamiki_lib/view/web_action.anubis read hayamiki_lib/types/hayamiki.anubis read system/string.anubis read locale/L3.anubis @@ -32,12 +33,7 @@ read calexium_lib/web/CXM_form.anubis read calexium_lib/web/widgets/css_helper.anubis read calexium_lib/web/widgets/button.anubis -public define WEB_Action_Name edit_table = controller_action("hk_c", "edit_table"). -public define WEB_Action_Name view_table = controller_action("hk_c", "view_table"). -public define WEB_Action_Name save_row = controller_action("hk_c", "save_row"). -public define WEB_Action_Name delete_row = controller_action("hk_c", "delete_row"). -public define WEB_Action_Name hk_cancel = controller_action("hk_c", "cancel"). -public define WEB_Action_Name ajax_edit_table = controller_action("hk_c", "ajax_edit_table"). + define CXM_Form_Field @@ -116,7 +112,7 @@ define HTML_Head_Tag join("",map_select((VT_edit_entry entry) |-> if entry is text_area(s_name, c_name, value, txt_editor, help) then if txt_editor is { none then failure, - rich_editor then success("CKEDITOR.on( 'loaded', function(){\n CKEDITOR.replace( '"+c_name+"_editor' );});") + rich_editor then success(" CKEDITOR.replace( '"+c_name+"_editor' );") } else failure, list)) @@ -144,6 +140,7 @@ public define HTML_Partial_Content ) = with table_name = vt_elist.table_name, with button_name = if get_String(lwa, "id","none") = "none" then _T("CREATE") else _T("UPDATE"), + with button_name_and_new = if get_String(lwa, "id","none") = "none" then _T("CREATE_AND_EDIT_NEW") else _T("UPDATE_AND_EDIT_NEW"), partial_content( @@ -153,6 +150,7 @@ public define HTML_Partial_Content edit_form_lines(db, _T, vt_elist.list, [])+ [ one_line_fields([ submit(save_row, failure, button_name, [("table_name", table_name)]), + submit(save_row_and_new, failure, button_name_and_new, [("table_name", table_name)]), submit(hk_cancel, failure, _T("CANCEL")) ]) ] diff --git a/view/web_action.anubis b/view/web_action.anubis new file mode 100644 index 0000000..165fd9c --- /dev/null +++ b/view/web_action.anubis @@ -0,0 +1,18 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 11/03/2017 + * Time: 21:55 + * © Calexium + */ + +read calexium_lib/web/CXM_making_a_web_site.anubis + +public define WEB_Action_Name edit_table = controller_action("hk_c", "edit_table"). +public define WEB_Action_Name view_table = controller_action("hk_c", "view_table"). +public define WEB_Action_Name save_row = controller_action("hk_c", "save_row"). +public define WEB_Action_Name save_row_and_new = controller_action("hk_c", "save_row_and_new"). +public define WEB_Action_Name delete_row = controller_action("hk_c", "delete_row"). +public define WEB_Action_Name hk_cancel = controller_action("hk_c", "cancel"). +public define WEB_Action_Name ajax_edit_table = controller_action("hk_c", "ajax_edit_table"). +public define WEB_Action_Name show_apps = controller_action("hk_c", "show_apps"). -- libgit2 0.21.4