liquid_feedback_frontend
view app/main/supporter/_show_box.lua @ 143:a33abf457d29
add initiative_id selector in suggestion api
fixes bug #301
fixes bug #301
| author | Daniel Poelzleithner <poelzi@poelzi.org> | 
|---|---|
| date | Wed Oct 06 16:35:33 2010 +0200 (2010-10-06) | 
| parents | 00d1004545f1 | 
| children | 034f96181e59 | 
 line source
     2 local initiative = param.get("initiative", "table")
     3 local supporter = Supporter:by_pk(initiative.id, app.session.member.id)
     5 local unique_string = multirand.string(16, '0123456789abcdef')
     8 local partial = {
     9   routing = {
    10     default = {
    11       mode = "redirect",
    12       module = "initiative",
    13       view = "show_support",
    14       id = initiative.id
    15     }
    16   }
    17 }
    19 local routing = {
    20   default = {
    21     mode = "redirect",
    22     module = request.get_module(),
    23     view = request.get_view(),
    24     id = param.get_id_cgi(),
    25     params = param.get_all_cgi()
    26   }
    27 }
    29 if not initiative.issue.fully_frozen and not initiative.issue.closed then
    30   if supporter then
    31     if not supporter:has_critical_opinion() then
    32       ui.container{
    33         attr = {
    34           class = "head head_supporter",
    35           style = "cursor: pointer;",
    36           onclick = "document.getElementById('support_content_" .. unique_string .. "').style.display = 'block';"
    37         },
    38         content = function()
    39           ui.image{
    40             static = "icons/16/thumb_up_green.png"
    41           }
    42           slot.put(_"Your are supporter")
    43           ui.image{
    44             static = "icons/16/dropdown.png"
    45           }
    46         end
    47       }
    48     else
    49       ui.container{
    50         attr = {
    51           class = "head head_potential_supporter",
    52           style = "cursor: pointer;",
    53           onclick = "document.getElementById('support_content_" .. unique_string .. "').style.display = 'block';"
    54         },
    55         content = function()
    56           ui.image{
    57             static = "icons/16/thumb_up.png"
    58           }
    59           slot.put(_"Your are potential supporter")
    60           ui.image{
    61             static = "icons/16/dropdown.png"
    62           }
    63         end
    64       }
    65     end
    66     ui.container{
    67       attr = { class = "content", id = "support_content_" .. unique_string .. "" },
    68       content = function()
    69         ui.container{
    70           attr = {
    71             class = "close",
    72             style = "cursor: pointer;",
    73             onclick = "document.getElementById('support_content_" .. unique_string .. "').style.display = 'none';"
    74           },
    75           content = function()
    76             ui.image{ static = "icons/16/cross.png" }
    77           end
    78         }
    79         if supporter then
    80           ui.link{
    81             image   = { static = "icons/16/thumb_down_red.png" },
    82             text    = _"Remove my support from this initiative",
    83             module  = "initiative",
    84             action  = "remove_support",
    85             id      = initiative.id,
    86             routing = routing,
    87             partial = partial
    88           }
    89         else
    90         end
    91       end
    92     }
    93   else
    94     if not initiative.revoked then
    95       local params = param.get_all_cgi()
    96       params.dyn = nil
    97       ui.link{
    98         image   = { static = "icons/16/thumb_up_green.png" },
    99         text    = _"Support this initiative",
   100         module  = "initiative",
   101         action  = "add_support",
   102         id      = initiative.id,
   103         routing = routing,
   104         partial = partial
   105       }
   106     end
   107   end
   108 end
