liquid_feedback_frontend

diff app/main/index/_member_home.lua @ 558:18e8de7a2b6a

Show notifications on start page as ulli list with links instead of tabs
author bsw
date Tue Jun 19 21:20:46 2012 +0200 (2012-06-19)
parents
children b904fc12cc1a
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/index/_member_home.lua	Tue Jun 19 21:20:46 2012 +0200
     1.3 @@ -0,0 +1,113 @@
     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 +
     1.8 +
     1.9 +execute.view{
    1.10 +  module = "index", view = "_notifications"
    1.11 +}
    1.12 +
    1.13 +    
    1.14 +ui.container{ attr = { class = "ui_filter_head" }, content = function()
    1.15 +
    1.16 +  ui.link{
    1.17 +    attr = { class = filter_unit == "personal" and "ui_tabs_link active" or nil },
    1.18 +    text = _"My units and areas",
    1.19 +    module = "index", view = "index", params = { filter_unit = "personal" }
    1.20 +  }
    1.21 +  
    1.22 +  slot.put(" ")
    1.23 +
    1.24 +  ui.link{
    1.25 +    attr = { class = filter_unit == "global" and "active" or nil },
    1.26 +    text = _"All units",
    1.27 +    module = "index", view = "index", params = { filter_unit = "global" }
    1.28 +  }
    1.29 +end }
    1.30 +
    1.31 +slot.put("<br />")
    1.32 +
    1.33 +
    1.34 +if filter_unit == "global" then
    1.35 +  execute.view{ module = "unit", view = "_list" }
    1.36 +  return
    1.37 +end
    1.38 +
    1.39 +local units = Unit:new_selector():exec()
    1.40 +
    1.41 +for i, unit in ipairs(units) do
    1.42 +  local trustee_member = Member:new_selector()
    1.43 +    :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.44 +    :optional_object_mode()
    1.45 +    :exec()
    1.46 +  
    1.47 +  local areas_selector = Area:new_selector()
    1.48 +    :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
    1.49 +    :add_where{ "area.unit_id = ?", unit.id }
    1.50 +    :add_where{ "area.active" }
    1.51 +    :add_order_by("area.member_weight DESC")
    1.52 +  
    1.53 +  local area_count = areas_selector:count()
    1.54 +  
    1.55 +  ui.container{ attr = { class = "member_area_list" }, content = function()
    1.56 +    ui.container{ attr = { class = "xunit_head" }, content = function()
    1.57 +      ui.link{
    1.58 +        text = unit.name,
    1.59 +        module = "unit", view = "show", id = unit.id
    1.60 +      }
    1.61 +
    1.62 +      if trustee_member then
    1.63 +        local text = _("Unit delegated to '#{name}'", { name = trustee_member.name })
    1.64 +        ui.image{
    1.65 +          attr = { class = "delegation_arrow", alt = text, title = text },
    1.66 +          static = "delegation_arrow_24_horizontal.png"
    1.67 +        }
    1.68 +        execute.view{
    1.69 +          module = "member_image",
    1.70 +          view = "_show",
    1.71 +          params = {
    1.72 +            member = trustee_member,
    1.73 +            image_type = "avatar",
    1.74 +            show_dummy = true,
    1.75 +            class = "micro_avatar",
    1.76 +            popup_text = text
    1.77 +          }
    1.78 +        }
    1.79 +      end
    1.80 +    end }
    1.81 +
    1.82 +    if area_count > 0 then
    1.83 +      execute.view{
    1.84 +        module = "area", view = "_list",
    1.85 +        params = { areas_selector = areas_selector, hide_membership = true }
    1.86 +      }
    1.87 +    elseif member:has_voting_right_for_unit_id(unit.id) then
    1.88 +      if for_member then
    1.89 +        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.90 +      else
    1.91 +        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.92 +      end
    1.93 +    end
    1.94 +    local max_area_count = Area:new_selector()
    1.95 +      :add_where{ "area.unit_id = ?", unit.id }
    1.96 +      :add_where{ "area.active" }
    1.97 +      :count()
    1.98 +    local more_area_count = max_area_count - area_count
    1.99 +    local delegated_count = Area:new_selector()
   1.100 +      :add_where{ "area.unit_id = ?", unit.id }
   1.101 +      :add_where{ "area.active" }
   1.102 +      :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
   1.103 +      :add_where{ "membership.member_id ISNULL" }
   1.104 +      :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
   1.105 +      :count()
   1.106 +    if more_area_count > 0 then
   1.107 +      slot.put("<br />")
   1.108 +      ui.container{ attr = { class = "more_areas" }, content = function()
   1.109 +        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.110 +      end }
   1.111 +    end
   1.112 +  end }
   1.113 +
   1.114 +end
   1.115 +
   1.116 +

Impressum / About Us