liquid_feedback_frontend
view app/main/supporter/_show_box.lua @ 1130:a3a1a6afcf68
Going to version 3.0.4
| author | bsw | 
|---|---|
| date | Wed Dec 24 13:46:04 2014 +0100 (2014-12-24) | 
| parents | 2cfa41e89c15 | 
| children | 
 line source
     1 local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id())
     4 local initiative = param.get("initiative", "table")
     5 local supporter = Supporter:by_pk(initiative.id, app.session.member.id)
     7 local partial = {
     8   routing = {
     9     default = {
    10       mode = "redirect",
    11       module = "initiative",
    12       view = "show_support",
    13       id = initiative.id
    14     }
    15   }
    16 }
    18 local routing = {
    19   default = {
    20     mode = "redirect",
    21     module = request.get_module(),
    22     view = request.get_view(),
    23     id = param.get_id_cgi(),
    24     params = param.get_all_cgi()
    25   }
    26 }
    28 if not initiative.issue.fully_frozen and not initiative.issue.closed then
    29   if supporter then
    30     if not supporter:has_critical_opinion() then
    31       ui.tag{ content = function()
    32         ui.image{
    33           static = "icons/16/thumb_up_green.png"
    34         }
    35         if initiative.issue.closed then
    36           slot.put(_"You were supporter")
    37         else
    38           slot.put(_"You are supporter")
    39         end
    40       end }
    41     else
    42       ui.tag{ attr = { class = "potential_supporter" }, content = function()
    43         ui.image{
    44           static = "icons/16/thumb_up.png"
    45         }
    46         if initiative.issue.closed then
    47           slot.put(_"You were potential supporter")
    48         else
    49           slot.put(_"You are potential supporter")
    50         end
    51       end }
    52     end
    53     slot.put(" (")
    54     ui.link{
    55       text    = _"Withdraw",
    56       module  = "initiative",
    57       action  = "remove_support",
    58       id      = initiative.id,
    59       routing = routing,
    60       partial = partial
    61     }
    62     slot.put(") ")
    63   elseif not initiative.revoked and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then
    64     local params = param.get_all_cgi()
    65     params.dyn = nil
    66     ui.link{
    67       text    = _"Support this initiative",
    68       module  = "initiative",
    69       action  = "add_support",
    70       id      = initiative.id,
    71       routing = routing,
    72       partial = partial
    73     }
    74     slot.put(" ")
    75   end
    76 end
    80 if not initiative.issue.closed then
    81   if not initiative.issue.fully_frozen and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then
    82     slot.put(" · ")
    83   end
    84   local ignored_initiative = IgnoredInitiative:by_pk(app.session.member.id, initiative.id)
    85   if ignored_initiative then
    86     ui.tag{
    87       content = _"Ignore initiative"
    88     }
    89     slot.put(" (")
    90     ui.link{
    91       text   = _"Cancel [nullify]",
    92       module = "initiative",
    93       action = "update_ignore",
    94       id     = initiative.id,
    95       params = { delete = true },
    96       routing = {
    97         default = {
    98           mode = "redirect",
    99           module = request.get_module(),
   100           view = request.get_view(),
   101           id = param.get_id_cgi(),
   102           params = param.get_all_cgi()
   103         }
   104       }
   105     }
   106     slot.put(")")
   107   else
   108     ui.link{
   109       text    = _"Ignore initiative",
   110       module  = "initiative",
   111       action  = "update_ignore",
   112       id      = initiative.id,
   113       routing = {
   114         default = {
   115           mode = "redirect",
   116           module = request.get_module(),
   117           view = request.get_view(),
   118           id = param.get_id_cgi(),
   119           params = param.get_all_cgi()
   120         }
   121       }
   122     }
   123   end
   124 end
