annotate env/ui/tabs.lua @ 282:7f41f3c44fae
Changes in policy admin interface for core 2.0
 | author | 
 bsw | 
 | date | 
 Fri Feb 17 10:20:26 2012 +0100 (2012-02-17) | 
 | parents | 
 fecd4c13054a  | 
 | children | 
 c587d8762e62  | 
 
 | rev | 
   line source | 
| 
bsw@278
 | 
     1 function ui.tabs(tabs)
 | 
| 
bsw@278
 | 
     2   ui.container{
 | 
| 
bsw@278
 | 
     3     attr = { class = "ui_tabs" },
 | 
| 
bsw@278
 | 
     4     content = function()
 | 
| 
bsw/jbe@0
 | 
     5       local params = param.get_all_cgi()
 | 
| 
bsw@278
 | 
     6       local current_tab = params["tab"]
 | 
| 
bsw@278
 | 
     7       ui.container{
 | 
| 
bsw@278
 | 
     8         attr = { class = "ui_tabs_links" },
 | 
| 
bsw/jbe@0
 | 
     9         content = function()
 | 
| 
bsw@278
 | 
    10           for i, tab in ipairs(tabs) do
 | 
| 
bsw@278
 | 
    11             params["tab"] = i > 1 and tab.name or nil
 | 
| 
bsw@278
 | 
    12             ui.link{
 | 
| 
bsw@278
 | 
    13               attr = { 
 | 
| 
bsw@278
 | 
    14                 class = (
 | 
| 
bsw@278
 | 
    15                   tab.name == current_tab and "selected" .. (tab.class and (" " .. tab.class) or "") or
 | 
| 
bsw@278
 | 
    16                   not current_tab and i == 1 and "selected" .. (tab.class and (" " .. tab.class) or "") or
 | 
| 
bsw@278
 | 
    17                   "" .. (tab.class and (" " .. tab.class) or "")
 | 
| 
bsw@278
 | 
    18                 )
 | 
| 
bsw@278
 | 
    19               },
 | 
| 
bsw@278
 | 
    20               module  = request.get_module(),
 | 
| 
bsw@278
 | 
    21               view    = request.get_view(),
 | 
| 
bsw@278
 | 
    22               id      = param.get_id_cgi(),
 | 
| 
bsw@278
 | 
    23               content = tab.label,
 | 
| 
bsw@278
 | 
    24               params  = params
 | 
| 
bsw/jbe@0
 | 
    25             }
 | 
| 
bsw@278
 | 
    26             slot.put(" ")
 | 
| 
bsw/jbe@0
 | 
    27           end
 | 
| 
bsw/jbe@0
 | 
    28         end
 | 
| 
bsw/jbe@0
 | 
    29       }
 | 
| 
bsw@278
 | 
    30       for i, tab in ipairs(tabs) do
 | 
| 
bsw@278
 | 
    31         if tab.name == current_tab and i > 1 then
 | 
| 
bsw@278
 | 
    32                                               app.html_title.prefix = tab.label
 | 
| 
bsw/jbe@19
 | 
    33               end
 | 
| 
bsw@278
 | 
    34         if tab.name == current_tab or not current_tab and i == 1 then
 | 
| 
bsw@278
 | 
    35           ui.container{
 | 
| 
bsw@278
 | 
    36             attr = { class = "ui_tabs_content" },
 | 
| 
bsw@278
 | 
    37             content = function()
 | 
| 
bsw@278
 | 
    38               if tab.content then
 | 
| 
bsw@278
 | 
    39                 tab.content()
 | 
| 
bsw@278
 | 
    40               else
 | 
| 
bsw@278
 | 
    41                 execute.view{
 | 
| 
bsw@278
 | 
    42                   module = tab.module,
 | 
| 
bsw@278
 | 
    43                   view   = tab.view,
 | 
| 
bsw@278
 | 
    44                   id     = tab.id,
 | 
| 
bsw@278
 | 
    45                   params = tab.params,
 | 
| 
bsw@278
 | 
    46                 }
 | 
| 
bsw@278
 | 
    47               end
 | 
| 
bsw@278
 | 
    48             end
 | 
| 
bsw@278
 | 
    49           }
 | 
| 
bsw/jbe@19
 | 
    50         end
 | 
| 
bsw/jbe@19
 | 
    51       end
 | 
| 
bsw/jbe@0
 | 
    52     end
 | 
| 
bsw@278
 | 
    53   }
 | 
| 
jorges@102
 | 
    54 end
 |