Commit ea1efe8b2abb5813464c7399d767aee6c0545475
1 parent
c6fff2c0
add foreign key view in edit view
Showing
23 changed files
with
166 additions
and
49 deletions
Show diff stats
ds_files/ds_types.anubis
| ... | ... | @@ -87,6 +87,7 @@ public define List(DS_Type) hayamiki_lib_types_description = |
| 87 | 87 | [ |
| 88 | 88 | component(extern_type("HK_App_Name", model_types+"hk_app_name.anubis"), "app_name"), |
| 89 | 89 | component(string, "table_name"), |
| 90 | + //component(extern_type("HK_FK_Attr", model_types+"hk_fk_attr.anubis"), "fk_attr"), | |
| 90 | 91 | ]), |
| 91 | 92 | alternative("integer_field", [ |
| 92 | 93 | component(extern_type("HK_Int_Choices", model_types+"hk_int_choices.anubis"), "choices", comment("integer of arbitrary size ")), |
| ... | ... | @@ -110,6 +111,11 @@ public define List(DS_Type) hayamiki_lib_types_description = |
| 110 | 111 | enum("none", comment("Nothing special, normal behaviour")), |
| 111 | 112 | enum("rich_editor", comment("Use richt text editor for that area")) |
| 112 | 113 | ]), |
| 114 | + | |
| 115 | +// ds_type("HK_FK_Attr", [ | |
| 116 | +// enum("one_to_one", comment("Foreign key relation is one to one")), | |
| 117 | +// enum("many_to_one", comment("Foreign key relation is many to one")) | |
| 118 | +// ]), | |
| 113 | 119 | |
| 114 | 120 | ds_type("HK_Int_Choices", [ |
| 115 | 121 | enum("no_choice", comment("No list choice is available. Hence the user must enter the value")), |
| ... | ... | @@ -178,6 +184,8 @@ public define List(DS_Type) hayamiki_lib_types_description = |
| 178 | 184 | ]) |
| 179 | 185 | ]), |
| 180 | 186 | |
| 187 | + | |
| 188 | + | |
| 181 | 189 | ds_type("HK_List_View", [ |
| 182 | 190 | enum("list_view_all"), |
| 183 | 191 | alternative("list_view", [ |
| ... | ... | @@ -186,12 +194,21 @@ public define List(DS_Type) hayamiki_lib_types_description = |
| 186 | 194 | component(extern_type("WEB_Action_Name", "calexium_lib/web/types/web_action_name.anubis"), "link_id_action") |
| 187 | 195 | ]) |
| 188 | 196 | ]), |
| 189 | - | |
| 197 | + | |
| 198 | + ds_type("HK_FK_View", [ | |
| 199 | + alternative("fk_view", [ | |
| 200 | + component(extern_type("HK_App_Name", model_types+"hk_app_name.anubis"), "app_name"), | |
| 201 | + component(string, "table_name"), | |
| 202 | + component(string, "fk_col_name", comment("column name of the foreign key. The column name must exists in the hk_model")), | |
| 203 | + ]) | |
| 204 | + ]), | |
| 205 | + | |
| 190 | 206 | ds_type("HK_Edit_View", [ |
| 191 | 207 | enum("edit_view_all"), |
| 192 | 208 | alternative("edit_view", [ |
| 193 | 209 | component(string, "view_name"), |
| 194 | - component(list, string, "columns") | |
| 210 | + component(list, string, "columns"), | |
| 211 | + component(list, extern_type("HK_FK_View", model_types+"hk_fk_view.anubis"), "fk_view") | |
| 195 | 212 | ]) |
| 196 | 213 | ]), |
| 197 | 214 | ... | ... |
model/display.anubis
| ... | ... | @@ -14,6 +14,7 @@ transmit calexium_lib/web/CXM_json.anubis |
| 14 | 14 | transmit hayamiki_lib/model/types/hk_display.anubis |
| 15 | 15 | transmit hayamiki_lib/model/types/hk_list_view.anubis |
| 16 | 16 | transmit hayamiki_lib/model/types/hk_edit_view.anubis |
| 17 | +transmit hayamiki_lib/model/types/hk_fk_view.anubis | |
| 17 | 18 | transmit hayamiki_lib/model/types/hk_icon.anubis |
| 18 | 19 | |
| 19 | 20 | public define HK_List_View |
| ... | ... | @@ -25,6 +26,16 @@ public define HK_List_View |
| 25 | 26 | list_view(view_name, columns, no_action). |
| 26 | 27 | |
| 27 | 28 | |
| 29 | +public define HK_Edit_View | |
| 30 | + edit_view | |
| 31 | + ( | |
| 32 | + String view_name, | |
| 33 | + List(String) columns | |
| 34 | + )= | |
| 35 | + edit_view(view_name, columns, []) | |
| 36 | +. | |
| 37 | + | |
| 38 | + | |
| 28 | 39 | public define JsonValue |
| 29 | 40 | to_JSON |
| 30 | 41 | ( | ... | ... |
model/types/hk_app.anubis
model/types/hk_app_name.anubis
model/types/hk_database.anubis
model/types/hk_datetime_field_attr.anubis
model/types/hk_display.anubis
model/types/hk_edit_view.anubis
| 1 | 1 | /* |
| 2 | 2 | * Created by 伝作 (Densaku). |
| 3 | 3 | * Types & Messages generator written by フランスのトトロ aka (David RENÉ) |
| 4 | - * Date: 2017-03-15 | |
| 5 | - * Time: 02:24:20 | |
| 4 | + * Date: 2017-03-18 | |
| 5 | + * Time: 23:38:31 | |
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | |
| ... | ... | @@ -10,12 +10,14 @@ transmit system/muscle.anubis |
| 10 | 10 | transmit system/convert.anubis |
| 11 | 11 | transmit tools/basis.anubis |
| 12 | 12 | |
| 13 | +transmit hayamiki_lib/model/types/hk_fk_view.anubis | |
| 13 | 14 | |
| 14 | 15 | public type HK_Edit_View: |
| 15 | - edit_view_all, | |
| 16 | + edit_view_all, | |
| 16 | 17 | edit_view( |
| 17 | - String view_name, | |
| 18 | - List(String) columns | |
| 18 | + String view_name, | |
| 19 | + List(String) columns, | |
| 20 | + List(HK_FK_View) fk_view | |
| 19 | 21 | ) |
| 20 | 22 | . |
| 21 | 23 | |
| ... | ... | @@ -37,12 +39,14 @@ public define Message |
| 37 | 39 | forget(add_string(_hk_edit_view_message, "__TYPE_ALT__", "edit_view_all")), |
| 38 | 40 | |
| 39 | 41 | //Alternative edit_view |
| 40 | - edit_view(_view_name, __columns) then | |
| 42 | + edit_view(_view_name, __columns, __fk_view) then | |
| 41 | 43 | forget(add_string(_hk_edit_view_message, "__TYPE_ALT__", "edit_view")); |
| 42 | 44 | // [type = String] edit_view.view_name |
| 43 | 45 | forget(add_string(_hk_edit_view_message, "view_name", _view_name)); |
| 44 | 46 | // [type = List(String)] edit_view.columns |
| 45 | - map_forget((String _columns) |-> add_string(_hk_edit_view_message, "columns", _columns), __columns), | |
| 47 | + map_forget((String _columns) |-> add_string(_hk_edit_view_message, "columns", _columns), __columns); | |
| 48 | + // [type = List(HK_FK_View)] edit_view.fk_view | |
| 49 | + map_forget((HK_FK_View _fk_view) |-> add_message(_hk_edit_view_message, "fk_view", to_Message(_fk_view)), __fk_view), | |
| 46 | 50 | |
| 47 | 51 | }; |
| 48 | 52 | _hk_edit_view_message |
| ... | ... | @@ -65,9 +69,12 @@ public define Maybe(HK_Edit_View) |
| 65 | 69 | if find_string(_hk_edit_view_message, "view_name") is {failure then failure, success(view_name) then |
| 66 | 70 | // [type = List(String)] edit_view.columns |
| 67 | 71 | with columns = find_string_list(_hk_edit_view_message, "columns"), |
| 72 | + // [type = List(HK_FK_View)] edit_view.fk_view | |
| 73 | + with mb_fk_view = map_escape(( Message msg ) |-> (Maybe(HK_FK_View)) from_Message(msg), find_messages(_hk_edit_view_message, "fk_view")), | |
| 74 | + if mb_fk_view is {failure then failure, success(fk_view) then | |
| 68 | 75 | |
| 69 | - success(edit_view(view_name, columns)) | |
| 70 | - } | |
| 76 | + success(edit_view(view_name, columns, fk_view)) | |
| 77 | + }} | |
| 71 | 78 | else |
| 72 | 79 | failure //No valid Alternative found ! |
| 73 | 80 | else | ... | ... |
| 1 | +/* | |
| 2 | + * Created by 伝作 (Densaku). | |
| 3 | + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 2017-03-18 | |
| 5 | + * Time: 23:38:31 | |
| 6 | + * | |
| 7 | + */ | |
| 8 | + | |
| 9 | +transmit system/muscle.anubis | |
| 10 | +transmit system/convert.anubis | |
| 11 | +transmit tools/basis.anubis | |
| 12 | + | |
| 13 | +transmit hayamiki_lib/model/types/hk_app_name.anubis | |
| 14 | + | |
| 15 | +public type HK_FK_View: | |
| 16 | + fk_view( | |
| 17 | + HK_App_Name app_name, | |
| 18 | + String table_name, | |
| 19 | + String fk_col_name //column name of the foreign key. The column name must exists in the hk_model | |
| 20 | + ) | |
| 21 | +. | |
| 22 | + | |
| 23 | + HK_FK_View message format | |
| 24 | + ========================= | |
| 25 | + | |
| 26 | + | |
| 27 | +public define Message | |
| 28 | + to_Message | |
| 29 | + ( | |
| 30 | + HK_FK_View _hk_fk_view | |
| 31 | + )= | |
| 32 | + with _hk_fk_view_message = message((Word32)0), // | |
| 33 | + forget(add_string(_hk_fk_view_message, "__TYPE__", "HK_FK_View")); | |
| 34 | + if _hk_fk_view is | |
| 35 | + { | |
| 36 | + //Alternative fk_view | |
| 37 | + fk_view(_app_name, _table_name, _fk_col_name) then | |
| 38 | + forget(add_string(_hk_fk_view_message, "__TYPE_ALT__", "fk_view")); | |
| 39 | + // [type = HK_App_Name] fk_view.app_name | |
| 40 | + forget(add_message(_hk_fk_view_message, "app_name", to_Message(_app_name))); | |
| 41 | + // [type = String] fk_view.table_name | |
| 42 | + forget(add_string(_hk_fk_view_message, "table_name", _table_name)); | |
| 43 | + // [type = String] fk_view.fk_col_name | |
| 44 | + forget(add_string(_hk_fk_view_message, "fk_col_name", _fk_col_name)), | |
| 45 | + | |
| 46 | + }; | |
| 47 | + _hk_fk_view_message | |
| 48 | +. | |
| 49 | + | |
| 50 | +public define Maybe(HK_FK_View) | |
| 51 | + from_Message | |
| 52 | + ( | |
| 53 | + Message _hk_fk_view_message | |
| 54 | + )= | |
| 55 | + if find_string(_hk_fk_view_message, "__TYPE__") is {failure then failure, success(__type__) then | |
| 56 | + if find_string(_hk_fk_view_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then | |
| 57 | + if __type__ = "HK_FK_View" then | |
| 58 | + //Alternative fk_view | |
| 59 | + if __type_alt__ = "fk_view" then //Alternative fk_view | |
| 60 | + // [type = HK_App_Name] fk_view.app_name | |
| 61 | + if find_message(_hk_fk_view_message, "app_name") is {failure then failure, success(app_name_msg) then | |
| 62 | + if (Maybe(HK_App_Name))from_Message(app_name_msg) is {failure then failure, success(app_name) then | |
| 63 | + // [type = String] fk_view.table_name | |
| 64 | + if find_string(_hk_fk_view_message, "table_name") is {failure then failure, success(table_name) then | |
| 65 | + // [type = String] fk_view.fk_col_name | |
| 66 | + if find_string(_hk_fk_view_message, "fk_col_name") is {failure then failure, success(fk_col_name) then | |
| 67 | + | |
| 68 | + success(fk_view(app_name, table_name, fk_col_name)) | |
| 69 | + }}}} | |
| 70 | + else | |
| 71 | + failure //No valid Alternative found ! | |
| 72 | + else | |
| 73 | + failure //Type not found in message ! | |
| 74 | + }} | |
| 75 | +. | |
| 76 | + | ... | ... |
model/types/hk_help_text.anubis
model/types/hk_icon.anubis
model/types/hk_int_choice.anubis
model/types/hk_int_choices.anubis
model/types/hk_list_view.anubis
model/types/hk_model.anubis
model/types/hk_model_attr.anubis
model/types/hk_model_column.anubis
model/types/hk_model_field.anubis
model/types/hk_table.anubis
model/types/hk_text_choice.anubis
model/types/hk_text_choices.anubis
model/types/hk_text_field_attr.anubis
view/view_table_types.anubis
| ... | ... | @@ -39,9 +39,15 @@ public define VT_edit_entry float(String s_name, String c_name, Float value) |
| 39 | 39 | public define VT_edit_entry information(String s_name, String c_name, String v_name, HK_Help_Text help) = information(s_name, c_name, v_name, 0, help). |
| 40 | 40 | |
| 41 | 41 | |
| 42 | -public type VT_edit: | |
| 43 | - vt_edit(String table_name, String view_name, List(VT_edit_entry) list). | |
| 42 | +public type HK_V_Edit_Tab: | |
| 43 | + hk_v_edit_tab(String fk_table_name, String fk_col_name, String list_view_name) | |
| 44 | +. | |
| 44 | 45 | |
| 46 | +public type VT_edit: | |
| 47 | + vt_edit(String table_name, String view_name, List(VT_edit_entry) list, List(HK_V_Edit_Tab) tabs). | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 45 | 51 | public type VT_view_entry: |
| 46 | 52 | text(String text), |
| 47 | 53 | link(String id, String text), | ... | ... |