liquid_feedback_frontend
view env/ui/tabs.lua @ 1586:1c21a43ef121
Fixed unevenly distributes white space around initiative list
| author | bsw | 
|---|---|
| date | Tue Jan 26 19:15:35 2021 +0100 (2021-01-26) | 
| parents | 904f6807f7fa | 
| children | 
 line source
     1 function ui.tabs(tabs)
     2   local attr = tabs.attr or {}
     3   attr.class = (attr.class and attr.class .. " " or "") .. "ui_tabs"
     4   ui.container{
     5     attr = attr,
     6     content = function()
     7       local params = request.get_param_strings()
     8       local current_tab = params["tab"]
     9       ui.container{
    10         attr = { class = "ui_tabs_links" },
    11         content = function()
    12           for i, tab in ipairs(tabs) do
    13             local params = request.get_param_strings()
    14             if tab.link_params then
    15               for key, value in pairs(tab.link_params) do
    16                 params[key] = value
    17               end
    18             end
    19             params["tab"] = i > 1 and tab.name or nil
    20             ui.link{
    21               attr = { 
    22                 class = (
    23                   tab.name == current_tab and "selected" .. (tab.class and (" " .. tab.class) or "") or
    24                   not current_tab and i == 1 and "selected" .. (tab.class and (" " .. tab.class) or "") or
    25                   "" .. (tab.class and (" " .. tab.class) or "")
    26                 )
    27               },
    28               module  = request.get_module(),
    29               view    = request.get_view(),
    30               id      = request.get_id_string(),
    31               content = tab.label,
    32               params  = params
    33             }
    34             slot.put(" ")
    35           end
    36         end
    37       }
    38       for i, tab in ipairs(tabs) do
    39         if tab.name == current_tab and i > 1 then
    40                                               app.html_title.prefix = tab.label
    41               end
    42         if tab.name == current_tab or not current_tab and i == 1 then
    43           ui.container{
    44             attr = { class = "ui_tabs_content" },
    45             content = function()
    46               if tab.content then
    47                 tab.content()
    48               else
    49                 execute.view{
    50                   module = tab.module,
    51                   view   = tab.view,
    52                   id     = tab.id,
    53                   params = tab.params,
    54                 }
    55               end
    56             end
    57           }
    58         end
    59       end
    60     end
    61   }
    62 end
