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: bsw@1630: ui.grid{ content = function() bsw@988: bsw@1630: ui.cell_main{ content = function() bsw@988: bsw@1630: ui.container { attr = { class = "mdl-card mdl-shadow--2dp mdl-card__fullwidth" }, content = function() bsw@1630: ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function() bsw@1630: ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _("Current unit and area delegations need confirmation") } bsw@988: end } bsw@1630: ui.container{ attr = { class = "mdl-card__content" }, content = function() bsw@988: bsw@1630: ui.form{ bsw@1630: module = "index", action = "check_delegations", bsw@1630: routing = { bsw@1630: default = { mode = "redirect", module = "index", view = "index" }, bsw@1630: error = { mode = "redirect", module = "index", view = "check_delegations" } bsw@1630: }, bsw@1630: content = function() bsw@988: bsw@1630: ui.tag{ bsw@1630: tag = "table", attr = { bsw@1630: class = "mdl-data-table mdl-js-data-table mdl-shadow--2dp" bsw@1630: }, bsw@1630: content = function() bsw@1630: ui.tag{ tag = "tr", content = function() bsw@1630: bsw@1630: ui.tag{ bsw@1630: tag = "th", attr = { bsw@1630: class = "mdl-data-table__cell--non-numeric" bsw@1630: }, bsw@1630: content = _"unit" bsw@1630: } bsw@1630: ui.tag{ bsw@1630: tag = "th", attr = { bsw@1630: class = "mdl-data-table__cell--non-numeric" bsw@1630: }, bsw@1630: content = _"area" bsw@1630: } bsw@1630: ui.tag{ bsw@1630: tag = "th", attr = { bsw@1630: class = "mdl-data-table__cell--non-numeric" bsw@1630: }, bsw@1630: content = _"delegated to" bsw@1630: } bsw@1630: ui.tag{ bsw@1630: tag = "th", attr = { bsw@1630: class = "mdl-data-table__cell--non-numeric" bsw@1630: }, bsw@1630: content = _"action" bsw@1630: } bsw@1630: end } bsw@1630: bsw@1630: for i, delegation in ipairs(delegations) do bsw@1630: bsw@1630: local unit = Unit:by_id(delegation.unit_id) bsw@1630: local area = Area:by_id(delegation.area_id) bsw@1630: local member = Member:by_id(delegation.trustee_id) bsw@1630: local info bsw@1630: if area then bsw@1630: area:load_delegation_info_once_for_member_id(app.session.member_id) bsw@1630: info = area.delegation_info bsw@1630: else bsw@1630: unit:load_delegation_info_once_for_member_id(app.session.member_id) bsw@1630: info = unit.delegation_info bsw@1630: end bsw@1630: bsw@1630: ui.tag{ tag = "tr", content = function () bsw@1630: bsw@1630: ui.tag { bsw@1630: tag = "td", bsw@1630: attr = { bsw@1630: class = "mdl-data-table__cell--non-numeric" bsw@1630: }, bsw@1630: content = delegation.unit_name bsw@1630: } bsw@1630: ui.tag { bsw@1630: tag = "td", bsw@1630: attr = { bsw@1630: class = "mdl-data-table__cell--non-numeric" bsw@1630: }, bsw@1630: content = delegation.area_name bsw@1630: } bsw@1630: ui.tag { bsw@1630: tag = "td", bsw@1630: attr = { bsw@1630: class = "mdl-data-table__cell--non-numeric" bsw@1630: }, bsw@1630: content = function() bsw@1630: if (member) then bsw@1630: local text = _"delegates to" bsw@1630: ui.image{ bsw@1630: attr = { class = "delegation_arrow", alt = text, title = text }, bsw@1630: static = "delegation_arrow_24_horizontal.png" bsw@1630: } bsw@1630: execute.view{ module = "member_image", view = "_show", params = { bsw@1630: member = member, class = "micro_avatar", popup_text = member.name, bsw@1630: image_type = "avatar", show_dummy = true, bsw@1630: } } bsw@1630: slot.put(" ") bsw@1630: ui.tag { tag = "span", content = delegation.member_name } bsw@1630: else bsw@1630: ui.tag{ tag = "span", content = _"Abandon unit delegation" } bsw@1630: end bsw@1630: end bsw@1630: } bsw@1630: bsw@1630: ui.tag { bsw@1630: tag = "td", bsw@1630: attr = { bsw@1630: class = "mdl-data-table__cell--non-numeric" bsw@1630: }, bsw@1630: content = function() bsw@1630: local checked = config.check_delegations_default bsw@1630: ui.tag{ tag = "input", attr = { bsw@1630: type = "radio", bsw@1630: id = "delegation_" .. delegation.id .. "_confirm", bsw@1630: name = "delegation_" .. delegation.id, bsw@1630: value = "confirm", bsw@1630: checked = checked == "confirm" and "checked" or nil bsw@1630: } } bsw@1630: ui.tag{ bsw@1630: tag = "label", bsw@1630: attr = { ["for"] = "delegation_" .. delegation.id .. "_confirm" }, bsw@1630: content = _"confirm" bsw@1630: } bsw@1630: ui.tag{ tag = "input", attr = { bsw@1630: type = "radio", bsw@1630: id = "delegation_" .. delegation.id .. "_revoke", bsw@1630: name = "delegation_" .. delegation.id, bsw@1630: value = "revoke", bsw@1630: checked = checked == "revoke" and "checked" or nil bsw@1630: } } bsw@1630: ui.tag{ bsw@1630: tag = "label", bsw@1630: attr = { ["for"] = "delegation_" .. delegation.id .. "_revoke" }, bsw@1630: content = _"revoke" bsw@1630: } bsw@1630: end bsw@1630: } bsw@1630: bsw@1630: end } bsw@1630: bsw@1630: end bsw@1630: bsw@1630: end bsw@988: } bsw@988: bsw@988: bsw@1630: slot.put("
") bsw@1630: bsw@1630: ui.submit{ bsw@1630: attr = { class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored" }, bsw@1630: text = _"Finish delegation check" bsw@1630: } bsw@1630: if not app.session.needs_delegation_check then bsw@1630: slot.put("   ") bsw@1630: ui.link{ bsw@1630: attr = { class = "mdl-button mdl-js-button" }, bsw@1630: module = "index", view = "index", text = _"Cancel" bsw@1630: } bsw@1630: end bsw@988: bsw@1630: bsw@1630: end bsw@1630: } bsw@1630: bsw@1630: bsw@1630: end } bsw@1630: end } bsw@1630: end } bsw@1630: bsw@1630: end } bsw@1630: bsw@1630: bsw@1630: bsw@1630: bsw@1630: bsw@1630: