liquid_feedback_frontend
view app/main/delegation/_show_box.lua @ 5:afd9f769c7ae
Version beta1
Final voting with Schulze-Method is now possible
Many bug fixes and code cleanup
Registration with invite codes
More sort and filter options
Seperated display of "supporters" and "potential supporters"
Optical changes
Flood limit / initiative contigent is now checked by frontend
Neccessary changes to access core beta11
Final voting with Schulze-Method is now possible
Many bug fixes and code cleanup
Registration with invite codes
More sort and filter options
Seperated display of "supporters" and "potential supporters"
Optical changes
Flood limit / initiative contigent is now checked by frontend
Neccessary changes to access core beta11
| author | bsw/jbe | 
|---|---|
| date | Fri Dec 25 12:00:00 2009 +0100 (2009-12-25) | 
| parents | 80c215dbf076 | 
| children | 00d1004545f1 | 
 line source
     1 slot.select("actions", function()
     3   local delegation
     4   local area_id
     5   local issue_id
     7   local scope = "global"
     9   if param.get("initiative_id", atom.integer) then
    10     issue_id = Initiative:by_id(param.get("initiative_id", atom.integer)).issue_id
    11     scope = "issue"
    12   end
    14   if param.get("issue_id", atom.integer) then
    15     issue_id = param.get("issue_id", atom.integer)
    16     scope = "issue"
    17   end
    19   if param.get("area_id", atom.integer) then
    20     area_id = param.get("area_id", atom.integer)
    21     scope = "area"
    22   end
    26   local delegation
    27   local issue
    28   if issue_id then
    29     issue = Issue:by_id(issue_id)
    30     delegation = Delegation:by_pk(app.session.member.id, nil, issue_id)
    31     if not delegation then
    32       delegation = Delegation:by_pk(app.session.member.id, issue.area_id)
    33     end
    34   elseif area_id then
    35     delegation = Delegation:by_pk(app.session.member.id, area_id)
    36   end
    38   if not delegation then
    39     delegation = Delegation:by_pk(app.session.member.id)
    40   end
    41   if delegation then
    42     ui.container{
    43       attr = { class = "delegation vote_info"},
    44       content = function()
    45         ui.container{
    46           attr = {
    47             title = _"Click for details",
    48             class = "head head_active",
    49             style = "cursor: pointer;",
    50             onclick = "document.getElementById('delegation_content').style.display = 'block';"
    51           },
    52           content = function()
    53             ui.image{
    54               static = "icons/16/error.png"
    55             }
    56             if delegation.issue_id then
    57               slot.put(_"Issue delegation active")
    58             elseif delegation.area_id then
    59               slot.put(_"Area wide delegation active")
    60             else
    61               slot.put(_"Global delegation active")
    62             end
    63             ui.image{
    64               static = "icons/16/dropdown.png"
    65             }
    66           end
    67         }
    68         ui.container{
    69           attr = { class = "content", id = "delegation_content" },
    70           content = function()
    71             ui.container{
    72               attr = {
    73                 class = "close",
    74                 style = "cursor: pointer;",
    75                 onclick = "document.getElementById('delegation_content').style.display = 'none';"
    76               },
    77               content = function()
    78                 ui.image{ static = "icons/16/cross.png" }
    79               end
    80             }
    82             local delegation_chain = Member:new_selector()
    83               :add_field("delegation_chain.*")
    84               :join("delegation_chain(" .. tostring(app.session.member.id) .. ", " .. tostring(area_id or "NULL") .. ", " .. tostring(issue_id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id")
    85               :add_order_by("index")
    86               :exec()
    88             for i, record in ipairs(delegation_chain) do
    89               local style
    90               local overridden = record.overridden
    91               if record.scope_in then
    92                 ui.container{
    93                   attr = { class = "delegation_info" },
    94                   content = function()
    95                     if not overridden then
    96                       ui.image{
    97                         attr = { class = "delegation_arrow" },
    98                         static = "delegation_arrow_vertical.jpg"
    99                       }
   100                     else
   101                       ui.image{
   102                         attr = { class = "delegation_arrow delegation_arrow_overridden" },
   103                         static = "delegation_arrow_vertical.jpg"
   104                       }
   105                     end
   106                     ui.container{
   107                       attr = { class = "delegation_scope" .. (overridden and " delegation_scope_overridden" or "") },
   108                       content = function()
   109                         if record.scope_in == "global" then
   110                           slot.put(_"Global delegation")
   111                         elseif record.scope_in == "area" then
   112                           slot.put(_"Area delegation")
   113                         elseif record.scope_in == "issue" then
   114                           slot.put(_"Issue delegation")
   115                         end
   116                       end
   117                     }
   118                     if i == 2 then
   119                       if not issue or (issue.state ~= "finished" and issue.state ~= "cancelled") then
   120                         ui.link{
   121                           attr = { class = "revoke" },
   122                           content = function()
   123                             ui.image{ static = "icons/16/delete.png" }
   124                             slot.put(_"Revoke")
   125                           end,
   126                           module = "delegation",
   127                           action = "update",
   128                           params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true },
   129                           routing = {
   130                             default = {
   131                               mode = "redirect",
   132                               module = request.get_module(),
   133                               view = request.get_view(),
   134                               id = param.get_id_cgi(),
   135                               params = param.get_all_cgi()
   136                             }
   137                           }
   138                         }
   139                       end
   140                     end
   141                   end
   142                 }
   143               end
   144               ui.container{
   145                 attr = { class = overridden and "delegation_overridden" or "" },
   146                 content = function()
   147                   execute.view{
   148                     module = "member",
   149                     view = "_show_thumb",
   150                     params = { member = record }
   151                   }
   152                 end
   153               }
   154               if record.participation and not record.overridden then
   155                 ui.container{
   156                   attr = { class = "delegation_participation" },
   157                   content = function()
   158                     slot.put("<br /><br />-----> Participation<br />")
   159                   end
   160                 }
   161               end
   162               slot.put("<br style='clear: left'/>")
   163             end
   164           end
   165         }
   166       end
   167     }
   170   end
   171   ui.link{
   172     content = function()
   173       if scope == "global" and delegation then
   174         ui.image{ static = "icons/16/table_go.png" }
   175         slot.put(_"Change global delegation")
   176       elseif scope == "global" and not delegation then
   177         ui.image{ static = "icons/16/table_go.png" }
   178         slot.put(_"Set global delegation")
   179       elseif scope == "area" and delegation and delegation.area_id then
   180         ui.image{ static = "icons/16/table_go.png" }
   181         slot.put(_"Change area delegation")
   182       elseif scope == "area" and not (delegation and delegation.area_id) then
   183         ui.image{ static = "icons/16/table_go.png" }
   184         slot.put(_"Set area delegation")
   185       elseif scope == "issue" then
   186         if delegation and delegation.issue_id then
   187           ui.image{ static = "icons/16/table_go.png" }
   188           slot.put(_"Change issue delegation")
   189         elseif issue.state ~= "finished" and issue.state ~= "cancelled" then
   190           ui.image{ static = "icons/16/table_go.png" }
   191           slot.put(_"Set issue delegation")
   192         end
   193       end
   194     end,
   195     module = "delegation",
   196     view = "new",
   197     params = {
   198       area_id = area_id,
   199       issue_id = issue_id 
   200     }
   201   }
   202 end)
