| 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/jbe@1309
 | 
    22 ui.container{ attr = { class = "mdl-card__title mdl-card--has-fab mdl-card--border" }, content = function ()
 | 
| 
bsw/jbe@1309
 | 
    23 
 | 
| 
bsw/jbe@1309
 | 
    24   ui.heading { 
 | 
| 
bsw/jbe@1309
 | 
    25     attr = { class = "mdl-card__title-text" },
 | 
| 
bsw/jbe@1309
 | 
    26     level = 2,
 | 
| 
bsw/jbe@1309
 | 
    27     content = function()
 | 
| 
bsw/jbe@1309
 | 
    28       ui.tag{ content = initiative.display_name }
 | 
| 
bsw/jbe@1309
 | 
    29     end 
 | 
| 
bsw/jbe@1309
 | 
    30   }
 | 
| 
bsw@1045
 | 
    31 
 | 
| 
bsw/jbe@1309
 | 
    32   if app.session.member and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then
 | 
| 
bsw/jbe@1309
 | 
    33     if not initiative.issue.closed and not initiative.member_info.supported then
 | 
| 
bsw/jbe@1309
 | 
    34       if not initiative.issue.fully_frozen then
 | 
| 
bsw/jbe@1309
 | 
    35         ui.link {
 | 
| 
bsw/jbe@1309
 | 
    36           attr = { class = "mdl-button mdl-js-button mdl-button--fab mdl-button--colored" ,
 | 
| 
bsw/jbe@1309
 | 
    37             style = "position: absolute; right: 20px; bottom: -27px;"
 | 
| 
bsw/jbe@1309
 | 
    38           },
 | 
| 
bsw/jbe@1309
 | 
    39           module = "initiative", action = "add_support", 
 | 
| 
bsw/jbe@1309
 | 
    40           routing = { default = {
 | 
| 
bsw/jbe@1309
 | 
    41             mode = "redirect", module = "initiative", view = "show", id = initiative.id
 | 
| 
bsw/jbe@1309
 | 
    42           } },
 | 
| 
bsw/jbe@1309
 | 
    43           id = initiative.id,
 | 
| 
bsw/jbe@1309
 | 
    44           content = function()
 | 
| 
bsw/jbe@1309
 | 
    45             ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
 | 
| 
bsw/jbe@1309
 | 
    46           end 
 | 
| 
bsw@1045
 | 
    47         }
 | 
| 
bsw/jbe@1309
 | 
    48       end
 | 
| 
bsw/jbe@1309
 | 
    49     end
 | 
| 
bsw/jbe@1309
 | 
    50     if initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.issue.member_info.direct_voted then
 | 
| 
bsw/jbe@1309
 | 
    51       ui.link {
 | 
| 
bsw/jbe@1309
 | 
    52         attr = { class = "mdl-button mdl-js-button mdl-button--fab mdl-button--colored" ,
 | 
| 
bsw/jbe@1309
 | 
    53           style = "position: absolute; right: 20px; bottom: -27px;"
 | 
| 
bsw/jbe@1309
 | 
    54         },
 | 
| 
bsw/jbe@1309
 | 
    55         module = "vote", view = "list", 
 | 
| 
bsw/jbe@1309
 | 
    56         params = { issue_id = initiative.issue_id },
 | 
| 
bsw/jbe@1309
 | 
    57         content = function()
 | 
| 
bsw/jbe@1309
 | 
    58           ui.tag{ tag = "i", attr = { class = "material-icons" }, content = config.voting_icon or "mail_outline" }
 | 
| 
bsw/jbe@1309
 | 
    59         end 
 | 
| 
bsw/jbe@1309
 | 
    60       }
 | 
| 
bsw/jbe@1309
 | 
    61     end
 | 
| 
bsw/jbe@1309
 | 
    62   end
 | 
| 
bsw/jbe@1309
 | 
    63 end }
 | 
| 
bsw/jbe@1309
 | 
    64 
 | 
| 
bsw/jbe@1309
 | 
    65 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function ()
 | 
| 
bsw/jbe@1309
 | 
    66 
 | 
| 
bsw/jbe@1309
 | 
    67   if not config.voting_only and app.session:has_access("authors_pseudonymous") then
 | 
| 
bsw/jbe@1309
 | 
    68     for i, member in ipairs(initiators) do
 | 
| 
bsw/jbe@1309
 | 
    69       if i > 1 then
 | 
| 
bsw/jbe@1309
 | 
    70         slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
    71       end
 | 
| 
bsw/jbe@1309
 | 
    72       util.micro_avatar( member )
 | 
