diff --git a/types/model/display.anubis b/types/model/display.anubis index b9b2c43..d4f9557 100644 --- a/types/model/display.anubis +++ b/types/model/display.anubis @@ -17,8 +17,8 @@ public type HK_List_View: public define HK_List_View list_view ( - String view_name, - List(String) columns + String view_name, + List(String) columns )= list_view(view_name, columns, ""). @@ -63,20 +63,57 @@ public type HK_Edit_View: edit_view_all, edit_view(String view_name, List(String) columns). +public define Message + to_Message + ( + HK_Edit_View edit_view + )= + with _msg = message(_HK_EDIT_VIEW), + if edit_view is + { + edit_view_all then forget(add_string(_msg, "type", "edit_view_all")), + edit_view(name, columns) then + forget(add_string(_msg, "type", "list_view")); + forget(add_string(_msg, "view_name", name)); + map_forget((String column) |-> forget(add_string(_msg, "columns", column)), columns) + }; + _msg + . + +public define Maybe(HK_Edit_View) + from_Message + ( + Message msg + )= + if *msg.what = _HK_EDIT_VIEW then + if find_string(msg, "type") is {failure then failure, success(type) then + if type = "edit_view_all" then success(edit_view_all) else + if type = "edit_view" then + if find_string(msg, "view_name") is {failure then failure, success(view_name) then + with columns = find_strings(msg, "columns"), + success(edit_view(view_name, columns))} + else + failure + } + else + failure + . + _HK_MODEL_DISPLAY message format: ========================= The message string name is "hk_display" +--------------+---------------+-------------------------------- | name | type | description +--------------+---------------+-------------------------------- - | "edits" | List(String) | List of columns for edit panel + | "list_edits" | List(Message) | List of (edit list) the Message id is _HK_EDIT_VIEW | "list_views" | List(Message) | List of (view list) the Message id is _HK_LIST_VIEW public type HK_Display: hk_display(List(HK_List_View) list_views, - //List(HK_Edit_View) edit_views - List(String)). + List(HK_Edit_View) list_edits + //List(String) + ). public define Message to_Message @@ -84,9 +121,10 @@ public define Message HK_Display display )= with hk_display_msg = message(_HK_MODEL_DISPLAY), - since display is hk_display(list_views, list_edit), + since display is hk_display(list_views, list_edits), map_forget((HK_List_View _view) |-> add_message(hk_display_msg, "list_views", to_Message(_view)), list_views); - map_forget((String _str) |-> add_string(hk_display_msg, "edits", _str), list_edit); + map_forget((HK_Edit_View _edit) |-> add_message(hk_display_msg, "list_edits", to_Message(_edit)), list_edits); +// map_forget((String _str) |-> add_string(hk_display_msg, "edits", _str), list_edit); hk_display_msg . @@ -98,10 +136,17 @@ public define Maybe(HK_Display) if find_message(msg, "hk_display") is { failure then failure, success(msg_hk_display) then if *msg_hk_display.what = _HK_MODEL_DISPLAY then with view_list = map_escape((Message _msg) |-> (Maybe(HK_List_View))from_Message(_msg), find_messages(msg_hk_display, "list_views")), + with edit_list = map_escape((Message _msg) |-> (Maybe(HK_Edit_View))from_Message(_msg), find_messages(msg_hk_display, "list_edits")), if view_list is { failure then failure, - success(list_views) then success(hk_display(list_views, find_strings(msg, "edits"))) + success(list_views) then + if edit_list is + { + failure then failure, + success(list_edits) then + success(hk_display(list_views, list_edits)) + } } else failure -- libgit2 0.21.4