diff --git a/hayamiki_lib b/hayamiki_lib index f3cb0a1..c6605b5 160000 --- a/hayamiki_lib +++ b/hayamiki_lib @@ -1 +1 @@ -Subproject commit f3cb0a1f4255b7c9a03256ab1b5d4f424789d139 +Subproject commit c6605b532d8610d3bbbad66926aa149aa86e8f88 diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis index 5637c8c..42d395a 100644 --- a/src/generation/columns.anubis +++ b/src/generation/columns.anubis @@ -137,9 +137,9 @@ public define Maybe(String) auto_now_add then if insert then success(name) else failure }, - foreign_key(_,_) then success(name), - integer_field then success(name), - char_field(_,_) then success(name), + foreign_key(_,_) then success(name), + integer_field(_) then success(name), + char_field(_,_) then success(name), text_field then success(name) }. @@ -225,7 +225,19 @@ public define Maybe(String) 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)+")"), - integer_field then success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), + integer_field(choices) then + //success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), + if choices is + { + no_choice then success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), + 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)+")") + else + success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), + } + //TODO make choices selection if need char_field(choices,_) then if choices is @@ -290,9 +302,9 @@ public define String */ to_String ( - HK_Model_Column col, - String current_type_name, - String general_type_name + HK_Model_Column col, //Model of the column + String current_type_name, //Instance name of the type i.e. toto (this is instance of Toto_Type below) + String general_type_name //Type declaration name i.e. Toto_Type ) = since col is hk_column(name, col_type, _, _), if col_type is @@ -305,7 +317,7 @@ public define String time_field(attrs) then "to_String("+current_type_name+"."+name+")", datetime_field(attrs) then "to_String("+current_type_name+"."+name+")" foreign_key(app,foreign_table) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")", - integer_field then "to_String("+current_type_name+"."+name+")", - char_field(_,_) then current_type_name+"."+name, + integer_field(_) then "to_String("+current_type_name+"."+name+")", + char_field(_,_) then current_type_name+"."+name, text_field then current_type_name+"."+name }. diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis index 38b4b9f..5093459 100644 --- a/src/generation/fields.anubis +++ b/src/generation/fields.anubis @@ -15,6 +15,8 @@ read hayamiki_lib/types/model/columns.anubis read model.anubis public define String +/** Return the corresponding Anubis type of the field + */ to_Anubis_type ( HK_Model_Field t @@ -29,7 +31,7 @@ public define String time_field(_) then "DB_time", datetime_field(_) then "DB_datetime", foreign_key(_,_) then "Int", - integer_field then "Int", + integer_field(_) then "Int", char_field(_,_) then "String", text_field then "String" }. @@ -49,7 +51,7 @@ public define String time_field(_) then fill("TIME", 15) +format_attributes(attributes), datetime_field(_) then fill("DATETIME", 15)+format_attributes(attributes), foreign_key(app,fk) then fill("INTEGER", 15) +format_attributes(attributes)+" REFERENCES "+fk+"(id) ", - integer_field then fill("INTEGER", 15) +format_attributes(attributes), + integer_field(_) then fill("INTEGER", 15) +format_attributes(attributes), char_field(_,size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes), text_field then fill("TEXT", 15) +format_attributes(attributes), }. @@ -68,8 +70,8 @@ public define String date_field(_) then "db_date(\"\")", time_field(_) then "db_time(\"\")", datetime_field(_) then "db_datetime(\"\")", - foreign_key(_,_) then "(Int)0", - integer_field then "(Int)0", + foreign_key(_,_) then "(Int)0", + integer_field(_) then "(Int)0", char_field(choices,size) then "\"\"", text_field then "\"\"" }. @@ -90,7 +92,7 @@ public define String 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+"\")", - integer_field then "get_Int(lwa, __prefix__+\""+name+"\")", + integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\")", char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", text_field then "get_String(lwa, __prefix__+\""+name+"\")" }. @@ -111,7 +113,7 @@ public define String time_field(_) then "db_time(text"+cursor_index+")", datetime_field(_) then "db_datetime(text"+cursor_index+")", foreign_key(_,_) then "(Int)db_integer"+cursor_index, - integer_field then "(Int)db_integer"+cursor_index, + integer_field(_) then "(Int)db_integer"+cursor_index, char_field(_,_) then "text"+cursor_index, text_field then "text"+cursor_index }. @@ -143,7 +145,7 @@ public define String "" }, foreign_key(_,_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", - integer_field then "bind_Int(\":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+")", text_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")" }. diff --git a/src/generation/html.anubis b/src/generation/html.anubis index 79e5107..22c3156 100644 --- a/src/generation/html.anubis +++ b/src/generation/html.anubis @@ -92,9 +92,9 @@ public define String date_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), time_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), datetime_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), - foreign_key(app,foreign_table) then to_HTML_cell_text(column, data_name, general_type_name), - integer_field 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), + foreign_key(app, foreign_table) then to_HTML_cell_text(column, data_name, general_type_name), + 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), text_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 ce7ca9b..5fb8aac 100644 --- a/src/generation/icons.anubis +++ b/src/generation/icons.anubis @@ -29,7 +29,7 @@ public define String time_field(attrs) then icn16_clock, datetime_field(attrs) then icn16_clock, foreign_key(app,foreign_table) then icn16_question, - integer_field then icn16_question, + integer_field(choice) then icn16_question, char_field(choice, size) then icn16_question, text_field then icn16_question }. -- libgit2 0.21.4