From ab0a36e7e3a19edb7d5242cd8a72b50e29639a00 Mon Sep 17 00:00:00 2001 From: totoro Date: Mon, 6 Aug 2018 00:44:30 +0200 Subject: [PATCH] add Maybe(target_id) in left menu. If target_id is present, this is means we want to use load_content function (loading HTML from server) and put the result in that target_id div --- web/widgets/left_menu.anubis | 63 +++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/web/widgets/left_menu.anubis b/web/widgets/left_menu.anubis index f00e6cd..572ebf7 100644 --- a/web/widgets/left_menu.anubis +++ b/web/widgets/left_menu.anubis @@ -16,19 +16,23 @@ public type Left_Menu_Entry: List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) WEB_Action_Name action, //action (url to apply when click String text, //text to show - List((String, String)) extra //extra web arguments to send when click + List((String, String)) extra, //extra web arguments to send when click + Maybe(String) target_id //target_id use during load_content ), title( //TITLE entry hence no selectable String title_id, //it's also use as icon prefix List(String) classes, //additional classes if need (change background color, font size, etc.) String text //text to show - ). + ) +. public type Left_Menu: no_left_menu, left_menu( List(Left_Menu_Entry) entries, - String selected). + String selected + ) +. public type Plugin_Left_Menu: plugin_left_menu( @@ -44,8 +48,8 @@ public define Left_Menu_Entry WEB_Action_Name action, String text )= - left_menu_entry(entry_id, [], action, text, []) - . + left_menu_entry(entry_id, [], action, text, [], failure) +. public define Left_Menu_Entry left_menu_entry @@ -54,8 +58,8 @@ public define Left_Menu_Entry String action, String text )= - left_menu_entry(entry_id, [], action_name(action), text, []) - . + left_menu_entry(entry_id, [], action_name(action), text, [], failure) +. public define Left_Menu_Entry left_menu_entry @@ -63,21 +67,45 @@ public define Left_Menu_Entry String entry_id, //it's also use as icon prefix WEB_Action_Name action, //action (url to apply when click String text, //text to show - List((String, String)) extra //extra web arguments to send when click + List((String, String)) extra //extra web arguments to send when click )= - left_menu_entry(entry_id, [], action, text, extra) - . + left_menu_entry(entry_id, [], action, text, extra, failure) +. public define Left_Menu_Entry left_menu_entry ( + String entry_id, //it's also use as icon prefix + WEB_Action_Name action, //action (url to apply when click + String text, //text to show + List((String, String)) extra, //extra web arguments to send when click + String target_id + )= + left_menu_entry(entry_id, [], action, text, extra, success(target_id)) +. + +public define Left_Menu_Entry + left_menu_entry + ( String entry_id, //it's also use as icon prefix String action, //action (url to apply when click String text, //text to show List((String, String)) extra //extra web arguments to send when click )= - left_menu_entry(entry_id, [], action_name(action), text, extra) - . + left_menu_entry(entry_id, [], action_name(action), text, extra, failure) +. + +public define Left_Menu_Entry + left_menu_entry + ( + String entry_id, //it's also use as icon prefix + String action, //action (url to apply when click + String text, //text to show + List((String, String)) extra, //extra web arguments to send when click + String target_id + )= + left_menu_entry(entry_id, [], action_name(action), text, extra, success(target_id)) +. public define Left_Menu_Entry title @@ -109,8 +137,15 @@ define List(HTML_Off_Form) with entry = if h is { - left_menu_entry(_menu_id, _classes, _action, _text, _extra) then - p([class("item "+_menu_id+"_icon"+if _menu_id=selected then " selected" else ""+ " "+join(" ", _classes))],actioner(same,same, link(_T(_text)),_action,_extra)), + left_menu_entry(_menu_id, _classes, _action, _text, _extra, _target_id) then + if _target_id is + { + failure then p([class("item "+_menu_id+"_icon"+if _menu_id=selected then " selected" else ""+ " "+join(" ", _classes))],actioner(same,same, link(_T(_text)),_action,_extra)), + success(target_id) then + p([class("item "+_menu_id+"_icon"+if _menu_id=selected then " selected" else ""+ " "+join(" ", _classes)), + event(onclick, "CalexiumToolBox.ajax_load_content('"+target_id+"', "+format_web_action_name_to_js(_action, _extra)+")")],text(_T(_text))), + } + title(_title_id, _classes, _text) then p([class("menu_title"), class(if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) // p([class("menu_title"), class("item "+_title_id+"_icon"+if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) -- libgit2 0.21.4