diff --git a/calexium_lib b/calexium_lib index 605449b..891e24c 160000 --- a/calexium_lib +++ b/calexium_lib @@ -1 +1 @@ -Subproject commit 605449b023dcef3ea0b7261c1d7d120e000d006e +Subproject commit 891e24cfc2eca3152e2cf33c5963979d963b7bae diff --git a/densaku_lib b/densaku_lib index e7fa05a..aaa5024 160000 --- a/densaku_lib +++ b/densaku_lib @@ -1 +1 @@ -Subproject commit e7fa05a251e0fe746b9524e94b42b5093c4714bf +Subproject commit aaa50241ac140b5441e8cfb34bd4e884a4828af7 diff --git a/hayamiki_generator.aproj b/hayamiki_generator.aproj index 8631004..21dcce6 100644 --- a/hayamiki_generator.aproj +++ b/hayamiki_generator.aproj @@ -155,15 +155,7 @@ - - - - - - - - - + @@ -725,9 +717,8 @@ - - + diff --git a/hayamiki_lib b/hayamiki_lib index 4eeb47a..23eeeae 160000 --- a/hayamiki_lib +++ b/hayamiki_lib @@ -1 +1 @@ -Subproject commit 4eeb47a275bd6a512a15b2284c27d3408caaead5 +Subproject commit 23eeeae84177732211b508466d55b46abae6fb17 diff --git a/src/check.anubis b/src/check.anubis index ec9180f..a917156 100644 --- a/src/check.anubis +++ b/src/check.anubis @@ -10,7 +10,7 @@ read hayamiki_lib/types/hayamiki.anubis read system/string.anubis read tools/list.anubis read tools/basis.anubis -transmit hayamiki_lib/model/types/hk_edit_view.anubis +transmit hayamiki_lib/view/types/hk_edit_view.anubis public define Maybe(List(String)) get_all_apps_name @@ -120,13 +120,14 @@ define Maybe(HK_Edit_View) if _edit_view is { edit_view_all then success(edit_view_all), - edit_view(v, c, fk_views) then + edit_view_list_form(v, c, fk_views) then with mb_fk_views = map_escape((HK_FK_View _fk_view) |-> resolve_HK_FK_View_foreign(apps_name, app_name, _fk_view), fk_views), if mb_fk_views is { failure then failure, - success(n_fk_views) then success(edit_view(v, c, n_fk_views)) + success(n_fk_views) then success(edit_view_list_form(v, c, n_fk_views)) } + edit_view_table_form(v, t) then success(edit_view_table_form(v, t)) } . diff --git a/src/generation/SQL_get_all.anubis b/src/generation/SQL_get_all.anubis index 58cd695..0c0868d 100644 --- a/src/generation/SQL_get_all.anubis +++ b/src/generation/SQL_get_all.anubis @@ -114,9 +114,12 @@ public define Maybe(One) " get_all_"+name+"_by_clause_to_json\n"+ " (\n"+ " SQLite3DataBase db,\n"+ -" String clause\n"+ +" HK_Referer referer,\n"+ +" String filter\n"+ " )=\n"+ -" if get_all_"+name+"_by_clause(db, clause) is\n"+ +" with clause = referer_to_sql_clause(referer, \""+name+"\", "+name+"_columns),\n\n"+ +" //with _and_ = if length(clause) > 0 & length(filter) > 0 then \" AND \" else \"\",\n"+ +" if get_all_"+name+"_by_clause(db, clause+filter) is\n"+ " {\n"+ " failure then json_member(\"rows\", json_array([])),\n"+ " success(cursor) then json_member(\"rows\", json_array(_get_all_"+name+"_to_json(db, cursor, [])))\n"+ diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis index 69e1de6..8ff80cf 100644 --- a/src/generation/columns.anubis +++ b/src/generation/columns.anubis @@ -45,11 +45,12 @@ public define Maybe(List(HK_Model_Column)) define List(String) /* return the list of all columns name + * */ _to_List_String ( List(HK_Model_Column) columns, - Bool with_pk, + Bool with_pk, //if set, add the primary key named "id" List(String) so_far )= if columns is @@ -207,7 +208,7 @@ public define String public define Maybe(String) /** Here we generate the VT_Edit entry according to the model */ - get_VT_edit_entry + get_HK_Form_Entry ( HK_Model_Column col, String type_name @@ -237,7 +238,7 @@ public define Maybe(String) auto_now then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime, 18, "+to_Anubis_source(help)+")"), auto_now_add then success("information(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+".datetime, 18, "+to_Anubis_source(help)+")") }, - foreign_key(app,foreign_table) then success("foreign_text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", vt_edit_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")"), + foreign_key(app,foreign_table) then success("foreign_text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", hk_form_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")"), integer_field(choices) then @@ -248,7 +249,7 @@ public define Maybe(String) int_choices(choices_list) then //if choice list is NOT empty we construct the possible choices selector if length(choices_list) > 0 then - success("choices_int(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", vt_edit_selector(get_choices_selector_"+to_lower(type_name)+"_"+name+"), "+to_Anubis_source(help)+")") + success("choices_int(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", hk_form_selector(get_choices_selector_"+to_lower(type_name)+"_"+name+"), "+to_Anubis_source(help)+")") else success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), } @@ -262,7 +263,7 @@ public define Maybe(String) text_choices(choices_list) then //if choice list is NOT empty we construct the possible choices selector if length(choices_list) > 0 then - success("choices_text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", vt_edit_selector(get_choices_selector_"+to_lower(type_name)+"_"+name+"), "+to_Anubis_source(help)+")") + success("choices_text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", hk_form_selector(get_choices_selector_"+to_lower(type_name)+"_"+name+"), "+to_Anubis_source(help)+")") else success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") } @@ -283,7 +284,7 @@ public define String { [] then indent+" "+join(",\n"+indent+" ", reverse(so_far)), [h . t] then - if get_VT_edit_entry(h, type_name) is + if get_HK_Form_Entry(h, type_name) is { failure then edit_entries(t, type_name, indent, so_far) success(result) then edit_entries(t, type_name, indent, [result . so_far]) diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis index 4b546c5..a3de5b8 100644 --- a/src/generation/fields.anubis +++ b/src/generation/fields.anubis @@ -105,7 +105,7 @@ public define String char_field(choices,size) then "\"\"", password_field(min_size) then "\"\"", text_field(_) then "\"\"", - color_field then "#DDD", + color_field then "\"#DDD\"", }. diff --git a/src/generation/files.anubis b/src/generation/files.anubis index b0e75dd..35f26c0 100644 --- a/src/generation/files.anubis +++ b/src/generation/files.anubis @@ -61,6 +61,7 @@ define Maybe(One) if generate_densaku_type(table, dest_dir, use_densaku) is { failure then failure, success(_) then if generate_type(strm, table, use_densaku) is { failure then failure, success(_) then if generate_get_default(strm, table) is { failure then failure, success(_) then + if generate_columns_list(strm, table) is { failure then failure, success(_) then if generate_extract_web_arg_to_type(strm, table) is { failure then failure, success(_) then if generate_extract_web_arg_to_update_field(strm, table) is { failure then failure, success(_) then if generate_extract_db_cursor_to_mb_type(strm, table) is { failure then failure, success(_) then @@ -77,7 +78,7 @@ define Maybe(One) if generate_choices_selector(strm, table) is { failure then failure, success(_) then if generate_VT_all_view(strm, table) is { failure then failure, success(_) then if generate_VT_all_edit(strm, table) is { failure then failure, success(_) then - success(unique)}}}}}}}}}}}}}}}}}}}} + success(unique)}}}}}}}}}}}}}}}}}}}}} }. define One diff --git a/src/generation/header.anubis b/src/generation/header.anubis index e3a998f..bf761d9 100644 --- a/src/generation/header.anubis +++ b/src/generation/header.anubis @@ -62,9 +62,10 @@ read data_base/sqlite.anubis read data_base/db_tools.anubis read calexium_lib/database/db_utils.anubis read calexium_lib/database/db_types.anubis -read hayamiki_lib/view/view_table_types.anubis +read hayamiki_lib/view/types/hk_form.anubis +read hayamiki_lib/view/types/hk_view.anubis read hayamiki_lib/types/hayamiki.anubis - +read hayamiki_lib/controller/hk_sql_utils.anubis read system/logger.anubis read system/datetime.anubis read system/convert.anubis @@ -72,7 +73,6 @@ read system/string.anubis read calexium_lib/net_services_protocols/logger_service.anubis read app/app_loggers.anubis - ") is failure then failure else foreign_table_header(stream, columns) . diff --git a/src/generation/types.anubis b/src/generation/types.anubis index dda137a..8955ceb 100644 --- a/src/generation/types.anubis +++ b/src/generation/types.anubis @@ -75,6 +75,7 @@ define List(String) since h is hk_column(name, col_type, _, _), _generate_get_default(t, [ to_Anubis_default(col_type) . so_far]) }. + public define Maybe(One) generate_get_default ( @@ -89,13 +90,32 @@ public define Maybe(One) if write_string(stream, "\n\ndefine "+type_name+"\n get_default_"+name+" =\n "+name+"("+ //head of the definition join(", ",_generate_get_default(columns, []))+ //all components of the type - ").\n") is //end of the function + ").\n\n") is //end of the function { failure then println("can't write get_default "+type_name); failure, success(_) then success(unique) }. +public define Maybe(One) + generate_columns_list + ( + Stream stream, + HK_Table table + )= + since table is hk_table(name, short_name, model, _), + since model is hk_model(columns, show_string), + with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. + + //generate the type of the table that contain all components + if write_string(stream, + "\n\ndefine List(String)\n "+name+"_columns =\n ["+ //head of the definition + join(",\n ",enclose("\"", to_List_String(columns, false)))+ //all columns name wihtout id + " ].\n\n") is //end of the list + { + failure then println("can't write generate_columns_list "+type_name); failure, + success(_) then success(unique) + }. @@ -351,9 +371,12 @@ public define Maybe(One) " get_selector_"+name+"\n"+ " (\n"+ " SQLite3DataBase db,\n"+ - " String clause\n"+ + " HK_Referer referer,\n"+ + " String filter\n"+ " )=\n"+ - " _get_selector_"+name+"(db, get_all_"+name+"_by_clause_to_list_type(db, clause), [])." + " with clause = referer_to_sql_clause(referer, \""+name+"\", "+name+"_columns),\n\n"+ + " with _and_ = if length(clause) > 0 & length(filter) > 0 then \" AND \" else \"\",\n"+ + " _get_selector_"+name+"(db, get_all_"+name+"_by_clause_to_list_type(db, clause+_and_+filter), [])." ) is //end of the function { failure then println("can't write generate_show_string "+type_name); failure, diff --git a/src/generation/vt_edit.anubis b/src/generation/vt_edit.anubis index 17839e9..726ea3c 100644 --- a/src/generation/vt_edit.anubis +++ b/src/generation/vt_edit.anubis @@ -15,7 +15,7 @@ read columns.anubis read html.anubis define String - edit_tab_entries + hk_form_tab_entries ( List(HK_FK_View) fk_views, String indent @@ -24,7 +24,7 @@ define String map((HK_FK_View fk_view) |-> since fk_view is fk_view(app_name, fk_table_name, fk_col), - indent+" hk_v_edit_tab(\""+fk_table_name+"\", \""+fk_col+"\", \"default\")" + indent+" hk_form_tab(\""+fk_table_name+"\", \""+fk_col+"\", \"default\")" , fk_views) ) @@ -47,45 +47,48 @@ public define Maybe(One) with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type. with view_name = if edit_view is { - edit_view_all then "default", - edit_view(v_name, _, _) then v_name + edit_view_all then "default", + edit_view_list_form(v_name, _, _) then v_name, + edit_view_table_form(v_name, _) then v_name }, with current_edit_view = if edit_view is { edit_view_all then columns, - edit_view(v_name, cols, _) then + edit_view_list_form(v_name, cols, _) then if get_HK_Model_Column_list_from_name_list(columns, cols) is { failure then println("generate_VT_edit: can't get all specified columns for table \""+table_name+"\" view name \""+v_name+"\" cols["+join(", ",cols)+"]");[], success(got_columns) then got_columns, } + edit_view_table_form(_,_) then todo "handle case 'edit_view_table_form'" }, with current_fk_views = if edit_view is { - edit_view_all then [], - edit_view(_, _, lfk) then lfk + edit_view_all then [], + edit_view_list_form(_, _, lfk) then lfk, + edit_view_table_form(_,_) then [] }, //generate the type of the table that contain all components if write_string(stream, "\n\n"+ //SQL query - "define VT_edit\n"+ + "define HK_Form\n"+ " _get_editable_"+table_name+"_"+view_name+"\n"+ " (\n"+ " "+type_name+" "+table_name+",\n"+ " SQLite3DataBase db\n"+ " )=\n"+ - " with edit_entries = (List(VT_edit_entry))\n"+ + " with edit_entries = (List(HK_Form_Entry))\n"+ " [\n"+ " hidden(\"id\", to_String("+table_name+".id)),\n"+ edit_entries(current_edit_view, table_name, " ", [])+"\n"+ " ],\n"+ - " with fk_view_entries = (List(HK_V_Edit_Tab))\n"+ + " with fk_view_entries = (List(HK_Form_Tab))\n"+ " [\n"+ - edit_tab_entries(current_fk_views, " ")+"\n"+ + hk_form_tab_entries(current_fk_views, " ")+"\n"+ " ],\n"+ - " vt_edit(\""+table_name+"\", \""+view_name+"\", edit_entries, fk_view_entries).\n\n" + " hk_form_in_list(\""+table_name+"\", \""+view_name+"\", edit_entries, fk_view_entries).\n\n" ) is //end of the function { failure then println("can't write generate_VT_view "+type_name); failure, @@ -122,7 +125,10 @@ public define Maybe(One) if view is { edit_view_all then true, //list_view_all is default view - edit_view(view_name, _, _) then + edit_view_list_form(view_name, _, _) then + //if not we search for view named 'default' + if view_name = "default" then true else false + edit_view_table_form(view_name, _) then //if not we search for view named 'default' if view_name = "default" then true else false }, @@ -149,8 +155,9 @@ public define String [view . t] then with view_name = if view is { - edit_view_all then "default", - edit_view(view_name, _, _) then view_name + edit_view_all then "default", + edit_view_list_form(view_name, _, _) then view_name + edit_view_table_form(view_name, _) then view_name }, _generate_get_editable_if_else( table_name, t, so_far + @@ -172,11 +179,11 @@ public define Maybe(One) )= since table is hk_table(table_name, short_name, model, display), if write_string(stream, - "public define VT_edit\n"+ + "public define HK_Form\n"+ " get_editable_"+table_name+"\n"+ " (\n"+ " SQLite3DataBase db,\n"+ - " VT_action action,\n"+ + " HK_Form_action action,\n"+ " String editor_view\n"+ " )=\n"+ " with "+table_name+" = if action is\n"+ diff --git a/src/generation/vt_view.anubis b/src/generation/vt_view.anubis index df57812..b05587a 100644 --- a/src/generation/vt_view.anubis +++ b/src/generation/vt_view.anubis @@ -48,7 +48,7 @@ define String date_field(attrs) then "date(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", time_field(attrs) then "time(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", datetime_field(attrs) then "datetime(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", - foreign_key(app,foreign_table) then "foreign_text(\""+to_upper(name)+"\", \""+name+"\", vt_edit_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")", + foreign_key(app,foreign_table) then "foreign_text(\""+to_upper(name)+"\", \""+name+"\", hk_form_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")", integer_field(choices) then if choices is { @@ -56,7 +56,7 @@ define String int_choices(choices_list) then //if choice list is NOT empty we construct the possible choices selector if length(choices_list) > 0 then - "choices_int(\""+to_upper(name)+"\", \""+name+"\", vt_edit_selector(get_choices_selector_"+to_lower(type_name)+"_"+name+"), "+to_Anubis_source(help)+")" + "choices_int(\""+to_upper(name)+"\", \""+name+"\", hk_form_selector(get_choices_selector_"+to_lower(type_name)+"_"+name+"), "+to_Anubis_source(help)+")" else "integer(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", } @@ -70,7 +70,7 @@ define String text_choices(choices_list) then //if choice list is NOT empty we construct the possible choices selector if length(choices_list) > 0 then - "choices_text(\""+to_upper(name)+"\", \""+name+"\", vt_edit_selector(get_choices_selector_"+to_lower(type_name)+"_"+name+"), "+to_Anubis_source(help)+")" + "choices_text(\""+to_upper(name)+"\", \""+name+"\", hk_form_selector(get_choices_selector_"+to_lower(type_name)+"_"+name+"), "+to_Anubis_source(help)+")" else "text(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" } diff --git a/src/model.3.0.0.anubis b/src/model.3.0.0.anubis index c5f6b4c..3f9ebbd 100644 --- a/src/model.3.0.0.anubis +++ b/src/model.3.0.0.anubis @@ -103,7 +103,7 @@ public define HK_Table production_mass_storage_table = list_view("current",["model_id", "serial", "status", "date_created"]) ], //list_edit - [ edit_view("default", ["purchase_id", "model_id", "serial", "status", "comments"])] + [ edit_view_list_form("default", ["purchase_id", "model_id", "serial", "status", "comments"])] ) ). @@ -367,7 +367,7 @@ public define HK_Table production_products_table = list_view("default", ["production_id", "date", "serial", "motherboard_id", "app_id", "status"]) ], //list_edit - [ edit_view("default", [ "production_id", "produced", "date", "serial", "security_code", "motherboard_id", "storage_id", "memory_id", "power_supply_id", "wifi", "mac", + [ edit_view_list_form("default", [ "production_id", "produced", "date", "serial", "security_code", "motherboard_id", "storage_id", "memory_id", "power_supply_id", "wifi", "mac", "app_id", "os_version", "published", "publish_date", "status", "date_created", "last_modified", "comments"])] ) ). @@ -401,7 +401,7 @@ public define HK_Table production_production_table = list_view("default", ["date", "type_ref_id", "sticker_tpl_id", "product_ref_id", "site_id", "product_count", "produced_count"]) ], //list_edit - [ edit_view("default", [ "date", "assembler_id", "type_ref_id", "product_ref_id", "site_id", "serial_prefix_id", "sticker_tpl_id", "starting_index", "product_count", "produced_count", "completed", + [ edit_view_list_form("default", [ "date", "assembler_id", "type_ref_id", "product_ref_id", "site_id", "serial_prefix_id", "sticker_tpl_id", "starting_index", "product_count", "produced_count", "completed", "active", "date_created", "last_modified", "comments"])] ) ). @@ -493,7 +493,7 @@ public define HK_Table production_type_number_table = list_view("default", ["type_ref", "description"]) ], //list_edit - [ edit_view("default", ["type_ref", "description", "comments"])] + [ edit_view_list_form("default", ["type_ref", "description", "comments"])] ) ). @@ -528,7 +528,7 @@ public define HK_Table production_supplier_table = list_view("default", ["company", "phone", "mobile", "email"]) ], //list_edit - [ edit_view("default", ["company", "contact_id", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", + [ edit_view_list_form("default", ["company", "contact_id", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", "siret", "tva_number", "date_created", "last_modified", "comments"])] ) ). @@ -553,7 +553,7 @@ public define HK_Table department_table = list_view("default", ["name"]) ], //list_edit - [ edit_view("default", ["name", "description", "comments"])] + [ edit_view_list_form("default", ["name", "description", "comments"])] ) ). @@ -576,7 +576,16 @@ public define HK_Table role_table = list_view("default", ["role_name"]) ], //list_edit - [ edit_view("default", ["role_name", "description", "comments"])] + [ edit_view_list_form("default", ["role_name", "description", "comments"]), + edit_view_table_form("table", + table([ + line([label("role_name"), column("role_name")]), + line([empty, column("description")]), + line([label("comments"), column("comments")]), + line([label("date_created"),column("date_created"),label("last_modified"),column("last_modified")]) + ]) + ) + ] ) ). @@ -606,7 +615,7 @@ public define HK_Table staff_table = ], //list_edit - [ edit_view("default", ["contact_id", "department_id", "role_id", "email", "incoming_date", "outgoing_date", "still_present", "date_created", "last_modified", "comments"])] + [ edit_view_list_form("default", ["contact_id", "department_id", "role_id", "email", "incoming_date", "outgoing_date", "still_present", "date_created", "last_modified", "comments"])] ) ). @@ -643,7 +652,7 @@ public define HK_Table address_book_contact_table = list_view("details", ["first_name", "last_name", "company", "url", "role", "phone", "mobile", "email", "address1", "address2", "zipcode", "city", "country"]) ], //list_edit - [ edit_view("default", ["first_name", "last_name", "company", "role", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", "comments"])] + [ edit_view_list_form("default", ["first_name", "last_name", "company", "role", "address1", "address2", "zipcode", "city", "country", "email", "url", "phone", "fax", "mobile", "comments"])] ) ). -- libgit2 0.21.4