From 93a3526ea45236af912bf543ed37ea1c136993ab Mon Sep 17 00:00:00 2001 From: totoro Date: Tue, 2 May 2017 10:47:40 +0900 Subject: [PATCH] add phone and email field generation --- calexium_lib | 2 +- hayamiki_lib | 2 +- src/generation/columns.anubis | 8 +++++++- src/generation/extractor.anubis | 4 +++- src/generation/fields.anubis | 16 +++++++++++++--- src/generation/html.anubis | 4 +++- src/generation/icons.anubis | 4 +++- src/generation/json.anubis | 12 +++++++++--- src/generation/vt_view.anubis | 5 ++++- src/generation/web_args.anubis | 7 ++++++- src/model.3.0.0.anubis | 16 ++++++++-------- 11 files changed, 58 insertions(+), 22 deletions(-) diff --git a/calexium_lib b/calexium_lib index 45e29b3..3a2758b 160000 --- a/calexium_lib +++ b/calexium_lib @@ -1 +1 @@ -Subproject commit 45e29b302fac0def4330ce9654cfa2cecd9e69f2 +Subproject commit 3a2758b69ccb9499f35eec40cc72b2cae14998fc diff --git a/hayamiki_lib b/hayamiki_lib index 95c6d50..5ef0dd2 160000 --- a/hayamiki_lib +++ b/hayamiki_lib @@ -1 +1 @@ -Subproject commit 95c6d5064c6062446d1d22c6b4cc3ad5a93f4df5 +Subproject commit 5ef0dd2a124781ed0bec0c17b95f4a4d78ec7822 diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis index 751017e..8c34789 100644 --- a/src/generation/columns.anubis +++ b/src/generation/columns.anubis @@ -153,6 +153,8 @@ public define Maybe(String) password_field(_) then success(name), text_field(_) then success(name), color_field then success(name), + phone_field then success(name), + email_field then success(name) }. public define List(String) @@ -270,6 +272,8 @@ public define Maybe(String) password_field(min_size) then success("password(\""+to_upper(col_name)+"\", \""+col_name+"\", "+to_Anubis_source(help)+")") 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)+")"), + email_field then success("email(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"), }. public define String @@ -319,7 +323,9 @@ public define String 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 + color_field then current_type_name+"."+name + phone_field then current_type_name+"."+name + email_field then current_type_name+"."+name }. diff --git a/src/generation/extractor.anubis b/src/generation/extractor.anubis index fe24b22..bcdbbba 100644 --- a/src/generation/extractor.anubis +++ b/src/generation/extractor.anubis @@ -31,7 +31,9 @@ public define String char_field(_,_) then "text"+cursor_index, password_field(_) then "text"+cursor_index, text_field(_) then "text"+cursor_index, - color_field then "text"+cursor_index + color_field then "text"+cursor_index, + phone_field then "text"+cursor_index, + email_field then "text"+cursor_index }. define List(String) diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis index a3de5b8..dde1e1d 100644 --- a/src/generation/fields.anubis +++ b/src/generation/fields.anubis @@ -37,6 +37,8 @@ public define String password_field(_) then "String", text_field(_) then "String", color_field then "String", + phone_field then "String", + email_field then "String" }. public define String @@ -59,7 +61,9 @@ public define String char_field(_,_) then "string", password_field(_) then "string", text_field(_) then "string", - color_field then "string" + color_field then "string", + phone_field then "string" + email_field then "string" }. public define String @@ -83,7 +87,9 @@ public define String password_field(size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), 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), + email_field then fill("VARCHAR(254)", 15) + format_attributes(attributes), +}. public define String to_Anubis_default @@ -106,6 +112,8 @@ public define String password_field(min_size) then "\"\"", text_field(_) then "\"\"", color_field then "\"#DDD\"", + phone_field then "\"\"", + email_field then "\"\"" }. @@ -144,5 +152,7 @@ public define String 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+")", - color_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+")", }. diff --git a/src/generation/html.anubis b/src/generation/html.anubis index 415ea26..af35604 100644 --- a/src/generation/html.anubis +++ b/src/generation/html.anubis @@ -102,7 +102,9 @@ public define String "text(\"********\")", //to_HTML_cell_text(column, data_name, general_type_name), 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), + 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), + email_field then to_HTML_cell_text(column, data_name, general_type_name) } }. diff --git a/src/generation/icons.anubis b/src/generation/icons.anubis index 89c3190..65f7ec3 100644 --- a/src/generation/icons.anubis +++ b/src/generation/icons.anubis @@ -34,6 +34,8 @@ public define String char_field(choice, size) then icn16_question, password_field(min_size) then icn16_question, text_field(_) then icn16_question, - color_field then icn16_question + color_field then icn16_question, + phone_field then icn16_phone, + email_field then icn16_email }. diff --git a/src/generation/json.anubis b/src/generation/json.anubis index a8fd335..b692835 100644 --- a/src/generation/json.anubis +++ b/src/generation/json.anubis @@ -35,6 +35,8 @@ public define String password_field(_) then "to_JSON_String("+current_type_name+"."+name+")", 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+")", + email_field then "to_JSON_String("+current_type_name+"."+name+")", } . @@ -64,7 +66,9 @@ public define String char_field(_,_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", password_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", text_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", - color_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+"))", + email_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", } . @@ -89,7 +93,9 @@ public define String float_field then "json_member(\""+name+"\", json_float(db_float"+cursor_index+",5))", char_field(_,_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", password_field(_) then "json_member(\""+name+"\", json_string(\"******\"))", - text_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))" - color_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))" + 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+"))", + email_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))" } . diff --git a/src/generation/vt_view.anubis b/src/generation/vt_view.anubis index af1d696..0d2f4b4 100644 --- a/src/generation/vt_view.anubis +++ b/src/generation/vt_view.anubis @@ -76,7 +76,10 @@ define String } password_field(min_size) then "password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", 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)+")" + color_field then "color(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", + phone_field then "phone(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", + email_field then "email(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" + }. diff --git a/src/generation/web_args.anubis b/src/generation/web_args.anubis index 1dc523a..5263550 100644 --- a/src/generation/web_args.anubis +++ b/src/generation/web_args.anubis @@ -32,6 +32,8 @@ public define String password_field(min_size) then "get_Password(lwa, __prefix__+\""+name+"_1\", __prefix__+\""+name+"_2\")", text_field(_) then "get_String(lwa, __prefix__+\""+name+"\")", color_field then "get_String(lwa, __prefix__+\""+name+"\")", + phone_field then "get_String(lwa, __prefix__+\""+name+"\")", + email_field then "get_String(lwa, __prefix__+\""+name+"\")" }. define (List(String), Int) @@ -143,7 +145,10 @@ public define String "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }", color_field then "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }" - //"get_String(lwa, __prefix__+\""+name+"\")" + phone_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+"))] }" }. define String diff --git a/src/model.3.0.0.anubis b/src/model.3.0.0.anubis index 21337a8..1e8f855 100644 --- a/src/model.3.0.0.anubis +++ b/src/model.3.0.0.anubis @@ -509,11 +509,11 @@ public define HK_Table production_supplier_table = hk_column("zipcode", char_field(10), []), hk_column("city", char_field(50), []), hk_column("country", char_field(50), []), - hk_column("email", char_field(75), []), + hk_column("email", email_field, []), hk_column("url", char_field(200), []), - hk_column("phone", char_field(20), []), + hk_column("phone", phone_field, []), hk_column("fax", char_field(20), []), - hk_column("mobile", char_field(20), []), + hk_column("mobile", phone_field, []), hk_column("siret", char_field(50), []), hk_column("tva_number", char_field(50), []), hk_column("date_created", datetime_field(auto_now_add), []), @@ -597,7 +597,7 @@ public define HK_Table staff_table = hk_column("contact_id", foreign_key(none, "address_book_contact"), []), hk_column("department_id", foreign_key("department"), []), hk_column("role_id", foreign_key("role"), []), - hk_column("email", char_field(75), []), + hk_column("email", email_field, []), hk_column("incoming_date", date_field(none), []), // hk_column("outgoing_date", date_field(none), [], help_text("if not still present in company. The date of official outgoing")), // hk_column("still_present", boolean_field, [], help_text("Still working for the company")), @@ -633,11 +633,11 @@ public define HK_Table address_book_contact_table = hk_column("zipcode", char_field(10), []), hk_column("city", char_field(50), []), hk_column("country", char_field(50), []), - hk_column("email", char_field(75), []), + hk_column("email", email_field, []), hk_column("url", char_field(200), []), - hk_column("phone", char_field(20), []), - hk_column("fax", char_field(20), []), - hk_column("mobile", char_field(20), []), + hk_column("phone", phone_field, []), + hk_column("fax", char_field(20), []), + hk_column("mobile", phone_field, []), 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 -- libgit2 0.21.4