| 
bsw/jbe@1309
 | 
    73     end -- for i, member
 | 
| 
bsw/jbe@1309
 | 
    74   end
 | 
| 
bsw/jbe@1309
 | 
    75   
 | 
| 
bsw/jbe@1309
 | 
    76   if member then
 | 
| 
bsw/jbe@1309
 | 
    77     ui.container { attr = { class = "mySupport float-right right" }, content = function ()
 | 
| 
bsw/jbe@1309
 | 
    78       if initiative.issue.fully_frozen then
 | 
| 
bsw/jbe@1309
 | 
    79         slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
    80         if initiative.issue.member_info.direct_voted then
 | 
| 
bsw/jbe@1309
 | 
    81           ui.tag { content = _"You have voted" }
 | 
| 
bsw/jbe@1309
 | 
    82           slot.put("<br />")
 | 
| 
bsw/jbe@1309
 | 
    83           if not initiative.issue.closed then
 | 
| 
bsw/jbe@1309
 | 
    84             ui.link {
 | 
| 
bsw/jbe@1309
 | 
    85               module = "vote", view = "list", 
 | 
| 
bsw/jbe@1309
 | 
    86               params = { issue_id = initiative.issue.id },
 | 
| 
bsw/jbe@1309
 | 
    87               text = _"change vote"
 | 
| 
bsw/jbe@1309
 | 
    88             }
 | 
| 
bsw/jbe@1309
 | 
    89           else
 | 
| 
bsw/jbe@1309
 | 
    90             ui.link {
 | 
| 
bsw/jbe@1309
 | 
    91               module = "vote", view = "list", 
 | 
| 
bsw/jbe@1309
 | 
    92               params = { issue_id = initiative.issue.id },
 | 
| 
bsw/jbe@1309
 | 
    93               text = _"show vote"
 | 
| 
bsw/jbe@1309
 | 
    94             }
 | 
| 
bsw/jbe@1309
 | 
    95           end
 | 
| 
bsw/jbe@1309
 | 
    96           slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
    97         elseif active_trustee_id then
 | 
| 
bsw/jbe@1309
 | 
    98           ui.tag { content = _"You have voted via delegation" }
 | 
| 
bsw/jbe@1309
 | 
    99           ui.link {
 | 
| 
bsw/jbe@1309
 | 
   100             content = _"Show voting ballot",
 | 
| 
bsw/jbe@1309
 | 
   101             module = "vote", view = "list", params = {
 | 
| 
bsw/jbe@1309
 | 
   102               issue_id = initiative.issue.id, member_id = active_trustee_id
 | 
| 
bsw/jbe@1309
 | 
   103             }
 | 
| 
bsw/jbe@1309
 | 
   104           }
 | 
| 
bsw/jbe@1309
 | 
   105         elseif not initiative.issue.closed then
 | 
| 
bsw/jbe@1309
 | 
   106           ui.link {
 | 
| 
bsw/jbe@1309
 | 
   107             attr = { class = "btn btn-default" },
 | 
| 
bsw/jbe@1309
 | 
   108             module = "vote", view = "list", 
 | 
| 
bsw/jbe@1309
 | 
   109             params = { issue_id = initiative.issue.id },
 | 
| 
bsw/jbe@1309
 | 
   110             text = _"vote now"
 | 
| 
bsw@1045
 | 
   111           }
 | 
| 
bsw@1045
 | 
   112         end
 | 
| 
bsw/jbe@1309
 | 
   113       elseif initiative.member_info.supported then
 | 
| 
bsw/jbe@1309
 | 
   114         ui.container{ content = function()
 | 
| 
bsw/jbe@1309
 | 
   115           ui.tag{ content = _"You are supporter" }
 | 
| 
bsw/jbe@1309
 | 
   116           slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   117           if initiative.member_info.satisfied then
 | 
| 
bsw/jbe@1309
 | 
   118             ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
 | 
| 
bsw/jbe@1309
 | 
   119           else
 | 
| 
bsw/jbe@1309
 | 
   120             ui.tag{ tag = "i", attr = { class = "material-icons" }, content = "thumb_up" }
 | 
| 
bsw/jbe@1309
 | 
   121           end           
 | 
| 
bsw/jbe@1309
 | 
   122         end }
 | 
| 
bsw/jbe@1309
 | 
   123         if initiative.issue.member_info.own_participation then
 | 
| 
bsw/jbe@1309
 | 
   124           ui.link {
 | 
| 
bsw/jbe@1309
 | 
   125             attr = { class = "btn-link" },
 | 
| 
bsw/jbe@1309
 | 
   126             module = "initiative", action = "remove_support", 
 | 
| 
bsw/jbe@1309
 | 
   127             routing = { default = {
 | 
| 
bsw/jbe@1309
 | 
   128               mode = "redirect", module = "initiative", view = "show", id = initiative.id
 | 
| 
bsw/jbe@1309
 | 
   129             } },
 | 
| 
bsw/jbe@1309
 | 
   130             id = initiative.id,
 | 
| 
bsw/jbe@1309
 | 
   131             text = _"remove my support"
 | 
| 
bsw/jbe@1309
 | 
   132           }
 | 
| 
bsw/jbe@1309
 | 
   133           
 | 
| 
bsw/jbe@1309
 | 
   134         else
 | 
| 
bsw/jbe@1309
 | 
   135           
 | 
| 
bsw/jbe@1309
 | 
   136           ui.link {
 | 
| 
bsw/jbe@1309
 | 
   137             module = "delegation", view = "show", params = {
 | 
| 
bsw/jbe@1309
 | 
   138               issue_id = initiative.issue_id,
 | 
| 
bsw/jbe@1309
 | 
   139               initiative_id = initiative.id
 | 
| 
bsw/jbe@1309
 | 
   140             },
 | 
| 
bsw/jbe@1309
 | 
   141             content = _"via delegation" 
 | 
| 
bsw/jbe@1309
 | 
   142           }
 | 
| 
bsw/jbe@1309
 | 
   143           
 | 
| 
bsw/jbe@1309
 | 
   144         end
 | 
| 
bsw/jbe@1309
 | 
   145         
 | 
| 
bsw/jbe@1309
 | 
   146         slot.put(" ")
 | 
| 
bsw/jbe@1309
 | 
   147         
 | 
| 
bsw/jbe@1309
 | 
   148       end
 | 
| 
bsw/jbe@1309
 | 
   149     end }
 | 
