Commit 630afb08c58293b925b11c08203428edb9a93b20

Authored by totoro
1 parent 87ca803d

add password_field

hayamiki_lib @ aa86c5cfded
1   -Subproject commit c6605b532d8610d3bbbad66926aa149aa86e8f88
  1 +Subproject commit aa86c5cfded0491eb77ebe770c364d4b90790930
... ...
src/generation/choices_selector.anubis
... ... @@ -40,7 +40,34 @@ define Maybe(One)
40 40 failure then println("can't write generate_choices_selector_"+table_name+"_"+column_name); failure,
41 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 72 public define Maybe(One)
46 73 generate_choices_selector
... ... @@ -60,6 +87,13 @@ public define Maybe(One)
60 87 text_choices(choices_list) then
61 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 97 else
64 98 success(unique), columns);
65 99 success(unique).
... ...
src/generation/columns.anubis
... ... @@ -116,6 +116,11 @@ public define String
116 116  
117 117  
118 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 124 get_column_name
120 125 (
121 126 HK_Model_Column col,
... ... @@ -140,6 +145,7 @@ public define Maybe(String)
140 145 foreign_key(_,_) then success(name),
141 146 integer_field(_) then success(name),
142 147 char_field(_,_) then success(name),
  148 + password_field(_) then success(name),
143 149 text_field then success(name)
144 150 }.
145 151  
... ... @@ -194,6 +200,8 @@ public define String
194 200  
195 201  
196 202 public define Maybe(String)
  203 +/** Here we generate the VT_Edit entry according to the model
  204 + */
197 205 get_VT_edit_entry
198 206 (
199 207 HK_Model_Column col,
... ... @@ -250,6 +258,7 @@ public define Maybe(String)
250 258 else
251 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 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 307 }.
299 308  
300 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 313 to_String
304 314 (
... ... @@ -319,5 +329,6 @@ public define String
319 329 foreign_key(app,foreign_table) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")",
320 330 integer_field(_) then "to_String("+current_type_name+"."+name+")",
321 331 char_field(_,_) then current_type_name+"."+name,
  332 + password_field(_) then current_type_name+"."+name,
322 333 text_field then current_type_name+"."+name
323 334 }.
... ...
src/generation/fields.anubis
... ... @@ -33,6 +33,7 @@ public define String
33 33 foreign_key(_,_) then "Int",
34 34 integer_field(_) then "Int",
35 35 char_field(_,_) then "String",
  36 + password_field(_) then "String",
36 37 text_field then "String"
37 38 }.
38 39  
... ... @@ -53,6 +54,7 @@ public define String
53 54 foreign_key(app,fk) then fill("INTEGER", 15) +format_attributes(attributes)+" REFERENCES "+fk+"(id) ",
54 55 integer_field(_) then fill("INTEGER", 15) +format_attributes(attributes),
55 56 char_field(_,size) then fill("VARCHAR("+size+")", 15) +format_attributes(attributes),
  57 + password_field(_) then fill("TEXT", 15) +format_attributes(attributes),
56 58 text_field then fill("TEXT", 15) +format_attributes(attributes),
57 59 }.
58 60  
... ... @@ -73,6 +75,7 @@ public define String
73 75 foreign_key(_,_) then "(Int)0",
74 76 integer_field(_) then "(Int)0",
75 77 char_field(choices,size) then "\"\"",
  78 + password_field(min_size) then "\"\"",
76 79 text_field then "\"\""
77 80 }.
78 81  
... ... @@ -94,6 +97,7 @@ public define String
94 97 foreign_key(_,_) then "get_Int(lwa, __prefix__+\""+name+"\")",
95 98 integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\")",
96 99 char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")",
  100 + password_field(min_size) then "get_String(lwa, __prefix__+\""+name+"_1\")",
97 101 text_field then "get_String(lwa, __prefix__+\""+name+"\")"
98 102 }.
99 103  
... ... @@ -115,6 +119,7 @@ public define String
115 119 foreign_key(_,_) then "(Int)db_integer"+cursor_index,
116 120 integer_field(_) then "(Int)db_integer"+cursor_index,
117 121 char_field(_,_) then "text"+cursor_index,
  122 + password_field(_) then "text"+cursor_index,
118 123 text_field then "text"+cursor_index
119 124 }.
120 125  
... ... @@ -147,5 +152,6 @@ public define String
147 152 foreign_key(_,_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")",
148 153 integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")",
149 154 char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
  155 + password_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
150 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 95 foreign_key(app, foreign_table) then to_HTML_cell_text(column, data_name, general_type_name),
96 96 integer_field(choices) then to_HTML_cell_text(column, data_name, general_type_name),
97 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 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 31 foreign_key(app,foreign_table) then icn16_question,
32 32 integer_field(choice) then icn16_question,
33 33 char_field(choice, size) then icn16_question,
  34 + password_field(min_size) then icn16_question,
34 35 text_field then icn16_question
35 36 }.
36 37  
... ...