liquid_feedback_frontend

diff app/main/lf2/_sidebar_unit.lua @ 217:73dbc9e2bfd4

Cummulative patch for enhancements at next generation frontend
author bsw
date Sat Mar 12 19:22:50 2011 +0100 (2011-03-12)
parents 1dab81353eb1
children 7ea52c710503
line diff
     1.1 --- a/app/main/lf2/_sidebar_unit.lua	Mon Mar 07 12:15:22 2011 +0100
     1.2 +++ b/app/main/lf2/_sidebar_unit.lua	Sat Mar 12 19:22:50 2011 +0100
     1.3 @@ -1,57 +1,86 @@
     1.4 +local unit = param.get("unit", "table")
     1.5 +
     1.6  local current_area_id = param.get("current_area_id", atom.integer)
     1.7  local current_phase = param.get_all_cgi()["phase"]
     1.8  
     1.9 -local member_areas_selector = Area:build_selector{
    1.10 -  member_id = app.session.member_id,
    1.11 -  order = "name"
    1.12 -}
    1.13 -local other_areas_selector = Area:build_selector{
    1.14 -  not_member_id = app.session.member_id,
    1.15 -  order = "name"
    1.16 +local records = {
    1.17 +  { id = 0, name = _"All units" },
    1.18 +  { id = "disabled", name = "" },
    1.19 +  { id = "disabled", name = _"Units, you are member of:" },
    1.20  }
    1.21  
    1.22 -local unit = {}
    1.23 -
    1.24 -local trustees = Member:new_selector()
    1.25 -  :add_field("delegation_chain.*")
    1.26 -  :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, NULL)", "delegation_chain", "member.id = delegation_chain.member_id")
    1.27 -  :add_order_by("index")
    1.28 -  :exec()
    1.29 -
    1.30 -local row_count = member_areas_selector:count() + other_areas_selector:count() + 4
    1.31 -if #trustees > 1 then
    1.32 -  row_count = row_count + 1
    1.33 +  
    1.34 +for i, unit in ipairs(Unit:get_flattened_tree()) do
    1.35 +  records[#records+1] = { id = unit.id, name = unit.flattened_tree_name }
    1.36  end
    1.37  
    1.38 -ui.box{ row_count = row_count, content = function()
    1.39 +records[#records+1] = { id = "disabled", name = "" }
    1.40 +records[#records+1] = { id = -1, name = _"Other units..." }
    1.41 +  
    1.42 +ui.box{ content = function()
    1.43    ui.box_row{ class = "head", content = function()
    1.44 -    ui.box_col{ class = "head", content = _"DE / Berlin / Friedrichshain-Kreuzberg" }
    1.45 +    ui.box_col{ class = "head", content = function()
    1.46 +      ui.form{
    1.47 +        method = "GET",
    1.48 +        module = "lf2", view = "index",
    1.49 +        content = function()
    1.50 +          ui.field.select{
    1.51 +            attr = { onchange = "this.form.submit();" },
    1.52 +            name = "_webmcp_id", 
    1.53 +            foreign_records = records,
    1.54 +            foreign_id = "id",
    1.55 +            foreign_name = "name",
    1.56 +            disabled_records = { disabled = true },
    1.57 +            value = unit and unit.id or 0
    1.58 +          }
    1.59 +        end
    1.60 +      }
    1.61 +    end }
    1.62    end }
    1.63 -  
    1.64 -  if #trustees > 1 then
    1.65 +
    1.66 +  if unit then
    1.67 +    local trustees = Member:new_selector()
    1.68 +      :add_field("delegation_chain.*")
    1.69 +      :join({ "delegation_chain(?, ?, NULL, NULL)", app.session.member.id, unit.id }, "delegation_chain", "member.id = delegation_chain.member_id")
    1.70 +      :add_order_by("index")
    1.71 +      :exec()
    1.72 +
    1.73 +    if #trustees > 1 then
    1.74 +      ui.box_row{ content = function() ui.box_col{ content = function()
    1.75 +        execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
    1.76 +      end } end }
    1.77 +    end
    1.78 +    
    1.79      ui.box_row{ content = function() ui.box_col{ content = function()
    1.80 -      execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
    1.81 +      if trustees[1].scope_out == "global" then
    1.82 +        text = _"Change or revoke unit delegation"
    1.83 +      else
    1.84 +        text = _"Set unit delegation"
    1.85 +      end  
    1.86 +      ui.link{
    1.87 +        text = text,
    1.88 +        module = "lf2", view = "delegation", params = { unit_id = unit.id }
    1.89 +      }    
    1.90      end } end }
    1.91    end
    1.92 -  
    1.93 -  ui.box_row{ content = function() ui.box_col{ content = function()
    1.94 -    if trustees[1].scope_out == "global" then
    1.95 -      text = _"Change or revoke unit delegation"
    1.96 -    else
    1.97 -      text = _"Set unit delegation"
    1.98 -    end  
    1.99 -    ui.link{
   1.100 -      text = text,
   1.101 -      module = "lf2", view = "delegation", params = { unit_id = unit.id }
   1.102 -    }    
   1.103 -  end } end }
   1.104 -  
   1.105 -    
   1.106 -  ui.form{
   1.107 -    method = "get",
   1.108 -    content = function()
   1.109 -      
   1.110 -      ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = function()
   1.111 +
   1.112 +end }
   1.113 +
   1.114 +if unit then
   1.115 +  local member_areas_selector = Area:build_selector{
   1.116 +    unit_id = unit.id,
   1.117 +    member_id = app.session.member_id,
   1.118 +    order = "name"
   1.119 +  }
   1.120 +  local other_areas_selector = Area:build_selector{
   1.121 +    unit_id = unit.id,
   1.122 +    not_member_id = app.session.member_id,
   1.123 +    order = "name"
   1.124 +  }
   1.125 +
   1.126 +  if member_areas_selector:count() > 0 then
   1.127 +    ui.box{ content = function()
   1.128 +      ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function()
   1.129          ui.link{ text = _"Areas, you are member of", module = "lf2", view = "index" }
   1.130        end } end }
   1.131  
   1.132 @@ -62,9 +91,13 @@
   1.133            current_phase = current_phase
   1.134          }
   1.135        }
   1.136 +    end }
   1.137 +  end
   1.138  
   1.139 -      ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = function()
   1.140 -        ui.link{ content = _"Other areas", module = "lf2", view = "index" }
   1.141 +  if other_areas_selector:count() > 0 then
   1.142 +    ui.box{ content = function()
   1.143 +      ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function()
   1.144 +        ui.link{ content = _"Areas", module = "lf2", view = "index" }
   1.145        end } end }
   1.146  
   1.147        execute.view{
   1.148 @@ -74,10 +107,8 @@
   1.149            current_phase = current_phase
   1.150          }
   1.151        }
   1.152 -
   1.153 -    end
   1.154 -  }
   1.155 -
   1.156 -end }
   1.157 +    end }
   1.158 +  end
   1.159 +end
   1.160  
   1.161  execute.view{ module = "lf2", view = "_search", params = { area = area } }

Impressum / About Us