Commit ab0a36e7e3a19edb7d5242cd8a72b50e29639a00
1 parent
c74f1371
add Maybe(target_id) in left menu. If target_id is present, this is means we wan…
…t to use load_content function (loading HTML from server) and put the result in that target_id div
Showing
1 changed file
with
49 additions
and
14 deletions
Show diff stats
web/widgets/left_menu.anubis
| @@ -16,19 +16,23 @@ public type Left_Menu_Entry: | @@ -16,19 +16,23 @@ public type Left_Menu_Entry: | ||
| 16 | List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) | 16 | List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) |
| 17 | WEB_Action_Name action, //action (url to apply when click | 17 | WEB_Action_Name action, //action (url to apply when click |
| 18 | String text, //text to show | 18 | String text, //text to show |
| 19 | - List((String, String)) extra //extra web arguments to send when click | 19 | + List((String, String)) extra, //extra web arguments to send when click |
| 20 | + Maybe(String) target_id //target_id use during load_content | ||
| 20 | ), | 21 | ), |
| 21 | title( //TITLE entry hence no selectable | 22 | title( //TITLE entry hence no selectable |
| 22 | String title_id, //it's also use as icon prefix | 23 | String title_id, //it's also use as icon prefix |
| 23 | List(String) classes, //additional classes if need (change background color, font size, etc.) | 24 | List(String) classes, //additional classes if need (change background color, font size, etc.) |
| 24 | String text //text to show | 25 | String text //text to show |
| 25 | - ). | 26 | + ) |
| 27 | +. | ||
| 26 | 28 | ||
| 27 | public type Left_Menu: | 29 | public type Left_Menu: |
| 28 | no_left_menu, | 30 | no_left_menu, |
| 29 | left_menu( | 31 | left_menu( |
| 30 | List(Left_Menu_Entry) entries, | 32 | List(Left_Menu_Entry) entries, |
| 31 | - String selected). | 33 | + String selected |
| 34 | + ) | ||
| 35 | +. | ||
| 32 | 36 | ||
| 33 | public type Plugin_Left_Menu: | 37 | public type Plugin_Left_Menu: |
| 34 | plugin_left_menu( | 38 | plugin_left_menu( |
| @@ -44,8 +48,8 @@ public define Left_Menu_Entry | @@ -44,8 +48,8 @@ public define Left_Menu_Entry | ||
| 44 | WEB_Action_Name action, | 48 | WEB_Action_Name action, |
| 45 | String text | 49 | String text |
| 46 | )= | 50 | )= |
| 47 | - left_menu_entry(entry_id, [], action, text, []) | ||
| 48 | - . | 51 | + left_menu_entry(entry_id, [], action, text, [], failure) |
| 52 | +. | ||
| 49 | 53 | ||
| 50 | public define Left_Menu_Entry | 54 | public define Left_Menu_Entry |
| 51 | left_menu_entry | 55 | left_menu_entry |
| @@ -54,8 +58,8 @@ public define Left_Menu_Entry | @@ -54,8 +58,8 @@ public define Left_Menu_Entry | ||
| 54 | String action, | 58 | String action, |
| 55 | String text | 59 | String text |
| 56 | )= | 60 | )= |
| 57 | - left_menu_entry(entry_id, [], action_name(action), text, []) | ||
| 58 | - . | 61 | + left_menu_entry(entry_id, [], action_name(action), text, [], failure) |
| 62 | +. | ||
| 59 | 63 | ||
| 60 | public define Left_Menu_Entry | 64 | public define Left_Menu_Entry |
| 61 | left_menu_entry | 65 | left_menu_entry |
| @@ -63,21 +67,45 @@ public define Left_Menu_Entry | @@ -63,21 +67,45 @@ public define Left_Menu_Entry | ||
| 63 | String entry_id, //it's also use as icon prefix | 67 | String entry_id, //it's also use as icon prefix |
| 64 | WEB_Action_Name action, //action (url to apply when click | 68 | WEB_Action_Name action, //action (url to apply when click |
| 65 | String text, //text to show | 69 | String text, //text to show |
| 66 | - List((String, String)) extra //extra web arguments to send when click | 70 | + List((String, String)) extra //extra web arguments to send when click |
| 67 | )= | 71 | )= |
| 68 | - left_menu_entry(entry_id, [], action, text, extra) | ||
| 69 | - . | 72 | + left_menu_entry(entry_id, [], action, text, extra, failure) |
| 73 | +. | ||
| 70 | 74 | ||
| 71 | public define Left_Menu_Entry | 75 | public define Left_Menu_Entry |
| 72 | left_menu_entry | 76 | left_menu_entry |
| 73 | ( | 77 | ( |
| 78 | + String entry_id, //it's also use as icon prefix | ||
| 79 | + WEB_Action_Name action, //action (url to apply when click | ||
| 80 | + String text, //text to show | ||
| 81 | + List((String, String)) extra, //extra web arguments to send when click | ||
| 82 | + String target_id | ||
| 83 | + )= | ||
| 84 | + left_menu_entry(entry_id, [], action, text, extra, success(target_id)) | ||
| 85 | +. | ||
| 86 | + | ||
| 87 | +public define Left_Menu_Entry | ||
| 88 | + left_menu_entry | ||
| 89 | + ( | ||
| 74 | String entry_id, //it's also use as icon prefix | 90 | String entry_id, //it's also use as icon prefix |
| 75 | String action, //action (url to apply when click | 91 | String action, //action (url to apply when click |
| 76 | String text, //text to show | 92 | String text, //text to show |
| 77 | List((String, String)) extra //extra web arguments to send when click | 93 | List((String, String)) extra //extra web arguments to send when click |
| 78 | )= | 94 | )= |
| 79 | - left_menu_entry(entry_id, [], action_name(action), text, extra) | ||
| 80 | - . | 95 | + left_menu_entry(entry_id, [], action_name(action), text, extra, failure) |
| 96 | +. | ||
| 97 | + | ||
| 98 | +public define Left_Menu_Entry | ||
| 99 | + left_menu_entry | ||
| 100 | + ( | ||
| 101 | + String entry_id, //it's also use as icon prefix | ||
| 102 | + String action, //action (url to apply when click | ||
| 103 | + String text, //text to show | ||
| 104 | + List((String, String)) extra, //extra web arguments to send when click | ||
| 105 | + String target_id | ||
| 106 | + )= | ||
| 107 | + left_menu_entry(entry_id, [], action_name(action), text, extra, success(target_id)) | ||
| 108 | +. | ||
| 81 | 109 | ||
| 82 | public define Left_Menu_Entry | 110 | public define Left_Menu_Entry |
| 83 | title | 111 | title |
| @@ -109,8 +137,15 @@ define List(HTML_Off_Form) | @@ -109,8 +137,15 @@ define List(HTML_Off_Form) | ||
| 109 | with entry = | 137 | with entry = |
| 110 | if h is | 138 | if h is |
| 111 | { | 139 | { |
| 112 | - left_menu_entry(_menu_id, _classes, _action, _text, _extra) then | ||
| 113 | - p([class("item "+_menu_id+"_icon"+if _menu_id=selected then " selected" else ""+ " "+join(" ", _classes))],actioner(same,same, link(_T(_text)),_action,_extra)), | 140 | + left_menu_entry(_menu_id, _classes, _action, _text, _extra, _target_id) then |
| 141 | + if _target_id is | ||
| 142 | + { | ||
| 143 | + 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)), | ||
| 144 | + success(target_id) then | ||
| 145 | + p([class("item "+_menu_id+"_icon"+if _menu_id=selected then " selected" else ""+ " "+join(" ", _classes)), | ||
| 146 | + event(onclick, "CalexiumToolBox.ajax_load_content('"+target_id+"', "+format_web_action_name_to_js(_action, _extra)+")")],text(_T(_text))), | ||
| 147 | + } | ||
| 148 | + | ||
| 114 | title(_title_id, _classes, _text) then | 149 | title(_title_id, _classes, _text) then |
| 115 | p([class("menu_title"), class(if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) | 150 | p([class("menu_title"), class(if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) |
| 116 | // p([class("menu_title"), class("item "+_title_id+"_icon"+if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) | 151 | // p([class("menu_title"), class("item "+_title_id+"_icon"+if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) |