bsw/jbe@0: local area = Area:by_id(param.get("area_id", atom.integer)) bsw/jbe@0: if area then bsw/jbe@0: slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name))) bsw/jbe@4: util.help("delegation.new.area") bsw/jbe@0: end bsw/jbe@0: bsw/jbe@0: local issue = Issue:by_id(param.get("issue_id", atom.integer)) bsw/jbe@0: if issue then bsw/jbe@0: 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: util.help("delegation.new.issue") bsw/jbe@0: end bsw/jbe@0: poelzi@111: local initiative = Initiative:by_id(param.get("initiative_id", atom.integer)) poelzi@111: bsw/jbe@4: if not area and not issue then bsw/jbe@4: slot.put_into("title", encode.html(_"Set global delegation")) bsw/jbe@4: util.help("delegation.new.global") bsw/jbe@4: end bsw/jbe@4: bsw/jbe@4: slot.select("actions", function() bsw/jbe@4: if issue then bsw/jbe@4: ui.link{ bsw/jbe@4: module = "issue", bsw/jbe@4: view = "show", bsw/jbe@4: id = issue.id, bsw/jbe@4: content = function() bsw/jbe@4: ui.image{ static = "icons/16/cancel.png" } bsw/jbe@4: slot.put(_"Cancel") bsw/jbe@4: end, bsw/jbe@4: } bsw/jbe@4: elseif area then bsw/jbe@4: ui.link{ bsw/jbe@4: module = "area", bsw/jbe@4: view = "show", bsw/jbe@4: id = area.id, bsw/jbe@4: content = function() bsw/jbe@4: ui.image{ static = "icons/16/cancel.png" } bsw/jbe@4: slot.put(_"Cancel") bsw/jbe@4: end, bsw/jbe@4: } bsw/jbe@4: else bsw/jbe@4: ui.link{ bsw/jbe@4: module = "index", bsw/jbe@4: view = "index", bsw/jbe@4: content = function() bsw/jbe@4: ui.image{ static = "icons/16/cancel.png" } bsw/jbe@4: slot.put(_"Cancel") bsw/jbe@4: end, bsw/jbe@4: } bsw/jbe@4: end bsw/jbe@4: end) bsw/jbe@4: bsw/jbe@4: bsw/jbe@0: bsw/jbe@0: local contact_members = Member:new_selector() bsw/jbe@0: :add_where{ "contact.member_id = ?", app.session.member.id } bsw/jbe@0: :join("contact", nil, "member.id = contact.other_member_id") bsw/jbe@4: :add_order_by("member.name") bsw/jbe@0: :exec() bsw/jbe@0: bsw/jbe@0: bsw/jbe@0: ui.form{ bsw/jbe@0: attr = { class = "vertical" }, bsw/jbe@0: module = "delegation", bsw/jbe@0: action = "update", bsw/jbe@0: params = { bsw/jbe@0: area_id = area and area.id or nil, bsw/jbe@0: issue_id = issue and issue.id or nil, bsw/jbe@0: }, bsw/jbe@0: routing = { bsw/jbe@0: default = { bsw/jbe@0: mode = "redirect", bsw/jbe@4: module = area and "area" or issue and "issue" or "index", bsw/jbe@4: view = (area or issue) and "show" or "index", bsw/jbe@4: id = area and area.id or issue and issue.id or nil, bsw/jbe@0: } bsw/jbe@0: }, bsw/jbe@0: content = function() bsw@10: local records = { bsw/jbe@4: { bsw/jbe@4: id = "-1", bsw/jbe@4: name = _"No delegation" bsw/jbe@4: } bsw/jbe@4: } poelzi@111: bsw/jbe@4: for i, record in ipairs(contact_members) do bsw/jbe@4: records[#records+1] = record bsw/jbe@4: end poelzi@111: disabled_records = {} poelzi@111: -- add initiative authors poelzi@111: if initiative then poelzi@111: records[#records+1] = {id="_", name=_"--- Initiators ---"} poelzi@111: disabled_records["_"] = true poelzi@111: for i,record in ipairs(initiative.initiators) do poelzi@111: trace.debug(record) poelzi@111: trace.debug(record.member.name) poelzi@111: records[#records+1] = record.member poelzi@111: end poelzi@111: end bsw/jbe@4: bsw/jbe@0: ui.field.select{ bsw/jbe@0: label = _"Trustee", bsw/jbe@0: name = "trustee_id", bsw/jbe@4: foreign_records = records, bsw/jbe@0: foreign_id = "id", bsw/jbe@4: foreign_name = "name", poelzi@111: disabled_records = disabled_records bsw/jbe@0: } poelzi@111: bsw/jbe@0: ui.submit{ text = _"Save" } bsw/jbe@0: end bsw/jbe@4: }