| rev | 
   line source | 
| 
bsw@1045
 | 
     1 local initiative = param.get("initiative", "table")
 | 
| 
bsw@1045
 | 
     2 local member = param.get("member", "table") or app.session.member
 | 
| 
bsw@1045
 | 
     3 
 | 
| 
bsw@1045
 | 
     4 -- TODO performance
 | 
| 
bsw@1045
 | 
     5 local initiator
 | 
| 
bsw@1045
 | 
     6 if member then
 | 
| 
bsw@1045
 | 
     7   initiator = Initiator:by_pk(initiative.id, member.id)
 | 
| 
bsw@1045
 | 
     8 end
 | 
| 
bsw@1045
 | 
     9 
 | 
| 
bsw@1045
 | 
    10 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
 | 
| 
bsw@1045
 | 
    11   :add_field("initiator.accepted", "accepted")
 | 
| 
bsw@1045
 | 
    12   :add_order_by("member.name")
 | 
| 
bsw@1045
 | 
    13 if initiator and initiator.accepted then
 | 
| 
bsw@1045
 | 
    14   initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted")
 | 
| 
bsw@1045
 | 
    15 else
 | 
| 
bsw@1045
 | 
    16   initiators_members_selector:add_where("initiator.accepted")
 | 
| 
bsw@1045
 | 
    17 end
 | 
| 
bsw@1045
 | 
    18 
 | 
| 
bsw@1045
 | 
    19 local initiators = initiators_members_selector:exec()
 | 
| 
bsw@1045
 | 
    20 
 | 
| 
bsw@1045
 | 
    21 
 | 
