bsw@988: local delegations = Delegation:delegations_to_check_for_member_id(app.session.member_id) bsw@988: bsw@988: ui.title(_"Current unit and area delegations need confirmation") bsw@988: bsw@988: ui.actions(function() bsw@988: if not app.session.needs_delegation_check then bsw@988: ui.link{ module = "index", view = "index", text = _"Cancel" } bsw@988: end bsw@988: end) bsw@988: bsw@988: util.help("index.check_delegations", _"Check delegations") bsw@988: bsw@988: ui.form{ bsw@988: module = "index", action = "check_delegations", bsw@988: routing = { bsw@988: default = { mode = "redirect", module = "index", view = "index" }, bsw@988: error = { mode = "redirect", module = "index", view = "check_delegations" } bsw@988: }, bsw@988: content = function() bsw@988: bsw@988: ui.tag{ tag = "table", attr = { class = "striped" }, content = function() bsw@988: bsw@988: ui.tag{ tag = "tr", content = function() bsw@988: bsw@988: ui.tag{ tag = "th", content = _"unit / area" } bsw@988: ui.tag{ tag = "th", content = _"delegated to" } bsw@988: ui.tag{ tag = "th", content = _"action" } bsw@988: bsw@988: end } bsw@988: bsw@988: for i, delegation in ipairs(delegations) do bsw@988: bsw@988: local unit = Unit:by_id(delegation.unit_id) bsw@988: local area = Area:by_id(delegation.area_id) bsw@988: local member = Member:by_id(delegation.trustee_id) bsw@988: local info bsw@988: if area then bsw@988: area:load_delegation_info_once_for_member_id(app.session.member_id) bsw@988: info = area.delegation_info bsw@988: else bsw@988: unit:load_delegation_info_once_for_member_id(app.session.member_id) bsw@988: info = unit.delegation_info bsw@988: end bsw@988: bsw@988: ui.tag{ tag = "tr", content = function () bsw@988: bsw@988: ui.tag { tag = "td", content = function() bsw@988: ui.tag{ tag = "span", attr = { class = "unit_link" }, content = delegation.unit_name } bsw@988: ui.tag{ tag = "span", attr = { class = "area_link" }, content = delegation.area_name } bsw@988: end } bsw@988: bsw@988: ui.tag { tag = "td", content = function() bsw@988: if (member) then bsw@988: local text = _"delegates to" bsw@988: ui.image{ bsw@988: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@988: static = "delegation_arrow_24_horizontal.png" bsw@988: } bsw@988: execute.view{ module = "member_image", view = "_show", params = { bsw@988: member = member, class = "micro_avatar", popup_text = member.name, bsw@988: image_type = "avatar", show_dummy = true, bsw@988: } } bsw@988: slot.put(" ") bsw@988: ui.tag { tag = "span", content = delegation.member_name } bsw@988: else bsw@988: ui.tag{ tag = "span", content = _"Abandon unit delegation" } bsw@988: end bsw@988: end } bsw@988: bsw@988: ui.tag { tag = "td", content = function() bsw@988: local checked = config.check_delegations_default bsw@988: ui.tag{ tag = "input", attr = { bsw@988: type = "radio", bsw@988: id = "delegation_" .. delegation.id .. "_confirm", bsw@988: name = "delegation_" .. delegation.id, bsw@988: value = "confirm", bsw@988: checked = checked == "confirm" and "checked" or nil bsw@988: } } bsw@988: ui.tag{ bsw@988: tag = "label", bsw@988: attr = { ["for"] = "delegation_" .. delegation.id .. "_confirm" }, bsw@988: content = _"confirm" bsw@988: } bsw@988: ui.tag{ tag = "input", attr = { bsw@988: type = "radio", bsw@988: id = "delegation_" .. delegation.id .. "_revoke", bsw@988: name = "delegation_" .. delegation.id, bsw@988: value = "revoke", bsw@988: checked = checked == "revoke" and "checked" or nil bsw@988: } } bsw@988: ui.tag{ bsw@988: tag = "label", bsw@988: attr = { ["for"] = "delegation_" .. delegation.id .. "_revoke" }, bsw@988: content = _"revoke" bsw@988: } bsw@988: end} bsw@988: bsw@988: end } bsw@988: bsw@988: end bsw@988: bsw@988: end} bsw@988: bsw@988: bsw@988: slot.put("
") bsw@988: bsw@988: ui.submit{ text = "Finish delegation check" } bsw@988: bsw@988: end bsw@988: }