Commit 049aee2e4f88bbc797c61291cb6bbcf2f4cb2553
1 parent
939b0056
add management of color_field
Showing
10 changed files
with
110 additions
and
20 deletions
Show diff stats
hayamiki_lib @ 4eeb47a275b
src/generation/columns.anubis
| @@ -150,7 +150,8 @@ public define Maybe(String) | @@ -150,7 +150,8 @@ public define Maybe(String) | ||
| 150 | float_field then success(name), | 150 | float_field then success(name), |
| 151 | char_field(_,_) then success(name), | 151 | char_field(_,_) then success(name), |
| 152 | password_field(_) then success(name), | 152 | password_field(_) then success(name), |
| 153 | - text_field(_) then success(name) | 153 | + text_field(_) then success(name), |
| 154 | + color_field then success(name), | ||
| 154 | }. | 155 | }. |
| 155 | 156 | ||
| 156 | public define List(String) | 157 | public define List(String) |
| @@ -266,7 +267,8 @@ public define Maybe(String) | @@ -266,7 +267,8 @@ public define Maybe(String) | ||
| 266 | success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") | 267 | success("text(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")") |
| 267 | } | 268 | } |
| 268 | password_field(min_size) then success("password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")") | 269 | password_field(min_size) then success("password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")") |
| 269 | - text_field(txt_attr) then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(txt_attr)+", "+to_Anubis_source(help)+")") | 270 | + text_field(txt_attr) then success("text_area(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(txt_attr)+", "+to_Anubis_source(help)+")"), |
| 271 | + color_field then success("color(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"), | ||
| 270 | }. | 272 | }. |
| 271 | 273 | ||
| 272 | public define String | 274 | public define String |
| @@ -316,6 +318,7 @@ public define String | @@ -316,6 +318,7 @@ public define String | ||
| 316 | char_field(_,_) then current_type_name+"."+name, | 318 | char_field(_,_) then current_type_name+"."+name, |
| 317 | password_field(_) then current_type_name+"."+name, | 319 | password_field(_) then current_type_name+"."+name, |
| 318 | text_field(_) then current_type_name+"."+name | 320 | text_field(_) then current_type_name+"."+name |
| 321 | + color_field then current_type_name+"."+name | ||
| 319 | }. | 322 | }. |
| 320 | 323 | ||
| 321 | 324 |
src/generation/extractor.anubis
| @@ -30,7 +30,8 @@ public define String | @@ -30,7 +30,8 @@ public define String | ||
| 30 | float_field then "db_float"+cursor_index, | 30 | float_field then "db_float"+cursor_index, |
| 31 | char_field(_,_) then "text"+cursor_index, | 31 | char_field(_,_) then "text"+cursor_index, |
| 32 | password_field(_) then "text"+cursor_index, | 32 | password_field(_) then "text"+cursor_index, |
| 33 | - text_field(_) then "text"+cursor_index | 33 | + text_field(_) then "text"+cursor_index, |
| 34 | + color_field then "text"+cursor_index | ||
| 34 | }. | 35 | }. |
| 35 | 36 | ||
| 36 | define List(String) | 37 | define List(String) |
src/generation/fields.anubis
| @@ -35,7 +35,8 @@ public define String | @@ -35,7 +35,8 @@ public define String | ||
| 35 | float_field then "Float", | 35 | float_field then "Float", |
| 36 | char_field(_,_) then "String", | 36 | char_field(_,_) then "String", |
| 37 | password_field(_) then "String", | 37 | password_field(_) then "String", |
| 38 | - text_field(_) then "String" | 38 | + text_field(_) then "String", |
| 39 | + color_field then "String", | ||
| 39 | }. | 40 | }. |
| 40 | 41 | ||
| 41 | public define String | 42 | public define String |
| @@ -57,7 +58,8 @@ public define String | @@ -57,7 +58,8 @@ public define String | ||
| 57 | float_field then "float", | 58 | float_field then "float", |
| 58 | char_field(_,_) then "string", | 59 | char_field(_,_) then "string", |
| 59 | password_field(_) then "string", | 60 | password_field(_) then "string", |
| 60 | - text_field(_) then "string" | 61 | + text_field(_) then "string", |
| 62 | + color_field then "string" | ||
| 61 | }. | 63 | }. |
| 62 | 64 | ||
| 63 | public define String | 65 | public define String |
| @@ -80,6 +82,7 @@ public define String | @@ -80,6 +82,7 @@ public define String | ||
| 80 | char_field(_,size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), | 82 | char_field(_,size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), |
| 81 | password_field(size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), | 83 | password_field(size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), |
| 82 | text_field(_) then fill("TEXT", 15) + format_attributes(attributes), | 84 | text_field(_) then fill("TEXT", 15) + format_attributes(attributes), |
| 85 | + color_field then fill("VARCHAR(8)",15)+ format_attributes(attributes), | ||
| 83 | }. | 86 | }. |
| 84 | 87 | ||
| 85 | public define String | 88 | public define String |
| @@ -101,7 +104,8 @@ public define String | @@ -101,7 +104,8 @@ public define String | ||
| 101 | float_field then "(Float)0.0", | 104 | float_field then "(Float)0.0", |
| 102 | char_field(choices,size) then "\"\"", | 105 | char_field(choices,size) then "\"\"", |
| 103 | password_field(min_size) then "\"\"", | 106 | password_field(min_size) then "\"\"", |
| 104 | - text_field(_) then "\"\"" | 107 | + text_field(_) then "\"\"", |
| 108 | + color_field then "#DDD", | ||
| 105 | }. | 109 | }. |
| 106 | 110 | ||
| 107 | 111 | ||
| @@ -139,5 +143,6 @@ public define String | @@ -139,5 +143,6 @@ public define String | ||
| 139 | float_field then "bind_Float(\":v_"+name+"\", "+type_name+"."+name+")", | 143 | float_field then "bind_Float(\":v_"+name+"\", "+type_name+"."+name+")", |
| 140 | char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", | 144 | char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", |
| 141 | password_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", | 145 | password_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", |
| 142 | - text_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")" | 146 | + text_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", |
| 147 | + color_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")", | ||
| 143 | }. | 148 | }. |
src/generation/files.anubis
| @@ -192,7 +192,7 @@ define One | @@ -192,7 +192,7 @@ define One | ||
| 192 | [table . t] then | 192 | [table . t] then |
| 193 | since table is hk_table(name, _, _, _), | 193 | since table is hk_table(name, _, _, _), |
| 194 | with transmit = "transmit "+name+".anubis", | 194 | with transmit = "transmit "+name+".anubis", |
| 195 | - with view = "vtm_view(\""+name+"\", get_viewable_"+name+")", | 195 | + with view = "vtm_view(\""+name+"\", get_viewable_"+name+", get_all_"+name+"_view_name)", |
| 196 | with edit = "vtm_edit(\""+name+"\", get_editable_"+name+")", | 196 | with edit = "vtm_edit(\""+name+"\", get_editable_"+name+")", |
| 197 | with writer = "tm_writer(\""+name+"\", update_"+name+"_from_type, update_"+name+"_from_fields)", | 197 | with writer = "tm_writer(\""+name+"\", update_"+name+"_from_type, update_"+name+"_from_fields)", |
| 198 | with delete = "tm_delete(\""+name+"\", delete_"+name+")", | 198 | with delete = "tm_delete(\""+name+"\", delete_"+name+")", |
src/generation/html.anubis
| @@ -102,6 +102,7 @@ public define String | @@ -102,6 +102,7 @@ public define String | ||
| 102 | "text(\"********\")", | 102 | "text(\"********\")", |
| 103 | //to_HTML_cell_text(column, data_name, general_type_name), | 103 | //to_HTML_cell_text(column, data_name, general_type_name), |
| 104 | text_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), | 104 | text_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), |
| 105 | + color_field then to_HTML_cell_text(column, data_name, general_type_name), | ||
| 105 | } | 106 | } |
| 106 | }. | 107 | }. |
| 107 | 108 |
src/generation/icons.anubis
| @@ -33,6 +33,7 @@ public define String | @@ -33,6 +33,7 @@ public define String | ||
| 33 | float_field then icn16_question, | 33 | float_field then icn16_question, |
| 34 | char_field(choice, size) then icn16_question, | 34 | char_field(choice, size) then icn16_question, |
| 35 | password_field(min_size) then icn16_question, | 35 | password_field(min_size) then icn16_question, |
| 36 | - text_field(_) then icn16_question | 36 | + text_field(_) then icn16_question, |
| 37 | + color_field then icn16_question | ||
| 37 | }. | 38 | }. |
| 38 | 39 |
src/generation/json.anubis
| @@ -33,7 +33,8 @@ public define String | @@ -33,7 +33,8 @@ public define String | ||
| 33 | float_field then "float_to_string("+current_type_name+"."+name+",5)", | 33 | float_field then "float_to_string("+current_type_name+"."+name+",5)", |
| 34 | char_field(_,_) then "to_JSON_String("+current_type_name+"."+name+")", | 34 | char_field(_,_) then "to_JSON_String("+current_type_name+"."+name+")", |
| 35 | password_field(_) then "to_JSON_String("+current_type_name+"."+name+")", | 35 | password_field(_) then "to_JSON_String("+current_type_name+"."+name+")", |
| 36 | - text_field(_) then "to_JSON_String("+current_type_name+"."+name+")" | 36 | + text_field(_) then "to_JSON_String("+current_type_name+"."+name+")", |
| 37 | + color_field then "to_JSON_String("+current_type_name+"."+name+")", | ||
| 37 | } | 38 | } |
| 38 | . | 39 | . |
| 39 | 40 | ||
| @@ -62,7 +63,8 @@ public define String | @@ -62,7 +63,8 @@ public define String | ||
| 62 | float_field then "json_member(\""+name+"\", json_float("+current_type_name+"."+name+",5))", | 63 | float_field then "json_member(\""+name+"\", json_float("+current_type_name+"."+name+",5))", |
| 63 | char_field(_,_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", | 64 | char_field(_,_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", |
| 64 | password_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", | 65 | password_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", |
| 65 | - text_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))" | 66 | + text_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", |
| 67 | + color_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))" | ||
| 66 | } | 68 | } |
| 67 | . | 69 | . |
| 68 | 70 | ||
| @@ -88,5 +90,6 @@ public define String | @@ -88,5 +90,6 @@ public define String | ||
| 88 | char_field(_,_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", | 90 | char_field(_,_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", |
| 89 | password_field(_) then "json_member(\""+name+"\", json_string(\"******\"))", | 91 | password_field(_) then "json_member(\""+name+"\", json_string(\"******\"))", |
| 90 | text_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))" | 92 | text_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))" |
| 93 | + color_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))" | ||
| 91 | } | 94 | } |
| 92 | . | 95 | . |
src/generation/vt_view.anubis
| @@ -74,8 +74,9 @@ define String | @@ -74,8 +74,9 @@ define String | ||
| 74 | else | 74 | else |
| 75 | "text(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" | 75 | "text(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" |
| 76 | } | 76 | } |
| 77 | - password_field(min_size) then "password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" | ||
| 78 | - text_field(txt_attr) then "text_area(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" | 77 | + password_field(min_size) then "password(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", |
| 78 | + text_field(txt_attr) then "text_area(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", | ||
| 79 | + color_field then "color(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")" | ||
| 79 | }. | 80 | }. |
| 80 | 81 | ||
| 81 | 82 | ||
| @@ -265,8 +266,73 @@ public define Maybe(One) | @@ -265,8 +266,73 @@ public define Maybe(One) | ||
| 265 | failure then println("can't write generate_get_viewable "+table_name); failure, | 266 | failure then println("can't write generate_get_viewable "+table_name); failure, |
| 266 | success(_) then success(unique) | 267 | success(_) then success(unique) |
| 267 | }. | 268 | }. |
| 269 | + | ||
| 270 | +public define List(String) | ||
| 271 | +/* Generate | ||
| 272 | + | ||
| 273 | +*/ | ||
| 274 | + _generate_list_view_name | ||
| 275 | + ( | ||
| 276 | + List(HK_List_View) list_view, //list view to generate | ||
| 277 | + List(String) so_far, | ||
| 278 | + Bool has_default //set to true if a default view was encountered. | ||
| 279 | + )= | ||
| 280 | + if list_view is | ||
| 281 | + { | ||
| 282 | + [] then | ||
| 283 | + //if default view was not generated, we force to generate it | ||
| 284 | + if has_default = false then | ||
| 285 | + reverse(["\"default\"" . so_far]) | ||
| 286 | + else | ||
| 287 | + reverse(so_far), | ||
| 288 | + [view . t] then | ||
| 289 | + with new_has_default = if has_default = true then //already true, no need to go further | ||
| 290 | + true | ||
| 291 | + else | ||
| 292 | + if view is | ||
| 293 | + { | ||
| 294 | + list_view_all then true, //list_view_all is default view | ||
| 295 | + list_view(view_name, _, _) then | ||
| 296 | + //if not we search for view named 'default' | ||
| 297 | + if view_name = "default" then true else false | ||
| 298 | + }, | ||
| 299 | + with view_name = if view is | ||
| 300 | + { | ||
| 301 | + list_view_all then "default", | ||
| 302 | + list_view(view_name, _, _) then view_name | ||
| 303 | + }, | ||
| 304 | + _generate_list_view_name(t, ["\""+view_name+"\"" . so_far], new_has_default) | ||
| 305 | + } | ||
| 306 | +. | ||
| 268 | 307 | ||
| 269 | public define Maybe(One) | 308 | public define Maybe(One) |
| 309 | + _generate_get_all_view_name | ||
| 310 | + ( | ||
| 311 | + Stream stream, | ||
| 312 | + HK_Table table, // | ||
| 313 | + List(HK_List_View) list_view | ||
| 314 | + )= | ||
| 315 | + since table is hk_table(table_name, short_name, model, display), | ||
| 316 | + if write_string(stream, | ||
| 317 | + "\n\npublic define List(String)\n"+ | ||
| 318 | + " get_all_"+table_name+"_view_name\n"+ | ||
| 319 | + " (\n"+ | ||
| 320 | + " One dummy\n"+ | ||
| 321 | + " )=\n"+ | ||
| 322 | + " [\n"+ | ||
| 323 | + " "+join(",\n ",_generate_list_view_name(list_view, [], false))+ | ||
| 324 | + "\n ]\n"+ | ||
| 325 | + ".\n\n" | ||
| 326 | + ) is //end of the function | ||
| 327 | + { | ||
| 328 | + failure then println("can't write _generate_get_all_view_name "+table_name); failure, | ||
| 329 | + success(_) then success(unique) | ||
| 330 | + } | ||
| 331 | +. | ||
| 332 | + | ||
| 333 | + | ||
| 334 | + | ||
| 335 | +public define Maybe(One) | ||
| 270 | generate_VT_all_view | 336 | generate_VT_all_view |
| 271 | ( | 337 | ( |
| 272 | Stream stream, | 338 | Stream stream, |
| @@ -277,8 +343,15 @@ public define Maybe(One) | @@ -277,8 +343,15 @@ public define Maybe(One) | ||
| 277 | since display is hk_display(list_view, list_edit), | 343 | since display is hk_display(list_view, list_edit), |
| 278 | 344 | ||
| 279 | with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. | 345 | with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. |
| 280 | - if _generate_VT_view(stream, table, list_view, false) is //list view to generate | 346 | + if _generate_get_all_view_name(stream, table, list_view) is |
| 281 | { | 347 | { |
| 282 | - failure then failure, | ||
| 283 | - success(_) then generate_get_viewable(stream, table, list_view) | ||
| 284 | - }. | 348 | + failure then failure, |
| 349 | + success(_) then | ||
| 350 | + | ||
| 351 | + if _generate_VT_view(stream, table, list_view, false) is //list view to generate | ||
| 352 | + { | ||
| 353 | + failure then failure, | ||
| 354 | + success(_) then generate_get_viewable(stream, table, list_view) | ||
| 355 | + } | ||
| 356 | + } | ||
| 357 | +. |
src/generation/web_args.anubis
| @@ -30,7 +30,8 @@ public define String | @@ -30,7 +30,8 @@ public define String | ||
| 30 | float_field then "get_Float(lwa, __prefix__+\""+name+"\")", | 30 | float_field then "get_Float(lwa, __prefix__+\""+name+"\")", |
| 31 | char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", | 31 | char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", |
| 32 | password_field(min_size) then "get_Password(lwa, __prefix__+\""+name+"_1\", __prefix__+\""+name+"_2\")", | 32 | password_field(min_size) then "get_Password(lwa, __prefix__+\""+name+"_1\", __prefix__+\""+name+"_2\")", |
| 33 | - text_field(_) then "get_String(lwa, __prefix__+\""+name+"\")" | 33 | + text_field(_) then "get_String(lwa, __prefix__+\""+name+"\")", |
| 34 | + color_field then "get_String(lwa, __prefix__+\""+name+"\")", | ||
| 34 | }. | 35 | }. |
| 35 | 36 | ||
| 36 | define (List(String), Int) | 37 | define (List(String), Int) |
| @@ -139,8 +140,10 @@ public define String | @@ -139,8 +140,10 @@ public define String | ||
| 139 | " )" | 140 | " )" |
| 140 | // if get_Password(lwa, __prefix__+"password_1", __prefix__+"password_2") is {failure then [], success(password) then [field("passwxord", bind_String(":v_password", password))] } | 141 | // if get_Password(lwa, __prefix__+"password_1", __prefix__+"password_2") is {failure then [], success(password) then [field("passwxord", bind_String(":v_password", password))] } |
| 141 | text_field(_) then | 142 | text_field(_) then |
| 143 | + "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }", | ||
| 144 | + color_field then | ||
| 142 | "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }" | 145 | "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }" |
| 143 | - //"get_String(lwa, __prefix__+\""+name+"\")" | 146 | + //"get_String(lwa, __prefix__+\""+name+"\")" |
| 144 | }. | 147 | }. |
| 145 | 148 | ||
| 146 | define String | 149 | define String |