liquid_feedback_frontend
view app/main/issue/_sidebar_whatcanido.lua @ 1100:41f55e4cb905
Added translation of phase durations
| author | bsw | 
|---|---|
| date | Mon Oct 27 12:03:08 2014 +0100 (2014-10-27) | 
| parents | 701a5cf6b067 | 
| children | abee3e49cd44 | 
 line source
     1 local issue = param.get("issue", "table")
     2 local initiative = param.get("initiative", "table")
     3 local member = param.get("member", "table") or app.session.member
     5 if initiative then
     6   issue = initiative.issue
     7 end
     9 local privileged_to_vote = app.session.member and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
    11 local active_trustee_id
    12 if member then
    13   if not issue.member_info.own_participation then
    14     if issue.member_info.first_trustee_participation then
    15       active_trustee_id = issue.member_info.first_trustee_id
    16     elseif issue.member_info.other_trustee_participation then
    17       active_trustee_id = issue.member_info.other_trustee_id
    18     end
    19   end
    20 end
    22 ui.sidebar ( "tab-whatcanido", function ()
    24   ui.sidebarHeadWhatCanIDo()
    26   local supporter
    28   if initiative and app.session.member_id then
    29     supporter = app.session.member:get_reference_selector("supporters")
    30       :add_where{ "initiative_id = ?", initiative.id }
    31       :optional_object_mode()
    32       :exec()
    33   end
    35   local view_module
    36   local view_id
    38   if initiative then
    39     issue = issue
    40     view_module = "initiative"
    41     view_id = initiative.id
    42   else
    43     view_module = "issue"
    44     view_id = issue.id
    45   end
    47   local initiator
    48   if initiative and app.session.member_id then
    49     initiator = Initiator:by_pk(initiative.id, app.session.member.id)
    50   end
    52   local initiators 
    54   if initiative then
    55     local initiators_members_selector = initiative:get_reference_selector("initiating_members")
    56       :add_field("initiator.accepted", "accepted")
    57       :add_order_by("member.name")
    58     if initiator and initiator.accepted then
    59       initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted")
    60     else
    61       initiators_members_selector:add_where("initiator.accepted")
    62     end
    64     initiators = initiators_members_selector:exec()
    65   end
    67   if initiator and 
    68     initiator.accepted and 
    69     not issue.fully_frozen and 
    70     not issue.closed and 
    71     not initiative.revoked 
    72   then
    74     ui.container { attr = { class = "sidebarRow" }, content = function ()
    75       ui.heading { level = 3, content = function()
    76         ui.tag { content = _"You are initiator of this initiative" }
    77       end }
    78       ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
    79         ui.tag { tag = "li", content = function ()
    80           ui.link{
    81             module = "draft", view = "new",
    82             params = { initiative_id = initiative.id },
    83             content = _"edit proposal and/or reasons"
    84           }
    85         end }
    86         ui.tag { tag = "li", content = function ()
    87           ui.link{
    88             attr = { class = "action" },
    89             module = "initiative", view = "add_initiator",
    90             params = { initiative_id = initiative.id },
    91             content = _"invite another initiator"
    92           }
    93         end }
    94         if #initiative.initiators > 1 then
    95           ui.tag { tag = "li", content = function ()
    96             ui.link{
    97               module = "initiative", view = "remove_initiator",
    98               params = { initiative_id = initiative.id },
    99               content = _"remove an initiator"
   100             }
   101           end }
   102         end
   103         ui.tag { tag = "li", content = function ()
   104           ui.link{
   105             module = "initiative", view = "revoke", id = initiative.id,
   106             content = _"revoke initiative"
   107           }
   108         end }
   109       end }
   110     end }
   111   end
   113   -- invited as initiator
   114   if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
   115     ui.container { attr = { class = "sidebarRow highlighted" }, content = function ()
   116       ui.heading { level = 3, content = function()
   117         ui.tag { content = _"You are invited to become initiator of this initiative" }
   118       end }
   119       ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   120         ui.tag{ tag = "li", content = function ()
   121           ui.link{
   122             content = _"accept invitation",
   123             module = "initiative",
   124             action = "accept_invitation",
   125             id     = initiative.id,
   126             routing = {
   127               default = {
   128                 mode = "redirect",
   129                 module = request.get_module(),
   130                 view = request.get_view(),
   131                 id = param.get_id_cgi(),
   132                 params = param.get_all_cgi()
   133               }
   134             }
   135           }
   136         end }
   138         ui.tag{ tag = "li", content = function ()
   139           ui.link{
   140             content = _"refuse invitation",
   141             module = "initiative",
   142             action = "reject_initiator_invitation",
   143             params = {
   144               initiative_id = initiative.id,
   145               member_id = app.session.member.id
   146             },
   147             routing = {
   148               default = {
   149                 mode = "redirect",
   150                 module = request.get_module(),
   151                 view = request.get_view(),
   152                 id = param.get_id_cgi(),
   153                 params = param.get_all_cgi()
   154               }
   155             }
   156           }
   157         end }
   158       end }
   159     end }
   160   end
   163   if privileged_to_vote and issue.member_info.first_trustee_id then
   164     local member = Member:by_id(issue.member_info.first_trustee_id)
   165     ui.sidebarSection( function ()
   166       ui.container { attr = { class = "right" }, content = function()
   167         execute.view{
   168           module = "member_image",
   169           view = "_show",
   170           params = {
   171             member = member,
   172             image_type = "avatar",
   173             show_dummy = true
   174           }
   175         }
   176       end }
   177       if issue.member_info.own_delegation_scope == "unit" then
   178         ui.heading{ level = 3, content = _"You delegated this organizational unit" }
   179       elseif issue.member_info.own_delegation_scope == "area" then
   180         ui.heading{ level = 3, content = _"You delegated this subject area" }
   181       elseif issue.member_info.own_delegation_scope == "issue" then
   182         ui.heading{ level = 3, content = _"You delegated this issue" }
   183       end
   185       ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   186         if issue.member_info.own_delegation_scope == "area" or
   187            issue.member_info.own_delegation_scope == "unit" then
   188           ui.tag { tag = "li", content = function ()
   189             ui.link {
   190               module = "delegation", view = "show", params = {
   191                 issue_id = issue.id,
   192                 initiative_id = initiative and initiative.id or nil
   193               },
   194               content = _"change/revoke delegation only for this issue" 
   195             }
   196           end }
   197         end
   198         if issue.member_info.own_delegation_scope == "unit" then
   199           ui.tag { tag = "li", content = function ()
   200             ui.link {
   201               module = "delegation", view = "show", params = {
   202                 unit_id = issue.area.unit_id,
   203               },
   204               content = _("change/revoke delegation of organizational unit", {
   205                 unit_name = issue.area.unit.name
   206               })
   207             }
   208           end }
   209         elseif issue.member_info.own_delegation_scope == "area" then
   210           ui.tag { tag = "li", content = function ()
   211             ui.link {
   212               module = "delegation", view = "show", params = {
   213                 area_id = issue.area_id,
   214               },
   215               content = _"change/revoke delegation of subject area" 
   216             }
   217           end }
   218         end
   219         if issue.member_info.own_delegation_scope == nil then
   220           ui.tag { tag = "li", content = function ()
   221             ui.link {
   222               module = "delegation", view = "show", params = {
   223                 issue_id = issue.id,
   224                 initiative_id = initiative and initiative.id or nil
   225               },
   226               content = _"choose issue delegatee" 
   227             }
   228           end }
   229         elseif issue.member_info.own_delegation_scope == "issue" then
   230           ui.tag { tag = "li", content = function ()
   231             ui.link {
   232               module = "delegation", view = "show", params = {
   233                 issue_id = issue.id,
   234                 initiative_id = initiative and initiative.id or nil
   235               },
   236               content = _"change/revoke issue delegation" 
   237             }
   238           end }
   239         end
   240       end }
   242       if issue.member_info.first_trustee_id and issue.member_info.own_participation then
   243         local text = _"As long as you are interested in this issue yourself, the delegation is suspended for this issue, but it will be applied again in the voting phase unless you vote yourself."
   244         if issue.state == "voting" then
   245           text = _"This delegation is suspended, because you voted yourself."
   246         end
   247         ui.container { content = text }
   248       end
   249     end )
   250   end
   252   if privileged_to_vote and not issue.closed and not issue.fully_frozen then
   253     if issue.member_info.own_participation then
   254       ui.sidebarSection( function ()
   255         ui.container{ attr = { class = "right" }, content = function()
   256           ui.image{ attr = { class = "right" }, static = "icons/48/eye.png" }
   257           if issue.member_info.weight and issue.member_info.weight > 1 then
   258             slot.put("<br />")
   259             ui.tag{ 
   260               attr = { class = "right" },
   261               content = "+" .. issue.member_info.weight - 1
   262            }
   263           end
   264         end }
   265         ui.heading{ level = 3, content = _("You are interested in this issue", { id = issue.id }) }
   266         ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   267           if issue.member_info.weight and issue.member_info.weight > 1 then
   268             ui.tag { tag = "li", content = function ()
   269               ui.link {
   270                 module = "delegation", view = "show_incoming",
   271                 params = { issue_id = issue.id, member_id = app.session.member_id },
   272                 content = _("you have #{count} incoming delegations", {
   273                   count = issue.member_info.weight - 1
   274                 })
   275               }
   276             end }
   277           end
   278           ui.tag { tag = "li", content = function ()
   279             ui.link {
   280               module = "interest", action = "update",
   281               routing = { default = {
   282                 mode = "redirect", module = view_module, view = "show", id = view_id
   283               } },
   284               params = { issue_id = issue.id, delete = true },
   285               text = _"remove my interest"
   286             }
   287           end }
   288         end }
   289       end )
   290     else
   291       ui.sidebarSection( function ()
   292         ui.heading{ level = 3, content = _("I want to participate in this issue", { id = issue.id }) }
   293         ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   294           ui.tag { tag = "li", content = function ()
   295             ui.link {
   296               module = "interest", action = "update", 
   297               params = { issue_id = issue.id },
   298               routing = { default = {
   299                 mode = "redirect", module = view_module, view = "show", id = view_id
   300               } },
   301               text = _"add my interest"
   302             }
   303           end }
   304           ui.tag { tag = "li", content = _"browse through the competing initiatives" }
   305         end }
   306       end )
   307     end
   309     if initiative then
   311       if not initiative.member_info.supported or active_trustee_id then
   312         ui.container { attr = { class = "sidebarRow" }, content = function ()
   313           ui.heading { level = 3, content = function()
   314             ui.tag { content = _"I like this initiative and I want to support it" }
   315           end }
   316           ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   317             ui.tag { tag = "li", content = function ()
   318               ui.link {
   319                 module = "initiative", action = "add_support", 
   320                 routing = { default = {
   321                   mode = "redirect", module = "initiative", view = "show", id = initiative.id
   322                 } },
   323                 id = initiative.id,
   324                 text = _"add my support"
   325               }
   326             end }
   327           end }
   328         end }
   330       else -- if not supported
   331         ui.container { attr = { class = "sidebarRow" }, content = function ()
   332           if initiative.member_info.satisfied then
   333             ui.image{ attr = { class = "right icon48" }, static = "icons/32/support_satisfied.png" }
   334           else
   335             ui.image{ attr = { class = "right icon48" }, static = "icons/32/support_unsatisfied.png" }
   336           end
   337           ui.heading { level = 3, content = _"You are supporting this initiative" }
   338           ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   339             if not initiative.member_info.satisfied then
   340               ui.tag { tag = "li", content = function ()
   341                 ui.tag { content = function ()
   342                   ui.link {
   343                     external = "#suggestions",
   344                     content = _"you restricted your support by rating suggestions as must or must not"
   345                   }
   346                 end }
   347               end }
   348             end
   349             ui.tag { tag = "li", content = function ()
   350               ui.tag { content = function ()
   351                 ui.link {
   352                   xattr = { class = "btn btn-remove" },
   353                   module = "initiative", action = "remove_support", 
   354                   routing = { default = {
   355                     mode = "redirect", module = "initiative", view = "show", id = initiative.id
   356                   } },
   357                   id = initiative.id,
   358                   text = _"remove my support"
   359                 }
   360               end }
   361             end }
   362           end }
   363         end }
   365       end -- not supported
   367       ui.container { attr = { class = "sidebarRow" }, content = function ()
   368         ui.heading { level = 3, content = _"I want to improve this initiative" }
   369         ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   370           if issue.state == "verification" then
   371             ui.tag { tag = "li", content = _"this issue is in verification phase, therefore the initiative text cannot be updated anymore" }
   372           elseif issue.state == "voting" then
   373             ui.tag { tag = "li", content = _"this issue is in voting phase, therefore the initiative text cannot be updated anymore" }
   374           else
   376             if initiative.member_info.initiated then
   377               ui.tag { tag = "li", content =_"take a look at the suggestions of your supporters" }
   378               ui.tag { tag = "li", content =_"if you like to implement a suggestion in your proposal and/or reasons, update your initiative draft" }
   379               ui.tag { tag = "li", content =_"to argue about suggestions, just add your arguments to your reasons in the initiative draft, so your supporters can learn about your opinion" }
   380             end
   382             if not initiative.member_info.supported or active_trustee_id then
   383               ui.tag { tag = "li", content =_"add your support (see above) and rate or write new suggestions (and thereby restrict your support to certain conditions if necessary)" }
   384             else
   385               ui.tag { tag = "li", content = _"take a look at the suggestions (see left) and rate them" }
   386               ui.tag { tag = "li", content = function ()
   387                 ui.link {
   388                   module = "suggestion", view = "new", params = {
   389                     initiative_id = initiative.id
   390                   },
   391                   content = _"write a new suggestion" 
   392                 }
   393               end }
   394             end
   395           end
   396         end }
   397       end }
   399     end
   401     if 
   402       (issue.state == "admission" or 
   403       issue.state == "discussion" or
   404       issue.state == "verification")
   405     then
   406       ui.sidebarSection( function ()
   407         if initiative then
   408           ui.heading{ level = 3, content = _"I don't like this initiative and I want to add my opinion or counter proposal" }
   409         else
   410           ui.heading{ level = 3, content = _"I don't like any of the initiative in this issue and I want to add my opinion or counter proposal" }
   411         end
   412         ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   413           ui.tag { tag = "li", content = function ()
   414             ui.link {
   415               module = "issue", view = "show", id = issue.id,
   416               content = _"take a look at the competing initiatives"
   417             }
   418           end }
   419           ui.tag { tag = "li", content = function ()
   420             ui.link {
   421               module = "initiative", view = "new", 
   422               params = { issue_id = issue.id },
   423               content = _"start a new competing initiative"
   424             }
   425           end }
   426         end }
   427       end )
   428     end 
   430     if not issue.member_info.first_trustee_id then
   431       ui.sidebarSection( function ()
   432         ui.heading{ level = 3, content = _"I want to delegate this issue" }
   434         ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   435           ui.tag { tag = "li", content = function ()
   436             ui.link {
   437               module = "delegation", view = "show", params = {
   438                 issue_id = issue.id,
   439                 initiative_id = initiative and initiative.id or nil
   440               },
   441               content = _"choose issue delegatee" 
   442             }
   443           end }
   444         end }
   445       end )
   446     end
   448   end
   450   if initiator and initiator.accepted == false then
   451     ui.container { attr = { class = "sidebarRow" }, content = function ()
   452       ui.heading { level = 3, content = function()
   453         ui.tag { content = _"You refused to become initiator of this initiative" }
   454       end }
   455       ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   456         ui.tag{ tag = "li", content = function ()
   457           ui.link{
   458             text   = _"allow invitation again",
   459             module = "initiative",
   460             action = "remove_initiator",
   461             params = {
   462               initiative_id = initiative.id,
   463               member_id = app.session.member.id
   464             },
   465             routing = {
   466               ok = {
   467                 mode = "redirect",
   468                 module = "initiative",
   469                 view = "show",
   470                 id = initiative.id
   471               }
   472             }
   473           }
   474         end }
   475       end }
   476     end }
   477   end
   481   if privileged_to_vote then
   483     if initiative and
   484       (issue.state == "admission" or 
   485       issue.state == "discussion" or
   486       issue.state == "verification")
   487     then
   489     elseif issue.state == "verification" then
   491     elseif issue.state == "voting" then
   492       if not issue.member_info.direct_voted then
   493         if not issue.member_info.non_voter then
   494           ui.container { attr = { class = "sidebarRow" }, content = function ()
   495             ui.heading { level = 3, content = _"I like to vote on this issue:" }
   496             ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   497               ui.tag { tag = "li", content = function ()
   498                 ui.tag { content = function ()
   499                   if not issue.closed then
   500                     ui.link {
   501                       xattr = { class = "btn btn-vote" },
   502                       module = "vote", view = "list", 
   503                       params = { issue_id = issue.id },
   504                       text = _"vote now"
   505                     }
   506                   end
   507                 end }
   508               end }
   509             end }
   510           end }
   511         end
   512         ui.container { attr = { class = "sidebarRow" }, content = function ()
   513           if not issue.member_info.non_voter then
   514             ui.heading { level = 3, content = _"I don't like to vote this issue (myself):" }
   515             ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   516               ui.tag { tag = "li", content = function ()
   517                 ui.link{
   518                   content = _"do not notify me about this voting anymore",
   519                   module = "vote",
   520                   action = "non_voter",
   521                   params = { issue_id = issue.id },
   522                   routing = {
   523                     default = {
   524                       mode = "redirect",
   525                       module = request.get_module(),
   526                       view = request.get_view(),
   527                       id = param.get_id_cgi(),
   528                       params = param.get_all_cgi()
   529                     }
   530                   }
   531                 }
   532               end }
   533             end }
   534           else
   535             ui.heading { level = 3, content = _"You do not like to vote this issue (yourself)" }
   536             ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   537               ui.tag { tag = "li", content = function ()
   538                 ui.link{
   539                   in_brackets = true,
   540                   content = _"discard",
   541                   module = "vote",
   542                   action = "non_voter",
   543                   params = { issue_id = issue.id, delete = true },
   544                   routing = {
   545                     default = {
   546                       mode = "redirect",
   547                       module = request.get_module(),
   548                       view = request.get_view(),
   549                       id = param.get_id_cgi(),
   550                       params = param.get_all_cgi()
   551                     }
   552                   }
   553                 }
   554               end }
   555             end }
   556           end
   557         end }
   558       else
   559         ui.container { attr = { class = "sidebarRow" }, content = function ()
   560           ui.heading { level = 3, content = _"I like to change/revoke my vote:" }
   561           ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   562             ui.tag { tag = "li", content = function ()
   563               ui.tag { content = function ()
   564                 if not issue.closed then
   565                   ui.link {
   566                     xattr = { class = "btn btn-vote" },
   567                     module = "vote", view = "list", 
   568                     params = { issue_id = issue.id },
   569                     text = _"change my vote"
   570                   }
   571                 end
   572               end }
   573             end }
   574             ui.tag { tag = "li", content = function ()
   575               ui.tag { content = function ()
   576                 if not issue.closed then
   577                   ui.link {
   578                     module = "vote", action = "update",
   579                     params = {
   580                       issue_id = issue.id,
   581                       discard = true
   582                     },
   583                     routing = {
   584                       default = {
   585                         mode = "redirect",
   586                         module = "issue",
   587                         view = "show",
   588                         id = issue.id
   589                       }
   590                     },
   591                     text = _"discard my vote"
   592                   }
   593                 end
   594               end }
   595             end }
   596           end } 
   598         end } 
   600       end
   601     end
   602   end
   604   if app.session.member and not privileged_to_vote then
   605     ui.sidebarSection( _"You are not entitled to vote in this unit" )
   606   end
   608   if issue.closed then
   609     ui.container { attr = { class = "sidebarRow" }, content = function ()
   610       ui.heading { level = 3, content = _"This issue is closed" }
   611     end }
   612   end
   614   if initiative and config.tell_others and config.tell_others.initiative then
   615     ui.container { attr = { class = "sidebarRow" }, content = function ()
   617       ui.heading { level = 3, content = _"Tell others about this initiative:" }
   618       ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   620         for i, link in ipairs (config.tell_others.initiative(initiative)) do
   621           ui.tag { tag = "li", content = function ()
   622             ui.link ( link )
   623           end }
   624         end
   626       end }
   627     end }
   628   end
   631 end )
