From 630afb08c58293b925b11c08203428edb9a93b20 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 23 Jul 2016 18:28:45 +0200 Subject: [PATCH] add password_field --- hayamiki_lib | 2 +- src/generation/choices_selector.anubis | 36 +++++++++++++++++++++++++++++++++++- src/generation/columns.anubis | 13 ++++++++++++- src/generation/fields.anubis | 6 ++++++ src/generation/html.anubis | 1 + src/generation/icons.anubis | 1 + 6 files changed, 56 insertions(+), 3 deletions(-) diff --git a/hayamiki_lib b/hayamiki_lib index c6605b5..aa86c5c 160000 --- a/hayamiki_lib +++ b/hayamiki_lib @@ -1 +1 @@ -Subproject commit c6605b532d8610d3bbbad66926aa149aa86e8f88 +Subproject commit aa86c5cfded0491eb77ebe770c364d4b90790930 diff --git a/src/generation/choices_selector.anubis b/src/generation/choices_selector.anubis index 24dbcf8..9e91fea 100644 --- a/src/generation/choices_selector.anubis +++ b/src/generation/choices_selector.anubis @@ -40,7 +40,34 @@ define Maybe(One) failure then println("can't write generate_choices_selector_"+table_name+"_"+column_name); failure, success(_) then success(unique) }. - . + + +define Maybe(One) + _generate_choices_int_selector + ( + Stream stream, + String table_name, + String column_name, + List(HK_Int_Choice) choices + )= + //generate the type of the table that contain all components + if write_string(stream, + "\n\n"+ + "public define List((List(CoreAttrs), WebArgValue, String))\n"+ + " get_choices_selector_"+table_name+"_"+column_name+"\n"+ + " (\n"+ + " SQLite3DataBase db,\n"+ + " )=\n"+ + " [\n"+ + concat(map((HK_Int_Choice hk_int_choice) |-> + since hk_int_choice is hk_int_choice(value, visible), + " ([], wav(\""+to_String(value)+"\"), \""+visible+"\"),\n", choices))+ + " ]." + ) is //end of the function + { + failure then println("can't write generate_choices_selector_"+table_name+"_"+column_name); failure, + success(_) then success(unique) + }. public define Maybe(One) generate_choices_selector @@ -60,6 +87,13 @@ public define Maybe(One) text_choices(choices_list) then _generate_choices_selector(stream, table_name, column_name, choices_list) } + else if field_type is integer_field(choices) then + if choices is + { + no_choice then success(unique), + int_choices(choices_list) then + _generate_choices_int_selector(stream, table_name, column_name, choices_list) + } else success(unique), columns); success(unique). diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis index 42d395a..3750099 100644 --- a/src/generation/columns.anubis +++ b/src/generation/columns.anubis @@ -116,6 +116,11 @@ public define String public define Maybe(String) +/** Return the column name according to the model. + * insert boolean indicate that we only want the column name during insert processing. + * In fact some column no need to be updated hence the column name will be ignored if + * the insert boolean = false. + */ get_column_name ( HK_Model_Column col, @@ -140,6 +145,7 @@ public define Maybe(String) foreign_key(_,_) then success(name), integer_field(_) then success(name), char_field(_,_) then success(name), + password_field(_) then success(name), text_field then success(name) }. @@ -194,6 +200,8 @@ public define String public define Maybe(String) +/** Here we generate the VT_Edit entry according to the model + */ get_VT_edit_entry ( HK_Model_Column col, @@ -250,6 +258,7 @@ public define Maybe(String) else 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)+")") }. @@ -298,7 +307,8 @@ public define Maybe(HK_Model_Column) }. public define String -/** to_String return the String of the given model of the column 'col' +/** to_String return the content of the given model column 'col' in String format. + * */ to_String ( @@ -319,5 +329,6 @@ public define String 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, + password_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 5093459..6aaf15f 100644 --- a/src/generation/fields.anubis +++ b/src/generation/fields.anubis @@ -33,6 +33,7 @@ public define String foreign_key(_,_) then "Int", integer_field(_) then "Int", char_field(_,_) then "String", + password_field(_) then "String", text_field then "String" }. @@ -53,6 +54,7 @@ public define String foreign_key(app,fk) then fill("INTEGER", 15) +format_attributes(attributes)+" REFERENCES "+fk+"(id) ", 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), }. @@ -73,6 +75,7 @@ public define String foreign_key(_,_) then "(Int)0", integer_field(_) then "(Int)0", char_field(choices,size) then "\"\"", + password_field(min_size) then "\"\"", text_field then "\"\"" }. @@ -94,6 +97,7 @@ public define String foreign_key(_,_) then "get_Int(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+"\")" }. @@ -115,6 +119,7 @@ public define String foreign_key(_,_) then "(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 }. @@ -147,5 +152,6 @@ public define String foreign_key(_,_) 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+")", + password_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 22c3156..3d2465d 100644 --- a/src/generation/html.anubis +++ b/src/generation/html.anubis @@ -95,6 +95,7 @@ public define String 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), + 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), } }. diff --git a/src/generation/icons.anubis b/src/generation/icons.anubis index 5fb8aac..f7d0dc5 100644 --- a/src/generation/icons.anubis +++ b/src/generation/icons.anubis @@ -31,6 +31,7 @@ public define String foreign_key(app,foreign_table) then icn16_question, 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 }. -- libgit2 0.21.4