liquid_feedback_frontend

diff app/main/delegation/_show_box.lua @ 4:80c215dbf076

Version alpha5

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 diff
     1.1 --- a/app/main/delegation/_show_box.lua	Mon Nov 30 12:00:00 2009 +0100
     1.2 +++ b/app/main/delegation/_show_box.lua	Thu Dec 10 12:00:00 2009 +0100
     1.3 @@ -1,121 +1,192 @@
     1.4 -slot.select("delegation", function()
     1.5 -
     1.6 -  local delegation
     1.7 -  local area_id
     1.8 -  local issue_id
     1.9 -
    1.10 -  local scope = "global"
    1.11 -
    1.12 -  if param.get("initiative_id", atom.integer) then
    1.13 -    issue_id = Initiative:by_id(param.get("initiative_id", atom.integer)).issue_id
    1.14 -    scope = "issue"
    1.15 -  end
    1.16 -
    1.17 -  if param.get("issue_id", atom.integer) then
    1.18 -    issue_id = param.get("issue_id", atom.integer)
    1.19 -    scope = "issue"
    1.20 -  end
    1.21 -
    1.22 -  if param.get("area_id", atom.integer) then
    1.23 -    area_id = param.get("area_id", atom.integer)
    1.24 -    scope = "area"
    1.25 -  end
    1.26 -
    1.27 -
    1.28 +slot.select("actions", function()
    1.29  
    1.30 -  local delegation
    1.31 -
    1.32 -  if issue_id then
    1.33 -    delegation = Delegation:by_pk(app.session.member.id, nil, issue_id)
    1.34 -    if not delegation then
    1.35 -      local issue = Issue:by_id(issue_id)
    1.36 -      delegation = Delegation:by_pk(app.session.member.id, issue.area_id)
    1.37 -    end
    1.38 -  elseif area_id then
    1.39 -    delegation = Delegation:by_pk(app.session.member.id, area_id)
    1.40 -  end
    1.41 -
    1.42 -  if not delegation then
    1.43 -    delegation = Delegation:by_pk(app.session.member.id)
    1.44 -  end
    1.45 -  if delegation then
    1.46 -    ui.container{
    1.47 -      attr = {
    1.48 -        class = "head",
    1.49 -        style = "cursor: pointer;",
    1.50 -        onclick = "document.getElementById('delegation_content').style.display = 'block';"
    1.51 -      },
    1.52 -      content = _"Your vote is delegated. [more]"
    1.53 -    }
    1.54 -    ui.container{
    1.55 -      attr = { class = "content", id = "delegation_content" },
    1.56 -      content = function()
    1.57 +  ui.container{
    1.58 +    attr = { class = "delegation vote_info"},
    1.59 +    content = function()
    1.60 +    
    1.61 +      local delegation
    1.62 +      local area_id
    1.63 +      local issue_id
    1.64 +    
    1.65 +      local scope = "global"
    1.66 +    
    1.67 +      if param.get("initiative_id", atom.integer) then
    1.68 +        issue_id = Initiative:by_id(param.get("initiative_id", atom.integer)).issue_id
    1.69 +        scope = "issue"
    1.70 +      end
    1.71 +    
    1.72 +      if param.get("issue_id", atom.integer) then
    1.73 +        issue_id = param.get("issue_id", atom.integer)
    1.74 +        scope = "issue"
    1.75 +      end
    1.76 +    
    1.77 +      if param.get("area_id", atom.integer) then
    1.78 +        area_id = param.get("area_id", atom.integer)
    1.79 +        scope = "area"
    1.80 +      end
    1.81 +    
    1.82 +    
    1.83 +    
    1.84 +      local delegation
    1.85 +    
    1.86 +      if issue_id then
    1.87 +        delegation = Delegation:by_pk(app.session.member.id, nil, issue_id)
    1.88 +        if not delegation then
    1.89 +          local issue = Issue:by_id(issue_id)
    1.90 +          delegation = Delegation:by_pk(app.session.member.id, issue.area_id)
    1.91 +        end
    1.92 +      elseif area_id then
    1.93 +        delegation = Delegation:by_pk(app.session.member.id, area_id)
    1.94 +      end
    1.95 +    
    1.96 +      if not delegation then
    1.97 +        delegation = Delegation:by_pk(app.session.member.id)
    1.98 +      end
    1.99 +      if delegation then
   1.100          ui.container{
   1.101            attr = {
   1.102 -            class = "close",
   1.103 +            title = _"Click for details",
   1.104 +            class = "head head_active",
   1.105              style = "cursor: pointer;",
   1.106 -            onclick = "document.getElementById('delegation_content').style.display = 'none';"
   1.107 +            onclick = "document.getElementById('delegation_content').style.display = 'block';"
   1.108            },
   1.109 -          content = _"X"
   1.110 +          content = function()
   1.111 +            ui.image{
   1.112 +              static = "icons/16/error.png"
   1.113 +            }
   1.114 +            if delegation.issue_id then
   1.115 +              slot.put(_"Issue delegation active")
   1.116 +            elseif delegation.area_id then
   1.117 +              slot.put(_"Area wide delegation active")
   1.118 +            else
   1.119 +              slot.put(_"Global delegation active")
   1.120 +            end
   1.121 +            ui.image{
   1.122 +              static = "icons/16/dropdown.png"
   1.123 +            }
   1.124 +          end
   1.125          }
   1.126 -
   1.127 -        local delegation_chain = db:query{ "SELECT * FROM delegation_chain(?, ?, ?) JOIN member ON member.id = member_id ORDER BY index", app.session.member.id, area_id, issue_id }
   1.128 -
   1.129 -        for i, record in ipairs(delegation_chain) do
   1.130 -          local style
   1.131 -          execute.view{
   1.132 -            module = "member",
   1.133 -            view = "_show_thumb",
   1.134 -            params = { member = record }
   1.135 -          }
   1.136 -          slot.put("<br style='clear: left'/>")
   1.137 -          if record.scope_out then
   1.138 +        ui.container{
   1.139 +          attr = { class = "content", id = "delegation_content" },
   1.140 +          content = function()
   1.141              ui.container{
   1.142 -              attr = { class = "delegation_info" },
   1.143 +              attr = {
   1.144 +                class = "close",
   1.145 +                style = "cursor: pointer;",
   1.146 +                onclick = "document.getElementById('delegation_content').style.display = 'none';"
   1.147 +              },
   1.148                content = function()
   1.149 -                ui.image{
   1.150 -                  attr = { class = "delegation_arrow" },
   1.151 -                  static = "delegation_arrow_vertical.jpg"
   1.152 -                }
   1.153 +                ui.image{ static = "icons/16/cross.png" }
   1.154 +              end
   1.155 +            }
   1.156 +    
   1.157 +            local delegation_chain = Member:new_selector()
   1.158 +              :add_field("delegation_chain.*")
   1.159 +              :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")
   1.160 +              :add_order_by("index")
   1.161 +              :exec()
   1.162 +    
   1.163 +            for i, record in ipairs(delegation_chain) do
   1.164 +              local style
   1.165 +              local overridden = record.overridden
   1.166 +              if record.scope_in then
   1.167                  ui.container{
   1.168 -                  attr = { class = "delegation_scope" },
   1.169 +                  attr = { class = "delegation_info" },
   1.170                    content = function()
   1.171 -                    if record.scope_out == "global" then
   1.172 -                      slot.put(_"Global delegation")
   1.173 -                    elseif record.scope_out == "area" then
   1.174 -                      slot.put(_"Area delegation")
   1.175 -                    elseif record.scope_out == "issue" then
   1.176 -                      slot.put(_"Issue delegation")
   1.177 +                    if not overridden then
   1.178 +                      ui.image{
   1.179 +                        attr = { class = "delegation_arrow" },
   1.180 +                        static = "delegation_arrow_vertical.jpg"
   1.181 +                      }
   1.182 +                    else
   1.183 +                      ui.image{
   1.184 +                        attr = { class = "delegation_arrow delegation_arrow_overridden" },
   1.185 +                        static = "delegation_arrow_vertical.jpg"
   1.186 +                      }
   1.187 +                    end
   1.188 +                    ui.container{
   1.189 +                      attr = { class = "delegation_scope" .. (overridden and " delegation_scope_overridden" or "") },
   1.190 +                      content = function()
   1.191 +                        if record.scope_in == "global" then
   1.192 +                          slot.put(_"Global delegation")
   1.193 +                        elseif record.scope_in == "area" then
   1.194 +                          slot.put(_"Area delegation")
   1.195 +                        elseif record.scope_in == "issue" then
   1.196 +                          slot.put(_"Issue delegation")
   1.197 +                        end
   1.198 +                      end
   1.199 +                    }
   1.200 +                    if i == 2 then
   1.201 +                      ui.link{
   1.202 +                        attr = { class = "revoke" },
   1.203 +                        content = function()
   1.204 +                          ui.image{ static = "icons/16/delete.png" }
   1.205 +                          slot.put(_"Revoke")
   1.206 +                        end,
   1.207 +                        module = "delegation",
   1.208 +                        action = "update",
   1.209 +                        params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true },
   1.210 +                        routing = {
   1.211 +                          default = {
   1.212 +                            mode = "redirect",
   1.213 +                            module = request.get_module(),
   1.214 +                            view = request.get_view(),
   1.215 +                            id = param.get_id_cgi(),
   1.216 +                            params = param.get_all_cgi()
   1.217 +                          }
   1.218 +                        }
   1.219 +                      }
   1.220                      end
   1.221                    end
   1.222                  }
   1.223 -                if record.id == app.session.member.id then
   1.224 -                  ui.link{
   1.225 -                    attr = { class = "revoke" },
   1.226 -                    content = function()
   1.227 -                      ui.image{ static = "icons/16/delete.png" }
   1.228 -                      slot.put(_"Revoke")
   1.229 -                    end,
   1.230 -                    module = "delegation",
   1.231 -                    action = "update",
   1.232 -                    params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true },
   1.233 -                    routing = {
   1.234 -                      default = {
   1.235 -                        mode = "redirect",
   1.236 -                        module = request.get_module(),
   1.237 -                        view = request.get_view(),
   1.238 -                        id = param.get_id_cgi(),
   1.239 -                        params = param.get_all_cgi()
   1.240 -                      }
   1.241 -                    }
   1.242 +              end
   1.243 +              ui.container{
   1.244 +                attr = { class = overridden and "delegation_overridden" or "" },
   1.245 +                content = function()
   1.246 +                  execute.view{
   1.247 +                    module = "member",
   1.248 +                    view = "_show_thumb",
   1.249 +                    params = { member = record }
   1.250                    }
   1.251                  end
   1.252 +              }
   1.253 +              if record.participation and not record.overridden then
   1.254 +                ui.container{
   1.255 +                  attr = { class = "delegation_participation" },
   1.256 +                  content = function()
   1.257 +                    slot.put("<br /><br />-----> Participation<br />")
   1.258 +                  end
   1.259 +                }
   1.260                end
   1.261 -            }
   1.262 +              slot.put("<br style='clear: left'/>")
   1.263 +            end
   1.264            end
   1.265 -        end
   1.266 +        }
   1.267        end
   1.268 -    }
   1.269 -  end
   1.270 -
   1.271 +      ui.link{
   1.272 +        content = function()
   1.273 +          ui.image{ static = "icons/16/table_go.png" }
   1.274 +          if scope == "global" and delegation then
   1.275 +            slot.put(_"Change global delegation")
   1.276 +          elseif scope == "global" and not delegation then
   1.277 +            slot.put(_"Set global delegation")
   1.278 +          elseif scope == "area" and delegation and delegation.area_id then
   1.279 +            slot.put(_"Change area delegation")
   1.280 +          elseif scope == "area" and not (delegation and delegation.area_id) then
   1.281 +            slot.put(_"Set area delegation")
   1.282 +          elseif scope == "issue" and delegation and delegation.issue_id then
   1.283 +            slot.put(_"Change issue delegation")
   1.284 +          elseif scope == "issue" and not (delegation and delegation.issue_id) then
   1.285 +            slot.put(_"Set issue delegation")
   1.286 +          end
   1.287 +        end,
   1.288 +        module = "delegation",
   1.289 +        view = "new",
   1.290 +        params = {
   1.291 +          area_id = area_id,
   1.292 +          issue_id = issue_id 
   1.293 +        }
   1.294 +      }
   1.295 +    end
   1.296 +  }
   1.297  end)

Impressum / About Us