diff --git a/src/generation/choices_selector.anubis b/src/generation/choices_selector.anubis new file mode 100644 index 0000000..24dbcf8 --- /dev/null +++ b/src/generation/choices_selector.anubis @@ -0,0 +1,70 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 06/04/2016 + * Time: 22:54 + * © Calexium + */ + +read hayamiki_lib/types/hayamiki.anubis +read tools/basis.anubis +read tools/streams.anubis +read system/string.anubis +read fields.anubis +read columns.anubis +read html.anubis + +define Maybe(One) + _generate_choices_selector + ( + Stream stream, + String table_name, + String column_name, + List(HK_Text_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_Text_Choice hk_txt_choice) |-> + since hk_txt_choice is hk_text_choice(value, visible), + " ([], wav(\""+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 + ( + Stream stream, + HK_Table table + )= + since table is hk_table(table_name, short_name, model, _), + since model is hk_model( columns, show_string), + + map_forget((HK_Model_Column column) |-> + since column is hk_column(column_name, field_type, _, _), + if field_type is char_field(choices, _) then + if choices is + { + no_choice then success(unique), + text_choices(choices_list) then + _generate_choices_selector(stream, table_name, column_name, choices_list) + } + else + success(unique), columns); + success(unique). + + + with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. + + -- libgit2 0.21.4