# HG changeset patch # User bsw # Date 1299173940 -3600 # Node ID 3e4ad069847a661faccb8917119ffe3de04754fe # Parent 4993b71b383f871550066fc22223cf3e3cba4749 Some more work at 2nd generation frontend code diff -r 4993b71b383f -r 3e4ad069847a app/main/_layout/lf2.html --- a/app/main/_layout/lf2.html Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/_layout/lf2.html Thu Mar 03 18:39:00 2011 +0100 @@ -89,6 +89,7 @@ background-color: #444; color: #fff; font-weight: bold; + text-decoration: none; } .tab1 .right a { @@ -98,6 +99,7 @@ .tab1 a.active { background-color: #7df; + color: #000; } /* @@ -245,16 +247,21 @@ padding-left: 0.2em; } -.box .row .col { -xborder: 1px solid red !important; -} - .box .row.head { background-color: #e4e7f0; color: #000; border-radius: 1ex 1ex 0 0; } +.box .row.last { + border-radius: 0 0 1ex 1ex; +} + +.box .row.head .col.head { + font-weight: bold; + color: #444; +} + .box .row.head .col a { background-color: #e4e7f0; color: #3B6E7F; @@ -275,6 +282,11 @@ color: #3B6E7F; } +.box .row.active, +.box .row.active a { + background-color: #DDF7FF; +} + /* Sidebar hover button */ .hoverbutton_container { @@ -461,7 +473,6 @@ .area .name { color: #444; - font-weight: bold; } .area .name a { @@ -473,20 +484,6 @@ margin-top: -3px; } -/* Issues */ - -.issue .issue_id { - font-weight: bold; -} - -.issue .state_name { - font-style: italic; -} - -.issue .time_left { - font-style: italic; -} - /* Initiatives */ .initiative .name, diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_area.lua --- a/app/main/lf2/_area.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_area.lua Thu Mar 03 18:39:00 2011 +0100 @@ -11,8 +11,8 @@ ui.box{ class = "area", content = function() ui.box_row{ class = "head", content = function() - ui.box_col{ class = "left name", content = area.name } - ui.box_col{ class = "right", content = _("#{direct_count}+#{delegated_count} Mitglieder", { + ui.box_col{ class = "head left name", content = area.name } + ui.box_col{ class = "right", content = _("#{direct_count}+#{delegated_count} members", { direct_count = area.direct_member_count, delegated_count = area.member_weight - area.direct_member_count } ) } @@ -22,21 +22,24 @@ ui.box_row{ class = "description", content = function() ui.box_col{ content = area.description } end } end - ui.box_row{ class = "member_count", content = function() - end } - - ui.box_row{ content = function() - ui.box_col{ class = "left", content = function() - execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } } + if #trustees > 1 then + ui.box_row{ content = function() + ui.box_col{ class = "left", content = function() + execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } } + end } + if trustees[1].scope_out == "area" then + text = _"Change or revoke area delegation..." + else + text = _"Set area delegation..." + end + ui.box_col{ class = "right", content = function() + ui.link{ + text = text, + module = "lf2", view = "delegation", params = { area_id = area.id } + } + end } end } - ui.box_col{ class = "right", content = function() - ui.tag{ content = _"[Change] or [revoke] area delegation [prefix]" } - ui.link{ text = _"[Change] or [revoke] area delegation [change]" } - ui.tag{ content = _"[Change] or [revoke] area delegation [midpart]" } - ui.link{ text = _"[Change] or [revoke] area delegation [revoke]" } - ui.tag{ content = _"[Change] or [revoke] area delegation [suffix]" } - end } - end } + end ui.box_row{ content = function() ui.box_col{ class = "left", content = function() @@ -63,11 +66,14 @@ text = _"Give up membership" } end - if not trustees then + if #trustees == 1 then if membership then slot.put(" · ") end - ui.link{ text = _"Delegate area...", module = "lf2", view = "delegation" } + ui.link{ + text = _"Set area delegation...", + module = "lf2", view = "delegation", params = { area_id = area.id } + } end end } end } diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_areas.lua --- a/app/main/lf2/_areas.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_areas.lua Thu Mar 03 18:39:00 2011 +0100 @@ -1,19 +1,31 @@ local areas = param.get("areas_selector", "table"):exec() +local current_area_id = param.get("current_area_id", atom.integer) local head_content = param.get("head_content", "function") -ui.box{ class = "areas", row_count = #areas, content = function() +if #areas == 0 then + return +end + +areas:load("membership_for_member", { member_id = app.session.member_id}, "membership") + +ui.box{ class = "areas", row_count = #areas + 1, content = function() if head_content then - ui.box_row{ class = "head", content = function() ui.box_col{ content = head_content } end } + ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function() + ui.link{ content = head_content, module = "lf2", view = "index" } + end } end } end for i, area in ipairs(areas) do local delegation = Delegation:by_pk(app.session.member_id, area.id) + local class = "area" + if (current_area_id and area.id == current_area_id) + or (not current_area_id and area.membership) + then + class = class .. " active" + end ui.box_row{ - class = "area", - toggle_content = function() - ui.image{ static = "lf2/icon_search_crossed.png" } - end, + class = class, content = function() ui.box_col{ class = "name", content = function() if delegation then @@ -26,4 +38,4 @@ end -end } \ No newline at end of file +end } diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_avatars.lua --- a/app/main/lf2/_avatars.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_avatars.lua Thu Mar 03 18:39:00 2011 +0100 @@ -22,7 +22,7 @@ image = "lf2/icon_delegation.png" text = _"Issue delegation" end - if param.get("arrows", atom.boolean) and (i > 1 or #members == 1) then + if param.get("arrows", atom.boolean) and (i > 1) then ui.image{ attr = { title = text, alt = text, class = class }, static = image } slot.put(member.scope) end diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_delegation_global.lua --- a/app/main/lf2/_delegation_global.lua Wed Mar 02 20:06:26 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -local trustees = Member:new_selector() - :add_field("delegation_chain.*") - :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, NULL)", "delegation_chain", "member.id = delegation_chain.member_id") - :add_order_by("index") - :exec() - -ui.box{ content = function() - ui.box_row{ class = "head", content = function() - ui.box_col{ content = _"Global delegation active" } - end } - ui.box_row{ content = function() ui.box_col{ content = function() - execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } } - end } end } - ui.box_row{ content = function() ui.box_col{ content = function() - ui.tag{ content = _"[Change] or [revoke] global delegation [prefix]" } - ui.link{ text = _"[Change] or [revoke] global delegation [change]" } - ui.tag{ content = _"[Change] or [revoke] global delegation [midpart]" } - ui.link{ text = _"[Change] or [revoke] global delegation [revoke]" } - ui.tag{ content = _"[Change] or [revoke] global delegation [suffix]" } - - end } end } -end } - \ No newline at end of file diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_interested.lua --- a/app/main/lf2/_interested.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_interested.lua Thu Mar 03 18:39:00 2011 +0100 @@ -1,10 +1,10 @@ local interested_members = param.get("interested_members", "table") ui.box{ content = function() ui.box_row{ class = "head interested", content = function() - ui.box_col{ class = "", content = _"Interested members" } + ui.box_col{ class = "head left", content = _"Members, interested in this issue" } + ui.box_col{ class = "right", content = _("#{count} members", { count = #interested_members }) } end } ui.box_row{ class = "interested", content = function() - ui.box_col{ content = _"The interested members are updated after some time." } ui.box_col{ class = "", content = function() execute.view{ module = "lf2", view = "_avatars", params = { members = interested_members } } end } diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_issues.lua --- a/app/main/lf2/_issues.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_issues.lua Thu Mar 03 18:39:00 2011 +0100 @@ -34,26 +34,14 @@ ui.box_row{ class = "head", content = function() - ui.box_col{ class = "issue_id left", content = function() + ui.box_col{ class = "issue_id left head", content = function() ui.link{ module = "lf2", view = "issue", id = issue.id, content = _("Issue ##{id}", { id = issue.id }) } end } - ui.box_col{ class = "unit_name right", content = function() - ui.link{ - module = "lf2", view = "unit", id = 1, - content = "Dummy unit name" - } - end } - ui.box_col{ class = "area_name right clearright", content = function() - ui.link{ - module = "lf2", view = "area_name", id = issue.area_id, - content = issue.area.name - } - end } - ui.box_col{ class = "policy_name left clearleft first", content = function() + ui.box_col{ class = "policy_name right", content = function() ui.link{ module = "lf2", view = "policy", id = issue.policy_id, content = issue.policy.name @@ -66,43 +54,80 @@ ui.box_col{ class = "state_name left", content = function() ui.tag{ content = issue.state_name } - slot.put(" · ") + end } + ui.box_col{ class = "state_time_left right", content = function() ui.tag{ content = issue.closed and _("since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left = issue.state_time_left }) } end } end } - if interest or delegation then + if #trustees > 1 then ui.box_row{ class = "head2", content = function() - ui.box_col{ class = "interest left", content = function() - if interest then - ui.image{ static = "lf2/icon_star.png" } - if issue.closed then - slot.put(" ", _"You were interested in this issue") - else - slot.put(" ", _"You are interested in this issue") - end - elseif delegating_interest then - ui.image{ static = "lf2/icon_delegated_star.png" } - if issue.closed then - slot.put(" ", _"You were interested in this issue by delegation") - else - slot.put(" ", _"You are interested in this issue by delegation") - end - elseif trustees then - slot.put(_"You have delegated this issue") + ui.box_col{ class = "left", content = function() + execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } } + end } + if not issue.closed and not issue.fully_frozen then + if trustees[1].scope_out == "issue" then + text = _"Change or revoke issue delegation..." else - slot.put(_"You are not interested in this issue") - end - end } - -- TODO if delegation ist falsch - if delegation then - slot.put(tostring(delegation.id)) - ui.box_col{ class = "delegation right", content = function() - execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } } + text = _"Set issue delegation..." + end + ui.box_col{ class = "right", content = function() + ui.link{ + text = text, + module = "lf2", view = "delegation", params = { issue_id = issue.id } + } end } end end } end + + ui.box_row{ class = "head2", content = function() + ui.box_col{ class = "interest left", content = function() + if interest then + ui.image{ static = "lf2/icon_star.png" } + if issue.closed then + slot.put(" ", _"You were interested in this issue") + else + slot.put(" ", _"You are interested in this issue") + end + elseif delegating_interest then + ui.image{ static = "lf2/icon_delegated_star.png" } + if issue.closed then + slot.put(" ", _"You were interested in this issue by delegation") + else + slot.put(" ", _"You are interested in this issue by delegation") + end + else + slot.put(_"You are not interested in this issue") + end + end } + + if not issue.closed and not issue.fully_frozen then + ui.box_col{ class = "right", content = function() + if interest then + ui.link{ + text = _"Remove interest", + module = "interest", action = "update", params = { issue_id = issue.id, delete = true }, + routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } } + } + else + ui.link{ + text = _"Add my interest", + module = "interest", action = "update", params = { issue_id = issue.id }, + routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } } + } + end + if #trustees == 1 then + slot.put(" · ") + ui.link{ + text = _"Set issue delegation...", + module = "lf2", view = "delegation", params = { issue_id = issue.id } + } + end + end } + end + + end } for i, initiative in ipairs(issue.initiatives) do ui.box_row{ class = "initiative", content = function() ui.box_col { content = function() diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_search.lua --- a/app/main/lf2/_search.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_search.lua Thu Mar 03 18:39:00 2011 +0100 @@ -1,35 +1,14 @@ -ui.container{ - attr = { class = "boxhead" }, - content = _"Search in initiatives for text:" -} - -ui.container{ - attr = { class = "search box" }, - content = function() - ui.container{ - attr = { class = "row first" }, - content = function() - ui.container{ - attr = { class = "col first" }, - content = function() +ui.box{ class = "search", content = function() + ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = _"Search in initiatives" } end } - ui.form{ - content = function() - - - slot.put(" ") - - ui.tag{ tag = "input", attr = { type = "text", name = "q" } } - - ui.submit{ text = _"Search" } - - end - } - - end - } - + ui.box_row{ content = function() ui.box_col{ content = function() + ui.form{ + content = function() + slot.put(" ") + ui.tag{ tag = "input", attr = { type = "text", name = "q" } } + ui.submit{ text = _"Search" } end } - end -} \ No newline at end of file + end } end } + +end } \ No newline at end of file diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_sidebar.lua --- a/app/main/lf2/_sidebar.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_sidebar.lua Thu Mar 03 18:39:00 2011 +0100 @@ -1,3 +1,5 @@ +local current_area_id = param.get("current_area_id", atom.integer) + local member_areas_selector = Area:build_selector{ member_id = app.session.member_id, order = "name" @@ -7,9 +9,10 @@ order = "name" } -execute.view{ module = "lf2", view = "_delegation_global" } +execute.view{ module = "lf2", view = "_sidebar_unit", params = { unit = {} } } --TODO ui.form{ + method = "get", content = function() ui.container{ attr = { class = "boxhead" }, content = _"" } @@ -18,6 +21,7 @@ execute.view{ module = "lf2", view = "_areas", params = { areas_selector = member_areas_selector, + current_area_id = current_area_id, head_content = function() ui.tag{ content = _"Areas, you are member of" } end } } @@ -25,6 +29,7 @@ execute.view{ module = "lf2", view = "_areas", params = { areas_selector = other_areas_selector, + current_area_id = current_area_id, head_content = function() ui.tag{ content = _"Areas, you are not member of" } end } } diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_sidebar_drafts.lua --- a/app/main/lf2/_sidebar_drafts.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_sidebar_drafts.lua Thu Mar 03 18:39:00 2011 +0100 @@ -5,7 +5,6 @@ :add_order_by("id DESC") :exec() -ui.container{ attr = { class = "boxhead" }, content = _"Draft revisions" } ui.box{ class = "drafts", content = function() if drafts then @@ -14,11 +13,14 @@ module = "draft", view = "diff", content = function() + ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = _"Draft revisions" } end } ui.box_row{ class = "", content = function() ui.box_col{ class = "scrolled", content = function() for i, draft in ipairs(drafts) do - ui.box_row{ class = "draft", content = function() + local class = "draft" + if i == 1 then class = class .. " first" end + ui.box_row{ class = class, content = function() ui.box_col{ class = "left", content = function() ui.link{ attr = { class = "created" }, diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_sidebar_initiatives.lua --- a/app/main/lf2/_sidebar_initiatives.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_sidebar_initiatives.lua Thu Mar 03 18:39:00 2011 +0100 @@ -1,5 +1,10 @@ +local head_content = param.get("head_content", "function") + local initiatives = param.get("initiatives", "table") ui.box{ content = function() + if head_content then + ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = head_content } end } + end ui.box_row{ class = "initiatives", content = function() ui.box_col{ class = "scrolled", content = function() execute.view{ module = "lf2", view = "_issue_initiatives", params = { initiatives = initiatives } } diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_sidebar_issue.lua --- a/app/main/lf2/_sidebar_issue.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/_sidebar_issue.lua Thu Mar 03 18:39:00 2011 +0100 @@ -35,7 +35,7 @@ ui.box{ class = "issue", content = function() - ui.box_row{ class = "issue_id head", content = function() ui.box_col{ content = function() + ui.box_row{ class = "issue_id head", content = function() ui.box_col{ class = "head", content = function() ui.link{ module = "lf2", view = "issue", id = issue.id, content = _("Issue ##{id}", { id = issue.id }) diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/_sidebar_unit.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/lf2/_sidebar_unit.lua Thu Mar 03 18:39:00 2011 +0100 @@ -0,0 +1,33 @@ +local unit = param.get("unit", "table") + +local trustees = Member:new_selector() + :add_field("delegation_chain.*") + :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, NULL)", "delegation_chain", "member.id = delegation_chain.member_id") + :add_order_by("index") + :exec() + +ui.box{ content = function() + ui.box_row{ class = "head", content = function() + ui.box_col{ class = "head", content = _"DE / Berlin / Friedrichshain-Kreuzberg" } + end } + + if #trustees > 1 then + ui.box_row{ content = function() ui.box_col{ content = function() + execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } } + end } end } + end + + ui.box_row{ content = function() ui.box_col{ content = function() + if trustees[1].scope_out == "global" then + text = _"Change or revoke unit delegation..." + else + text = _"Set unit delegation..." + end + ui.link{ + text = text, + module = "lf2", view = "delegation", params = { unit_id = unit.id } + } + end } end } + +end } + \ No newline at end of file diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/area.lua --- a/app/main/lf2/area.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/area.lua Thu Mar 03 18:39:00 2011 +0100 @@ -3,7 +3,7 @@ slot.set_layout("lf2") slot.select("sidebar", function() - execute.view{ module = "lf2", view = "_sidebar" } + execute.view{ module = "lf2", view = "_sidebar", params = { current_area_id = area.id } } end) execute.view{ module = "lf2", view = "_area", params = { area = area } } diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/delegation.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/lf2/delegation.lua Thu Mar 03 18:39:00 2011 +0100 @@ -0,0 +1,134 @@ +slot.set_layout("lf2") + +local area = Area:by_id(param.get("area_id", atom.integer)) +local issue = Issue:by_id(param.get("issue_id", atom.integer)) +local initiative = Initiative:by_id(param.get("initiative_id", atom.integer)) + +local contact_members = Member:build_selector{ + is_contact_of_member_id = app.session.member_id, + order = "name" +}:exec() + +if area then + title = _"Set delegation for Area '#{name}'":gsub("#{name}", area.name) +end + +if issue then + title = _"Set delegation for Issue ##{number} in Area '#{area_name}'":gsub("#{number}", issue.id):gsub("#{area_name}", issue.area.name) +end + +if not area and not issue then + title = _"Set unit delegation" +end + +ui.box{ content = function() + + ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = title } end } + + ui.form{ + attr = { class = "vertical" }, + module = "delegation", + action = "update", + params = { + area_id = area and area.id or nil, + issue_id = issue and issue.id or nil, + }, + routing = { + default = { + mode = "redirect", + module = "lf2", + view = area and "area" or issue and "issue" or "index", + id = area and area.id or issue and issue.id or nil, + } + }, + content = function() + local records + + if issue then + local delegate_name = "" + local scope = "no delegation set" + local area_delegation = Delegation:by_pk(app.session.member_id, issue.area_id) + if area_delegation then + delegate_name = area_delegation.trustee and area_delegation.trustee.name or _"abandoned" + scope = _"area" + else + local unit_delegation = Delegation:by_pk(app.session.member_id) + if unit_delegation then + delegate_name = unit_delegation.trustee.name + scope = _"unit" + end + end + records = { + { + id = -1, + name = _("Apply unit or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) + }, + { + id = 0, + name = _"Abandon unit and area delegations for this issue" + }, + + } + elseif area then + local delegate_name = "" + local scope = "no delegation set" + local unit_delegation = Delegation:by_pk(app.session.member_id) + if unit_delegation then + delegate_name = unit_delegation.trustee.name + scope = _"unit" + end + records = { + { + id = -1, + name = _("Apply unit delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope }) + }, + { + id = 0, + name = _"Abandon unit delegation for this area" + } + } + + else + records = { + { + id = -1, + name = _"No delegation" + } + } + + end + -- add saved members + records[#records+1] = {id="_", name= "--- " .. _"Saved contacts" .. " ---"} + for i, record in ipairs(contact_members) do + records[#records+1] = record + end + -- add initiative authors + if initiative then + records[#records+1] = {id="_", name= "--- " .. _"Initiators" .. " ---"} + for i,record in ipairs(initiative.initiators) do + records[#records+1] = record.member + end + end + + disabled_records = {} + disabled_records["_"] = true + + + ui.box_row{ content = function() ui.box_col{ content = function() + ui.field.select{ + label = _"Trustee", + name = "trustee_id", + foreign_records = records, + foreign_id = "id", + foreign_name = "name", + disabled_records = disabled_records + } + end } end } + + ui.box_row{ content = function() ui.box_col{ content = function() + ui.submit{ text = _"Save" } + end } end } + end + } + +end } \ No newline at end of file diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/initiative.lua --- a/app/main/lf2/initiative.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/initiative.lua Thu Mar 03 18:39:00 2011 +0100 @@ -24,10 +24,10 @@ slot.select("sidebar", function() execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue } } - ui.container{ attr = { class = "boxhead" }, content = _"Alternative initiatives" } execute.view{ module = "lf2", view = "_sidebar_initiatives", params = { - initiatives = alternative_initiatives + initiatives = alternative_initiatives, + head_content = function() ui.tag{ content = _"Alternative initiatives" } end } } execute.view{ module = "lf2", view = "_sidebar_drafts", params = { diff -r 4993b71b383f -r 3e4ad069847a app/main/lf2/issue.lua --- a/app/main/lf2/issue.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/app/main/lf2/issue.lua Thu Mar 03 18:39:00 2011 +0100 @@ -40,7 +40,7 @@ local delegating_interest = issue.delegating_interest slot.select("sidebar", function() - execute.view{ module = "lf2", view = "_sidebar" } + execute.view{ module = "lf2", view = "_sidebar", params = { current_area_id = issue.area_id } } end) execute.view{ module = "lf2", view = "_area", params = { area = area } } diff -r 4993b71b383f -r 3e4ad069847a locale/translations.en.lua --- a/locale/translations.en.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/locale/translations.en.lua Thu Mar 03 18:39:00 2011 +0100 @@ -678,11 +678,11 @@ ["[Change] or [revoke] area delegation [prefix]"] = ""; ["[Change] or [revoke] area delegation [revoke]"] = "revoke"; ["[Change] or [revoke] area delegation [suffix]"] = " area delegation"; -["[Change] or [revoke] global delegation [change]"] = "Change"; -["[Change] or [revoke] global delegation [midpart]"] = " or "; -["[Change] or [revoke] global delegation [prefix]"] = ""; -["[Change] or [revoke] global delegation [revoke]"] = "revoke"; -["[Change] or [revoke] global delegation [suffix]"] = " global delegation"; +["[Change] or [revoke] unit delegation [change]"] = "Change"; +["[Change] or [revoke] unit delegation [midpart]"] = " or "; +["[Change] or [revoke] unit delegation [prefix]"] = ""; +["[Change] or [revoke] unit delegation [revoke]"] = "revoke"; +["[Change] or [revoke] unit delegation [suffix]"] = " unit delegation"; ["[Registered members only]"] = false; ["[not displayed public]"] = false; ["a bit unsatisfied"] = false; diff -r 4993b71b383f -r 3e4ad069847a model/area.lua --- a/model/area.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/model/area.lua Thu Mar 03 18:39:00 2011 +0100 @@ -50,6 +50,38 @@ ref = 'allowed_policies' } +Area:add_reference{ + mode = '11', + to = "Membership", + this_key = 'id', + that_key = 'area_id', + ref = 'membership_for_member', + back_ref = 'area', + selector_generator = function(list, options) + local member_id = assert(options.member_id) + + -- build list of issue ids + local ids = { sep = ", " } + for i, object in ipairs(list) do + local id = object.id + if id ~= nil then + ids[#ids+1] = {"?", id} + end + end + + if #ids == 0 then + return Membership:new_selector():empty_list_mode() + end + + local selector = Membership:new_selector() + selector:add_where{ 'membership.area_id IN ($)', ids } + selector:add_where{ 'membership.member_id = ?', member_id } + + return selector + end +} + + function Area.object_get:default_policy() return Policy:new_selector() :join("allowed_policy", nil, "allowed_policy.policy_id = policy.id") diff -r 4993b71b383f -r 3e4ad069847a model/issue.lua --- a/model/issue.lua Wed Mar 02 20:06:26 2011 +0100 +++ b/model/issue.lua Thu Mar 03 18:39:00 2011 +0100 @@ -166,7 +166,7 @@ local selector = DelegatingInterestSnapshot:new_selector() selector:join("issue", nil, "delegating_interest_snapshot.issue_id = issue.id AND delegating_interest_snapshot.event = issue.latest_snapshot_event") selector:add_where{ 'delegating_interest_snapshot.issue_id IN ($)', ids } - selector:add_where{ 'delegating_interest_snapshot.member_id = ?', options.member_id } + selector:add_where{ 'delegating_interest_snapshot.member_id = ?', member_id } return selector end