bsw/jbe@0: local areas_selector = param.get("areas_selector", "table") bsw/jbe@0: bsw@9: areas_selector bsw@9: :reset_fields() bsw@9: :add_field("area.id", nil, { "grouped" }) bsw@9: :add_field("area.name", nil, { "grouped" }) bsw@9: :add_field("member_weight", nil, { "grouped" }) bsw@9: :add_field("direct_member_count", nil, { "grouped" }) bsw@9: :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.accepted ISNULL AND issue.closed ISNULL)", "issues_new_count") bsw@9: :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") bsw@9: :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") bsw@9: :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL)", "issues_voting_count") bsw@10: :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed NOTNULL)", "issues_finished_count") bsw@10: :add_field("(SELECT COUNT(*) FROM issue WHERE issue.area_id = area.id AND issue.fully_frozen ISNULL AND issue.closed NOTNULL)", "issues_cancelled_count") bsw@51: bsw@51: if app.session.member_id then bsw@51: areas_selector bsw@51: :add_field({ "(SELECT COUNT(*) FROM issue LEFT JOIN direct_voter ON direct_voter.issue_id = issue.id AND direct_voter.member_id = ? WHERE issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL AND direct_voter.member_id ISNULL)", app.session.member.id }, "issues_to_vote_count") bsw@51: :left_join("membership", "_membership", { "_membership.area_id = area.id AND _membership.member_id = ?", app.session.member.id }) bsw@51: :add_field("_membership.member_id NOTNULL", "is_member", { "grouped" }) bsw@274: :left_join("delegation", nil, { bsw@274: "delegation.truster_id = ? AND delegation.area_id = area.id AND delegation.scope = 'area'", app.session.member_id bsw@274: }) bsw@274: :left_join("member", nil, "member.id = delegation.trustee_id") bsw@274: :add_field("member.id", "trustee_member_id", { "grouped" }) bsw@274: :add_field("member.name", "trustee_member_name", { "grouped" }) bsw@51: else bsw@51: areas_selector:add_field("0", "issues_to_vote_count") bsw@51: end bsw@9: bsw/jbe@19: local label_attr = { style = "text-align: right; width: 4em;" } bsw/jbe@19: local field_attr = { style = "text-align: right; width: 4em;" } bsw/jbe@19: bsw@269: ui.list{ bsw@280: attr = { class = "area_list", style = "width: 100%; table-layout: fixed;" }, bsw@269: records = areas_selector:exec(), bsw@269: columns = { bsw@269: { bsw@280: label_attr = { style = "width: 2em;" }, bsw@269: content = function(record) bsw@269: if record.is_member then bsw@269: local text = _"Member of area" bsw@269: ui.image{ bsw@269: attr = { title = text, alt = text, style = "vertical-align: middle;" }, bsw@269: static = "icons/16/user_gray.png", bsw@269: } bsw@269: end bsw@269: end bsw@269: }, bsw/jbe@0: { bsw@280: label_attr = { style = "width: 2em;" }, bsw@269: content = function(record) bsw@274: if record.trustee_member_id then bsw@274: local trustee_member = Member:by_id(record.trustee_member_id) bsw@274: local text = _("Area delegated to '#{name}'", { name = record.trustee_member_name }) bsw@274: execute.view{ bsw@274: module = "member_image", bsw@274: view = "_show", bsw@274: params = { bsw@274: member = trustee_member, bsw@274: image_type = "avatar", bsw@274: show_dummy = true, bsw@274: class = "micro_avatar", bsw@274: popup_text = text bsw@274: } bsw@269: } bsw@269: end bsw@269: end bsw@269: }, bsw@269: { bsw@280: label_attr = { style = "width: 110px" }, bsw@269: content = function(record) bsw@269: if record.member_weight and record.direct_member_count then bsw@269: local max_value = MemberCount:get() bsw@269: ui.bargraph{ bsw@269: max_value = max_value, bsw@269: width = 100, bsw@269: bars = { bsw@269: { color = "#444", value = record.direct_member_count }, bsw@269: { color = "#777", value = record.member_weight - record.direct_member_count }, bsw@269: { color = "#ddd", value = max_value - record.member_weight }, bsw@269: } bsw@269: } bsw@269: end bsw@269: end bsw/jbe@0: }, bsw/jbe@0: { bsw@280: label_attr = { style = "width: 100%" }, bsw@269: content = function(record) bsw@269: ui.link{ bsw@269: text = record.name, bsw@269: module = "area", bsw@269: view = "show", bsw@269: id = record.id bsw@269: } bsw@269: end bsw/jbe@0: }, bsw/jbe@0: { bsw@269: label = function() bsw@269: local title = _"New" bsw@269: ui.image{ bsw@269: attr = { title = title, alt = title }, bsw@269: static = "icons/16/new.png" bsw@269: } bsw@269: end, bsw@269: field_attr = field_attr, bsw@269: label_attr = label_attr, bsw@269: content = function(record) bsw@269: ui.link{ bsw@269: text = tostring(record.issues_new_count), bsw@269: module = "area", bsw@269: view = "show", bsw@269: id = record.id, bsw@269: params = { filter = "new", tab = "issues" } bsw@269: } bsw@269: end bsw@269: }, bsw@269: { bsw@269: label = function() bsw@269: local title = _"Discussion" bsw@269: ui.image{ bsw@269: attr = { title = title, alt = title }, bsw@269: static = "icons/16/comments.png" bsw@269: } bsw@269: end, bsw@269: field_attr = field_attr, bsw@269: label_attr = label_attr, bsw@269: content = function(record) bsw@269: ui.link{ bsw@269: text = tostring(record.issues_discussion_count), bsw@269: module = "area", bsw@269: view = "show", bsw@269: id = record.id, bsw@269: params = { filter = "accepted", tab = "issues" } bsw@269: } bsw@269: end bsw/jbe@0: }, bsw/jbe@0: { bsw@269: label = function() bsw@269: local title = _"Frozen" bsw@269: ui.image{ bsw@269: attr = { title = title, alt = title }, bsw@269: static = "icons/16/lock.png" bsw@269: } bsw@269: end, bsw@269: field_attr = field_attr, bsw@269: label_attr = label_attr, bsw@269: content = function(record) bsw@269: ui.link{ bsw@269: text = tostring(record.issues_frozen_count), bsw@269: module = "area", bsw@269: view = "show", bsw@269: id = record.id, bsw@269: params = { filter = "half_frozen", tab = "issues" } bsw@269: } bsw@269: end bsw@269: }, bsw@269: { bsw@269: label = function() bsw@269: local title = _"Voting" bsw@269: ui.image{ bsw@269: attr = { title = title, alt = title }, bsw@269: static = "icons/16/email_open.png" bsw@269: } bsw@269: end, bsw@269: field_attr = field_attr, bsw@269: label_attr = label_attr, bsw@269: content = function(record) bsw@269: ui.link{ bsw@269: text = tostring(record.issues_voting_count), bsw@269: module = "area", bsw@269: view = "show", bsw@269: id = record.id, bsw@269: params = { filter = "frozen", tab = "issues" } bsw@269: } bsw@269: end bsw@269: }, bsw@269: { bsw@269: label = function() bsw@269: local title = _"Finished" bsw@269: ui.image{ bsw@269: attr = { title = title, alt = title }, bsw@269: static = "icons/16/tick.png" bsw@269: } bsw@269: end, bsw@269: field_attr = field_attr, bsw@269: label_attr = label_attr, bsw@269: content = function(record) bsw@269: ui.link{ bsw@269: text = tostring(record.issues_finished_count), bsw@269: module = "area", bsw@269: view = "show", bsw@269: id = record.id, bsw@269: params = { filter = "finished", issue_list = "newest", tab = "issues" } bsw@269: } bsw@269: end bsw@269: }, bsw@269: { bsw@269: label = function() bsw@269: local title = _"Cancelled" bsw@269: ui.image{ bsw@269: attr = { title = title, alt = title }, bsw@269: static = "icons/16/cross.png" bsw@269: } bsw@269: end, bsw@269: field_attr = field_attr, bsw@269: label_attr = label_attr, bsw@269: content = function(record) bsw@269: ui.link{ bsw@269: text = tostring(record.issues_cancelled_count), bsw@269: module = "area", bsw@269: view = "show", bsw@269: id = record.id, bsw@269: params = { filter = "cancelled", issue_list = "newest", tab = "issues" } bsw@269: } bsw@269: end bsw@285: } bsw@269: } bsw/jbe@4: } bsw@274: --[[ bsw/jbe@4: ui.bargraph_legend{ bsw/jbe@4: width = 25, bsw/jbe@4: bars = { bsw/jbe@4: { color = "#444", label = _"Direct membership" }, bsw/jbe@4: { color = "#777", label = _"Membership by delegation" }, bsw/jbe@4: { color = "#ddd", label = _"No membership at all" }, bsw/jbe@4: } bsw/jbe@4: } bsw/jbe@4: bsw/jbe@19: slot.put("
  ") bsw/jbe@19: bsw/jbe@19: bsw@51: if app.session.member_id then bsw@51: ui.image{ bsw@51: attr = { title = title, alt = title }, bsw@51: static = "icons/16/user_gray.png" bsw@51: } bsw@51: slot.put(" ") bsw@51: slot.put(_"Member of area") bsw@51: slot.put("   ") mail@240: mail@240: ui.image{ mail@240: attr = { title = title, alt = title }, mail@240: static = "icons/16/link.png" mail@240: } mail@240: slot.put(" ") mail@240: slot.put(_"Area delegated") mail@240: slot.put("   ") bsw@51: end bsw/jbe@19: bsw/jbe@19: ui.image{ bsw/jbe@19: attr = { title = title, alt = title }, bsw/jbe@19: static = "icons/16/new.png" bsw/jbe@19: } bsw/jbe@19: slot.put(" ") bsw/jbe@19: slot.put(_"New") bsw/jbe@19: slot.put("   ") bsw/jbe@19: bsw/jbe@19: ui.image{ bsw/jbe@19: attr = { title = title, alt = title }, bsw/jbe@19: static = "icons/16/comments.png" bsw/jbe@19: } bsw/jbe@19: slot.put(" ") bsw/jbe@19: slot.put(_"Discussion") bsw/jbe@19: slot.put("   ") bsw/jbe@19: bsw/jbe@19: ui.image{ bsw/jbe@19: attr = { title = title, alt = title }, bsw/jbe@19: static = "icons/16/lock.png" bsw/jbe@19: } bsw/jbe@19: slot.put(" ") bsw/jbe@19: slot.put(_"Frozen") bsw/jbe@19: slot.put("   ") bsw/jbe@19: bsw/jbe@19: ui.image{ bsw/jbe@19: attr = { title = title, alt = title }, bsw/jbe@19: static = "icons/16/email_open.png" bsw/jbe@19: } bsw/jbe@19: slot.put(" ") bsw/jbe@19: slot.put(_"Voting") bsw/jbe@19: slot.put("   ") bsw/jbe@19: bsw/jbe@19: ui.image{ bsw/jbe@19: attr = { title = title, alt = title }, bsw/jbe@19: static = "icons/16/tick.png" bsw/jbe@19: } bsw/jbe@19: slot.put(" ") bsw/jbe@19: slot.put(_"Finished") bsw/jbe@19: slot.put("   ") bsw/jbe@19: bsw/jbe@19: ui.image{ bsw/jbe@19: attr = { title = title, alt = title }, bsw/jbe@19: static = "icons/16/cross.png" bsw/jbe@19: } bsw/jbe@19: slot.put(" ") bsw/jbe@19: slot.put(_"Cancelled") bsw/jbe@19: bsw@274: --]]