liquid_feedback_frontend

annotate app/main/delegation/new.lua @ 277:bde068b37608

Dropdown boxes except of delegation box removed, optical enhancements and repositioning of elements
author bsw
date Mon Feb 13 00:16:42 2012 +0100 (2012-02-13)
parents 7196685f9dd7
children a72a389399fc
rev   line source
bsw@248 1 local unit = Unit:by_id(param.get("unit_id", atom.integer))
bsw@248 2 if unit then
bsw@264 3 slot.put_into("title", encode.html(config.single_unit_id and _"Set global delegation" or _"Set unit delegation"))
bsw@248 4 util.help("delegation.new.unit")
bsw@248 5 end
bsw@248 6
bsw/jbe@0 7 local area = Area:by_id(param.get("area_id", atom.integer))
bsw/jbe@0 8 if area then
bsw/jbe@0 9 slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name)))
bsw/jbe@4 10 util.help("delegation.new.area")
bsw/jbe@0 11 end
bsw/jbe@0 12
bsw/jbe@0 13 local issue = Issue:by_id(param.get("issue_id", atom.integer))
bsw/jbe@0 14 if issue then
bsw/jbe@0 15 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 16 util.help("delegation.new.issue")
bsw/jbe@0 17 end
bsw/jbe@0 18
poelzi@111 19 local initiative = Initiative:by_id(param.get("initiative_id", atom.integer))
poelzi@111 20
bsw/jbe@4 21 slot.select("actions", function()
bsw/jbe@4 22 if issue then
bsw/jbe@4 23 ui.link{
bsw/jbe@4 24 module = "issue",
bsw/jbe@4 25 view = "show",
bsw/jbe@4 26 id = issue.id,
bsw/jbe@4 27 content = function()
bsw/jbe@4 28 ui.image{ static = "icons/16/cancel.png" }
bsw/jbe@4 29 slot.put(_"Cancel")
bsw/jbe@4 30 end,
bsw/jbe@4 31 }
bsw/jbe@4 32 elseif area then
bsw/jbe@4 33 ui.link{
bsw/jbe@4 34 module = "area",
bsw/jbe@4 35 view = "show",
bsw/jbe@4 36 id = area.id,
bsw/jbe@4 37 content = function()
bsw/jbe@4 38 ui.image{ static = "icons/16/cancel.png" }
bsw/jbe@4 39 slot.put(_"Cancel")
bsw/jbe@4 40 end,
bsw/jbe@4 41 }
bsw/jbe@4 42 else
bsw/jbe@4 43 ui.link{
bsw/jbe@4 44 module = "index",
bsw/jbe@4 45 view = "index",
bsw/jbe@4 46 content = function()
bsw/jbe@4 47 ui.image{ static = "icons/16/cancel.png" }
bsw/jbe@4 48 slot.put(_"Cancel")
bsw/jbe@4 49 end,
bsw/jbe@4 50 }
bsw/jbe@4 51 end
bsw/jbe@4 52 end)
bsw/jbe@4 53
bsw/jbe@4 54
bsw@199 55 local contact_members = Member:build_selector{
bsw@199 56 is_contact_of_member_id = app.session.member_id,
bsw@199 57 order = "name"
bsw@199 58 }:exec()
bsw/jbe@0 59
bsw/jbe@0 60 ui.form{
bsw/jbe@0 61 attr = { class = "vertical" },
bsw/jbe@0 62 module = "delegation",
bsw/jbe@0 63 action = "update",
bsw/jbe@0 64 params = {
bsw@248 65 unit_id = unit and unit.id or nil,
bsw/jbe@0 66 area_id = area and area.id or nil,
bsw/jbe@0 67 issue_id = issue and issue.id or nil,
bsw/jbe@0 68 },
bsw/jbe@0 69 routing = {
bsw/jbe@0 70 default = {
bsw/jbe@0 71 mode = "redirect",
bsw@273 72 module = area and "area" or issue and "issue" or "area",
bsw@273 73 view = (area or issue) and "show" or "list",
bsw/jbe@4 74 id = area and area.id or issue and issue.id or nil,
bsw@273 75 params = { unit_id = unit and unit.id or nil }
bsw/jbe@0 76 }
bsw/jbe@0 77 },
bsw/jbe@0 78 content = function()
bsw@180 79 local records
bsw@180 80
bsw@180 81 if issue then
bsw@183 82 local delegate_name = ""
bsw@183 83 local scope = "no delegation set"
bsw@248 84 local area_delegation = Delegation:by_pk(app.session.member_id, nil, issue.area_id)
bsw@183 85 if area_delegation then
bsw@187 86 delegate_name = area_delegation.trustee and area_delegation.trustee.name or _"abandoned"
bsw@183 87 scope = _"area"
bsw@183 88 else
bsw@248 89 local unit_delegation = Delegation:by_pk(app.session.member_id, issue.area.unit_id)
bsw@248 90 if unit_delegation then
bsw@248 91 delegate_name = unit_delegation.trustee.name
bsw@264 92 scope = config.single_unit_id and _"global" or _"unit"
bsw@248 93 end
bsw@183 94 end
bsw@264 95 local text_apply
bsw@264 96 local text_abandon
bsw@264 97 if config.single_unit_id then
bsw@264 98 text_apply = _("Apply global or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
bsw@264 99 text_abandon = _"Abandon unit and area delegations for this issue"
bsw@264 100 else
bsw@264 101 text_apply = _("Apply unit or area delegation for this issue (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
bsw@264 102 text_abandon = _"Abandon unit and area delegations for this issue"
bsw@264 103 end
bsw@180 104 records = {
bsw@264 105 { id = -1, name = text_apply },
bsw@264 106 { id = 0, name = text_abandom }
bsw/jbe@4 107 }
bsw@180 108 elseif area then
bsw@183 109 local delegate_name = ""
bsw@183 110 local scope = "no delegation set"
bsw@248 111 local unit_delegation = Delegation:by_pk(app.session.member_id, area.unit_id)
bsw@248 112 if unit_delegation then
bsw@248 113 delegate_name = unit_delegation.trustee.name
bsw@264 114 scope = config.single_unit_id and _"global" or _"unit"
bsw@264 115 end
bsw@264 116 local text_apply
bsw@264 117 local text_abandon
bsw@264 118 if config.single_unit_id then
bsw@264 119 text_apply = _("Apply global delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
bsw@264 120 text_abandon = _"Abandon global delegation for this area"
bsw@264 121 else
bsw@264 122 text_apply = _("Apply unit delegation for this area (Currently: #{delegate_name} [#{scope}])", { delegate_name = delegate_name, scope = scope })
bsw@264 123 text_abandon = _"Abandon unit delegation for this area"
bsw@183 124 end
bsw@180 125 records = {
bsw@180 126 {
bsw@180 127 id = -1,
bsw@264 128 name = text_apply
bsw@180 129 },
bsw@180 130 {
bsw@180 131 id = 0,
bsw@264 132 name = text_abandon
bsw@180 133 }
bsw@180 134 }
bsw@180 135
bsw@180 136 else
bsw@180 137 records = {
bsw@180 138 {
bsw@180 139 id = -1,
bsw@180 140 name = _"No delegation"
bsw@180 141 }
bsw@180 142 }
bsw@180 143
bsw@180 144 end
bsw@183 145 -- add saved members
bsw@183 146 records[#records+1] = {id="_", name= "--- " .. _"Saved contacts" .. " ---"}
bsw/jbe@4 147 for i, record in ipairs(contact_members) do
bsw/jbe@4 148 records[#records+1] = record
bsw/jbe@4 149 end
poelzi@111 150 -- add initiative authors
poelzi@111 151 if initiative then
bsw@183 152 records[#records+1] = {id="_", name= "--- " .. _"Initiators" .. " ---"}
poelzi@111 153 for i,record in ipairs(initiative.initiators) do
poelzi@111 154 records[#records+1] = record.member
poelzi@111 155 end
poelzi@111 156 end
bsw/jbe@4 157
bsw@183 158 disabled_records = {}
bsw@183 159 disabled_records["_"] = true
bsw@183 160
bsw/jbe@0 161 ui.field.select{
bsw/jbe@0 162 label = _"Trustee",
bsw/jbe@0 163 name = "trustee_id",
bsw/jbe@4 164 foreign_records = records,
bsw/jbe@0 165 foreign_id = "id",
bsw/jbe@4 166 foreign_name = "name",
poelzi@111 167 disabled_records = disabled_records
bsw/jbe@0 168 }
poelzi@111 169
bsw/jbe@0 170 ui.submit{ text = _"Save" }
bsw/jbe@0 171 end
bsw/jbe@4 172 }

Impressum / About Us