liquid_feedback_frontend

diff app/main/index/_member_home.lua @ 619:7dc5ab12bfe3

Optical enhancements :)
author bsw
date Mon Jun 25 14:40:34 2012 +0200 (2012-06-25)
parents 9423b529d5a4
children cc542ac26edc
line diff
     1.1 --- a/app/main/index/_member_home.lua	Mon Jun 25 01:17:27 2012 +0200
     1.2 +++ b/app/main/index/_member_home.lua	Mon Jun 25 14:40:34 2012 +0200
     1.3 @@ -3,10 +3,7 @@
     1.4  local filter_unit = param.get_all_cgi()["filter_unit"] or "my_areas"
     1.5  
     1.6  if not for_member then
     1.7 -  execute.view{
     1.8 -    module = "index", view = "_notifications"
     1.9 -  }
    1.10 -    
    1.11 +
    1.12    ui.container{ attr = { class = "ui_filter" }, content = function()
    1.13      ui.container{ attr = { class = "ui_filter_head" }, content = function()
    1.14  
    1.15 @@ -35,8 +32,6 @@
    1.16    end }
    1.17  end
    1.18  
    1.19 -  slot.put("<br />")
    1.20 -
    1.21  if not for_member then
    1.22    if filter_unit == "global" then
    1.23      execute.view{ module = "unit", view = "_list" }
    1.24 @@ -76,15 +71,40 @@
    1.25      
    1.26      local area_count = areas_selector:count()
    1.27      
    1.28 -    ui.container{ attr = { class = "area_list" }, content = function()
    1.29 -      ui.container{ attr = { class = "unit_head" }, content = function()
    1.30 -        ui.link{
    1.31 -          text = unit.name,
    1.32 -          module = "unit", view = "show", id = unit.id
    1.33 -        }
    1.34 +    local max_area_count = Area:new_selector()
    1.35 +      :add_where{ "area.unit_id = ?", unit.id }
    1.36 +      :add_where{ "area.active" }
    1.37 +      :count()
    1.38 +    local more_area_count = max_area_count - area_count
    1.39 +    local delegated_count = Area:new_selector()
    1.40 +      :add_where{ "area.unit_id = ?", unit.id }
    1.41 +      :add_where{ "area.active" }
    1.42 +      :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
    1.43 +      :add_where{ "membership.member_id ISNULL" }
    1.44 +      :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
    1.45 +      :add_where{ "delegation.trustee_id NOTNULL" }
    1.46 +      :count()
    1.47  
    1.48 -        execute.view{ module = "delegation", view = "_info", params = { unit = unit } }
    1.49 -      end }
    1.50 +    local more_area_text
    1.51 +    if area_count == 0 and more_area_count == 1 then
    1.52 +      more_area_text = _("You are not participating in the only area of the unit")
    1.53 +    elseif area_count == 0 and more_area_count > 0 then
    1.54 +      more_area_text = _("You are not participating in any of the #{count} areas in this unit", { count = more_area_count })
    1.55 +    elseif area_count > 0 and more_area_count == 1 then
    1.56 +      more_area_text = _("One more area in this unit")
    1.57 +    elseif area_count > 0 and more_area_count > 0 then
    1.58 +      more_area_text = _("#{count} more areas in this unit", { count = more_area_count })
    1.59 +    end
    1.60 +    local delegated_text
    1.61 +    if delegated_count == 1 then
    1.62 +      delegated_text = _("One of them have an area delegation set", { count = delegated_count })
    1.63 +    elseif delegated_count > 0 then
    1.64 +      delegated_text = _("#{count} of them have an area delegation set", { count = delegated_count })
    1.65 +    end
    1.66 +
    1.67 +              ui.container{ attr = { class = "area_list" }, content = function()
    1.68 +
    1.69 +    execute.view{ module = "unit", view = "_head", params = { unit = unit, show_content = true } }
    1.70  
    1.71        if area_count > 0 then
    1.72          local areas = areas_selector:exec()
    1.73 @@ -95,57 +115,23 @@
    1.74              }
    1.75            }
    1.76          end
    1.77 -      elseif member:has_voting_right_for_unit_id(unit.id) then
    1.78 +      end
    1.79 +  
    1.80 +      if area_count == 0 and member:has_voting_right_for_unit_id(unit.id) or
    1.81 +         more_area_count > 0 then
    1.82 +        
    1.83          ui.container{ attr = { class = "area" }, content = function()
    1.84            ui.container{ attr = { class = "content" }, content = function()
    1.85 -            slot.put("<br />")
    1.86 -            if for_member then
    1.87 -              ui.tag{ content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." }
    1.88 -            else
    1.89 -              ui.tag{ content = _"You have voting privileges for this unit, but you are not member of any of its areas." }
    1.90 +            if more_area_text then
    1.91 +              ui.link{ module = "unit", view = "show", id = unit.id, text = more_area_text }
    1.92 +            end
    1.93 +            if delegated_text then
    1.94 +              slot.put(" &middot; ")
    1.95 +              ui.tag{ content = delegated_text }
    1.96              end
    1.97            end }
    1.98          end }
    1.99        end
   1.100 -      local max_area_count = Area:new_selector()
   1.101 -        :add_where{ "area.unit_id = ?", unit.id }
   1.102 -        :add_where{ "area.active" }
   1.103 -        :count()
   1.104 -      local more_area_count = max_area_count - area_count
   1.105 -      local delegated_count = Area:new_selector()
   1.106 -        :add_where{ "area.unit_id = ?", unit.id }
   1.107 -        :add_where{ "area.active" }
   1.108 -        :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
   1.109 -        :add_where{ "membership.member_id ISNULL" }
   1.110 -        :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
   1.111 -        :add_where{ "delegation.trustee_id NOTNULL" }
   1.112 -        :count()
   1.113 -      if more_area_count > 0 then
   1.114 -        ui.container{ attr = { class = "area" }, content = function()
   1.115 -          ui.container{ attr = { class = "content" }, content = function()
   1.116 -            slot.put("<br />")
   1.117 -            local text
   1.118 -            if more_area_count == 1 then
   1.119 -              text = _("One more area in this unit")
   1.120 -            else
   1.121 -              text = _("#{count} more areas in this unit", { count = more_area_count })
   1.122 -            end
   1.123 -            ui.link{ module = "unit", view = "show", id = unit.id, text = text }
   1.124 -            if delegated_count > 0 then
   1.125 -              slot.put(" &middot; ")
   1.126 -              local text
   1.127 -              if delegated_count == 1 then
   1.128 -                text = _("One of them have an area delegation set", { count = delegated_count })
   1.129 -              else
   1.130 -                text = _("#{count} of them have an area delegation set", { count = delegated_count })
   1.131 -              end
   1.132 -              ui.tag{ content = text }
   1.133 -            end
   1.134 -          end }
   1.135 -        end }
   1.136 -      end
   1.137 -      slot.put("<br />")
   1.138 -      slot.put("<br />")
   1.139      end }
   1.140    end
   1.141  end

Impressum / About Us