liquid_feedback_frontend
annotate app/main/delegation/new.lua @ 118:93f4e465b50d
add initiator support in delegation
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Mon Sep 20 20:32:04 2010 +0200 (2010-09-20) |
parents | bf885faf3452 |
children | 02aacb3dffe0 |
rev | line source |
---|---|
bsw/jbe@0 | 1 local area = Area:by_id(param.get("area_id", atom.integer)) |
bsw/jbe@0 | 2 if area then |
bsw/jbe@0 | 3 slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name))) |
bsw/jbe@4 | 4 util.help("delegation.new.area") |
bsw/jbe@0 | 5 end |
bsw/jbe@0 | 6 |
bsw/jbe@0 | 7 local issue = Issue:by_id(param.get("issue_id", atom.integer)) |
bsw/jbe@0 | 8 if issue then |
bsw/jbe@0 | 9 slot.put_into("title", encode.html(_"Set delegation for Issue ##{number} in Area '#{area_name}'":gsub("#{number}", issue.id):gsub("#{area_name}", issue.area.name))) |
bsw/jbe@4 | 10 util.help("delegation.new.issue") |
bsw/jbe@0 | 11 end |
bsw/jbe@0 | 12 |
poelzi@111 | 13 local initiative = Initiative:by_id(param.get("initiative_id", atom.integer)) |
poelzi@111 | 14 |
bsw/jbe@4 | 15 if not area and not issue then |
bsw/jbe@4 | 16 slot.put_into("title", encode.html(_"Set global delegation")) |
bsw/jbe@4 | 17 util.help("delegation.new.global") |
bsw/jbe@4 | 18 end |
bsw/jbe@4 | 19 |
bsw/jbe@4 | 20 slot.select("actions", function() |
bsw/jbe@4 | 21 if issue then |
bsw/jbe@4 | 22 ui.link{ |
bsw/jbe@4 | 23 module = "issue", |
bsw/jbe@4 | 24 view = "show", |
bsw/jbe@4 | 25 id = issue.id, |
bsw/jbe@4 | 26 content = function() |
bsw/jbe@4 | 27 ui.image{ static = "icons/16/cancel.png" } |
bsw/jbe@4 | 28 slot.put(_"Cancel") |
bsw/jbe@4 | 29 end, |
bsw/jbe@4 | 30 } |
bsw/jbe@4 | 31 elseif area then |
bsw/jbe@4 | 32 ui.link{ |
bsw/jbe@4 | 33 module = "area", |
bsw/jbe@4 | 34 view = "show", |
bsw/jbe@4 | 35 id = area.id, |
bsw/jbe@4 | 36 content = function() |
bsw/jbe@4 | 37 ui.image{ static = "icons/16/cancel.png" } |
bsw/jbe@4 | 38 slot.put(_"Cancel") |
bsw/jbe@4 | 39 end, |
bsw/jbe@4 | 40 } |
bsw/jbe@4 | 41 else |
bsw/jbe@4 | 42 ui.link{ |
bsw/jbe@4 | 43 module = "index", |
bsw/jbe@4 | 44 view = "index", |
bsw/jbe@4 | 45 content = function() |
bsw/jbe@4 | 46 ui.image{ static = "icons/16/cancel.png" } |
bsw/jbe@4 | 47 slot.put(_"Cancel") |
bsw/jbe@4 | 48 end, |
bsw/jbe@4 | 49 } |
bsw/jbe@4 | 50 end |
bsw/jbe@4 | 51 end) |
bsw/jbe@4 | 52 |
bsw/jbe@4 | 53 |
bsw/jbe@0 | 54 |
bsw/jbe@0 | 55 local contact_members = Member:new_selector() |
bsw/jbe@0 | 56 :add_where{ "contact.member_id = ?", app.session.member.id } |
bsw/jbe@0 | 57 :join("contact", nil, "member.id = contact.other_member_id") |
bsw/jbe@4 | 58 :add_order_by("member.name") |
bsw/jbe@0 | 59 :exec() |
bsw/jbe@0 | 60 |
bsw/jbe@0 | 61 |
bsw/jbe@0 | 62 ui.form{ |
bsw/jbe@0 | 63 attr = { class = "vertical" }, |
bsw/jbe@0 | 64 module = "delegation", |
bsw/jbe@0 | 65 action = "update", |
bsw/jbe@0 | 66 params = { |
bsw/jbe@0 | 67 area_id = area and area.id or nil, |
bsw/jbe@0 | 68 issue_id = issue and issue.id or nil, |
bsw/jbe@0 | 69 }, |
bsw/jbe@0 | 70 routing = { |
bsw/jbe@0 | 71 default = { |
bsw/jbe@0 | 72 mode = "redirect", |
bsw/jbe@4 | 73 module = area and "area" or issue and "issue" or "index", |
bsw/jbe@4 | 74 view = (area or issue) and "show" or "index", |
bsw/jbe@4 | 75 id = area and area.id or issue and issue.id or nil, |
bsw/jbe@0 | 76 } |
bsw/jbe@0 | 77 }, |
bsw/jbe@0 | 78 content = function() |
bsw@10 | 79 local records = { |
bsw/jbe@4 | 80 { |
bsw/jbe@4 | 81 id = "-1", |
bsw/jbe@4 | 82 name = _"No delegation" |
bsw/jbe@4 | 83 } |
bsw/jbe@4 | 84 } |
poelzi@111 | 85 |
bsw/jbe@4 | 86 for i, record in ipairs(contact_members) do |
bsw/jbe@4 | 87 records[#records+1] = record |
bsw/jbe@4 | 88 end |
poelzi@111 | 89 disabled_records = {} |
poelzi@111 | 90 -- add initiative authors |
poelzi@111 | 91 if initiative then |
poelzi@111 | 92 records[#records+1] = {id="_", name=_"--- Initiators ---"} |
poelzi@111 | 93 disabled_records["_"] = true |
poelzi@111 | 94 for i,record in ipairs(initiative.initiators) do |
poelzi@111 | 95 trace.debug(record) |
poelzi@111 | 96 trace.debug(record.member.name) |
poelzi@111 | 97 records[#records+1] = record.member |
poelzi@111 | 98 end |
poelzi@111 | 99 end |
bsw/jbe@4 | 100 |
bsw/jbe@0 | 101 ui.field.select{ |
bsw/jbe@0 | 102 label = _"Trustee", |
bsw/jbe@0 | 103 name = "trustee_id", |
bsw/jbe@4 | 104 foreign_records = records, |
bsw/jbe@0 | 105 foreign_id = "id", |
bsw/jbe@4 | 106 foreign_name = "name", |
poelzi@111 | 107 disabled_records = disabled_records |
bsw/jbe@0 | 108 } |
poelzi@111 | 109 |
bsw/jbe@0 | 110 ui.submit{ text = _"Save" } |
bsw/jbe@0 | 111 end |
bsw/jbe@4 | 112 } |