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