Commit 609807d9459e4e0072378c89ba615b127fce1cc6
1 parent
764acb4e
add foreign_key_active_filter
Showing
4 changed files
with
123 additions
and
41 deletions
Show diff stats
ds_files/ds_types.anubis
| ... | ... | @@ -91,8 +91,9 @@ public define List(DS_Type_File) hayamiki_lib_types_description = |
| 91 | 91 | [ |
| 92 | 92 | component(extern_type("HK_App_Name", model_types+"hk_app_name.anubis"), "app_name"), |
| 93 | 93 | component(string, "table_name"), |
| 94 | - component(list, string, "searchable_fields"), | |
| 95 | - component(list, extern_type("HK_Foreign_Key_Clause", model_types+"hk_foreign_key_clause.anubis"), "hk_fk_clause"), | |
| 94 | + component(list, string, "searchable_fields", comment("if that list contain any string, this is means we use the drop down with input field. if one of the string is \"__HK_SHOW_STRING__\" this is means we search also in show_string ")), | |
| 95 | + component(list, extern_type("HK_Foreign_Key_Active_Filter", model_types+"hk_foreign_key_active_filter.anubis"), "hk_fk_active_filter", comment("make dependence of foreign key with another fk entris on current table")), | |
| 96 | + component(list, extern_type("HK_Foreign_Key_Clause", model_types+"hk_foreign_key_clause.anubis"), "hk_fk_clause", comment("on_delete, on_update")), | |
| 96 | 97 | ]), |
| 97 | 98 | alternative("integer_field", [ |
| 98 | 99 | component(extern_type("HK_Int_Choices", model_types+"hk_int_choices.anubis"), "choices", comment("integer of arbitrary size ")), |
| ... | ... | @@ -140,7 +141,14 @@ public define List(DS_Type_File) hayamiki_lib_types_description = |
| 140 | 141 | ]), |
| 141 | 142 | alternative("on_update", [ |
| 142 | 143 | component(extern_type("HK_Foreign_Key_Clause_On_Directive", model_types+"hk_foreign_key_clause_on_directive.anubis"), "on_update") |
| 143 | - ]) | |
| 144 | + ]) | |
| 145 | + ]), | |
| 146 | + | |
| 147 | + ds_type("HK_Foreign_Key_Active_Filter", [ | |
| 148 | + alternative("active_filter", [ | |
| 149 | + component(string, "column"), | |
| 150 | + component(string, "fk_column") | |
| 151 | + ]) | |
| 144 | 152 | ]), |
| 145 | 153 | |
| 146 | 154 | ds_type("HK_Int_Choices", [ |
| ... | ... | @@ -228,8 +236,8 @@ public define List(DS_Type_File) hayamiki_lib_types_description = |
| 228 | 236 | |
| 229 | 237 | ds_type("HK_Filter", [ |
| 230 | 238 | alternative("hk_filter", [ |
| 231 | - component(string, "filter_name"), | |
| 232 | - component(string, "filter_string") | |
| 239 | + component(string, "filter_name", comment("name of the filter which will be display on dropdown")), | |
| 240 | + component(string, "filter_string", comment("filter in sql format after WHERE")) | |
| 233 | 241 | ]) |
| 234 | 242 | ]), |
| 235 | 243 | |
| ... | ... | @@ -253,10 +261,6 @@ public define List(DS_Type_File) hayamiki_lib_types_description = |
| 253 | 261 | |
| 254 | 262 | |
| 255 | 263 | |
| 256 | - | |
| 257 | - | |
| 258 | - | |
| 259 | - | |
| 260 | 264 | ds_type("HK_Editor", [ |
| 261 | 265 | enum("edit_view_all"), |
| 262 | 266 | alternative("edit_view_list_form", [ | ... | ... |
model/fields.anubis
| ... | ... | @@ -188,7 +188,7 @@ public define HK_Model_Field |
| 188 | 188 | ( |
| 189 | 189 | String table_name |
| 190 | 190 | )= |
| 191 | - foreign_key(this, table_name, [], []). | |
| 191 | + foreign_key(this, table_name, [], [], []). | |
| 192 | 192 | |
| 193 | 193 | |
| 194 | 194 | public define HK_Model_Field |
| ... | ... | @@ -197,7 +197,7 @@ public define HK_Model_Field |
| 197 | 197 | HK_App_Name hk_app_name, |
| 198 | 198 | String table_name |
| 199 | 199 | )= |
| 200 | - foreign_key(hk_app_name, table_name, [], []). | |
| 200 | + foreign_key(hk_app_name, table_name, [], [], []). | |
| 201 | 201 | |
| 202 | 202 | public define HK_Model_Field |
| 203 | 203 | foreign_key |
| ... | ... | @@ -206,7 +206,7 @@ public define HK_Model_Field |
| 206 | 206 | String table_name, |
| 207 | 207 | List(String) searchable_fields |
| 208 | 208 | )= |
| 209 | - foreign_key(hk_app_name, table_name, searchable_fields, []). | |
| 209 | + foreign_key(hk_app_name, table_name, searchable_fields, [], []). | |
| 210 | 210 | |
| 211 | 211 | public define HK_Model_Field |
| 212 | 212 | foreign_key |
| ... | ... | @@ -215,7 +215,7 @@ public define HK_Model_Field |
| 215 | 215 | String table_name, |
| 216 | 216 | List(HK_Foreign_Key_Clause) fk_clause |
| 217 | 217 | )= |
| 218 | - foreign_key(hk_app_name, table_name, [], fk_clause). | |
| 218 | + foreign_key(hk_app_name, table_name, [], [], fk_clause). | |
| 219 | 219 | |
| 220 | 220 | public define HK_Model_Field |
| 221 | 221 | foreign_key |
| ... | ... | @@ -223,7 +223,7 @@ public define HK_Model_Field |
| 223 | 223 | String table_name, |
| 224 | 224 | List(String) searchable_fields |
| 225 | 225 | )= |
| 226 | - foreign_key(this, table_name, searchable_fields, []) | |
| 226 | + foreign_key(this, table_name, searchable_fields, [], []) | |
| 227 | 227 | . |
| 228 | 228 | |
| 229 | 229 | public define HK_Model_Field |
| ... | ... | @@ -233,7 +233,7 @@ public define HK_Model_Field |
| 233 | 233 | List(String) searchable_fields, |
| 234 | 234 | List(HK_Foreign_Key_Clause) fk_clause |
| 235 | 235 | )= |
| 236 | - foreign_key(this, table_name, searchable_fields, fk_clause) | |
| 236 | + foreign_key(this, table_name, searchable_fields, [], fk_clause) | |
| 237 | 237 | . |
| 238 | 238 | |
| 239 | 239 | public define HK_Model_Field |
| ... | ... | @@ -242,7 +242,7 @@ public define HK_Model_Field |
| 242 | 242 | String table_name, |
| 243 | 243 | List(HK_Foreign_Key_Clause) fk_clause |
| 244 | 244 | )= |
| 245 | - foreign_key(this, table_name, [], fk_clause) | |
| 245 | + foreign_key(this, table_name, [], [], fk_clause) | |
| 246 | 246 | . |
| 247 | 247 | |
| 248 | 248 | public define HK_Model_Field |
| ... | ... | @@ -309,7 +309,7 @@ public define JsonValue |
| 309 | 309 | json_member("dt_attribute", json_string(to_String(attr))) |
| 310 | 310 | ], |
| 311 | 311 | |
| 312 | - foreign_key(app_name, table_name, _, _) then // foreign key to 'id' in another (or same) table and column_name for choice selector. | |
| 312 | + foreign_key(app_name, table_name, _, _, _) then // foreign key to 'id' in another (or same) table and column_name for choice selector. | |
| 313 | 313 | [ json_member("type", json_string("foreign_key")), |
| 314 | 314 | json_member("app_name", to_JSON(app_name)), |
| 315 | 315 | json_member("table_name", json_string(table_name)), | ... | ... |
| 1 | +/* | |
| 2 | + * Created by 伝作 (Densaku). | |
| 3 | + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 2019-07-14 | |
| 5 | + * Time: 16:15:41 | |
| 6 | + * | |
| 7 | + */ | |
| 8 | + | |
| 9 | +transmit system/muscle.anubis | |
| 10 | +transmit system/convert.anubis | |
| 11 | +transmit tools/basis.anubis | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | +public type HK_Foreign_Key_Active_Filter: | |
| 17 | + active_filter( | |
| 18 | + String column, | |
| 19 | + String fk_column | |
| 20 | + ) | |
| 21 | +. | |
| 22 | + | |
| 23 | + HK_Foreign_Key_Active_Filter message format | |
| 24 | + =========================================== | |
| 25 | + | |
| 26 | + | |
| 27 | +public define Message | |
| 28 | + to_Message | |
| 29 | + ( | |
| 30 | + HK_Foreign_Key_Active_Filter _hk_foreign_key_active_filter | |
| 31 | + )= | |
| 32 | + with _hk_foreign_key_active_filter_message = message((Word32)0), // | |
| 33 | + forget(add_string(_hk_foreign_key_active_filter_message, "__TYPE__", "HK_Foreign_Key_Active_Filter")); | |
| 34 | + if _hk_foreign_key_active_filter is | |
| 35 | + { | |
| 36 | + //Alternative active_filter | |
| 37 | + active_filter(_column, _fk_column) then | |
| 38 | + forget(add_string(_hk_foreign_key_active_filter_message, "__TYPE_ALT__", "active_filter")); | |
| 39 | + // [type = String] active_filter.column | |
| 40 | + forget(add_string(_hk_foreign_key_active_filter_message, "column", _column)); | |
| 41 | + // [type = String] active_filter.fk_column | |
| 42 | + forget(add_string(_hk_foreign_key_active_filter_message, "fk_column", _fk_column)), | |
| 43 | + | |
| 44 | + }; | |
| 45 | + _hk_foreign_key_active_filter_message | |
| 46 | +. | |
| 47 | + | |
| 48 | +public define Maybe(HK_Foreign_Key_Active_Filter) | |
| 49 | + from_Message | |
| 50 | + ( | |
| 51 | + Message _hk_foreign_key_active_filter_message | |
| 52 | + )= | |
| 53 | + if find_string(_hk_foreign_key_active_filter_message, "__TYPE__") is {failure then failure, success(__type__) then | |
| 54 | + if find_string(_hk_foreign_key_active_filter_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then | |
| 55 | + if __type__ = "HK_Foreign_Key_Active_Filter" then | |
| 56 | + //Alternative active_filter | |
| 57 | + if __type_alt__ = "active_filter" then //Alternative active_filter | |
| 58 | + // [type = String] active_filter.column | |
| 59 | + if find_string(_hk_foreign_key_active_filter_message, "column") is {failure then failure, success(_column_) then | |
| 60 | + // [type = String] active_filter.fk_column | |
| 61 | + if find_string(_hk_foreign_key_active_filter_message, "fk_column") is {failure then failure, success(_fk_column_) then | |
| 62 | + | |
| 63 | + success(active_filter(_column_, _fk_column_)) | |
| 64 | + }} | |
| 65 | + else | |
| 66 | + failure //No valid Alternative found ! | |
| 67 | + else | |
| 68 | + failure //Type not found in message ! | |
| 69 | + }} | |
| 70 | +. | |
| 71 | + | ... | ... |
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: 2018-11-10 | |
| 5 | - * Time: 17:14:38 | |
| 4 | + * Date: 2019-07-14 | |
| 5 | + * Time: 16:15:41 | |
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | |
| ... | ... | @@ -15,55 +15,57 @@ transmit hayamiki_lib/model/types/hk_text_field_attr.anubis |
| 15 | 15 | transmit hayamiki_lib/model/types/hk_text_choices.anubis |
| 16 | 16 | transmit hayamiki_lib/model/types/hk_int_choices.anubis |
| 17 | 17 | transmit hayamiki_lib/model/types/hk_foreign_key_clause.anubis |
| 18 | +transmit hayamiki_lib/model/types/hk_foreign_key_active_filter.anubis | |
| 18 | 19 | transmit hayamiki_lib/model/types/hk_app_name.anubis |
| 19 | 20 | transmit hayamiki_lib/model/types/hk_datetime_field_attr.anubis |
| 20 | 21 | |
| 21 | 22 | |
| 22 | 23 | |
| 23 | 24 | public type HK_Model_Field: |
| 24 | - p_key, | |
| 25 | - boolean_field, //true or false | |
| 25 | + p_key, | |
| 26 | + boolean_field, //true or false | |
| 26 | 27 | date_field( |
| 27 | - HK_Datetime_Field_Attr hk_dt_f_attr //date with the precision of the day | |
| 28 | + HK_Datetime_Field_Attr hk_dt_f_attr //date with the precision of the day | |
| 28 | 29 | ), |
| 29 | 30 | time_field( |
| 30 | - HK_Datetime_Field_Attr hk_dt_f_attr //time with the precision of the second | |
| 31 | + HK_Datetime_Field_Attr hk_dt_f_attr //time with the precision of the second | |
| 31 | 32 | ), |
| 32 | 33 | datetime_field( |
| 33 | - HK_Datetime_Field_Attr hk_dt_f_attr //datetime with the precision of the second | |
| 34 | + HK_Datetime_Field_Attr hk_dt_f_attr //datetime with the precision of the second | |
| 34 | 35 | ), |
| 35 | 36 | //foreign key to 'id' in another (or same) table and column_name for choice selector) |
| 36 | 37 | |
| 37 | 38 | foreign_key( |
| 38 | - HK_App_Name app_name, | |
| 39 | - String table_name, | |
| 40 | - List(String) searchable_fields, | |
| 41 | - List(HK_Foreign_Key_Clause) hk_fk_clause | |
| 39 | + HK_App_Name app_name, | |
| 40 | + String table_name, | |
| 41 | + List(String) searchable_fields, //if that list contain any string, this is means we use the drop down with input field. if one of the string is "__HK_SHOW_STRING__" this is means we search also in show_string | |
| 42 | + List(HK_Foreign_Key_Active_Filter) hk_fk_active_filter, //make dependence of foreign key with another fk entris on current table | |
| 43 | + List(HK_Foreign_Key_Clause) hk_fk_clause //on_delete, on_update | |
| 42 | 44 | ), |
| 43 | 45 | integer_field( |
| 44 | - HK_Int_Choices choices //integer of arbitrary size | |
| 46 | + HK_Int_Choices choices //integer of arbitrary size | |
| 45 | 47 | ), |
| 46 | - float_field, | |
| 48 | + float_field, | |
| 47 | 49 | char_field( |
| 48 | - HK_Text_Choices choices, | |
| 49 | - Int size //text of maximal size 'size' (number of characters) | |
| 50 | + HK_Text_Choices choices, | |
| 51 | + Int size //text of maximal size 'size' (number of characters) | |
| 50 | 52 | ), |
| 51 | 53 | password_field( |
| 52 | - Int min_size //the password field doesn't show the password string or store it in hashed version into database | |
| 54 | + Int min_size //the password field doesn't show the password string or store it in hashed version into database | |
| 53 | 55 | ), |
| 54 | 56 | //text of variable size |
| 55 | 57 | |
| 56 | 58 | text_field( |
| 57 | - HK_Text_Field_Attr hk_text_field_attr | |
| 59 | + HK_Text_Field_Attr hk_text_field_attr | |
| 58 | 60 | ), |
| 59 | - color_field, //String which representing RGBA color like HTML | |
| 61 | + color_field, //String which representing RGBA color like HTML | |
| 60 | 62 | //phone field |
| 61 | 63 | |
| 62 | 64 | phone_field( |
| 63 | - HK_Phone_Field_Attr hk_ph_f_attr //phone line number type like (cellphone, landline, fax, etc) | |
| 65 | + HK_Phone_Field_Attr hk_ph_f_attr //phone line number type like (cellphone, landline, fax, etc) | |
| 64 | 66 | ), |
| 65 | - url_field, //url field for website and so forth | |
| 66 | - email_field //email field | |
| 67 | + url_field, //url field for website and so forth | |
| 68 | + email_field //email field | |
| 67 | 69 | . |
| 68 | 70 | |
| 69 | 71 | HK_Model_Field message format |
| ... | ... | @@ -107,7 +109,7 @@ public define Message |
| 107 | 109 | |
| 108 | 110 | //Alternative foreign_key |
| 109 | 111 | //foreign key to 'id' in another (or same) table and column_name for choice selector) |
| 110 | - foreign_key(_app_name, _table_name, __searchable_fields, __hk_fk_clause) then | |
| 112 | + foreign_key(_app_name, _table_name, __searchable_fields, __hk_fk_active_filter, __hk_fk_clause) then | |
| 111 | 113 | forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "foreign_key")); |
| 112 | 114 | // [type = HK_App_Name] foreign_key.app_name |
| 113 | 115 | forget(add_message(_hk_model_field_message, "app_name", to_Message(_app_name))); |
| ... | ... | @@ -115,6 +117,8 @@ public define Message |
| 115 | 117 | forget(add_string(_hk_model_field_message, "table_name", _table_name)); |
| 116 | 118 | // [type = List(String)] foreign_key.searchable_fields |
| 117 | 119 | map_forget((String _searchable_fields) |-> add_string(_hk_model_field_message, "searchable_fields", _searchable_fields), __searchable_fields); |
| 120 | + // [type = List(HK_Foreign_Key_Active_Filter)] foreign_key.hk_fk_active_filter | |
| 121 | + map_forget((HK_Foreign_Key_Active_Filter _hk_fk_active_filter) |-> add_message(_hk_model_field_message, "hk_fk_active_filter", to_Message(_hk_fk_active_filter)), __hk_fk_active_filter); | |
| 118 | 122 | // [type = List(HK_Foreign_Key_Clause)] foreign_key.hk_fk_clause |
| 119 | 123 | map_forget((HK_Foreign_Key_Clause _hk_fk_clause) |-> add_message(_hk_model_field_message, "hk_fk_clause", to_Message(_hk_fk_clause)), __hk_fk_clause), |
| 120 | 124 | |
| ... | ... | @@ -220,12 +224,15 @@ public define Maybe(HK_Model_Field) |
| 220 | 224 | if find_string(_hk_model_field_message, "table_name") is {failure then failure, success(_table_name_) then |
| 221 | 225 | // [type = List(String)] foreign_key.searchable_fields |
| 222 | 226 | with _searchable_fields_ = find_string_list(_hk_model_field_message, "searchable_fields"), |
| 227 | + // [type = List(HK_Foreign_Key_Active_Filter)] foreign_key.hk_fk_active_filter | |
| 228 | + with mb__hk_fk_active_filter_ = map_escape(( Message msg ) |-> (Maybe(HK_Foreign_Key_Active_Filter)) from_Message(msg), find_messages(_hk_model_field_message, "hk_fk_active_filter")), | |
| 229 | + if mb__hk_fk_active_filter_ is {failure then failure, success(_hk_fk_active_filter_) then | |
| 223 | 230 | // [type = List(HK_Foreign_Key_Clause)] foreign_key.hk_fk_clause |
| 224 | 231 | with mb__hk_fk_clause_ = map_escape(( Message msg ) |-> (Maybe(HK_Foreign_Key_Clause)) from_Message(msg), find_messages(_hk_model_field_message, "hk_fk_clause")), |
| 225 | 232 | if mb__hk_fk_clause_ is {failure then failure, success(_hk_fk_clause_) then |
| 226 | 233 | |
| 227 | - success(foreign_key(_app_name_, _table_name_, _searchable_fields_, _hk_fk_clause_)) | |
| 228 | - }}}} | |
| 234 | + success(foreign_key(_app_name_, _table_name_, _searchable_fields_, _hk_fk_active_filter_, _hk_fk_clause_)) | |
| 235 | + }}}}} | |
| 229 | 236 | else //Alternative integer_field |
| 230 | 237 | if __type_alt__ = "integer_field" then //Alternative integer_field |
| 231 | 238 | // [type = HK_Int_Choices] integer_field.choices | ... | ... |