Commit b947f1f018393d4c7ea6c4e149e8301e0db126d8
1 parent
bba31ce5
add searchable fields list in foreign key
Showing
4 changed files
with
20 additions
and
14 deletions
Show diff stats
ds_files/ds_types.anubis
| ... | ... | @@ -90,7 +90,7 @@ public define List(DS_Type_File) hayamiki_lib_types_description = |
| 90 | 90 | [ |
| 91 | 91 | component(extern_type("HK_App_Name", model_types+"hk_app_name.anubis"), "app_name"), |
| 92 | 92 | component(string, "table_name"), |
| 93 | - //component(extern_type("HK_FK_Attr", model_types+"hk_fk_attr.anubis"), "fk_attr"), | |
| 93 | + component(list, string, "searchable_fields"), | |
| 94 | 94 | ]), |
| 95 | 95 | alternative("integer_field", [ |
| 96 | 96 | component(extern_type("HK_Int_Choices", model_types+"hk_int_choices.anubis"), "choices", comment("integer of arbitrary size ")), |
| ... | ... | @@ -118,10 +118,11 @@ public define List(DS_Type_File) hayamiki_lib_types_description = |
| 118 | 118 | enum("rich_editor", comment("Use richt text editor for that area")) |
| 119 | 119 | ]), |
| 120 | 120 | |
| 121 | - // ds_type("HK_FK_Attr", [ | |
| 122 | - // enum("one_to_one", comment("Foreign key relation is one to one")), | |
| 123 | - // enum("many_to_one", comment("Foreign key relation is many to one")) | |
| 124 | - // ]), | |
| 121 | +// ds_type("HK_FK_Attr", [ | |
| 122 | +// alternative("searchable", [ | |
| 123 | +// component(list, string, "searchable_fields") | |
| 124 | +// ]) | |
| 125 | +// ]), | |
| 125 | 126 | |
| 126 | 127 | ds_type("HK_Int_Choices", [ |
| 127 | 128 | enum("no_choice", comment("No list choice is available. Hence the user must enter the value")), | ... | ... |
model/fields.anubis
| ... | ... | @@ -152,7 +152,7 @@ public define HK_Model_Field |
| 152 | 152 | ( |
| 153 | 153 | String table_name |
| 154 | 154 | )= |
| 155 | - foreign_key(this, table_name). | |
| 155 | + foreign_key(this, table_name, []). | |
| 156 | 156 | |
| 157 | 157 | public define HK_Model_Field |
| 158 | 158 | text_field |
| ... | ... | @@ -218,7 +218,7 @@ public define JsonValue |
| 218 | 218 | json_member("dt_attribute", json_string(to_String(attr))) |
| 219 | 219 | ], |
| 220 | 220 | |
| 221 | - foreign_key(app_name, table_name) then // foreign key to 'id' in another (or same) table and column_name for choice selector. | |
| 221 | + foreign_key(app_name, table_name,_) then // foreign key to 'id' in another (or same) table and column_name for choice selector. | |
| 222 | 222 | [ json_member("type", json_string("foreign_key")), |
| 223 | 223 | json_member("app_name", to_JSON(app_name)), |
| 224 | 224 | json_member("table_name", json_string(table_name)), | ... | ... |
model/types/hk_model_field.anubis
| 1 | 1 | /* |
| 2 | 2 | * Created by 伝作 (Densaku). |
| 3 | 3 | * Types & Messages generator written by フランスのトトロ aka (David RENÉ) |
| 4 | - * Date: 2017-05-19 | |
| 5 | - * Time: 09:24:24 | |
| 4 | + * Date: 2017-05-24 | |
| 5 | + * Time: 01:57:03 | |
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | |
| ... | ... | @@ -34,7 +34,8 @@ public type HK_Model_Field: |
| 34 | 34 | |
| 35 | 35 | foreign_key( |
| 36 | 36 | HK_App_Name app_name, |
| 37 | - String table_name | |
| 37 | + String table_name, | |
| 38 | + List(String) searchable_fields | |
| 38 | 39 | ), |
| 39 | 40 | integer_field( |
| 40 | 41 | HK_Int_Choices choices //integer of arbitrary size |
| ... | ... | @@ -98,12 +99,14 @@ public define Message |
| 98 | 99 | |
| 99 | 100 | //Alternative foreign_key |
| 100 | 101 | //foreign key to 'id' in another (or same) table and column_name for choice selector) |
| 101 | - foreign_key(_app_name, _table_name) then | |
| 102 | + foreign_key(_app_name, _table_name, __searchable_fields) then | |
| 102 | 103 | forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "foreign_key")); |
| 103 | 104 | // [type = HK_App_Name] foreign_key.app_name |
| 104 | 105 | forget(add_message(_hk_model_field_message, "app_name", to_Message(_app_name))); |
| 105 | 106 | // [type = String] foreign_key.table_name |
| 106 | - forget(add_string(_hk_model_field_message, "table_name", _table_name)), | |
| 107 | + forget(add_string(_hk_model_field_message, "table_name", _table_name)); | |
| 108 | + // [type = List(String)] foreign_key.searchable_fields | |
| 109 | + map_forget((String _searchable_fields) |-> add_string(_hk_model_field_message, "searchable_fields", _searchable_fields), __searchable_fields), | |
| 107 | 110 | |
| 108 | 111 | //Alternative integer_field |
| 109 | 112 | integer_field(_choices) then |
| ... | ... | @@ -198,8 +201,10 @@ public define Maybe(HK_Model_Field) |
| 198 | 201 | if (Maybe(HK_App_Name))from_Message(_app_name__msg) is {failure then failure, success(_app_name_) then |
| 199 | 202 | // [type = String] foreign_key.table_name |
| 200 | 203 | if find_string(_hk_model_field_message, "table_name") is {failure then failure, success(_table_name_) then |
| 204 | + // [type = List(String)] foreign_key.searchable_fields | |
| 205 | + with _searchable_fields_ = find_string_list(_hk_model_field_message, "searchable_fields"), | |
| 201 | 206 | |
| 202 | - success(foreign_key(_app_name_, _table_name_)) | |
| 207 | + success(foreign_key(_app_name_, _table_name_, _searchable_fields_)) | |
| 203 | 208 | }}} |
| 204 | 209 | else //Alternative integer_field |
| 205 | 210 | if __type_alt__ = "integer_field" then //Alternative integer_field | ... | ... |
view/view_table_renderer.anubis