| rev | 
   line source | 
| 
bsw@525
 | 
     1 local area = param.get("area", "table")
 | 
| 
bsw@525
 | 
     2 
 | 
| 
bsw@525
 | 
     3 execute.view{ module = "unit", view = "_head", params = { unit = area.unit } }
 | 
| 
bsw@525
 | 
     4 
 | 
| 
bsw@525
 | 
     5 slot.select("head", function()
 | 
| 
bsw@525
 | 
     6 
 | 
| 
bsw@525
 | 
     7   ui.container{ attr = { class = "area_head" }, content = function()
 | 
| 
bsw@525
 | 
     8 
 | 
| 
bsw@525
 | 
     9     execute.view{ module = "delegation", view = "_info", params = { area = area } }
 | 
| 
bsw@525
 | 
    10 
 | 
| 
bsw@525
 | 
    11     ui.container{ attr = { class = "title" }, content = function()
 | 
| 
bsw@525
 | 
    12       -- area name
 | 
| 
bsw@525
 | 
    13       ui.link{
 | 
| 
bsw@525
 | 
    14         module = "area", view = "show", id = area.id,
 | 
| 
bsw@525
 | 
    15         attr = { class = "area_name" }, content = area.name 
 | 
| 
bsw@525
 | 
    16       }
 | 
| 
bsw@525
 | 
    17     end }
 | 
| 
bsw@525
 | 
    18     
 | 
| 
bsw@525
 | 
    19     ui.container{ attr = { class = "content" }, content = function()
 | 
| 
bsw@525
 | 
    20 
 | 
| 
bsw@525
 | 
    21       -- actions (members with appropriate voting right only)
 | 
| 
bsw@525
 | 
    22       if app.session.member_id then
 | 
| 
bsw@525
 | 
    23 
 | 
| 
bsw@525
 | 
    24         -- membership
 | 
| 
bsw@525
 | 
    25         local membership = Membership:by_pk(area.id, app.session.member.id)
 | 
| 
bsw@525
 | 
    26 
 | 
| 
bsw@525
 | 
    27         if membership then
 | 
| 
bsw@525
 | 
    28           
 | 
| 
bsw@525
 | 
    29           ui.tag{ content = _"You are member" }
 | 
| 
bsw@525
 | 
    30           
 | 
| 
bsw@525
 | 
    31           slot.put(" ")
 | 
| 
bsw@525
 | 
    32           
 | 
| 
bsw@525
 | 
    33           ui.tag{ content = function()
 | 
| 
bsw@525
 | 
    34             slot.put("(")
 | 
| 
bsw@525
 | 
    35             ui.link{
 | 
| 
bsw@525
 | 
    36               text    = _"Withdraw",
 | 
| 
bsw@525
 | 
    37               module  = "membership",
 | 
| 
bsw@525
 | 
    38               action  = "update",
 | 
| 
bsw@525
 | 
    39               params  = { area_id = area.id, delete = true },
 | 
| 
bsw@525
 | 
    40               routing = { default = { mode = "redirect", module = "area", view = "show", id = area.id } }
 | 
| 
bsw@525
 | 
    41             }
 | 
| 
bsw@525
 | 
    42             slot.put(")")
 | 
| 
bsw@525
 | 
    43           end }
 | 
| 
bsw@525
 | 
    44           
 | 
| 
bsw@525
 | 
    45           slot.put(" · ")
 | 
| 
bsw@525
 | 
    46 
 | 
| 
bsw@525
 | 
    47         elseif app.session.member:has_voting_right_for_unit_id(area.unit_id) then
 | 
| 
bsw@525
 | 
    48           ui.link{
 | 
| 
bsw@525
 | 
    49             text   = _"Become a member",
 | 
| 
bsw@525
 | 
    50             module = "membership",
 | 
| 
bsw@525
 | 
    51             action = "update",
 | 
| 
bsw@525
 | 
    52             params = { area_id = area.id },
 | 
| 
bsw@525
 | 
    53             routing = {
 | 
| 
bsw@525
 | 
    54               default = {
 | 
| 
bsw@525
 | 
    55                 mode = "redirect",
 | 
| 
bsw@525
 | 
    56                 module = "area",
 | 
| 
bsw@525
 | 
    57                 view = "show",
 | 
| 
bsw@525
 | 
    58                 id = area.id
 | 
| 
bsw@525
 | 
    59               }
 | 
| 
bsw@525
 | 
    60             }
 | 
| 
bsw@525
 | 
    61           }
 | 
| 
bsw@525
 | 
    62 
 | 
| 
bsw@525
 | 
    63           slot.put(" · ")
 | 
| 
bsw@525
 | 
    64 
 | 
| 
bsw@525
 | 
    65         end
 | 
| 
bsw@525
 | 
    66 
 | 
| 
bsw@525
 | 
    67         -- create new issue
 | 
| 
bsw@525
 | 
    68         if app.session.member:has_voting_right_for_unit_id(area.unit_id) then
 | 
| 
bsw@525
 | 
    69           ui.link{
 | 
| 
bsw@525
 | 
    70             content = function()
 | 
| 
bsw@525
 | 
    71               slot.put(_"Create new issue")
 | 
| 
bsw@525
 | 
    72             end,
 | 
| 
bsw@525
 | 
    73             module = "initiative",
 | 
| 
bsw@525
 | 
    74             view = "new",
 | 
| 
bsw@525
 | 
    75             params = { area_id = area.id }
 | 
| 
bsw@525
 | 
    76           }
 | 
| 
bsw@525
 | 
    77         end
 | 
| 
bsw@525
 | 
    78 
 | 
| 
bsw@525
 | 
    79       end
 | 
| 
bsw@525
 | 
    80 
 | 
| 
bsw@525
 | 
    81     end }
 | 
| 
bsw@525
 | 
    82     
 | 
| 
bsw@525
 | 
    83   end }
 | 
| 
bsw@525
 | 
    84 
 | 
| 
bsw@525
 | 
    85 end) |