annotate app/main/admin/unit_list.lua @ 1045:701a5cf6b067
Imported LiquidFeedback Frontend 3.0 branch
 | author | 
 bsw | 
 | date | 
 Thu Jul 10 01:19:48 2014 +0200 (2014-07-10) | 
 | parents | 
 36fa53881a8e  | 
 | children | 
  | 
 
 | rev | 
   line source | 
| 
bsw@829
 | 
     1 local inactive = param.get("inactive", atom.boolean)
 | 
| 
bsw@829
 | 
     2 
 | 
| 
bsw@829
 | 
     3 local units = Unit:get_flattened_tree{ include_inactive = inactive }
 | 
| 
bsw@263
 | 
     4 
 | 
| 
bsw@595
 | 
     5 ui.title(_"Unit list")
 | 
| 
bsw@263
 | 
     6 
 | 
| 
bsw@595
 | 
     7 ui.actions(function()
 | 
| 
bsw@263
 | 
     8   ui.link{
 | 
| 
bsw@263
 | 
     9     text = _"Create new unit",
 | 
| 
bsw@263
 | 
    10     module = "admin",
 | 
| 
bsw@263
 | 
    11     view = "unit_edit"
 | 
| 
bsw@263
 | 
    12   }
 | 
| 
bsw@829
 | 
    13   slot.put(" · ")
 | 
| 
bsw@829
 | 
    14   if inactive then
 | 
| 
bsw@829
 | 
    15     ui.link{
 | 
| 
bsw@829
 | 
    16       text = _"Hide active units",
 | 
| 
bsw@829
 | 
    17       module = "admin",
 | 
| 
bsw@829
 | 
    18       view = "unit_list"
 | 
| 
bsw@829
 | 
    19     }
 | 
| 
bsw@829
 | 
    20   else
 | 
| 
bsw@829
 | 
    21     ui.link{
 | 
| 
bsw@829
 | 
    22       text = _"Show inactive units",
 | 
| 
bsw@829
 | 
    23       module = "admin",
 | 
| 
bsw@829
 | 
    24       view = "unit_list",
 | 
| 
bsw@829
 | 
    25       params = { inactive = true }
 | 
| 
bsw@829
 | 
    26     }
 | 
| 
bsw@829
 | 
    27   end
 | 
| 
bsw@263
 | 
    28 end)
 | 
| 
bsw@263
 | 
    29  
 | 
| 
bsw@263
 | 
    30 ui.list{
 | 
| 
bsw@263
 | 
    31   records = units,
 | 
| 
bsw@263
 | 
    32   columns = {
 | 
| 
bsw@263
 | 
    33     {
 | 
| 
bsw@263
 | 
    34       content = function(unit)
 | 
| 
bsw@829
 | 
    35         for i = 1, unit.depth - 1 do
 | 
| 
bsw@829
 | 
    36           slot.put("     ")
 | 
| 
bsw@829
 | 
    37         end
 | 
| 
bsw@829
 | 
    38         local style = ""
 | 
| 
bsw@829
 | 
    39         if not unit.active then
 | 
| 
bsw@829
 | 
    40           style = "text-decoration: line-through;"
 | 
| 
bsw@829
 | 
    41         end
 | 
| 
bsw@513
 | 
    42         ui.link{
 | 
| 
bsw@829
 | 
    43           attr = { style = "font-weight: bold;" .. style },
 | 
| 
bsw@829
 | 
    44           text = unit.name,
 | 
| 
bsw@513
 | 
    45           module = "admin", view = "unit_edit", id = unit.id
 | 
| 
bsw@513
 | 
    46         }
 | 
| 
bsw@829
 | 
    47         slot.put(" · ")
 | 
| 
bsw@513
 | 
    48         ui.link{
 | 
| 
bsw@513
 | 
    49           text = _"Edit areas",
 | 
| 
bsw@513
 | 
    50           module = "admin", view = "area_list", params = { unit_id = unit.id }
 | 
| 
bsw@513
 | 
    51         }
 | 
| 
bsw@263
 | 
    52       end 
 | 
| 
bsw@263
 | 
    53     }
 | 
| 
bsw@263
 | 
    54   }
 | 
| 
bsw@263
 | 
    55 } |