annotate app/main/admin/area_list.lua @ 259:4c0bff8141ee
Add session table creation script
 | author | 
 bsw | 
 | date | 
 Tue Feb 07 17:27:07 2012 +0100 (2012-02-07) | 
 | parents | 
 46351752814f  | 
 | children | 
 f42d16567c5d  | 
 
 | rev | 
   line source | 
| 
bsw@193
 | 
     1 local show_not_in_use = param.get("show_not_in_use", atom.boolean) or false
 | 
| 
bsw/jbe@0
 | 
     2 
 | 
| 
bsw@193
 | 
     3 local areas = Area:build_selector{ active = not show_not_in_use }:exec()
 | 
| 
bsw/jbe@0
 | 
     4 
 | 
| 
bsw/jbe@0
 | 
     5 
 | 
| 
bsw/jbe@0
 | 
     6 slot.put_into("title", _"Area list")
 | 
| 
bsw/jbe@0
 | 
     7 
 | 
| 
bsw@193
 | 
     8 
 | 
| 
bsw@193
 | 
     9 slot.select("actions", function()
 | 
| 
bsw@193
 | 
    10 
 | 
| 
bsw@193
 | 
    11   if show_not_in_use then
 | 
| 
bsw@193
 | 
    12     ui.link{
 | 
| 
bsw@193
 | 
    13       attr = { class = { "admin_only" } },
 | 
| 
bsw@193
 | 
    14       text = _"Show areas in use",
 | 
| 
bsw@193
 | 
    15       module = "admin",
 | 
| 
bsw@193
 | 
    16       view = "area_list"
 | 
| 
bsw@193
 | 
    17     }
 | 
| 
bsw@193
 | 
    18 
 | 
| 
bsw@193
 | 
    19   else
 | 
| 
bsw@193
 | 
    20     ui.link{
 | 
| 
bsw@193
 | 
    21       attr = { class = { "admin_only" } },
 | 
| 
bsw@193
 | 
    22       text = _"Create new area",
 | 
| 
bsw@193
 | 
    23       module = "admin",
 | 
| 
bsw@193
 | 
    24       view = "area_show"
 | 
| 
bsw@193
 | 
    25     }
 | 
| 
bsw@193
 | 
    26     ui.link{
 | 
| 
bsw@193
 | 
    27       attr = { class = { "admin_only" } },
 | 
| 
bsw@193
 | 
    28       text = _"Show areas not in use",
 | 
| 
bsw@193
 | 
    29       module = "admin",
 | 
| 
bsw@193
 | 
    30       view = "area_list",
 | 
| 
bsw@193
 | 
    31       params = { show_not_in_use = true }
 | 
| 
bsw@193
 | 
    32     }
 | 
| 
bsw@193
 | 
    33   end
 | 
| 
bsw@193
 | 
    34 
 | 
| 
bsw@193
 | 
    35 end)
 | 
| 
bsw@193
 | 
    36 
 | 
| 
bsw/jbe@0
 | 
    37 
 | 
| 
bsw/jbe@0
 | 
    38 ui.list{
 | 
| 
bsw/jbe@0
 | 
    39   records = areas,
 | 
| 
bsw/jbe@0
 | 
    40   columns = {
 | 
| 
bsw@193
 | 
    41 
 | 
| 
bsw@193
 | 
    42     { label = _"Area", name = "name" },
 | 
| 
bsw@193
 | 
    43 
 | 
| 
bsw@193
 | 
    44     { content = function(record)
 | 
| 
bsw/jbe@0
 | 
    45         if app.session.member.admin then
 | 
| 
bsw/jbe@0
 | 
    46           ui.link{
 | 
| 
bsw/jbe@0
 | 
    47             attr = { class = { "action admin_only" } },
 | 
| 
bsw/jbe@0
 | 
    48             text = _"Edit",
 | 
| 
bsw/jbe@0
 | 
    49             module = "admin",
 | 
| 
bsw/jbe@0
 | 
    50             view = "area_show",
 | 
| 
bsw/jbe@0
 | 
    51             id = record.id
 | 
| 
bsw/jbe@0
 | 
    52           }
 | 
| 
bsw/jbe@0
 | 
    53         end
 | 
| 
bsw/jbe@0
 | 
    54       end
 | 
| 
bsw/jbe@0
 | 
    55     }
 | 
| 
bsw@193
 | 
    56 
 | 
| 
bsw/jbe@0
 | 
    57   }
 | 
| 
bsw/jbe@0
 | 
    58 } |