| 
bsw/jbe@1309
 | 
   150     
 | 
| 
bsw/jbe@1309
 | 
   151   end
 | 
| 
bsw/jbe@1309
 | 
   152 
 | 
| 
bsw/jbe@1309
 | 
   153   if config.initiative_abstract then
 | 
| 
bsw/jbe@1309
 | 
   154     local abstract = string.match(initiative.current_draft.content, "(.+)<!%--END_OF_ABSTRACT%-->")
 | 
| 
bsw/jbe@1309
 | 
   155     if abstract then
 | 
| 
bsw/jbe@1309
 | 
   156       ui.container{
 | 
| 
bsw/jbe@1309
 | 
   157         attr = { class = "abstract", style = "padding-right: 140px;" },
 | 
| 
bsw/jbe@1309
 | 
   158         content = function() slot.put(abstract) end
 | 
| 
bsw/jbe@1309
 | 
   159       }
 | 
| 
bsw/jbe@1309
 | 
   160     end
 | 
| 
bsw/jbe@1309
 | 
   161   end
 | 
| 
bsw/jbe@1309
 | 
   162   
 | 
| 
bsw/jbe@1309
 | 
   163   ui.container { attr = { class = "support" }, content = function ()
 | 
| 
bsw/jbe@1309
 | 
   164     
 | 
| 
bsw/jbe@1309
 | 
   165     if not config.voting_only then
 | 
| 
bsw@1045
 | 
   166       execute.view {
 | 
| 
bsw@1045
 | 
   167         module = "initiative", view = "_bargraph", params = {
 | 
| 
bsw@1045
 | 
   168           initiative = initiative
 | 
| 
bsw@1045
 | 
   169         }
 | 
| 
bsw@1045
 | 
   170       }
 | 
| 
bsw/jbe@1309
 | 
   171       slot.put(" ")
 | 
| 
bsw@1045
 | 
   172 
 | 
| 
bsw/jbe@1309
 | 
   173       ui.supporter_count(initiative)
 | 
| 
bsw@1045
 | 
   174     end
 | 
| 
bsw@1045
 | 
   175     
 | 
| 
bsw/jbe@1309
 | 
   176   end }
 | 
| 
bsw/jbe@1309
 | 
   177   
 | 
| 
bsw/jbe@1309
 | 
   178 end }
 | 
| 
bsw@1045
 | 
   179 
 | 
| 
bsw/jbe@1309
 | 
   180 execute.view {
 | 
| 
bsw/jbe@1309
 | 
   181   module = "initiative", view = "_sidebar_state",
 | 
| 
bsw/jbe@1309
 | 
   182   params = { initiative = initiative }
 | 
| 
bsw/jbe@1309
 | 
   183 }
 | 
| 
bsw@1045
 | 
   184 
 |