From 20d4ed207e52b9e144580a8c76693925f529006b Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 23 Jul 2017 22:45:04 +0200 Subject: [PATCH] add table constraint on model definition add mobile and url field --- calexium_lib | 2 +- ds_files/20170524-graphviz.pdf | Bin 0 -> 34608 bytes ds_files/graphviz.pdf | Bin 0 -> 35152 bytes hayamiki_generator.aproj | 3 +++ hayamiki_lib | 2 +- src/check.anubis | 4 ++-- src/generation/SQL_get_all.anubis | 4 ++-- src/generation/SQL_get_count.anubis | 2 +- src/generation/choices_selector.anubis | 2 +- src/generation/columns.anubis | 16 +++++++++++----- src/generation/create_table.anubis | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------ src/generation/densaku.anubis | 2 +- src/generation/edit_view_list_form.anubis | 2 +- src/generation/edit_view_table_form.anubis | 2 +- src/generation/extractor.anubis | 9 ++++++--- src/generation/fields.anubis | 34 +++++++++++++++++++++++----------- src/generation/files.anubis | 11 +++++++---- src/generation/fn_delete.anubis | 2 +- src/generation/html.anubis | 4 +++- src/generation/icons.anubis | 2 ++ src/generation/json.anubis | 6 ++++++ src/generation/types.anubis | 18 +++++++++--------- src/generation/vt_edit.anubis | 4 ++-- src/generation/vt_view.anubis | 6 ++++-- src/generation/web_args.anubis | 12 ++++++++++-- 25 files changed, 193 insertions(+), 87 deletions(-) create mode 100644 ds_files/20170524-graphviz.pdf create mode 100644 ds_files/graphviz.pdf diff --git a/calexium_lib b/calexium_lib index 07f1bbc..b3254dc 160000 --- a/calexium_lib +++ b/calexium_lib @@ -1 +1 @@ -Subproject commit 07f1bbce4bbd814d97625f59577e98fc4f8eceea +Subproject commit b3254dcbe8651bb63cc91b71934155fd560bf621 diff --git a/ds_files/20170524-graphviz.pdf b/ds_files/20170524-graphviz.pdf new file mode 100644 index 0000000..5f6493d Binary files /dev/null and b/ds_files/20170524-graphviz.pdf differ diff --git a/ds_files/graphviz.pdf b/ds_files/graphviz.pdf new file mode 100644 index 0000000..0c9acec Binary files /dev/null and b/ds_files/graphviz.pdf differ diff --git a/hayamiki_generator.aproj b/hayamiki_generator.aproj index 027b378..c2f041b 100644 --- a/hayamiki_generator.aproj +++ b/hayamiki_generator.aproj @@ -37,6 +37,7 @@ + @@ -68,6 +69,7 @@ + @@ -712,6 +714,7 @@ + diff --git a/hayamiki_lib b/hayamiki_lib index 57345f2..c0af45f 160000 --- a/hayamiki_lib +++ b/hayamiki_lib @@ -1 +1 @@ -Subproject commit 57345f2acee9ffeb19673b957d0aeb7296dfb742 +Subproject commit c0af45f7cc7c251cbac2837e95cdb7bea2379d95 diff --git a/src/check.anubis b/src/check.anubis index ec1f4a0..a5d2a96 100644 --- a/src/check.anubis +++ b/src/check.anubis @@ -164,7 +164,7 @@ define Maybe(List(HK_Table)) [] then success(reverse(so_far)), [h . t] then since h is hk_table(name, short_name, model, display), - since model is hk_model(columns, display_string), + since model is hk_model(columns, constraints, display_string), with table_name = if length(app_name) > 0 then app_name +"_"+name else name, if resolve_foreign(apps_name, app_name, table_name, columns, []) is { @@ -175,7 +175,7 @@ define Maybe(List(HK_Table)) { failure then failure, success(checked_list_edits) then - resolve_foreign(apps_name, app_name, t, [hk_table(table_name, name, hk_model(checked_model, display_string), hk_display(list_views, checked_list_edits)) . so_far]) + resolve_foreign(apps_name, app_name, t, [hk_table(table_name, name, hk_model(checked_model, constraints, display_string), hk_display(list_views, checked_list_edits)) . so_far]) } } diff --git a/src/generation/SQL_get_all.anubis b/src/generation/SQL_get_all.anubis index aafe99a..a792999 100644 --- a/src/generation/SQL_get_all.anubis +++ b/src/generation/SQL_get_all.anubis @@ -17,7 +17,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, _), + since model is hk_model(columns, constraints, _), 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 @@ -74,7 +74,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, _), + since model is hk_model(columns, constraints, _), 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 diff --git a/src/generation/SQL_get_count.anubis b/src/generation/SQL_get_count.anubis index ebfa344..1cf8b7b 100644 --- a/src/generation/SQL_get_count.anubis +++ b/src/generation/SQL_get_count.anubis @@ -19,7 +19,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, _), + since model is hk_model(columns, constraints, _), 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 diff --git a/src/generation/choices_selector.anubis b/src/generation/choices_selector.anubis index 7272ce8..cf44069 100644 --- a/src/generation/choices_selector.anubis +++ b/src/generation/choices_selector.anubis @@ -80,7 +80,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(table_name, short_name, model, _), - since model is hk_model( columns, show_string), + since model is hk_model( columns, constraints, show_string), map_forget((HK_Model_Column column) |-> since column is hk_column(column_name, field_type, _, _), diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis index acf6887..46b185a 100644 --- a/src/generation/columns.anubis +++ b/src/generation/columns.anubis @@ -109,8 +109,8 @@ public define List(String) { [] then reverse(so_far), [h . t ] then - since h is hk_column(name, col_type, _, _), - with result = to_Bind(col_type, type_name, name, insert), + since h is hk_column(name, col_type, attributes, _), + with result = to_Bind(col_type, attributes, type_name, name, insert), //we eliminate the empty string because during the join it will have an empty line if result = "" then to_Bind_list(t, type_name, so_far, insert) @@ -164,6 +164,8 @@ public define Maybe(String) text_field(_) then success(name), color_field then success(name), phone_field then success(name), + mobile_field then success(name), + url_field then success(name), email_field then success(name) }. @@ -287,6 +289,8 @@ public define Maybe(String) text_field(txt_attr) then success("text_area(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(txt_attr)+", "+to_Anubis_source(help)+")"), color_field then success("color(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"), phone_field then success("phone(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"), + mobile_field then success("mobile_phone(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"), + url_field then success("url(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"), email_field then success("email(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"), }. @@ -336,9 +340,11 @@ public define String float_field then "float_to_string("+current_type_name+"."+name+",5)", char_field(_,_) then current_type_name+"."+name, password_field(_) then current_type_name+"."+name, - text_field(_) then current_type_name+"."+name - color_field then current_type_name+"."+name - phone_field then current_type_name+"."+name + text_field(_) then current_type_name+"."+name, + color_field then current_type_name+"."+name, + phone_field then current_type_name+"."+name, + mobile_field then current_type_name+"."+name, + url_field then current_type_name+"."+name, email_field then current_type_name+"."+name }. diff --git a/src/generation/create_table.anubis b/src/generation/create_table.anubis index 090d47b..c1f7bf5 100644 --- a/src/generation/create_table.anubis +++ b/src/generation/create_table.anubis @@ -65,12 +65,50 @@ define String . define String + to_String + ( + HK_On_Conflict on_conflict + )= + if on_conflict is + { + rollback then "ROLLBACK", + abort then "ABORT", + fail then "FAIL", + ignore then "IGNORE", + replace then "REPLACE" + } +. + +define String + create_table_generate_one_constraint + ( + HK_Constraint constraint, + String indent + )= + since constraint is unique(_name, columns, _on_conflict), + with name = if _name = "" then "" else "CONSTRAINT "+_name+" ", + indent+name+"UNIQUE ("+ + indent+indent+join(",\n"+indent+indent, columns)+"\n"+ + indent+")"+ + indent+"ON CONFLICT "+to_String(_on_conflict) +. + +define String + create_table_generate_constraints + ( + List(HK_Constraint) constraints, + String indent + )= + join(",\n"+indent, map((HK_Constraint constraint) |-> create_table_generate_one_constraint(constraint, indent), constraints)) +. + +define String create_table_generate_one_table ( HK_Table table )= since table is hk_table(name, short_name, model, display), - since model is hk_model( columns, _), + since model is hk_model( columns, constraints, _), "\n"+ " // "+to_upper(name)+"\n"+ @@ -78,6 +116,7 @@ define String "\"CREATE TABLE "+name+" (\n"+ //columns " "+create_table_generate_columns([hk_column("id",p_key) . columns], " ")+ + create_table_generate_constraints(constraints, " ")+ "\n)\".\n" . @@ -124,23 +163,24 @@ define String public define Maybe(One) generate_create_table ( - List(HK_App) apps, //list of the table model description - String dest_dir + List(HK_App) apps, //list of the table model description + String dest_dir, + String version, + String _sha1 )= - //TODO manage version - with version = "1.0.0.0", - version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language + + with version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis", - with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_scripts.anubis", - + with create_file_name = dest_dir+"database/generated/migration/to_"+version+"_create.anubis", + //with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_SQL.anubis", //create all necessary directories if doesn't exist. make_directories(file_name); //create script file name as new file. Previous file with same name will be erased - if file(script_file_name, new) is + if file(create_file_name, new) is { - failure then println("Can't create script "+script_file_name);failure, + failure then println("Can't create script "+create_file_name);failure, success(fd_script) then with script_stream = make_stream(fd_script), //write into script file the generated create table @@ -150,6 +190,10 @@ public define Maybe(One) * Date: "+_Int_to_ISO_8601_date(now)+" * Time: "+_Int_to_ISO_8601_time(now)+" */ + +read system/logger.anubis +read calexium_lib/net_services_protocols/logger_service.anubis +read calexium_lib/database/migration_common_sqlite3.anubis read data_base/sqlite_foreign_key.anubis read data_base/db_types.anubis\n"+ //call the generation of all tables @@ -158,12 +202,40 @@ read data_base/db_types.anubis\n"+ "\npublic define List(String) db_indexes = [].\n"+ "// ///////////////////////////////\n"+ "// Foreign keys \n"+ - "public define List((String, String, String, String, FK_Null, FK_Cascade)) db_relations = [].\n" + "public define List((String, String, String, String, FK_Null, FK_Cascade)) db_relations = [].\n\n\n +define String _version = \""+version+"\". + +public define Maybe(One) + create_v"+version_str+"_tables + ( + SQLite3DataBase db, + Logger logger_debug + )= + if drop_all_triggers(db, logger_debug) is failure then failure else + + with tables = (List(DbTable)) [ +"+generate_all_tables_list(apps, " ")+" + ], + if create_tables(db, logger_debug, tables, _version) is + { + failure then failure, + success(_) then + if make_foreign_keys(db, logger_debug, db_relations, _version) is failure then failure else + success(unique) + } +. + +public define DB_Version db_model_version = db_version(\""+version+"\", \""+_sha1+"\"). +\n\n" + ) is { - failure then println ("Can't generate script "+script_file_name);failure, + failure then println ("Can't generate script "+create_file_name);failure, success(_) then //create file with create table management (alter_table, etc...) + if file_exists(file_name) then + success(println("Skip creation of "+file_name+" because it's already exists and preventing to erase custom migration stuff")) + else if file(file_name, new) is { failure then println("can't create file "+file_name);failure, @@ -183,6 +255,7 @@ read data_base/db_tools.anubis read calexium_lib/database/db_utils.anubis read calexium_lib/database/migration_common_sqlite3.anubis +read calexium_lib/database/migration_sqlite3.anubis read calexium_lib/net_services_protocols/logger_service.anubis read data_base/alter_table.anubis @@ -190,28 +263,9 @@ read types/app_types.anubis read app/app_constants.anubis read app/app_loggers.anubis -read database/generated/migration/to_"+version+"_scripts.anubis +read database/generated/migration/to_"+version+"_create.anubis define String _version = \""+version+"\". - -public define Maybe(One) - create_v"+version_str+"_tables - ( - SQLite3DataBase db, - Logger logger_debug - )= - if drop_all_triggers(db, logger_debug) is failure then failure else - - with tables = (List(DbTable)) [ -"+generate_all_tables_list(apps, " ")+" - ], - if create_tables(db, logger_debug, tables, _version) is - { - failure then failure, - success(_) then - if make_foreign_keys(db, logger_debug, db_relations, _version) is failure then failure else - success(unique) - }. public define Maybe(One) create_v"+version_str+"_indexes @@ -243,12 +297,17 @@ public define Maybe(One) SQLite3DataBase db, Logger logger, )= - if to_v"+version_str+"_pre(db, logger) is failure then failure + if to_v"+version_str+"_pre(db, logger) is failure then failure else if create_v"+version_str+"_tables(db, logger) is failure then failure - else if to_v"+version_str+"_post(db, logger) is failure then failure - else create_v"+version_str+"_indexes(db, logger). + else if to_v"+version_str+"_post(db, logger) is failure then failure + else create_v"+version_str+"_indexes(db, logger) +. - +global define Migration + migration_to_v"+version_str+" + = + migration(db_model_version, migrate_to_v"+version_str+", create_v"+version_str+"_tables, create_v"+version_str+"_indexes) +. ") }}} . diff --git a/src/generation/densaku.anubis b/src/generation/densaku.anubis index 9472609..e110d60 100644 --- a/src/generation/densaku.anubis +++ b/src/generation/densaku.anubis @@ -37,7 +37,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, display), - since model is hk_model(columns, show_string), + since model is hk_model(columns, constraints, 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 HK_Table that contain all components diff --git a/src/generation/edit_view_list_form.anubis b/src/generation/edit_view_list_form.anubis index 8d2383a..1fc86b1 100644 --- a/src/generation/edit_view_list_form.anubis +++ b/src/generation/edit_view_list_form.anubis @@ -43,7 +43,7 @@ public define Maybe(One) List(HK_FK_View) l_fk_view //List of foreign key view to display )= since table is hk_table(table_name, short_name, model, display), - since model is hk_model( columns, _), + since model is hk_model( columns, constraints, _), with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type. if write_string(stream, diff --git a/src/generation/edit_view_table_form.anubis b/src/generation/edit_view_table_form.anubis index c10ee0b..9db8e1d 100644 --- a/src/generation/edit_view_table_form.anubis +++ b/src/generation/edit_view_table_form.anubis @@ -129,7 +129,7 @@ public define Maybe(One) HK_Editor_Table form_in_table //edit view to generate )= since table is hk_table(table_name, short_name, model, display), - since model is hk_model( columns, _), + since model is hk_model( columns, constraints, _), with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type. //generate the type of the table that contain all components diff --git a/src/generation/extractor.anubis b/src/generation/extractor.anubis index 4643740..ff275c5 100644 --- a/src/generation/extractor.anubis +++ b/src/generation/extractor.anubis @@ -33,6 +33,8 @@ public define String text_field(_) then "text"+cursor_index, color_field then "text"+cursor_index, phone_field then "text"+cursor_index, + mobile_field then "text"+cursor_index, + url_field then "text"+cursor_index, email_field then "text"+cursor_index }. @@ -73,7 +75,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, display), - since model is hk_model(columns, _), + since model is hk_model(columns, constraint, _), 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 @@ -168,7 +170,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, display), - since model is hk_model(columns, _), + since model is hk_model(columns, constraints, _), 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 @@ -204,8 +206,9 @@ public define Maybe(One) " json_object(\n"+ " map(((Int -> SQLite3Datum) -> JsonMember extractor) |-> extractor(cursor) , extractors)\n"+ " ))\n"+ - " }\n.\n"+ + " }\n.\n\n"+ +"public define String get_"+name+"_show_string(SQLite3DataBase db, DB_id _idx).\n\n"+ "define (Int -> SQLite3Datum) -> JsonMember\n"+ " get_extractor\n"+ " (\n"+ diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis index 4f6df6a..1c30394 100644 --- a/src/generation/fields.anubis +++ b/src/generation/fields.anubis @@ -38,6 +38,8 @@ public define String text_field(_) then "String", color_field then "String", phone_field then "String", + mobile_field then "String", + url_field then "String", email_field then "String" }. @@ -62,7 +64,9 @@ public define String password_field(_) then "string", text_field(_) then "string", color_field then "string", - phone_field then "string" + phone_field then "string", + mobile_field then "String", + url_field then "String", email_field then "string" }. @@ -95,6 +99,8 @@ public define String text_field(_) then fill("TEXT", 15) + format_attributes(attributes), color_field then fill("VARCHAR(8)",15)+ format_attributes(attributes), phone_field then fill("VARCHAR(20)", 15) + format_attributes(attributes), + mobile_field then fill("VARCHAR(20)", 15) + format_attributes(attributes), + url_field then fill("VARCHAR(2048)", 15) + format_attributes(attributes), email_field then fill("VARCHAR(254)", 15) + format_attributes(attributes), }. @@ -120,7 +126,9 @@ public define String text_field(_) then "\"\"", color_field then "\"#DDD\"", phone_field then "\"\"", - email_field then "\"\"" + mobile_field then "\"\"", + url_field then "\"\"", + email_field then "\"\"" }. @@ -130,11 +138,13 @@ public define String public define String to_Bind ( - HK_Model_Field t, - String type_name, //name of the type - String name, //name of component into the type - Bool insert //true if insert time else false for update + HK_Model_Field t, + List(HK_Model_Attr) attributes, + String type_name, //name of the type + String name, //name of component into the type + Bool insert //true if insert time else false for update ) = + with or_null = if not_null:attributes then "" else "_or_NULL", //check if not_null is member of the list of column's attributes if t is { //anubis(_T) then "constant_byte_array(0,0)", @@ -156,10 +166,12 @@ public define String foreign_key(_,_,_) then "bind_DB_id_or_NULL(\":v_"+name+"\", "+type_name+"."+name+")", integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", float_field then "bind_Float(\":v_"+name+"\", "+type_name+"."+name+")", - char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", + char_field(_,_) then "bind_String"+or_null+"(\":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+")", - color_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", - phone_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", - email_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", + text_field(_) then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")", + color_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")", + phone_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")", + mobile_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")", + url_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")", + email_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")", }. diff --git a/src/generation/files.anubis b/src/generation/files.anubis index f26b007..e1f92e8 100644 --- a/src/generation/files.anubis +++ b/src/generation/files.anubis @@ -41,10 +41,10 @@ define Maybe(One) ) = since org_table is hk_table(name, short_name, old_model, display), - since old_model is hk_model(columns, show_string), + since old_model is hk_model(columns, constraints, show_string), since display is hk_display(list_view, list_edit), - with model = hk_model([hk_column("id", p_key, []). columns], show_string ), + with model = hk_model([hk_column("id", p_key, []). columns], constraints, show_string ), with table = hk_table(name, short_name, model, display), println("Generating file for table ["+name+"]"); with file_name = dest_dir+"database/generated/"+name+".anubis", @@ -221,7 +221,7 @@ define One //view interface //selector get_selector_"+name+", - hk_trigger_set(var([]), var([])) //initialize the triggers list as empty + hk_trigger_set(var([]), var([]), var([]), var([]), var([]), var([])) //initialize the triggers list as empty )", _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [controller . so_far_controllers], dest_dir) @@ -256,6 +256,7 @@ define Maybe(One) with ini = loadIniFile(destination_dir+"/hayamiki.ini"), with db_SHA1 = readString(ini, "DB_MODEL", "SHA1", "N/A"), + with version = readString(ini, "DB_MODEL", "Version", "0.0.0.0"), println("Saved DB model SHA1 = "+db_SHA1); with current_db_SHA1 = to_ascii(sha1(serialize(db))), println("Current DB model SHA1 = "+current_db_SHA1); @@ -272,12 +273,14 @@ define Maybe(One) println("Generating VTM for Database "+name); make_vtm(apps, destination_dir); println("Generating create for Database "+name); - if generate_create_table(apps, destination_dir) is failure then println("failure");failure else + if generate_create_table(apps, destination_dir, version, current_db_SHA1) is failure then println("failure");failure else println("Generating menu for Database "+name); if generate_hk_menus(apps, destination_dir) is failure then println("failure");failure else if generate_cxm_lib_menus(apps, destination_dir) is failure then println("failure");failure else writeString(ini, "DB_MODEL", "SHA1", current_db_SHA1); + writeString(ini, "DB_MODEL", "Version", version); writeIniInfo(ini); + sleep(3000); success(unique) }. diff --git a/src/generation/fn_delete.anubis b/src/generation/fn_delete.anubis index ca80148..0b431d5 100644 --- a/src/generation/fn_delete.anubis +++ b/src/generation/fn_delete.anubis @@ -21,7 +21,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model( columns, _), + since model is hk_model( columns, constraints, _), 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 diff --git a/src/generation/html.anubis b/src/generation/html.anubis index aa94f99..3f248b7 100644 --- a/src/generation/html.anubis +++ b/src/generation/html.anubis @@ -108,6 +108,8 @@ public define String text_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), color_field then to_HTML_cell_text(column, data_name, general_type_name), phone_field then to_HTML_cell_text(column, data_name, general_type_name), + mobile_field then to_HTML_cell_text(column, data_name, general_type_name), + url_field then to_HTML_cell_text(column, data_name, general_type_name), email_field then to_HTML_cell_text(column, data_name, general_type_name) } }. @@ -121,7 +123,7 @@ public define String HK_Viewer list_view //list view to generate )= since table is hk_table(table_name, short, model, _), //get name and model of the table - since model is hk_model( columns, _), //get all columns of table + since model is hk_model( columns, _, _), //get all columns of table // since display is db_display(views, _), // with current_list_column = if list_view is { diff --git a/src/generation/icons.anubis b/src/generation/icons.anubis index dc7be08..66bc44d 100644 --- a/src/generation/icons.anubis +++ b/src/generation/icons.anubis @@ -36,6 +36,8 @@ public define String text_field(_) then icn16_question, color_field then icn16_question, phone_field then icn16_phone, + mobile_field then icn16_question, + url_field then icn16_question, email_field then icn16_email }. diff --git a/src/generation/json.anubis b/src/generation/json.anubis index c5a6748..5896bd3 100644 --- a/src/generation/json.anubis +++ b/src/generation/json.anubis @@ -36,6 +36,8 @@ public define String text_field(_) then "to_JSON_String("+current_type_name+"."+name+")", color_field then "to_JSON_String("+current_type_name+"."+name+")", phone_field then "to_JSON_String("+current_type_name+"."+name+")", + mobile_field then "to_JSON_String("+current_type_name+"."+name+")", + url_field then "to_JSON_String("+current_type_name+"."+name+")", email_field then "to_JSON_String("+current_type_name+"."+name+")", } . @@ -68,6 +70,8 @@ public define String text_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", color_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", phone_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", + mobile_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", + url_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", email_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", } . @@ -100,6 +104,8 @@ public define String text_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", color_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", phone_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", + mobile_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", + url_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", email_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))" } . diff --git a/src/generation/types.anubis b/src/generation/types.anubis index 9f0705a..e40da37 100644 --- a/src/generation/types.anubis +++ b/src/generation/types.anubis @@ -38,7 +38,7 @@ public define Maybe(One) Bool use_densaku )= since table is hk_table(name, short_name, model, display), - since model is hk_model(columns, show_string), + since model is hk_model(columns, constraints, show_string), with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. //if we use densaku for generating the type, we insert the read of that type after densaku generation @@ -83,7 +83,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, show_string), + since model is hk_model(columns, constraints, 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 @@ -104,7 +104,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, show_string), + since model is hk_model(columns, constraints, 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 @@ -127,7 +127,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, show_string), + since model is hk_model(columns, constraints, 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 @@ -205,7 +205,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, show_string), + since model is hk_model(columns, constraints, 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 @@ -259,7 +259,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, show_string), + since model is hk_model(columns, constraints, 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 @@ -290,7 +290,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model( columns, _), + since model is hk_model( columns, constraints, _), 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 @@ -399,7 +399,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model( columns, show_string), + since model is hk_model( columns, constraints, 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 @@ -435,7 +435,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model( columns, show_string), + since model is hk_model( columns, constraints, 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 diff --git a/src/generation/vt_edit.anubis b/src/generation/vt_edit.anubis index 280f994..d82fd6b 100644 --- a/src/generation/vt_edit.anubis +++ b/src/generation/vt_edit.anubis @@ -29,7 +29,7 @@ public define Maybe(One) HK_Editor edit_view //edit view to generate )= since table is hk_table(table_name, short_name, model, display), - since model is hk_model( columns, _), + since model is hk_model( columns, constraints, _), //since display is db_display(list_view, list_edit), with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type. @@ -170,7 +170,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, display), - since model is hk_model( columns, _), + since model is hk_model( columns, constraints, _), since display is hk_display(_, list_edit), with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. diff --git a/src/generation/vt_view.anubis b/src/generation/vt_view.anubis index c19f1a1..70e3f8b 100644 --- a/src/generation/vt_view.anubis +++ b/src/generation/vt_view.anubis @@ -79,6 +79,8 @@ define String text_field(txt_attr) then "text_area(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", color_field then "color(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", phone_field then "phone(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", + mobile_field then "mobile_phone(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", + url_field then "url(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", email_field then "email(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" }. @@ -113,7 +115,7 @@ public define Maybe(One) HK_Viewer list_view //list view to generate )= since table is hk_table(table_name, short_name, model, display), - since model is hk_model( columns, _), + since model is hk_model( columns, constraints, _), //since display is db_display(list_view, list_edit), with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type. @@ -351,7 +353,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, display), - since model is hk_model( columns, _), + since model is hk_model( columns, constraints, _), since display is hk_display(list_view, list_edit), with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. diff --git a/src/generation/web_args.anubis b/src/generation/web_args.anubis index 54f25eb..ec7578a 100644 --- a/src/generation/web_args.anubis +++ b/src/generation/web_args.anubis @@ -34,6 +34,8 @@ public define String text_field(_) then "get_String(lwa, __prefix__+\""+name+"\")", color_field then "get_String(lwa, __prefix__+\""+name+"\")", phone_field then "get_String(lwa, __prefix__+\""+name+"\")", + mobile_field then "get_String(lwa, __prefix__+\""+name+"\")", + url_field then "get_String(lwa, __prefix__+\""+name+"\")", email_field then "get_String(lwa, __prefix__+\""+name+"\")" }. @@ -87,6 +89,8 @@ public define String text_field(_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", color_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", phone_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", + mobile_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", + url_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", email_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+")," }. @@ -120,7 +124,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, _), + since model is hk_model(columns, constraint, _), with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. since _generate_extract_web_arg_to_type(columns, [], 0) is ((List(String))list_of_web_arg, (Int) nb_closure), //generate the type of the table that contain all components @@ -215,6 +219,10 @@ public define String "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }" phone_field then "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }" + mobile_field then + "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }" + url_field then + "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }" email_field then "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }" }. @@ -245,7 +253,7 @@ public define Maybe(One) HK_Table table )= since table is hk_table(name, short_name, model, _), - since model is hk_model(columns, _), + since model is hk_model(columns, constraints, _), 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 -- libgit2 0.21.4