liquid_feedback_frontend

diff app/main/initiative/_list_element.lua @ 345:7d6a3c411f99

Code cleanup (removed code not needed any more)
author bsw
date Tue Feb 28 22:27:19 2012 +0100 (2012-02-28)
parents 0ec49ed35954
children 76d7eafb3893
line diff
     1.1 --- a/app/main/initiative/_list_element.lua	Tue Feb 28 22:14:13 2012 +0100
     1.2 +++ b/app/main/initiative/_list_element.lua	Tue Feb 28 22:27:19 2012 +0100
     1.3 @@ -1,181 +1,133 @@
     1.4  local initiative = param.get("initiative", "table")
     1.5  local selected = param.get("selected", atom.boolean)
     1.6  
     1.7 -local head_name = "initiative_head_" ..    tostring(initiative.id)
     1.8 -local link_name = "initiative_link_" ..    tostring(initiative.id)
     1.9 -local name      = "initiative_content_" .. tostring(initiative.id)
    1.10 -local icon_name = "initiative_icon_" ..    tostring(initiative.id)
    1.11 -
    1.12 -ui.container{
    1.13 -  attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") },
    1.14 -  content = function()
    1.15 -    local module = "initiative"
    1.16 -    local view = "show"
    1.17 -    local id = initiative.id
    1.18 -    local params = {}
    1.19 -    ui.container{
    1.20 -      attr = {
    1.21 -        name = name,
    1.22 -        class = "ui_tabs_accordeon_head",
    1.23 -        id = head_name,
    1.24 -      },
    1.25 +ui.list{
    1.26 +  attr = { class = "nohover" },
    1.27 +  records = { { a = 1} },
    1.28 +  columns = {
    1.29 +    {
    1.30 +      field_attr = { style = "width: 3em; text-align: center;"},
    1.31        content = function()
    1.32 -
    1.33 -        ui.list{
    1.34 -          attr = { class = "nohover" },
    1.35 -          records = { { a = 1} },
    1.36 -          columns = {
    1.37 -            {
    1.38 -              field_attr = { style = "width: 3em; text-align: center;"},
    1.39 -              content = function()
    1.40 -                if
    1.41 -                  initiative.issue.accepted and initiative.issue.closed
    1.42 -                  and initiative.issue.ranks_available or initiative.admitted == false
    1.43 -                then 
    1.44 -                  ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
    1.45 -                else
    1.46 -                  slot.put(" ")
    1.47 -                end
    1.48 -              end
    1.49 -            },
    1.50 +        if
    1.51 +          initiative.issue.accepted and initiative.issue.closed
    1.52 +          and initiative.issue.ranks_available or initiative.admitted == false
    1.53 +        then 
    1.54 +          ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
    1.55 +        else
    1.56 +          slot.put(" ")
    1.57 +        end
    1.58 +      end
    1.59 +    },
    1.60  
    1.61 -            {
    1.62 -              field_attr = { style = "width: 100px;"},
    1.63 -              content = function()
    1.64 -                if initiative.issue.fully_frozen and initiative.issue.closed then
    1.65 -                  if initiative.issue.ranks_available then 
    1.66 -                    if initiative.negative_votes and initiative.positive_votes then
    1.67 -                      local max_value = initiative.issue.voter_count
    1.68 -                      ui.bargraph{
    1.69 -                        max_value = max_value,
    1.70 -                        width = 100,
    1.71 -                        bars = {
    1.72 -                          { color = "#0a0", value = initiative.positive_votes },
    1.73 -                          { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
    1.74 -                          { color = "#a00", value = initiative.negative_votes },
    1.75 -                        }
    1.76 -                      }
    1.77 -                    else
    1.78 -                      slot.put(" ")
    1.79 -                    end
    1.80 -                  else
    1.81 -                    slot.put(_"Counting of votes")
    1.82 -                  end
    1.83 -                else
    1.84 -                  local max_value = initiative.issue.population or 0
    1.85 -                  ui.bargraph{
    1.86 -                    max_value = max_value,
    1.87 -                    width = 100,
    1.88 -                    quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
    1.89 -                    quorum_color = "#00F",
    1.90 -                    bars = {
    1.91 -                      { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
    1.92 -                      { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
    1.93 -                      { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) },
    1.94 -                    }
    1.95 -                  }
    1.96 -                end
    1.97 -              end
    1.98 -            },
    1.99 -            {
   1.100 -              field_attr = { style = "width: 24px;" },
   1.101 -              content = function()
   1.102 -                if initiative.is_initiator then
   1.103 -                  slot.put(" ")
   1.104 -                  local label = _"You are initiator of this initiative"
   1.105 -                  ui.image{
   1.106 -                    attr = { alt = label, title = label },
   1.107 -                    static = "icons/16/user_edit.png"
   1.108 -                  }
   1.109 -                elseif initiative.is_supporter then
   1.110 -                  slot.put(" ")
   1.111 -                  local label = _"You are supporter of this initiative"
   1.112 -                  ui.image{
   1.113 -                    attr = { alt = label, title = label },
   1.114 -                    static = "icons/16/thumb_up_green.png"
   1.115 -                  }
   1.116 -                elseif initiative.is_potential_supporter then
   1.117 -                  slot.put(" ")
   1.118 -                  local label = _"You are potentially supporter of this initiative"
   1.119 -                  ui.image{
   1.120 -                    attr = { alt = label, title = label },
   1.121 -                    static = "icons/16/thumb_up.png"
   1.122 -                  }
   1.123 -                elseif initiative.is_supporter_via_delegation then
   1.124 -                  slot.put(" ")
   1.125 -                  local label = _"You are supporter of this initiative via delegation"
   1.126 -                  ui.image{
   1.127 -                    attr = { alt = label, title = label },
   1.128 -                    static = "icons/16/thumb_up_green.png"
   1.129 -                  }
   1.130 -                end
   1.131 -    
   1.132 -              end
   1.133 -            },
   1.134 -            {
   1.135 -              content = function()
   1.136 -                local link_class = "initiative_link"
   1.137 -                if initiative.revoked then
   1.138 -                  link_class = "revoked"
   1.139 -                end
   1.140 -                if selected then
   1.141 -                  link_class = link_class .. " selected"
   1.142 -                end
   1.143 -                if initiative.is_supporter then
   1.144 -                  link_class = link_class .. " supported"
   1.145 -                end
   1.146 -                if initiative.is_potential_supporter then
   1.147 -                  link_class = link_class .. " potentially_supported"
   1.148 -                end
   1.149 -                if initiative.is_supporter_via_delegation then
   1.150 -                  link_class = link_class .. " supported"
   1.151 -                end
   1.152 -                ui.link{
   1.153 -                  attr = { id = link_name, class = link_class },
   1.154 -                  content = function()
   1.155 -                    local name
   1.156 -                    if initiative.name_highlighted then
   1.157 -                      name = encode.highlight(initiative.name_highlighted)
   1.158 -                    else
   1.159 -                      name = encode.html(initiative.shortened_name)
   1.160 -                    end
   1.161 -                    ui.tag{ content = "i" .. initiative.id .. ": " }
   1.162 -                    slot.put(name)
   1.163 -                  end,
   1.164 -                  module  = module,
   1.165 -                  view    = view,
   1.166 -                  id      = id,
   1.167 -                  params  = params,
   1.168 +    {
   1.169 +      field_attr = { style = "width: 100px;"},
   1.170 +      content = function()
   1.171 +        if initiative.issue.fully_frozen and initiative.issue.closed then
   1.172 +          if initiative.issue.ranks_available then 
   1.173 +            if initiative.negative_votes and initiative.positive_votes then
   1.174 +              local max_value = initiative.issue.voter_count
   1.175 +              ui.bargraph{
   1.176 +                max_value = max_value,
   1.177 +                width = 100,
   1.178 +                bars = {
   1.179 +                  { color = "#0a0", value = initiative.positive_votes },
   1.180 +                  { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
   1.181 +                  { color = "#a00", value = initiative.negative_votes },
   1.182                  }
   1.183 -                  
   1.184 -              end
   1.185 -            }
   1.186 -          }
   1.187 -        }
   1.188 -      end
   1.189 -    }
   1.190 -  end
   1.191 -}
   1.192 -
   1.193 -if ui.is_partial_loading_enabled() then
   1.194 -  ui.container{
   1.195 -    attr = {
   1.196 -      id = name,
   1.197 -      class = "ui_tabs_accordeon_content",
   1.198 -    },
   1.199 -    content = function()
   1.200 -      ui.container{
   1.201 -        attr = { id = name .. "_content", style = "clear: left;" },
   1.202 -        content = function()
   1.203 -          execute.view{
   1.204 -            module = "initiative",
   1.205 -            view = "show_partial",
   1.206 -            params = {
   1.207 -              initiative = initiative,
   1.208 +              }
   1.209 +            else
   1.210 +              slot.put(" ")
   1.211 +            end
   1.212 +          else
   1.213 +            slot.put(_"Counting of votes")
   1.214 +          end
   1.215 +        else
   1.216 +          local max_value = initiative.issue.population or 0
   1.217 +          ui.bargraph{
   1.218 +            max_value = max_value,
   1.219 +            width = 100,
   1.220 +            quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
   1.221 +            quorum_color = "#00F",
   1.222 +            bars = {
   1.223 +              { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
   1.224 +              { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
   1.225 +              { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) },
   1.226              }
   1.227            }
   1.228          end
   1.229 -      }
   1.230 -    end
   1.231 +      end
   1.232 +    },
   1.233 +    {
   1.234 +      field_attr = { style = "width: 24px;" },
   1.235 +      content = function()
   1.236 +        if initiative.is_initiator then
   1.237 +          slot.put(" ")
   1.238 +          local label = _"You are initiator of this initiative"
   1.239 +          ui.image{
   1.240 +            attr = { alt = label, title = label },
   1.241 +            static = "icons/16/user_edit.png"
   1.242 +          }
   1.243 +        elseif initiative.is_supporter then
   1.244 +          slot.put(" ")
   1.245 +          local label = _"You are supporter of this initiative"
   1.246 +          ui.image{
   1.247 +            attr = { alt = label, title = label },
   1.248 +            static = "icons/16/thumb_up_green.png"
   1.249 +          }
   1.250 +        elseif initiative.is_potential_supporter then
   1.251 +          slot.put(" ")
   1.252 +          local label = _"You are potentially supporter of this initiative"
   1.253 +          ui.image{
   1.254 +            attr = { alt = label, title = label },
   1.255 +            static = "icons/16/thumb_up.png"
   1.256 +          }
   1.257 +        elseif initiative.is_supporter_via_delegation then
   1.258 +          slot.put(" ")
   1.259 +          local label = _"You are supporter of this initiative via delegation"
   1.260 +          ui.image{
   1.261 +            attr = { alt = label, title = label },
   1.262 +            static = "icons/16/thumb_up_green.png"
   1.263 +          }
   1.264 +        end
   1.265 +
   1.266 +      end
   1.267 +    },
   1.268 +    {
   1.269 +      content = function()
   1.270 +        local link_class = "initiative_link"
   1.271 +        if initiative.revoked then
   1.272 +          link_class = "revoked"
   1.273 +        end
   1.274 +        if selected then
   1.275 +          link_class = link_class .. " selected"
   1.276 +        end
   1.277 +        if initiative.is_supporter then
   1.278 +          link_class = link_class .. " supported"
   1.279 +        end
   1.280 +        if initiative.is_potential_supporter then
   1.281 +          link_class = link_class .. " potentially_supported"
   1.282 +        end
   1.283 +        if initiative.is_supporter_via_delegation then
   1.284 +          link_class = link_class .. " supported"
   1.285 +        end
   1.286 +        ui.link{
   1.287 +          attr = { class = link_class },
   1.288 +          content = function()
   1.289 +            local name
   1.290 +            if initiative.name_highlighted then
   1.291 +              name = encode.highlight(initiative.name_highlighted)
   1.292 +            else
   1.293 +              name = encode.html(initiative.shortened_name)
   1.294 +            end
   1.295 +            ui.tag{ content = "i" .. initiative.id .. ": " }
   1.296 +            slot.put(name)
   1.297 +          end,
   1.298 +          module  = "initiative",
   1.299 +          view    = "show",
   1.300 +          id      = initiative.id
   1.301 +        }
   1.302 +          
   1.303 +      end
   1.304 +    }
   1.305    }
   1.306 -end
   1.307 \ No newline at end of file
   1.308 +}

Impressum / About Us