| 
bsw@1045
 | 
    22 ui.sectionHead( "initiativeInfo", function ()
 | 
| 
bsw@1045
 | 
    23 
 | 
| 
bsw@1045
 | 
    24     ui.heading { 
 | 
| 
bsw@1045
 | 
    25       level = 1,
 | 
| 
bsw@1045
 | 
    26       content = initiative.display_name
 | 
| 
bsw@1045
 | 
    27     }
 | 
| 
bsw@1045
 | 
    28 
 | 
| 
bsw@1045
 | 
    29     ui.container { attr = { class = "support" }, content = function ()
 | 
| 
bsw@1045
 | 
    30       if initiative.supporter_count == nil then
 | 
| 
bsw@1045
 | 
    31         ui.tag { 
 | 
| 
bsw@1045
 | 
    32           attr = { class = "supporterCount" },
 | 
| 
bsw@1045
 | 
    33           content = _"[calculating]"
 | 
| 
bsw@1045
 | 
    34         }
 | 
| 
bsw@1045
 | 
    35       elseif initiative.issue.closed == nil then
 | 
| 
bsw@1045
 | 
    36         ui.tag { 
 | 
| 
bsw@1045
 | 
    37           attr = { class = "satisfiedSupporterCount" },
 | 
| 
bsw@1045
 | 
    38           content = _("#{count} supporter", { count = initiative.satisfied_supporter_count })
 | 
| 
bsw@1045
 | 
    39         }
 | 
| 
bsw@1045
 | 
    40         if initiative.potential_supporter_count and
 | 
| 
bsw@1045
 | 
    41             initiative.potential_supporter_count > 0 
 | 
| 
bsw@1045
 | 
    42         then
 | 
| 
bsw@1045
 | 
    43           slot.put ( " " )
 | 
| 
bsw@1045
 | 
    44           ui.tag { 
 | 
| 
bsw@1045
 | 
    45             attr = { class = "potentialSupporterCount" },
 | 
| 
bsw@1045
 | 
    46             content = _("(+ #{count} potential)", { count = initiative.potential_supporter_count })
 | 
| 
bsw@1045
 | 
    47           }
 | 
| 
bsw@1045
 | 
    48         end
 | 
| 
bsw@1045
 | 
    49       
 | 
| 
bsw@1045
 | 
    50       end 
 | 
| 
bsw@1045
 | 
    51       
 | 
| 
bsw@1045
 | 
    52       slot.put ( "<br />" )
 | 
| 
bsw@1045
 | 
    53       
 | 
| 
bsw@1045
 | 
    54       execute.view {
 | 
| 
bsw@1045
 | 
    55         module = "initiative", view = "_bargraph", params = {
 | 
| 
bsw@1045
 | 
    56           initiative = initiative
 | 
| 
bsw@1045
 | 
    57         }
 | 
| 
bsw@1045
 | 
    58       }
 | 
| 
bsw@1045
 | 
    59     end }
 | 
| 
bsw@1045
 | 
    60     
 | 
| 
bsw@1045
 | 
    61     if member then
 | 
| 
bsw@1045
 | 
    62       ui.container { attr = { class = "mySupport right" }, content = function ()
 | 
| 
bsw@1045
 | 
    63         if initiative.issue.fully_frozen then
 | 
| 
bsw@1045
 | 
    64           if initiative.issue.member_info.direct_voted then
 | 
| 
bsw@1045
 | 
    65             --ui.image { attr = { class = "icon48 right" }, static = "icons/48/voted_ok.png" }
 | 
| 
bsw@1045
 | 
    66             ui.tag { content = _"You have voted" }
 | 
| 
bsw@1045
 | 
    67             slot.put("<br />")
 | 
| 
bsw@1045
 | 
    68             if not initiative.issue.closed then
 | 
| 
bsw@1045
 | 
    69               ui.link {
 | 
| 
bsw@1045
 | 
    70                 module = "vote", view = "list", 
 | 
| 
bsw@1045
 | 
    71                 params = { issue_id = initiative.issue.id },
 | 
| 
bsw@1045
 | 
    72                 text = _"change vote"
 | 
| 
bsw@1045
 | 
    73               }
 | 
| 
bsw@1045
 | 
    74             else
 | 
| 
bsw@1045
 | 
    75               ui.link {
 | 
| 
bsw@1045
 | 
    76                 module = "vote", view = "list", 
 | 
| 
bsw@1045
 | 
    77                 params = { issue_id = initiative.issue.id },
 | 
| 
bsw@1045
 | 
    78                 text = _"show vote"
 | 
| 
bsw@1045
 | 
    79               }
 | 
| 
bsw@1045
 | 
    80             end
 | 
| 
bsw@1045
 | 
    81             slot.put(" ")
 | 
| 
bsw@1045
 | 
    82           elseif active_trustee_id then
 | 
| 
bsw@1045
 | 
    83             ui.tag { content = _"You have voted via delegation" }
 | 
| 
bsw@1045
 | 
    84             ui.link {
 | 
| 
bsw@1045
 | 
    85               content = _"Show voting ballot",
 | 
| 
bsw@1045
 | 
    86               module = "vote", view = "list", params = {
 | 
| 
bsw@1045
 | 
    87                 issue_id = initiative.issue.id, member_id = active_trustee_id
 | 
| 
bsw@1045
 | 
    88               }
 | 
| 
bsw@1045
 | 
    89             }
 | 
| 
bsw@1045
 | 
    90           elseif not initiative.issue.closed then
 | 
| 
bsw@1045
 | 
    91             ui.link {
 | 
| 
bsw@1045
 | 
    92               attr = { class = "btn btn-default" },
 | 
| 
bsw@1045
 | 
    93               module = "vote", view = "list", 
 | 
| 
bsw@1045
 | 
    94               params = { issue_id = initiative.issue.id },
 | 
| 
bsw@1045
 | 
    95               text = _"vote now"
 | 
| 
bsw@1045
 | 
    96             }
 | 
| 
bsw@1045
 | 
    97           end
 | 
| 
bsw@1045
 | 
    98         elseif initiative.member_info.supported then
 | 
| 
bsw@1045
 | 
    99           if initiative.member_info.satisfied then
 | 
| 
bsw@1045
 | 
   100             ui.image { attr = { class = "icon48 right" }, static = "icons/32/support_satisfied.png" }
 | 
| 
bsw@1045
 | 
   101           else
 | 
| 
bsw@1045
 | 
   102             ui.image { attr = { class = "icon48 right" }, static = "icons/32/support_unsatisfied.png" }
 | 
| 
bsw@1045
 | 
   103           end           
 | 
| 
bsw@1045
 | 
   104           ui.container { content = _"You are supporter" }
 | 
| 
bsw@1045
 | 
   105 
 | 
| 
bsw@1045
 | 
   106           if initiative.issue.member_info.own_participation then
 | 
| 
bsw@1045
 | 
   107             ui.link {
 | 
| 
bsw@1045
 | 
   108               attr = { class = "btn-link" },
 | 
| 
bsw@1045
 | 
   109               module = "initiative", action = "remove_support", 
 | 
| 
bsw@1045
 | 
   110               routing = { default = {
 | 
| 
bsw@1045
 | 
   111                 mode = "redirect", module = "initiative", view = "show", id = initiative.id
 | 
| 
bsw@1045
 | 
   112               } },
 | 
| 
bsw@1045
 | 
   113               id = initiative.id,
 | 
| 
bsw@1045
 | 
   114               text = "remove my support"
 | 
| 
bsw@1045
 | 
   115             }
 | 
| 
bsw@1045
 | 
   116             
 | 
| 
bsw@1045
 | 
   117           else
 | 
| 
bsw@1045
 | 
   118             
 | 
| 
bsw@1045
 | 
   119             ui.link {
 | 
| 
bsw@1045
 | 
   120               module = "delegation", view = "show", params = {
 | 
| 
bsw@1045
 | 
   121                 issue_id = initiative.issue_id,
 | 
| 
bsw@1045
 | 
   122                 initiative_id = initiative.id
 | 
| 
bsw@1045
 | 
   123               },
 | 
| 
bsw@1045
 | 
   124               content = _"via delegation" 
 | 
| 
bsw@1045
 | 
   125             }
 | 
| 
bsw@1045
 | 
   126             
 | 
| 
bsw@1045
 | 
   127           end
 | 
| 
bsw@1045
 | 
   128           
 | 
| 
bsw@1045
 | 
   129           slot.put(" ")
 | 
| 
bsw@1045
 | 
   130       
 | 
| 
bsw@1045
 | 
   131 
 | 
| 
bsw@1045
 | 
   132         else
 | 
| 
bsw@1045
 | 
   133           ui.link {
 | 
| 
bsw@1045
 | 
   134             attr = { class = "btn btn-default" },
 | 
| 
bsw@1045
 | 
   135             module = "initiative", action = "add_support", 
 | 
| 
bsw@1045
 | 
   136             routing = { default = {
 | 
| 
bsw@1045
 | 
   137               mode = "redirect", module = "initiative", view = "show", id = initiative.id
 | 
| 
bsw@1045
 | 
   138             } },
 | 
| 
bsw@1045
 | 
   139             id = initiative.id,
 | 
| 
bsw@1045
 | 
   140             text = _"add my support"
 | 
| 
bsw@1045
 | 
   141           }
 | 
| 
bsw@1045
 | 
   142             
 | 
| 
bsw@1045
 | 
   143         end
 | 
| 
bsw@1045
 | 
   144       end }
 | 
| 
bsw@1045
 | 
   145       
 | 
| 
bsw@1045
 | 
   146     end
 | 
| 
bsw@1045
 | 
   147     
 | 
| 
bsw@1045
 | 
   148     slot.put("<br style='clear: both;'/>")
 | 
| 
bsw@1045
 | 
   149 
 | 
| 
bsw@1045
 | 
   150     ui.container {
 | 
| 
bsw@1045
 | 
   151       attr = { class = "initiators" },
 | 
| 
bsw@1045
 | 
   152       content = function ()
 | 
| 
bsw@1045
 | 
   153       
 | 
| 
bsw@1045
 | 
   154         if app.session:has_access("authors_pseudonymous") then
 | 
| 
bsw@1045
 | 
   155           for i, member in ipairs(initiators) do
 | 
| 
bsw@1045
 | 
   156             if i > 1 then
 | 
| 
bsw@1045
 | 
   157               slot.put(" ")
 | 
| 
bsw@1045
 | 
   158             end
 | 
| 
bsw@1045
 | 
   159             util.micro_avatar(member)
 | 
| 
bsw@1045
 | 
   160             if member.accepted == nil then
 | 
| 
bsw@1045
 | 
   161               slot.put ( " " )
 | 
| 
bsw@1045
 | 
   162               ui.tag { content = _"(invited)" }
 | 
| 
bsw@1045
 | 
   163             end
 | 
| 
bsw@1045
 | 
   164           end -- for i, member
 | 
| 
bsw@1045
 | 
   165           
 | 
| 
bsw@1045
 | 
   166         end
 | 
| 
bsw@1045
 | 
   167           
 | 
| 
bsw@1045
 | 
   168       end
 | 
| 
bsw@1045
 | 
   169     } -- ui.container "initiators"
 | 
| 
bsw@1045
 | 
   170 
 | 
| 
bsw@1045
 | 
   171     ui.container {
 | 
| 
bsw@1045
 | 
   172       attr = { class = "links" },
 | 
| 
bsw@1045
 | 
   173       content = function ()
 | 
| 
bsw@1045
 | 
   174         
 | 
| 
bsw@1045
 | 
   175         local drafts_count = initiative:get_reference_selector("drafts"):count()
 | 
| 
bsw@1045
 | 
   176         ui.link {
 | 
| 
bsw@1045
 | 
   177           content = _("suggestions (#{count}) ↓", {
 | 
| 
bsw@1045
 | 
   178             count = # ( initiative.suggestions )
 | 
| 
bsw@1045
 | 
   179           }),
 | 
| 
bsw@1045
 | 
   180           external = "#suggestions"
 | 
| 
bsw@1045
 | 
   181         }
 | 
| 
bsw@1045
 | 
   182 
 | 
| 
bsw@1045
 | 
   183         slot.put ( " | " )
 | 
| 
bsw@1045
 | 
   184           
 | 
| 
bsw@1045
 | 
   185         ui.link{
 | 
| 
bsw@1045
 | 
   186           module = "initiative", view = "history", id = initiative.id,
 | 
| 
bsw@1045
 | 
   187           content = _("draft history (#{count})", { count = drafts_count })
 | 
| 
bsw@1045
 | 
   188         }
 | 
| 
bsw@1045
 | 
   189         
 | 
| 
bsw@1045
 | 
   190       end
 | 
| 
bsw@1045
 | 
   191     } -- ui.containers "links"
 | 
| 
bsw@1045
 | 
   192   end )
 | 
| 
bsw@1045
 | 
   193  
 | 
| 
bsw@1045
 | 
   194   execute.view {
 | 
| 
bsw@1045
 | 
   195     module = "initiative", view = "_sidebar_state",
 | 
| 
bsw@1045
 | 
   196     params = { initiative = initiative }
 | 
| 
bsw@1045
 | 
   197   }
 | 
| 
bsw@1045
 | 
   198 
 |