liquid_feedback_frontend
view app/main/supporter/_show_box.lua @ 618:56147a5153f6
German translation fixed
| author | bsw | 
|---|---|
| date | Mon Jun 25 01:17:27 2012 +0200 (2012-06-25) | 
| parents | 5ca9de94cb13 | 
| children | cdd0bcbbef8b | 
 line source
     1 local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id())
     3 -- TODO performance
     4 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
     6 local initiative = param.get("initiative", "table")
     7 local supporter = Supporter:by_pk(initiative.id, app.session.member.id)
     9 local partial = {
    10   routing = {
    11     default = {
    12       mode = "redirect",
    13       module = "initiative",
    14       view = "show_support",
    15       id = initiative.id
    16     }
    17   }
    18 }
    20 local routing = {
    21   default = {
    22     mode = "redirect",
    23     module = request.get_module(),
    24     view = request.get_view(),
    25     id = param.get_id_cgi(),
    26     params = param.get_all_cgi()
    27   }
    28 }
    30 if not initiative.issue.fully_frozen and not initiative.issue.closed then
    31   if supporter then
    32     if not supporter:has_critical_opinion() then
    33       ui.tag{ content = function()
    34         ui.image{
    35           static = "icons/16/thumb_up_green.png"
    36         }
    37         if initiative.issue.closed then
    38           slot.put(_"You were supporter")
    39         else
    40           slot.put(_"You are supporter")
    41         end
    42       end }
    43     else
    44       ui.tag{ attr = { class = "potential_supporter" }, content = function()
    45         ui.image{
    46           static = "icons/16/thumb_up.png"
    47         }
    48         if initiative.issue.closed then
    49           slot.put(_"You were potential supporter")
    50         else
    51           slot.put(_"You are potential supporter")
    52         end
    53       end }
    54     end
    55     slot.put(" (")
    56     ui.link{
    57       text    = _"Withdraw",
    58       module  = "initiative",
    59       action  = "remove_support",
    60       id      = initiative.id,
    61       routing = routing,
    62       partial = partial
    63     }
    64     slot.put(") ")
    65   elseif not initiative.revoked and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then
    66     local params = param.get_all_cgi()
    67     params.dyn = nil
    68     ui.link{
    69       text    = _"Support this initiative",
    70       module  = "initiative",
    71       action  = "add_support",
    72       id      = initiative.id,
    73       routing = routing,
    74       partial = partial
    75     }
    76     slot.put(" ")
    77   end
    78 end
    80 if app.session.member_id
    81   and not initiative.issue.half_frozen
    82   and not initiative.issue.closed
    83   and not initiative.revoked
    84   and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id)
    85 then
    86   ui.link{
    87     content = function()
    88       slot.put(_"Add suggestion")
    89     end,
    90     module = "suggestion",
    91     view = "new",
    92     params = {
    93       initiative_id = initiative.id
    94     }
    95   }
    96   slot.put(" ")
    97 end
    99 if (initiative.discussion_url and #initiative.discussion_url > 0) then
   100   if initiative.discussion_url:find("^https?://") then
   101     if initiative.discussion_url and #initiative.discussion_url > 0 then
   102       ui.link{
   103         attr = {
   104           target = "_blank",
   105           title = _"Discussion with initiators"
   106         },
   107         text = _"Discuss with initiators",
   108         external = initiative.discussion_url
   109       }
   110       slot.put(" ")
   111     end
   112   else
   113     slot.put(encode.html(initiative.discussion_url))
   114   end
   115 end
   116 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
   117   ui.link{
   118     image = { static = "icons/16/comments.png" },
   119     text   = _"change discussion URL",
   120     module = "initiative",
   121     view   = "edit",
   122     id     = initiative.id
   123   }
   124   slot.put(" ")
   125 end
   126 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
   127   ui.link{
   128     content = function()
   129       ui.image{ static = "icons/16/script_add.png" }
   130       slot.put(_"Edit draft")
   131     end,
   132     module = "draft",
   133     view = "new",
   134     params = { initiative_id = initiative.id }
   135   }
   136   slot.put(" ")
   137 end
   139 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
   140   ui.link{
   141     content = function()
   142       ui.image{ static = "icons/16/script_delete.png" }
   143       slot.put(_"Revoke initiative")
   144     end,
   145     module = "initiative",
   146     view = "revoke",
   147     id = initiative.id
   148   }
   149   slot.put(" ")
   150 end
   152 if not initiative.issue.closed then
   153   local ignored_initiative = IgnoredInitiative:by_pk(app.session.member.id, initiative.id)
   154   if ignored_initiative then
   155     ui.tag{
   156       content = _"You have ignored this initiative"
   157     }
   158     ui.link{
   159       text   = _"Stop ignoring initiative",
   160       module = "initiative",
   161       action = "update_ignore",
   162       id     = initiative.id,
   163       params = { delete = true },
   164       routing = {
   165         default = {
   166           mode = "redirect",
   167           module = request.get_module(),
   168           view = request.get_view(),
   169           id = param.get_id_cgi(),
   170           params = param.get_all_cgi()
   171         }
   172       }
   173     }
   174   else
   175     ui.link{
   176       text    = _"Ignore initiative",
   177       module  = "initiative",
   178       action  = "update_ignore",
   179       id      = initiative.id,
   180       routing = {
   181         default = {
   182           mode = "redirect",
   183           module = request.get_module(),
   184           view = request.get_view(),
   185           id = param.get_id_cgi(),
   186           params = param.get_all_cgi()
   187         }
   188       }
   189     }
   190   end
   191 end
