liquid_feedback_frontend
annotate env/ui/tabs.lua @ 75:733f65c0c0a0
Bugfixes, feature enhancements, code-cleanup, and major work on API
Details:
- API
-- Allow relation name to be passed to helper function util.autoapi{...}
-- Added area API
-- Bugfixes in API
--- Correctly return initiatives (bug #162)
--- Correctly process "id" parameter for initiative API
--- Bugfix related to "state" parameter (bug #165)
--- Changed constant "discussion" to "accepted" (in model/issue.lua, used by API)
--- Fixed JSON encoding in auto_api (bug #181)
--- Ignore list filter "voted" in case of public access
--- Enable access to API without session
- Work on RSS feed (incomplete yet)
- Other bugfixes
-- Handle empty browser identification string
-- Handle invalid date in member/update.lua (bugs #24 #109 #115 #136)
-- Better handle errors while converting uploaded images. (bug #79 +5 duplicates)
-- Don't display revoked initiatives in list of new drafts (bug #134)
-- Fixed syntax error in app/main/member/_action/update_name.lua throwing unexpected error, when new name was too short
-- Do not display refresh support button for revoked initiatives
-- Repaired issue search (bug #150)
-- Fixed typos in german translation files
--- "initi(i)erte"
--- "Er(g)eignisse" (bug #161)
- Code cleanup
-- Removed deprecated motd files locale/motd/de.txt and locale/motd/de_public.txt
-- Removed redundant code in app/main/index/_updated_drafts.lua
- New features and (optical) enhancements
-- Support change of notify email; notification of not approved address added to start page
-- Settings dialog splitted into single pages
-- Mark deactivated members
-- Calendar for birthday selection in profile
-- Policy list public readable when public access is enabled
Details:
- API
-- Allow relation name to be passed to helper function util.autoapi{...}
-- Added area API
-- Bugfixes in API
--- Correctly return initiatives (bug #162)
--- Correctly process "id" parameter for initiative API
--- Bugfix related to "state" parameter (bug #165)
--- Changed constant "discussion" to "accepted" (in model/issue.lua, used by API)
--- Fixed JSON encoding in auto_api (bug #181)
--- Ignore list filter "voted" in case of public access
--- Enable access to API without session
- Work on RSS feed (incomplete yet)
- Other bugfixes
-- Handle empty browser identification string
-- Handle invalid date in member/update.lua (bugs #24 #109 #115 #136)
-- Better handle errors while converting uploaded images. (bug #79 +5 duplicates)
-- Don't display revoked initiatives in list of new drafts (bug #134)
-- Fixed syntax error in app/main/member/_action/update_name.lua throwing unexpected error, when new name was too short
-- Do not display refresh support button for revoked initiatives
-- Repaired issue search (bug #150)
-- Fixed typos in german translation files
--- "initi(i)erte"
--- "Er(g)eignisse" (bug #161)
- Code cleanup
-- Removed deprecated motd files locale/motd/de.txt and locale/motd/de_public.txt
-- Removed redundant code in app/main/index/_updated_drafts.lua
- New features and (optical) enhancements
-- Support change of notify email; notification of not approved address added to start page
-- Settings dialog splitted into single pages
-- Mark deactivated members
-- Calendar for birthday selection in profile
-- Policy list public readable when public access is enabled
| author | bsw | 
|---|---|
| date | Thu Jul 08 18:44:02 2010 +0200 (2010-07-08) | 
| parents | 4f39f0a0d5b5 | 
| children | d4b4adb9a4df | 
| rev | line source | 
|---|---|
| bsw/jbe@19 | 1 if config.user_tab_mode == "accordeon" or config.user_tab_mode == "accordeon_first_expanded" or config.user_tab_mode == "accordeon_all_expanded" then | 
| bsw/jbe@19 | 2 | 
| bsw/jbe@19 | 3 function ui.tabs(tabs) | 
| bsw/jbe@19 | 4 local params = param.get_all_cgi() | 
| bsw/jbe@19 | 5 local current_tabs_string = params["tab"] | 
| bsw/jbe@19 | 6 local current_tabs = {} | 
| bsw/jbe@19 | 7 if current_tabs_string then | 
| bsw/jbe@19 | 8 for current_tab in current_tabs_string:gmatch("([^%|]+)") do | 
| bsw/jbe@19 | 9 current_tabs[current_tab] = current_tab | 
| bsw/jbe@19 | 10 end | 
| bsw/jbe@19 | 11 end | 
| bsw/jbe@19 | 12 | 
| bsw/jbe@19 | 13 local unique_string = param.get("tab_id") or multirand.string(16, '0123456789abcdef') | 
| bsw/jbe@19 | 14 | 
| bsw/jbe@19 | 15 function render_tab(tab, first) | 
| bsw/jbe@0 | 16 local params = param.get_all_cgi() | 
| bsw/jbe@19 | 17 local active = false | 
| bsw/jbe@19 | 18 for current_tab in pairs(current_tabs) do | 
| bsw/jbe@19 | 19 if tab.name == current_tab then | 
| bsw/jbe@19 | 20 active = true | 
| bsw/jbe@19 | 21 end | 
| bsw/jbe@19 | 22 end | 
| bsw/jbe@19 | 23 if config.user_tab_mode == "accordeon_first_expanded" then | 
| bsw/jbe@19 | 24 if first and current_tabs_string == nil then | 
| bsw/jbe@19 | 25 active = true | 
| bsw/jbe@19 | 26 end | 
| bsw/jbe@19 | 27 end | 
| bsw/jbe@19 | 28 local link_tabs = {} | 
| bsw/jbe@19 | 29 if config.user_tab_mode == "accordeon" | 
| bsw/jbe@19 | 30 or config.user_tab_mode == "accordeon_first_expanded" | 
| bsw/jbe@19 | 31 or config.user_tab_mode == "accordeon_all_expanded" and current_tabs_string | 
| bsw/jbe@19 | 32 then | 
| bsw/jbe@19 | 33 if not current_tabs_string and not first then | 
| bsw/jbe@19 | 34 link_tabs[tabs[1].name] = true | 
| bsw/jbe@19 | 35 end | 
| bsw/jbe@19 | 36 for current_tab in pairs(current_tabs) do | 
| bsw/jbe@19 | 37 if current_tab ~= tab.name then | 
| bsw/jbe@19 | 38 link_tabs[current_tab] = true | 
| bsw/jbe@19 | 39 end | 
| bsw/jbe@19 | 40 end | 
| bsw/jbe@19 | 41 elseif config.user_tab_mode == "accordeon_all_expanded" and not current_tabs_string then | 
| bsw/jbe@19 | 42 for i, current_tab in ipairs(tabs) do | 
| bsw/jbe@19 | 43 if current_tab.name ~= tab.name then | 
| bsw/jbe@19 | 44 link_tabs[current_tab.name] = true | 
| bsw/jbe@19 | 45 end | 
| bsw/jbe@19 | 46 end | 
| bsw/jbe@19 | 47 end | 
| bsw/jbe@19 | 48 if not active then | 
| bsw/jbe@19 | 49 link_tabs[tab.name] = true | 
| bsw/jbe@19 | 50 end | 
| bsw/jbe@19 | 51 local link_tab_string = "" | 
| bsw/jbe@19 | 52 for link_tab in pairs(link_tabs) do | 
| bsw/jbe@19 | 53 if #link_tab_string > 0 then | 
| bsw/jbe@19 | 54 link_tab_string = link_tab_string .. "|" | 
| bsw/jbe@19 | 55 end | 
| bsw/jbe@19 | 56 link_tab_string = link_tab_string .. link_tab | 
| bsw/jbe@19 | 57 end | 
| bsw/jbe@19 | 58 params["tab"] = link_tab_string | 
| bsw/jbe@19 | 59 local onclick | 
| bsw/jbe@19 | 60 if not tab.content then | 
| bsw/jbe@19 | 61 onclick = | 
| bsw/jbe@19 | 62 'if (ui_tabs_active["' .. unique_string .. '"]["' .. tab.name .. '"]) {' .. | 
| bsw/jbe@19 | 63 'el=document.getElementById("tab' .. unique_string .. '_content_' .. tab.name .. '");' .. | 
| bsw/jbe@19 | 64 'el.innerHTML="";' .. | 
| bsw/jbe@19 | 65 'el.style.display="none";' .. | 
| bsw/jbe@19 | 66 'ui_tabs_active["' .. unique_string .. '"]["' .. tab.name .. '"]=false' .. | 
| bsw/jbe@19 | 67 '} else {' .. | 
| bsw/jbe@19 | 68 'ui_tabs_active["' .. unique_string .. '"]["' .. tab.name .. '"]=true;' .. | 
| bsw/jbe@19 | 69 'document.getElementById("tab' .. unique_string .. '_content_' .. tab.name .. '").style.display="block"; ' .. | 
| bsw/jbe@19 | 70 ui._partial_load_js{ | 
| bsw/jbe@19 | 71 params = { tab = tab.name } | 
| bsw/jbe@19 | 72 } .. | 
| bsw/jbe@19 | 73 '};' .. | 
| bsw/jbe@19 | 74 'return(false);' | 
| bsw/jbe@19 | 75 end | 
| bsw/jbe@19 | 76 ui.link{ | 
| bsw/jbe@19 | 77 attr = { | 
| bsw/jbe@19 | 78 name = "tab_" .. tab.name, | 
| bsw/jbe@19 | 79 class = ( | 
| bsw@57 | 80 tab.name == current_tab and "ui_tabs_accordeon_head selected" .. (tab.class and (" " .. tab.class) or "") or | 
| bsw@57 | 81 not current_tab and i == 1 and "ui_tabs_accordeon_head selected" .. (tab.class and (" " .. tab.class) or "") or | 
| bsw@57 | 82 "ui_tabs_accordeon_head" .. (tab.class and (" " .. tab.class) or "") | 
| bsw/jbe@19 | 83 ), | 
| bsw/jbe@19 | 84 id = "tab" .. unique_string .. "_head_" .. tab.name, | 
| bsw/jbe@19 | 85 onclick = onclick, | 
| bsw/jbe@19 | 86 }, | 
| bsw/jbe@19 | 87 module = request.get_module(), | 
| bsw/jbe@19 | 88 view = request.get_view(), | 
| bsw/jbe@19 | 89 id = param.get_id_cgi(), | 
| bsw/jbe@19 | 90 params = params, | 
| bsw/jbe@19 | 91 anchor = "tab" .. unique_string .. "_" .. tab.name, | 
| bsw/jbe@0 | 92 content = function() | 
| bsw/jbe@19 | 93 if tab.icon then | 
| bsw/jbe@19 | 94 if not tab.icon.attr then | 
| bsw/jbe@19 | 95 tab.icon.attr = {} | 
| bsw/jbe@19 | 96 end | 
| bsw/jbe@19 | 97 tab.icon.attr.id = "tab" .. unique_string .. "_icon_" .. tab.name | 
| bsw/jbe@19 | 98 tab.icon.attr.width = 16 | 
| bsw/jbe@19 | 99 tab.icon.attr.height = 16 | 
| bsw/jbe@19 | 100 ui.image(tab.icon) | 
| bsw/jbe@19 | 101 end | 
| bsw/jbe@19 | 102 slot.put(tab.label) | 
| bsw/jbe@19 | 103 end | 
| bsw/jbe@19 | 104 } | 
| bsw/jbe@19 | 105 local expanded = active or not request.get_json_request_slots() and config.user_tab_mode == "accordeon_all_expanded" and not current_tabs_string | 
| bsw/jbe@19 | 106 ui.container{ | 
| bsw/jbe@19 | 107 attr = { | 
| bsw@57 | 108 class = "ui_tabs_accordeon_content" .. (tab.class and (" " .. tab.class) or ""), | 
| bsw/jbe@19 | 109 style = not expanded and "display: none;" or nil, | 
| bsw/jbe@19 | 110 id = "tab" .. unique_string .. "_content_" .. tab.name | 
| bsw/jbe@19 | 111 }, | 
| bsw/jbe@19 | 112 content = function() | 
| bsw/jbe@19 | 113 if expanded then | 
| bsw/jbe@19 | 114 ui.script{ script = 'ui_tabs_active["' .. unique_string .. '"]["' .. tab.name .. '"] = true;' } | 
| bsw/jbe@19 | 115 execute.view{ | 
| bsw/jbe@19 | 116 module = tab.module, | 
| bsw/jbe@19 | 117 view = tab.view, | 
| bsw/jbe@19 | 118 id = tab.id, | 
| bsw/jbe@19 | 119 params = tab.params | 
| bsw/jbe@0 | 120 } | 
| bsw/jbe@19 | 121 else | 
| bsw/jbe@19 | 122 slot.put(" ") | 
| bsw/jbe@0 | 123 end | 
| bsw/jbe@0 | 124 end | 
| bsw/jbe@0 | 125 } | 
| bsw/jbe@19 | 126 end | 
| bsw/jbe@19 | 127 | 
| bsw/jbe@19 | 128 if not request.get_json_request_slots() or not current_tabs_string then | 
| bsw/jbe@19 | 129 ui.script{ script = "ui_tabs_active['" .. unique_string .. "'] = {};" } | 
| bsw/jbe@19 | 130 ui.container{ | 
| bsw/jbe@19 | 131 attr = { class = "ui_tabs" }, | 
| bsw/jbe@19 | 132 content = function() | 
| bsw/jbe@19 | 133 for i, tab in ipairs(tabs) do | 
| bsw/jbe@19 | 134 local static_params = tabs.static_params or {} | 
| bsw/jbe@19 | 135 static_params.tab = tab.name | 
| bsw/jbe@19 | 136 static_params.tab_id = unique_string | 
| bsw/jbe@19 | 137 ui.partial{ | 
| bsw/jbe@19 | 138 module = tabs.module, | 
| bsw/jbe@19 | 139 view = tabs.view, | 
| bsw/jbe@19 | 140 id = tabs.id, | 
| bsw/jbe@19 | 141 params = static_params, | 
| bsw/jbe@19 | 142 param_names = { "page" }, | 
| bsw/jbe@19 | 143 hourglass_target = "tab" .. unique_string .. "_icon_" .. tab.name, | 
| bsw/jbe@19 | 144 target = "tab" .. unique_string .. "_content_" .. tab.name, | 
| bsw/jbe@19 | 145 content = function() | 
| bsw/jbe@19 | 146 render_tab(tab, i == 1) | 
| bsw/jbe@19 | 147 end | 
| bsw/jbe@19 | 148 } | 
| bsw/jbe@19 | 149 end | 
| bsw/jbe@19 | 150 end | 
| bsw/jbe@19 | 151 } | 
| bsw/jbe@19 | 152 else | 
| bsw/jbe@19 | 153 local dyntab | 
| bsw/jbe@0 | 154 for i, tab in ipairs(tabs) do | 
| bsw/jbe@19 | 155 if tab.name == current_tabs_string then | 
| bsw/jbe@19 | 156 dyntab = tab | 
| bsw/jbe@0 | 157 end | 
| bsw/jbe@0 | 158 end | 
| bsw/jbe@19 | 159 if dyntab then | 
| bsw/jbe@19 | 160 local static_params = tabs.static_params or {} | 
| bsw/jbe@19 | 161 static_params.tab = dyntab.name | 
| bsw/jbe@19 | 162 static_params.tab_id = unique_string | 
| bsw/jbe@19 | 163 dyntab.params.tab_id = unique_string | 
| bsw/jbe@19 | 164 ui.partial{ | 
| bsw/jbe@19 | 165 module = tabs.module, | 
| bsw/jbe@19 | 166 view = tabs.view, | 
| bsw/jbe@19 | 167 id = tabs.id, | 
| bsw/jbe@19 | 168 params = static_params, | 
| bsw/jbe@19 | 169 param_names = { "page" }, | 
| bsw/jbe@19 | 170 hourglass_target = "tab" .. unique_string .. "_icon_" .. dyntab.name, | 
| bsw/jbe@19 | 171 target = "tab" .. unique_string .. "_content_" .. dyntab.name, | 
| bsw/jbe@19 | 172 content = function() | 
| bsw/jbe@19 | 173 execute.view{ | 
| bsw/jbe@19 | 174 module = dyntab.module, | 
| bsw/jbe@19 | 175 view = dyntab.view, | 
| bsw/jbe@19 | 176 id = dyntab.id, | 
| bsw/jbe@19 | 177 params = dyntab.params, | 
| bsw/jbe@19 | 178 } | 
| bsw/jbe@19 | 179 end | 
| bsw/jbe@19 | 180 } | 
| bsw/jbe@19 | 181 end | 
| bsw/jbe@0 | 182 end | 
| bsw/jbe@19 | 183 end | 
| bsw/jbe@19 | 184 | 
| bsw/jbe@19 | 185 else -- 'classic tab' | 
| bsw/jbe@0 | 186 | 
| bsw/jbe@19 | 187 function ui.tabs(tabs) | 
| bsw/jbe@19 | 188 ui.container{ | 
| bsw/jbe@19 | 189 attr = { class = "ui_tabs" }, | 
| bsw/jbe@19 | 190 content = function() | 
| bsw/jbe@19 | 191 local params = param.get_all_cgi() | 
| bsw/jbe@19 | 192 local current_tab = params["tab"] | 
| bsw/jbe@19 | 193 ui.container{ | 
| bsw/jbe@19 | 194 attr = { class = "ui_tabs_links" }, | 
| bsw/jbe@19 | 195 content = function() | 
| bsw/jbe@19 | 196 for i, tab in ipairs(tabs) do | 
| bsw/jbe@19 | 197 params["tab"] = i > 1 and tab.name or nil | 
| bsw/jbe@19 | 198 ui.link{ | 
| bsw/jbe@19 | 199 attr = { | 
| bsw/jbe@19 | 200 class = ( | 
| bsw@57 | 201 tab.name == current_tab and "selected" .. (tab.class and (" " .. tab.class) or "") or | 
| bsw@57 | 202 not current_tab and i == 1 and "selected" .. (tab.class and (" " .. tab.class) or "") or | 
| bsw@57 | 203 "" .. (tab.class and (" " .. tab.class) or "") | 
| bsw/jbe@19 | 204 ) | 
| bsw/jbe@19 | 205 }, | 
| bsw/jbe@19 | 206 module = request.get_module(), | 
| bsw/jbe@19 | 207 view = request.get_view(), | 
| bsw/jbe@19 | 208 id = param.get_id_cgi(), | 
| bsw/jbe@19 | 209 content = tab.label, | 
| bsw/jbe@19 | 210 params = params | 
| bsw/jbe@19 | 211 } | 
| bsw/jbe@19 | 212 slot.put(" ") | 
| bsw/jbe@19 | 213 end | 
| bsw/jbe@19 | 214 end | 
| bsw/jbe@19 | 215 } | 
| bsw/jbe@19 | 216 for i, tab in ipairs(tabs) do | 
| bsw/jbe@19 | 217 if tab.name == current_tab or not current_tab and i == 1 then | 
| bsw/jbe@19 | 218 ui.container{ | 
| bsw/jbe@19 | 219 attr = { class = "ui_tabs_content" }, | 
| bsw/jbe@19 | 220 content = function() | 
| bsw/jbe@19 | 221 if tab.content then | 
| bsw/jbe@19 | 222 tab.content() | 
| bsw/jbe@19 | 223 else | 
| bsw/jbe@19 | 224 execute.view{ | 
| bsw/jbe@19 | 225 module = tab.module, | 
| bsw/jbe@19 | 226 view = tab.view, | 
| bsw/jbe@19 | 227 id = tab.id, | 
| bsw/jbe@19 | 228 params = tab.params, | 
| bsw/jbe@19 | 229 } | 
| bsw/jbe@19 | 230 end | 
| bsw/jbe@19 | 231 end | 
| bsw/jbe@19 | 232 } | 
| bsw/jbe@19 | 233 end | 
| bsw/jbe@19 | 234 end | 
| bsw/jbe@19 | 235 end | 
| bsw/jbe@19 | 236 } | 
| bsw/jbe@19 | 237 end | 
| bsw/jbe@19 | 238 | 
| bsw/jbe@19 | 239 end |