liquid_feedback_frontend

diff app/main/index/_member_home.lua @ 598:9df26b41ace0

Improved member home page and area list
author bsw
date Sun Jun 24 22:30:29 2012 +0200 (2012-06-24)
parents 487cca534fbe
children 9423b529d5a4
line diff
     1.1 --- a/app/main/index/_member_home.lua	Sun Jun 24 20:50:02 2012 +0200
     1.2 +++ b/app/main/index/_member_home.lua	Sun Jun 24 22:30:29 2012 +0200
     1.3 @@ -1,27 +1,37 @@
     1.4  local member = param.get("member", "table")
     1.5  local for_member = param.get("for_member", atom.boolean)
     1.6 -local filter_unit = param.get_all_cgi()["filter_unit"] or "personal"
     1.7 +local filter_unit = param.get_all_cgi()["filter_unit"] or "my_areas"
     1.8  
     1.9  if not for_member then
    1.10    execute.view{
    1.11      module = "index", view = "_notifications"
    1.12    }
    1.13      
    1.14 -  ui.container{ attr = { class = "ui_filter_head" }, content = function()
    1.15 +  ui.container{ attr = { class = "ui_filter" }, content = function()
    1.16 +    ui.container{ attr = { class = "ui_filter_head" }, content = function()
    1.17 +
    1.18 +      ui.link{
    1.19 +        attr = { class = filter_unit == "my_areas" and "ui_tabs_link active" or nil },
    1.20 +        text = _"My areas",
    1.21 +        module = "index", view = "index", params = { filter_unit = "my_areas" }
    1.22 +      }
    1.23 +      
    1.24 +      slot.put(" ")
    1.25  
    1.26 -    ui.link{
    1.27 -      attr = { class = filter_unit == "personal" and "ui_tabs_link active" or nil },
    1.28 -      text = _"My units and areas",
    1.29 -      module = "index", view = "index", params = { filter_unit = "personal" }
    1.30 -    }
    1.31 -    
    1.32 -    slot.put(" ")
    1.33 +      ui.link{
    1.34 +        attr = { class = filter_unit == "my_units" and "ui_tabs_link active" or nil },
    1.35 +        text = _"All areas in my units",
    1.36 +        module = "index", view = "index", params = { filter_unit = "my_units" }
    1.37 +      }
    1.38 +      
    1.39 +      slot.put(" ")
    1.40  
    1.41 -    ui.link{
    1.42 -      attr = { class = filter_unit == "global" and "active" or nil },
    1.43 -      text = _"All units",
    1.44 -      module = "index", view = "index", params = { filter_unit = "global" }
    1.45 -    }
    1.46 +      ui.link{
    1.47 +        attr = { class = filter_unit == "global" and "active" or nil },
    1.48 +        text = _"All units",
    1.49 +        module = "index", view = "index", params = { filter_unit = "global" }
    1.50 +      }
    1.51 +    end }
    1.52    end }
    1.53  end
    1.54  
    1.55 @@ -35,61 +45,67 @@
    1.56  
    1.57  end
    1.58  
    1.59 -local units = Unit:new_selector():exec()
    1.60 +local units = Unit:new_selector():add_order_by("name"):exec()
    1.61 +
    1.62 +if member then
    1.63 +  units:load_delegation_info_once_for_member_id(member.id)
    1.64 +end
    1.65  
    1.66  for i, unit in ipairs(units) do
    1.67    if member:has_voting_right_for_unit_id(unit.id) then
    1.68 -    local trustee_member = Member:new_selector()
    1.69 -      :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id })
    1.70 -      :optional_object_mode()
    1.71 -      :exec()
    1.72 -    
    1.73 +   
    1.74      local areas_selector = Area:new_selector()
    1.75 -      :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
    1.76 +      :reset_fields()
    1.77 +      :add_field("area.id", nil, { "grouped" })
    1.78 +      :add_field("area.name", nil, { "grouped" })
    1.79 +      :add_field("member_weight", nil, { "grouped" })
    1.80 +      :add_field("direct_member_count", nil, { "grouped" })
    1.81 +      :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.accepted ISNULL AND issue.closed ISNULL)", "issues_new_count")
    1.82 +      :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.accepted NOTNULL AND issue.half_frozen ISNULL AND issue.closed ISNULL)", "issues_discussion_count")
    1.83 +      :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.half_frozen NOTNULL AND issue.fully_frozen ISNULL AND issue.closed ISNULL)", "issues_frozen_count")
    1.84 +      :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL)", "issues_voting_count")
    1.85 +      :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed NOTNULL)", "issues_finished_count")
    1.86 +      :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen ISNULL AND issue.closed NOTNULL)", "issues_cancelled_count")
    1.87        :add_where{ "area.unit_id = ?", unit.id }
    1.88        :add_where{ "area.active" }
    1.89 -      :add_order_by("area.member_weight DESC")
    1.90 +      :add_order_by("area.name")
    1.91 +
    1.92 +    if filter_unit == "my_areas" then
    1.93 +      areas_selector:join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
    1.94 +    end
    1.95      
    1.96      local area_count = areas_selector:count()
    1.97      
    1.98 -    ui.container{ attr = { class = "member_area_list" }, content = function()
    1.99 +    ui.container{ attr = { class = "area_list" }, content = function()
   1.100        ui.container{ attr = { class = "unit_head" }, content = function()
   1.101          ui.link{
   1.102            text = unit.name,
   1.103            module = "unit", view = "show", id = unit.id
   1.104          }
   1.105  
   1.106 -        if trustee_member then
   1.107 -          local text = _("Unit delegated to '#{name}'", { name = trustee_member.name })
   1.108 -          ui.image{
   1.109 -            attr = { class = "delegation_arrow", alt = text, title = text },
   1.110 -            static = "delegation_arrow_24_horizontal.png"
   1.111 -          }
   1.112 +        execute.view{ module = "delegation", view = "_info", params = { unit = unit } }
   1.113 +      end }
   1.114 +
   1.115 +      if area_count > 0 then
   1.116 +        local areas = areas_selector:exec()
   1.117 +        for i, area in ipairs(areas) do
   1.118            execute.view{
   1.119 -            module = "member_image",
   1.120 -            view = "_show",
   1.121 -            params = {
   1.122 -              member = trustee_member,
   1.123 -              image_type = "avatar",
   1.124 -              show_dummy = true,
   1.125 -              class = "micro_avatar",
   1.126 -              popup_text = text
   1.127 +            module = "area", view = "_list_entry", params = {
   1.128 +              area = area
   1.129              }
   1.130            }
   1.131          end
   1.132 -      end }
   1.133 -
   1.134 -      if area_count > 0 then
   1.135 -        execute.view{
   1.136 -          module = "area", view = "_list",
   1.137 -          params = { areas_selector = areas_selector, hide_membership = true }
   1.138 -        }
   1.139        elseif member:has_voting_right_for_unit_id(unit.id) then
   1.140 -        if for_member then
   1.141 -          ui.container{ attr = { class = "voting_priv_info" }, content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." }
   1.142 -        else
   1.143 -          ui.container{ attr = { class = "voting_priv_info" }, content = _"You have voting privileges for this unit, but you are not member of any of its areas." }
   1.144 -        end
   1.145 +        ui.container{ attr = { class = "area" }, content = function()
   1.146 +          ui.container{ attr = { class = "content" }, content = function()
   1.147 +            slot.put("<br />")
   1.148 +            if for_member then
   1.149 +              ui.tag{ content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." }
   1.150 +            else
   1.151 +              ui.tag{ content = _"You have voting privileges for this unit, but you are not member of any of its areas." }
   1.152 +            end
   1.153 +          end }
   1.154 +        end }
   1.155        end
   1.156        local max_area_count = Area:new_selector()
   1.157          :add_where{ "area.unit_id = ?", unit.id }
   1.158 @@ -102,13 +118,18 @@
   1.159          :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
   1.160          :add_where{ "membership.member_id ISNULL" }
   1.161          :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
   1.162 +        :add_where{ "delegation.trustee_id NOTNULL" }
   1.163          :count()
   1.164        if more_area_count > 0 then
   1.165 -        slot.put("<br />")
   1.166 -        ui.container{ attr = { class = "more_areas" }, content = function()
   1.167 -          ui.link{ content = _("#{count} more areas in this unit, #{delegated_count} of them are delegated", { count = more_area_count, delegated_count = delegated_count }), module = "unit", view = "show", id = unit.id }
   1.168 +        ui.container{ attr = { class = "area" }, content = function()
   1.169 +          ui.container{ attr = { class = "content" }, content = function()
   1.170 +            slot.put("<br />")
   1.171 +            ui.link{ content = _("#{count} more areas in this unit, #{delegated_count} of them have an area delegation set", { count = more_area_count, delegated_count = delegated_count }), module = "unit", view = "show", id = unit.id }
   1.172 +          end }
   1.173          end }
   1.174        end
   1.175 +      slot.put("<br />")
   1.176 +      slot.put("<br />")
   1.177      end }
   1.178    end
   1.179  end

Impressum / About Us