| rev | 
   line source | 
| 
bsw@525
 | 
     1 local area = param.get("area", "table")
 | 
| 
bsw@774
 | 
     2 local member = param.get("member", "table")
 | 
| 
bsw@525
 | 
     3 
 | 
| 
bsw@529
 | 
     4 local show_content = param.get("show_content", atom.boolean)
 | 
| 
bsw@529
 | 
     5 
 | 
| 
bsw@529
 | 
     6 area:load_delegation_info_once_for_member_id(app.session.member_id)
 | 
| 
bsw@529
 | 
     7 
 | 
| 
bsw@619
 | 
     8 if not param.get("hide_unit", atom.boolean) then
 | 
| 
bsw@619
 | 
     9   execute.view{ module = "unit", view = "_head", params = { unit = area.unit } }
 | 
| 
bsw@619
 | 
    10 end
 | 
| 
bsw@525
 | 
    11 
 | 
| 
bsw@526
 | 
    12 ui.container{ attr = { class = "area_head" }, content = function()
 | 
| 
bsw@525
 | 
    13 
 | 
| 
bsw@774
 | 
    14   execute.view{ module = "delegation", view = "_info", params = { area = area, member = member } }
 | 
| 
bsw@525
 | 
    15 
 | 
| 
bsw@526
 | 
    16   ui.container{ attr = { class = "title" }, content = function()
 | 
| 
bsw@526
 | 
    17     -- area name
 | 
| 
bsw@526
 | 
    18     ui.link{
 | 
| 
bsw@526
 | 
    19       module = "area", view = "show", id = area.id,
 | 
| 
bsw@526
 | 
    20       attr = { class = "area_name" }, content = area.name 
 | 
| 
bsw@526
 | 
    21     }
 | 
| 
bsw@526
 | 
    22   end }
 | 
| 
bsw@526
 | 
    23   
 | 
| 
bsw@529
 | 
    24   if show_content then
 | 
| 
bsw@529
 | 
    25     
 | 
| 
bsw@529
 | 
    26     ui.container{ attr = { class = "content" }, content = function()
 | 
| 
bsw@525
 | 
    27 
 | 
| 
bsw@529
 | 
    28       -- actions (members with appropriate voting right only)
 | 
| 
bsw@781
 | 
    29       if member then
 | 
| 
bsw@525
 | 
    30 
 | 
| 
bsw@529
 | 
    31         -- membership
 | 
| 
bsw@774
 | 
    32         local membership = Membership:by_pk(area.id, member.id)
 | 
| 
bsw@525
 | 
    33 
 | 
| 
bsw@529
 | 
    34         if membership then
 | 
| 
bsw@529
 | 
    35           
 | 
| 
bsw@774
 | 
    36           if app.session.member_id == member.id then
 | 
| 
bsw@774
 | 
    37             ui.tag{ content = _"You are participating in this area" }
 | 
| 
bsw@782
 | 
    38             slot.put(" ")
 | 
| 
bsw@774
 | 
    39             ui.tag{ content = function()
 | 
| 
bsw@774
 | 
    40               slot.put("(")
 | 
| 
bsw@774
 | 
    41               ui.link{
 | 
| 
bsw@774
 | 
    42                 text    = _"Withdraw",
 | 
| 
bsw@774
 | 
    43                 module  = "membership",
 | 
| 
bsw@774
 | 
    44                 action  = "update",
 | 
| 
bsw@774
 | 
    45                 params  = { area_id = area.id, delete = true },
 | 
| 
bsw@774
 | 
    46                 routing = {
 | 
| 
bsw@774
 | 
    47                   default = {
 | 
| 
bsw@774
 | 
    48                     mode = "redirect",
 | 
| 
bsw@774
 | 
    49                     module = request.get_module(),
 | 
| 
bsw@774
 | 
    50                     view = request.get_view(),
 | 
| 
bsw@774
 | 
    51                     id = param.get_id_cgi(),
 | 
| 
bsw@774
 | 
    52                     params = param.get_all_cgi()
 | 
| 
bsw@774
 | 
    53                   }
 | 
| 
bsw@529
 | 
    54                 }
 | 
| 
bsw@529
 | 
    55               }
 | 
| 
bsw@774
 | 
    56               slot.put(")")
 | 
| 
bsw@774
 | 
    57             end }
 | 
| 
bsw@774
 | 
    58           else
 | 
| 
bsw@774
 | 
    59             ui.tag{ content = _"Member is participating in this area" }
 | 
| 
bsw@774
 | 
    60           end
 | 
| 
bsw@529
 | 
    61 
 | 
| 
bsw@774
 | 
    62         elseif app.session.member_id == member.id and member:has_voting_right_for_unit_id(area.unit_id) then
 | 
| 
bsw@526
 | 
    63           ui.link{
 | 
| 
bsw@529
 | 
    64             text   = _"Participate in this area",
 | 
| 
bsw@529
 | 
    65             module = "membership",
 | 
| 
bsw@529
 | 
    66             action = "update",
 | 
| 
bsw@529
 | 
    67             params = { area_id = area.id },
 | 
| 
bsw@528
 | 
    68             routing = {
 | 
| 
bsw@528
 | 
    69               default = {
 | 
| 
bsw@528
 | 
    70                 mode = "redirect",
 | 
| 
bsw@528
 | 
    71                 module = request.get_module(),
 | 
| 
bsw@528
 | 
    72                 view = request.get_view(),
 | 
| 
bsw@528
 | 
    73                 id = param.get_id_cgi(),
 | 
| 
bsw@528
 | 
    74                 params = param.get_all_cgi()
 | 
| 
bsw@528
 | 
    75               }
 | 
| 
bsw@528
 | 
    76             }
 | 
| 
bsw@526
 | 
    77           }
 | 
| 
bsw@529
 | 
    78         end
 | 
| 
bsw@622
 | 
    79         
 | 
| 
bsw@774
 | 
    80         if app.session.member_id == member.id and app.session.member:has_voting_right_for_unit_id(area.unit_id) then
 | 
| 
bsw@529
 | 
    81 
 | 
| 
bsw@622
 | 
    82           slot.put(" · ")
 | 
| 
bsw@622
 | 
    83           if area.delegation_info.own_delegation_scope ~= "area" then
 | 
| 
bsw@622
 | 
    84             ui.link{ text = _"Delegate area", module = "delegation", view = "show", params = { area_id = area.id } }
 | 
| 
bsw@622
 | 
    85           else
 | 
| 
bsw@622
 | 
    86             ui.link{ text = _"Change area delegation", module = "delegation", view = "show", params = { area_id = area.id } }
 | 
| 
bsw@622
 | 
    87           end
 | 
| 
bsw@622
 | 
    88           slot.put(" · ")
 | 
| 
bsw@525
 | 
    89 
 | 
| 
bsw@529
 | 
    90           ui.link{
 | 
| 
bsw@529
 | 
    91             content = function()
 | 
| 
bsw@529
 | 
    92               slot.put(_"Create new issue")
 | 
| 
bsw@529
 | 
    93             end,
 | 
| 
bsw@529
 | 
    94             module = "initiative",
 | 
| 
bsw@529
 | 
    95             view = "new",
 | 
| 
bsw@529
 | 
    96             params = { area_id = area.id }
 | 
| 
bsw@525
 | 
    97           }
 | 
| 
bsw@529
 | 
    98         end
 | 
| 
bsw@525
 | 
    99 
 | 
| 
bsw@525
 | 
   100       end
 | 
| 
bsw@525
 | 
   101 
 | 
| 
bsw@529
 | 
   102     end }
 | 
| 
bsw@526
 | 
   103 
 | 
| 
bsw@529
 | 
   104   else
 | 
| 
bsw@529
 | 
   105     slot.put("<br />")
 | 
| 
bsw@529
 | 
   106   end
 | 
| 
bsw@526
 | 
   107 
 | 
| 
bsw@526
 | 
   108 end } |