From 80c9c10d01f61d55c712a80296af34f9f3c2b870 Mon Sep 17 00:00:00 2001 From: totoro Date: Thu, 9 Mar 2017 18:32:07 +0100 Subject: [PATCH] Use the DB_id instead of Int for foreign key Add attribute for used editor for text_field --- calexium_lib | 2 +- hayamiki_lib | 2 +- src/generation/columns.anubis | 7 ++++--- src/generation/cxm_lib_menu.anubis | 1 + src/generation/fields.anubis | 26 +++++++++++++------------- src/generation/html.anubis | 2 +- src/generation/icons.anubis | 2 +- src/generation/types.anubis | 19 ++++++++++++------- src/model.3.0.0.anubis | 2 +- 9 files changed, 35 insertions(+), 28 deletions(-) diff --git a/calexium_lib b/calexium_lib index 5b85c04..455f1bc 160000 --- a/calexium_lib +++ b/calexium_lib @@ -1 +1 @@ -Subproject commit 5b85c04ccb6f2723207bb2b0640de7ec64850665 +Subproject commit 455f1bc540754c023475efc76ab6394c9f8968cd diff --git a/hayamiki_lib b/hayamiki_lib index 9ab9ecc..99a5429 160000 --- a/hayamiki_lib +++ b/hayamiki_lib @@ -1 +1 @@ -Subproject commit 9ab9ecc773adfda2d84d6cd559b1fe7ef305880e +Subproject commit 99a54291b71c079ff268a039c9c43cc17e093f36 diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis index 3750099..d2b3ba8 100644 --- a/src/generation/columns.anubis +++ b/src/generation/columns.anubis @@ -9,6 +9,7 @@ read system/string.anubis read tools/list.anubis read hayamiki_lib/types/model/columns.anubis +read hayamiki_lib/types/model/fields.anubis read fields.anubis @@ -146,7 +147,7 @@ public define Maybe(String) integer_field(_) then success(name), char_field(_,_) then success(name), password_field(_) then success(name), - text_field then success(name) + text_field(_) then success(name) }. public define List(String) @@ -259,7 +260,7 @@ public define Maybe(String) success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") } password_field(min_size) then success("password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")") - text_field then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") + text_field(txt_attr) then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(txt_attr)+", "+to_Anubis_source(help)+")") }. public define String @@ -330,5 +331,5 @@ public define String integer_field(_) then "to_String("+current_type_name+"."+name+")", char_field(_,_) then current_type_name+"."+name, password_field(_) then current_type_name+"."+name, - text_field then current_type_name+"."+name + text_field(_) then current_type_name+"."+name }. diff --git a/src/generation/cxm_lib_menu.anubis b/src/generation/cxm_lib_menu.anubis index f7b6658..f8bebed 100644 --- a/src/generation/cxm_lib_menu.anubis +++ b/src/generation/cxm_lib_menu.anubis @@ -81,6 +81,7 @@ public define Maybe(One) * Time: "+_Int_to_ISO_8601_time(now)+" */ +transmit calexium_lib/web/CXM_making_a_web_site.anubis transmit calexium_lib/web/widgets/menu.anubis public define List(Menu_Item) diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis index af00812..ef4cb7e 100644 --- a/src/generation/fields.anubis +++ b/src/generation/fields.anubis @@ -30,11 +30,11 @@ public define String date_field(_) then "DB_date", time_field(_) then "DB_time", datetime_field(_) then "DB_datetime", - foreign_key(_,_) then "Int", + foreign_key(_,_) then "DB_id", integer_field(_) then "Int", char_field(_,_) then "String", password_field(_) then "String", - text_field then "String" + text_field(_) then "String" }. public define String @@ -53,11 +53,11 @@ public define String date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/database/db_types.anubis\")", time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/database/db_types.anubis\")", datetime_field(_) then "extern_type(\"DB_datetime\", \"calexium_lib/database/db_types.anubis\")", - foreign_key(_,_) then "int", + foreign_key(_,_) then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")", integer_field(_) then "int", char_field(_,_) then "string", password_field(_) then "string", - text_field then "string" + text_field(_) then "string" }. public define String @@ -78,7 +78,7 @@ public define String integer_field(_) then fill("INTEGER", 15) +format_attributes(attributes), char_field(_,size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes), password_field(_) then fill("TEXT", 15) +format_attributes(attributes), - text_field then fill("TEXT", 15) +format_attributes(attributes), + text_field(_) then fill("TEXT", 15) +format_attributes(attributes), }. public define String @@ -95,11 +95,11 @@ public define String date_field(_) then "db_date(\"\")", time_field(_) then "db_time(\"\")", datetime_field(_) then "db_datetime(\"\")", - foreign_key(_,_) then "(Int)0", + foreign_key(_,_) then "(DB_id)none", integer_field(_) then "(Int)0", char_field(choices,size) then "\"\"", password_field(min_size) then "\"\"", - text_field then "\"\"" + text_field(_) then "\"\"" }. public define String @@ -117,11 +117,11 @@ public define String date_field(attrs) then if attrs = none then "get_DB_date(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_date,", time_field(attrs) then if attrs = none then "get_DB_time(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_time,", datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_datetime,", - foreign_key(_,_) then "get_Int(lwa, __prefix__+\""+name+"\")", + foreign_key(_,_) then "with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),", integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\")", char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", password_field(min_size) then "get_String(lwa, __prefix__+\""+name+"_1\")", - text_field then "get_String(lwa, __prefix__+\""+name+"\")" + text_field(_) then "get_String(lwa, __prefix__+\""+name+"\")" }. public define String @@ -139,11 +139,11 @@ public define String date_field(_) then "db_date(text"+cursor_index+")", time_field(_) then "db_time(text"+cursor_index+")", datetime_field(_) then "db_datetime(text"+cursor_index+")", - foreign_key(_,_) then "(Int)db_integer"+cursor_index, + foreign_key(_,_) then "db_id((Int)db_integer"+cursor_index+")", integer_field(_) then "(Int)db_integer"+cursor_index, char_field(_,_) then "text"+cursor_index, password_field(_) then "text"+cursor_index, - text_field then "text"+cursor_index + text_field(_) then "text"+cursor_index }. public define String @@ -172,9 +172,9 @@ public define String else "" }, - foreign_key(_,_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", + foreign_key(_,_) then "bind_DB_id_or_NULL(\":v_"+name+"\", "+type_name+"."+name+")", integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", password_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", - text_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")" + text_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")" }. diff --git a/src/generation/html.anubis b/src/generation/html.anubis index 3d2465d..f2f3093 100644 --- a/src/generation/html.anubis +++ b/src/generation/html.anubis @@ -96,7 +96,7 @@ public define String integer_field(choices) then to_HTML_cell_text(column, data_name, general_type_name), char_field(choices, size) then to_HTML_cell_text(column, data_name, general_type_name), password_field(min_size) then to_HTML_cell_text(column, data_name, general_type_name), - text_field then to_HTML_cell_text(column, data_name, general_type_name), + text_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), } }. diff --git a/src/generation/icons.anubis b/src/generation/icons.anubis index f7d0dc5..97cdfd6 100644 --- a/src/generation/icons.anubis +++ b/src/generation/icons.anubis @@ -32,6 +32,6 @@ public define String integer_field(choice) then icn16_question, char_field(choice, size) then icn16_question, password_field(min_size) then icn16_question, - text_field then icn16_question + text_field(_) then icn16_question }. diff --git a/src/generation/types.anubis b/src/generation/types.anubis index 1ddb439..5e96d94 100644 --- a/src/generation/types.anubis +++ b/src/generation/types.anubis @@ -399,12 +399,17 @@ public define Maybe(One) " get_"+name+"_show_string\n"+ " (\n"+ " SQLite3DataBase db,\n"+ - " Int idx\n"+ + " DB_id _idx\n"+ " )=\n"+ - " if get_"+name+"(db, idx) is\n"+ + " if _idx is \n"+ " {\n"+ - " failure then default_select,\n"+ - " success(obj) then "+show_string+"\n"+ + " none then default_select,\n"+ + " db_id(idx) then \n"+ + " if get_"+name+"(db, idx) is\n"+ + " {\n"+ + " failure then default_select,\n"+ + " success(obj) then "+show_string+"\n"+ + " }\n"+ " }." ) is //end of the function { @@ -434,12 +439,12 @@ public define Maybe(One) " )=\n"+ " if list is\n"+ " {\n"+ - " [] then reverse(so_far),\n"+ + " [] then [selector_default_entry . reverse(so_far)],\n"+ " [ h . t ] then \n"+ " if h.id is \n"+ " {\n"+ - " none then [],\n"+ - " db_id(id) then _get_selector_"+name+"(db, t, [([], wav(to_String(id)), get_"+name+"_show_string(db, id)) . so_far])\n"+ + " none then [selector_default_entry],\n"+ + " db_id(_id) then _get_selector_"+name+"(db, t, [([], wav(to_String(_id)), get_"+name+"_show_string(db, h.id)) . so_far])\n"+ " }\n"+ " }.\n\n"+ "public define List((List(CoreAttrs), WebArgValue, String))\n"+ diff --git a/src/model.3.0.0.anubis b/src/model.3.0.0.anubis index 0edb70b..82cb6f3 100644 --- a/src/model.3.0.0.anubis +++ b/src/model.3.0.0.anubis @@ -270,7 +270,7 @@ public define HK_Table production_power_supply_table = hk_column("status", char_field(10), []), // hk_column("date_created", datetime_field(auto_now_add), []), hk_column("last_modified", datetime_field(auto_now), []), - hk_column("comments", text_field, []) // whatever the user wants to keep + hk_column("comments", text_field(rich_editor), []) // whatever the user wants to keep ], "obj.serial" ), -- libgit2 0.21.4