liquid_feedback_frontend

annotate app/main/index/check_delegations.lua @ 988:81bde33c2256

Added support for regular delegation check, fixed css for pagination
author bsw
date Sat Apr 20 18:40:34 2013 +0200 (2013-04-20)
parents
children 14dfa591bc97
rev   line source
bsw@988 1 local delegations = Delegation:delegations_to_check_for_member_id(app.session.member_id)
bsw@988 2
bsw@988 3 ui.title(_"Current unit and area delegations need confirmation")
bsw@988 4
bsw@988 5 ui.actions(function()
bsw@988 6 if not app.session.needs_delegation_check then
bsw@988 7 ui.link{ module = "index", view = "index", text = _"Cancel" }
bsw@988 8 end
bsw@988 9 end)
bsw@988 10
bsw@988 11 util.help("index.check_delegations", _"Check delegations")
bsw@988 12
bsw@988 13 ui.form{
bsw@988 14 module = "index", action = "check_delegations",
bsw@988 15 routing = {
bsw@988 16 default = { mode = "redirect", module = "index", view = "index" },
bsw@988 17 error = { mode = "redirect", module = "index", view = "check_delegations" }
bsw@988 18 },
bsw@988 19 content = function()
bsw@988 20
bsw@988 21 ui.tag{ tag = "table", attr = { class = "striped" }, content = function()
bsw@988 22
bsw@988 23 ui.tag{ tag = "tr", content = function()
bsw@988 24
bsw@988 25 ui.tag{ tag = "th", content = _"unit / area" }
bsw@988 26 ui.tag{ tag = "th", content = _"delegated to" }
bsw@988 27 ui.tag{ tag = "th", content = _"action" }
bsw@988 28
bsw@988 29 end }
bsw@988 30
bsw@988 31 for i, delegation in ipairs(delegations) do
bsw@988 32
bsw@988 33 local unit = Unit:by_id(delegation.unit_id)
bsw@988 34 local area = Area:by_id(delegation.area_id)
bsw@988 35 local member = Member:by_id(delegation.trustee_id)
bsw@988 36 local info
bsw@988 37 if area then
bsw@988 38 area:load_delegation_info_once_for_member_id(app.session.member_id)
bsw@988 39 info = area.delegation_info
bsw@988 40 else
bsw@988 41 unit:load_delegation_info_once_for_member_id(app.session.member_id)
bsw@988 42 info = unit.delegation_info
bsw@988 43 end
bsw@988 44
bsw@988 45 ui.tag{ tag = "tr", content = function ()
bsw@988 46
bsw@988 47 ui.tag { tag = "td", content = function()
bsw@988 48 ui.tag{ tag = "span", attr = { class = "unit_link" }, content = delegation.unit_name }
bsw@988 49 ui.tag{ tag = "span", attr = { class = "area_link" }, content = delegation.area_name }
bsw@988 50 end }
bsw@988 51
bsw@988 52 ui.tag { tag = "td", content = function()
bsw@988 53 if (member) then
bsw@988 54 local text = _"delegates to"
bsw@988 55 ui.image{
bsw@988 56 attr = { class = "delegation_arrow", alt = text, title = text },
bsw@988 57 static = "delegation_arrow_24_horizontal.png"
bsw@988 58 }
bsw@988 59 execute.view{ module = "member_image", view = "_show", params = {
bsw@988 60 member = member, class = "micro_avatar", popup_text = member.name,
bsw@988 61 image_type = "avatar", show_dummy = true,
bsw@988 62 } }
bsw@988 63 slot.put(" ")
bsw@988 64 ui.tag { tag = "span", content = delegation.member_name }
bsw@988 65 else
bsw@988 66 ui.tag{ tag = "span", content = _"Abandon unit delegation" }
bsw@988 67 end
bsw@988 68 end }
bsw@988 69
bsw@988 70 ui.tag { tag = "td", content = function()
bsw@988 71 local checked = config.check_delegations_default
bsw@988 72 ui.tag{ tag = "input", attr = {
bsw@988 73 type = "radio",
bsw@988 74 id = "delegation_" .. delegation.id .. "_confirm",
bsw@988 75 name = "delegation_" .. delegation.id,
bsw@988 76 value = "confirm",
bsw@988 77 checked = checked == "confirm" and "checked" or nil
bsw@988 78 } }
bsw@988 79 ui.tag{
bsw@988 80 tag = "label",
bsw@988 81 attr = { ["for"] = "delegation_" .. delegation.id .. "_confirm" },
bsw@988 82 content = _"confirm"
bsw@988 83 }
bsw@988 84 ui.tag{ tag = "input", attr = {
bsw@988 85 type = "radio",
bsw@988 86 id = "delegation_" .. delegation.id .. "_revoke",
bsw@988 87 name = "delegation_" .. delegation.id,
bsw@988 88 value = "revoke",
bsw@988 89 checked = checked == "revoke" and "checked" or nil
bsw@988 90 } }
bsw@988 91 ui.tag{
bsw@988 92 tag = "label",
bsw@988 93 attr = { ["for"] = "delegation_" .. delegation.id .. "_revoke" },
bsw@988 94 content = _"revoke"
bsw@988 95 }
bsw@988 96 end}
bsw@988 97
bsw@988 98 end }
bsw@988 99
bsw@988 100 end
bsw@988 101
bsw@988 102 end}
bsw@988 103
bsw@988 104
bsw@988 105 slot.put("<br />")
bsw@988 106
bsw@988 107 ui.submit{ text = "Finish delegation check" }
bsw@988 108
bsw@988 109 end
bsw@988 110 }

Impressum / About Us