liquid_feedback_frontend
view app/main/delegation/_show_box.lua @ 4:80c215dbf076
Version alpha5
Many optical changes and improved usability
Support for different wiki-formatting-engines
Help system
Many optical changes and improved usability
Support for different wiki-formatting-engines
Help system
| author | bsw/jbe | 
|---|---|
| date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) | 
| parents | 5c601807d397 | 
| children | afd9f769c7ae | 
 line source
     1 slot.select("actions", function()
     3   ui.container{
     4     attr = { class = "delegation vote_info"},
     5     content = function()
     7       local delegation
     8       local area_id
     9       local issue_id
    11       local scope = "global"
    13       if param.get("initiative_id", atom.integer) then
    14         issue_id = Initiative:by_id(param.get("initiative_id", atom.integer)).issue_id
    15         scope = "issue"
    16       end
    18       if param.get("issue_id", atom.integer) then
    19         issue_id = param.get("issue_id", atom.integer)
    20         scope = "issue"
    21       end
    23       if param.get("area_id", atom.integer) then
    24         area_id = param.get("area_id", atom.integer)
    25         scope = "area"
    26       end
    30       local delegation
    32       if issue_id then
    33         delegation = Delegation:by_pk(app.session.member.id, nil, issue_id)
    34         if not delegation then
    35           local issue = Issue:by_id(issue_id)
    36           delegation = Delegation:by_pk(app.session.member.id, issue.area_id)
    37         end
    38       elseif area_id then
    39         delegation = Delegation:by_pk(app.session.member.id, area_id)
    40       end
    42       if not delegation then
    43         delegation = Delegation:by_pk(app.session.member.id)
    44       end
    45       if delegation then
    46         ui.container{
    47           attr = {
    48             title = _"Click for details",
    49             class = "head head_active",
    50             style = "cursor: pointer;",
    51             onclick = "document.getElementById('delegation_content').style.display = 'block';"
    52           },
    53           content = function()
    54             ui.image{
    55               static = "icons/16/error.png"
    56             }
    57             if delegation.issue_id then
    58               slot.put(_"Issue delegation active")
    59             elseif delegation.area_id then
    60               slot.put(_"Area wide delegation active")
    61             else
    62               slot.put(_"Global delegation active")
    63             end
    64             ui.image{
    65               static = "icons/16/dropdown.png"
    66             }
    67           end
    68         }
    69         ui.container{
    70           attr = { class = "content", id = "delegation_content" },
    71           content = function()
    72             ui.container{
    73               attr = {
    74                 class = "close",
    75                 style = "cursor: pointer;",
    76                 onclick = "document.getElementById('delegation_content').style.display = 'none';"
    77               },
    78               content = function()
    79                 ui.image{ static = "icons/16/cross.png" }
    80               end
    81             }
    83             local delegation_chain = Member:new_selector()
    84               :add_field("delegation_chain.*")
    85               :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")
    86               :add_order_by("index")
    87               :exec()
    89             for i, record in ipairs(delegation_chain) do
    90               local style
    91               local overridden = record.overridden
    92               if record.scope_in then
    93                 ui.container{
    94                   attr = { class = "delegation_info" },
    95                   content = function()
    96                     if not overridden then
    97                       ui.image{
    98                         attr = { class = "delegation_arrow" },
    99                         static = "delegation_arrow_vertical.jpg"
   100                       }
   101                     else
   102                       ui.image{
   103                         attr = { class = "delegation_arrow delegation_arrow_overridden" },
   104                         static = "delegation_arrow_vertical.jpg"
   105                       }
   106                     end
   107                     ui.container{
   108                       attr = { class = "delegation_scope" .. (overridden and " delegation_scope_overridden" or "") },
   109                       content = function()
   110                         if record.scope_in == "global" then
   111                           slot.put(_"Global delegation")
   112                         elseif record.scope_in == "area" then
   113                           slot.put(_"Area delegation")
   114                         elseif record.scope_in == "issue" then
   115                           slot.put(_"Issue delegation")
   116                         end
   117                       end
   118                     }
   119                     if i == 2 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                 }
   142               end
   143               ui.container{
   144                 attr = { class = overridden and "delegation_overridden" or "" },
   145                 content = function()
   146                   execute.view{
   147                     module = "member",
   148                     view = "_show_thumb",
   149                     params = { member = record }
   150                   }
   151                 end
   152               }
   153               if record.participation and not record.overridden then
   154                 ui.container{
   155                   attr = { class = "delegation_participation" },
   156                   content = function()
   157                     slot.put("<br /><br />-----> Participation<br />")
   158                   end
   159                 }
   160               end
   161               slot.put("<br style='clear: left'/>")
   162             end
   163           end
   164         }
   165       end
   166       ui.link{
   167         content = function()
   168           ui.image{ static = "icons/16/table_go.png" }
   169           if scope == "global" and delegation then
   170             slot.put(_"Change global delegation")
   171           elseif scope == "global" and not delegation then
   172             slot.put(_"Set global delegation")
   173           elseif scope == "area" and delegation and delegation.area_id then
   174             slot.put(_"Change area delegation")
   175           elseif scope == "area" and not (delegation and delegation.area_id) then
   176             slot.put(_"Set area delegation")
   177           elseif scope == "issue" and delegation and delegation.issue_id then
   178             slot.put(_"Change issue delegation")
   179           elseif scope == "issue" and not (delegation and delegation.issue_id) then
   180             slot.put(_"Set issue delegation")
   181           end
   182         end,
   183         module = "delegation",
   184         view = "new",
   185         params = {
   186           area_id = area_id,
   187           issue_id = issue_id 
   188         }
   189       }
   190     end
   191   }
   192 end)
