Commit 630afb08c58293b925b11c08203428edb9a93b20
1 parent
87ca803d
add password_field
Showing
6 changed files
with
56 additions
and
3 deletions
Show diff stats
hayamiki_lib @ aa86c5cfded
src/generation/choices_selector.anubis
| @@ -40,7 +40,34 @@ define Maybe(One) | @@ -40,7 +40,34 @@ define Maybe(One) | ||
| 40 | failure then println("can't write generate_choices_selector_"+table_name+"_"+column_name); failure, | 40 | failure then println("can't write generate_choices_selector_"+table_name+"_"+column_name); failure, |
| 41 | success(_) then success(unique) | 41 | success(_) then success(unique) |
| 42 | }. | 42 | }. |
| 43 | - . | 43 | + |
| 44 | + | ||
| 45 | +define Maybe(One) | ||
| 46 | + _generate_choices_int_selector | ||
| 47 | + ( | ||
| 48 | + Stream stream, | ||
| 49 | + String table_name, | ||
| 50 | + String column_name, | ||
| 51 | + List(HK_Int_Choice) choices | ||
| 52 | + )= | ||
| 53 | + //generate the type of the table that contain all components | ||
| 54 | + if write_string(stream, | ||
| 55 | + "\n\n"+ | ||
| 56 | + "public define List((List(CoreAttrs), WebArgValue, String))\n"+ | ||
| 57 | + " get_choices_selector_"+table_name+"_"+column_name+"\n"+ | ||
| 58 | + " (\n"+ | ||
| 59 | + " SQLite3DataBase db,\n"+ | ||
| 60 | + " )=\n"+ | ||
| 61 | + " [\n"+ | ||
| 62 | + concat(map((HK_Int_Choice hk_int_choice) |-> | ||
| 63 | + since hk_int_choice is hk_int_choice(value, visible), | ||
| 64 | + " ([], wav(\""+to_String(value)+"\"), \""+visible+"\"),\n", choices))+ | ||
| 65 | + " ]." | ||
| 66 | + ) is //end of the function | ||
| 67 | + { | ||
| 68 | + failure then println("can't write generate_choices_selector_"+table_name+"_"+column_name); failure, | ||
| 69 | + success(_) then success(unique) | ||
| 70 | + }. | ||
| 44 | 71 | ||
| 45 | public define Maybe(One) | 72 | public define Maybe(One) |
| 46 | generate_choices_selector | 73 | generate_choices_selector |
| @@ -60,6 +87,13 @@ public define Maybe(One) | @@ -60,6 +87,13 @@ public define Maybe(One) | ||
| 60 | text_choices(choices_list) then | 87 | text_choices(choices_list) then |
| 61 | _generate_choices_selector(stream, table_name, column_name, choices_list) | 88 | _generate_choices_selector(stream, table_name, column_name, choices_list) |
| 62 | } | 89 | } |
| 90 | + else if field_type is integer_field(choices) then | ||
| 91 | + if choices is | ||
| 92 | + { | ||
| 93 | + no_choice then success(unique), | ||
| 94 | + int_choices(choices_list) then | ||
| 95 | + _generate_choices_int_selector(stream, table_name, column_name, choices_list) | ||
| 96 | + } | ||
| 63 | else | 97 | else |
| 64 | success(unique), columns); | 98 | success(unique), columns); |
| 65 | success(unique). | 99 | success(unique). |
src/generation/columns.anubis
| @@ -116,6 +116,11 @@ public define String | @@ -116,6 +116,11 @@ public define String | ||
| 116 | 116 | ||
| 117 | 117 | ||
| 118 | public define Maybe(String) | 118 | public define Maybe(String) |
| 119 | +/** Return the column name according to the model. | ||
| 120 | + * insert boolean indicate that we only want the column name during insert processing. | ||
| 121 | + * In fact some column no need to be updated hence the column name will be ignored if | ||
| 122 | + * the insert boolean = false. | ||
| 123 | + */ | ||
| 119 | get_column_name | 124 | get_column_name |
| 120 | ( | 125 | ( |
| 121 | HK_Model_Column col, | 126 | HK_Model_Column col, |
| @@ -140,6 +145,7 @@ public define Maybe(String) | @@ -140,6 +145,7 @@ public define Maybe(String) | ||
| 140 | foreign_key(_,_) then success(name), | 145 | foreign_key(_,_) then success(name), |
| 141 | integer_field(_) then success(name), | 146 | integer_field(_) then success(name), |
| 142 | char_field(_,_) then success(name), | 147 | char_field(_,_) then success(name), |
| 148 | + password_field(_) then success(name), | ||
| 143 | text_field then success(name) | 149 | text_field then success(name) |
| 144 | }. | 150 | }. |
| 145 | 151 | ||
| @@ -194,6 +200,8 @@ public define String | @@ -194,6 +200,8 @@ public define String | ||
| 194 | 200 | ||
| 195 | 201 | ||
| 196 | public define Maybe(String) | 202 | public define Maybe(String) |
| 203 | +/** Here we generate the VT_Edit entry according to the model | ||
| 204 | + */ | ||
| 197 | get_VT_edit_entry | 205 | get_VT_edit_entry |
| 198 | ( | 206 | ( |
| 199 | HK_Model_Column col, | 207 | HK_Model_Column col, |
| @@ -250,6 +258,7 @@ public define Maybe(String) | @@ -250,6 +258,7 @@ public define Maybe(String) | ||
| 250 | else | 258 | else |
| 251 | success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") | 259 | success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") |
| 252 | } | 260 | } |
| 261 | + password_field(min_size) then success("password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")") | ||
| 253 | text_field then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") | 262 | text_field then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") |
| 254 | }. | 263 | }. |
| 255 | 264 | ||
| @@ -298,7 +307,8 @@ public define Maybe(HK_Model_Column) | @@ -298,7 +307,8 @@ public define Maybe(HK_Model_Column) | ||
| 298 | }. | 307 | }. |
| 299 | 308 | ||
| 300 | public define String | 309 | public define String |
| 301 | -/** to_String return the String of the given model of the column 'col' | 310 | +/** to_String return the content of the given model column 'col' in String format. |
| 311 | + * | ||
| 302 | */ | 312 | */ |
| 303 | to_String | 313 | to_String |
| 304 | ( | 314 | ( |
| @@ -319,5 +329,6 @@ public define String | @@ -319,5 +329,6 @@ public define String | ||
| 319 | foreign_key(app,foreign_table) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")", | 329 | foreign_key(app,foreign_table) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")", |
| 320 | integer_field(_) then "to_String("+current_type_name+"."+name+")", | 330 | integer_field(_) then "to_String("+current_type_name+"."+name+")", |
| 321 | char_field(_,_) then current_type_name+"."+name, | 331 | char_field(_,_) then current_type_name+"."+name, |
| 332 | + password_field(_) then current_type_name+"."+name, | ||
| 322 | text_field then current_type_name+"."+name | 333 | text_field then current_type_name+"."+name |
| 323 | }. | 334 | }. |
src/generation/fields.anubis
| @@ -33,6 +33,7 @@ public define String | @@ -33,6 +33,7 @@ public define String | ||
| 33 | foreign_key(_,_) then "Int", | 33 | foreign_key(_,_) then "Int", |
| 34 | integer_field(_) then "Int", | 34 | integer_field(_) then "Int", |
| 35 | char_field(_,_) then "String", | 35 | char_field(_,_) then "String", |
| 36 | + password_field(_) then "String", | ||
| 36 | text_field then "String" | 37 | text_field then "String" |
| 37 | }. | 38 | }. |
| 38 | 39 | ||
| @@ -53,6 +54,7 @@ public define String | @@ -53,6 +54,7 @@ public define String | ||
| 53 | foreign_key(app,fk) then fill("INTEGER", 15) +format_attributes(attributes)+" REFERENCES "+fk+"(id) ", | 54 | foreign_key(app,fk) then fill("INTEGER", 15) +format_attributes(attributes)+" REFERENCES "+fk+"(id) ", |
| 54 | integer_field(_) then fill("INTEGER", 15) +format_attributes(attributes), | 55 | integer_field(_) then fill("INTEGER", 15) +format_attributes(attributes), |
| 55 | char_field(_,size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes), | 56 | char_field(_,size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes), |
| 57 | + password_field(_) then fill("TEXT", 15) +format_attributes(attributes), | ||
| 56 | text_field then fill("TEXT", 15) +format_attributes(attributes), | 58 | text_field then fill("TEXT", 15) +format_attributes(attributes), |
| 57 | }. | 59 | }. |
| 58 | 60 | ||
| @@ -73,6 +75,7 @@ public define String | @@ -73,6 +75,7 @@ public define String | ||
| 73 | foreign_key(_,_) then "(Int)0", | 75 | foreign_key(_,_) then "(Int)0", |
| 74 | integer_field(_) then "(Int)0", | 76 | integer_field(_) then "(Int)0", |
| 75 | char_field(choices,size) then "\"\"", | 77 | char_field(choices,size) then "\"\"", |
| 78 | + password_field(min_size) then "\"\"", | ||
| 76 | text_field then "\"\"" | 79 | text_field then "\"\"" |
| 77 | }. | 80 | }. |
| 78 | 81 | ||
| @@ -94,6 +97,7 @@ public define String | @@ -94,6 +97,7 @@ public define String | ||
| 94 | foreign_key(_,_) then "get_Int(lwa, __prefix__+\""+name+"\")", | 97 | foreign_key(_,_) then "get_Int(lwa, __prefix__+\""+name+"\")", |
| 95 | integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\")", | 98 | integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\")", |
| 96 | char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", | 99 | char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", |
| 100 | + password_field(min_size) then "get_String(lwa, __prefix__+\""+name+"_1\")", | ||
| 97 | text_field then "get_String(lwa, __prefix__+\""+name+"\")" | 101 | text_field then "get_String(lwa, __prefix__+\""+name+"\")" |
| 98 | }. | 102 | }. |
| 99 | 103 | ||
| @@ -115,6 +119,7 @@ public define String | @@ -115,6 +119,7 @@ public define String | ||
| 115 | foreign_key(_,_) then "(Int)db_integer"+cursor_index, | 119 | foreign_key(_,_) then "(Int)db_integer"+cursor_index, |
| 116 | integer_field(_) then "(Int)db_integer"+cursor_index, | 120 | integer_field(_) then "(Int)db_integer"+cursor_index, |
| 117 | char_field(_,_) then "text"+cursor_index, | 121 | char_field(_,_) then "text"+cursor_index, |
| 122 | + password_field(_) then "text"+cursor_index, | ||
| 118 | text_field then "text"+cursor_index | 123 | text_field then "text"+cursor_index |
| 119 | }. | 124 | }. |
| 120 | 125 | ||
| @@ -147,5 +152,6 @@ public define String | @@ -147,5 +152,6 @@ public define String | ||
| 147 | foreign_key(_,_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", | 152 | foreign_key(_,_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", |
| 148 | integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", | 153 | integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", |
| 149 | char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", | 154 | char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", |
| 155 | + password_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", | ||
| 150 | text_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")" | 156 | text_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")" |
| 151 | }. | 157 | }. |
src/generation/html.anubis
| @@ -95,6 +95,7 @@ public define String | @@ -95,6 +95,7 @@ public define String | ||
| 95 | foreign_key(app, foreign_table) then to_HTML_cell_text(column, data_name, general_type_name), | 95 | foreign_key(app, foreign_table) then to_HTML_cell_text(column, data_name, general_type_name), |
| 96 | integer_field(choices) then to_HTML_cell_text(column, data_name, general_type_name), | 96 | integer_field(choices) then to_HTML_cell_text(column, data_name, general_type_name), |
| 97 | char_field(choices, size) then to_HTML_cell_text(column, data_name, general_type_name), | 97 | char_field(choices, size) then to_HTML_cell_text(column, data_name, general_type_name), |
| 98 | + password_field(min_size) then to_HTML_cell_text(column, data_name, general_type_name), | ||
| 98 | text_field then to_HTML_cell_text(column, data_name, general_type_name), | 99 | text_field then to_HTML_cell_text(column, data_name, general_type_name), |
| 99 | } | 100 | } |
| 100 | }. | 101 | }. |
src/generation/icons.anubis
| @@ -31,6 +31,7 @@ public define String | @@ -31,6 +31,7 @@ public define String | ||
| 31 | foreign_key(app,foreign_table) then icn16_question, | 31 | foreign_key(app,foreign_table) then icn16_question, |
| 32 | integer_field(choice) then icn16_question, | 32 | integer_field(choice) then icn16_question, |
| 33 | char_field(choice, size) then icn16_question, | 33 | char_field(choice, size) then icn16_question, |
| 34 | + password_field(min_size) then icn16_question, | ||
| 34 | text_field then icn16_question | 35 | text_field then icn16_question |
| 35 | }. | 36 | }. |
| 36 | 37 |