| 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 ui.form{ | 
| bsw@988 | 12   module = "index", action = "check_delegations", | 
| bsw@988 | 13   routing = { | 
| bsw@988 | 14     default = { mode = "redirect", module = "index", view = "index" }, | 
| bsw@988 | 15     error = { mode = "redirect", module = "index", view = "check_delegations" } | 
| bsw@988 | 16   }, | 
| bsw@988 | 17   content = function() | 
| bsw@988 | 18 | 
| bsw@988 | 19     ui.tag{ tag = "table", attr = { class = "striped" }, content = function() | 
| bsw@988 | 20 | 
| bsw@988 | 21       ui.tag{ tag = "tr", content = function() | 
| bsw@988 | 22 | 
| bsw@988 | 23         ui.tag{ tag = "th", content = _"unit / area" } | 
| bsw@988 | 24         ui.tag{ tag = "th", content = _"delegated to" } | 
| bsw@988 | 25         ui.tag{ tag = "th", content = _"action" } | 
| bsw@988 | 26 | 
| bsw@988 | 27       end } | 
| bsw@988 | 28 | 
| bsw@988 | 29       for i, delegation in ipairs(delegations) do | 
| bsw@988 | 30 | 
| bsw@988 | 31         local unit = Unit:by_id(delegation.unit_id) | 
| bsw@988 | 32         local area = Area:by_id(delegation.area_id) | 
| bsw@988 | 33         local member = Member:by_id(delegation.trustee_id) | 
| bsw@988 | 34         local info | 
| bsw@988 | 35         if area then | 
| bsw@988 | 36           area:load_delegation_info_once_for_member_id(app.session.member_id) | 
| bsw@988 | 37           info = area.delegation_info | 
| bsw@988 | 38         else | 
| bsw@988 | 39           unit:load_delegation_info_once_for_member_id(app.session.member_id) | 
| bsw@988 | 40           info = unit.delegation_info | 
| bsw@988 | 41         end | 
| bsw@988 | 42 | 
| bsw@988 | 43         ui.tag{ tag = "tr", content = function () | 
| bsw@988 | 44 | 
| bsw@988 | 45           ui.tag { tag = "td", content = function() | 
| bsw@988 | 46             ui.tag{ tag = "span", attr = { class = "unit_link" }, content = delegation.unit_name } | 
| bsw@988 | 47             ui.tag{ tag = "span", attr = { class = "area_link" }, content = delegation.area_name } | 
| bsw@988 | 48           end } | 
| bsw@988 | 49 | 
| bsw@988 | 50           ui.tag { tag = "td", content = function() | 
| bsw@988 | 51             if (member) then | 
| bsw@988 | 52               local text = _"delegates to" | 
| bsw@988 | 53               ui.image{ | 
| bsw@988 | 54                 attr = { class = "delegation_arrow", alt = text, title = text }, | 
| bsw@988 | 55                 static = "delegation_arrow_24_horizontal.png" | 
| bsw@988 | 56               } | 
| bsw@988 | 57               execute.view{ module = "member_image", view = "_show", params = { | 
| bsw@988 | 58                 member = member, class = "micro_avatar", popup_text = member.name, | 
| bsw@988 | 59                   image_type = "avatar", show_dummy = true, | 
| bsw@988 | 60                 } } | 
| bsw@988 | 61               slot.put(" ") | 
| bsw@988 | 62               ui.tag { tag = "span", content = delegation.member_name } | 
| bsw@988 | 63             else | 
| bsw@988 | 64               ui.tag{ tag = "span", content = _"Abandon unit delegation" } | 
| bsw@988 | 65             end | 
| bsw@988 | 66           end } | 
| bsw@988 | 67 | 
| bsw@988 | 68           ui.tag { tag = "td", content = function() | 
| bsw@988 | 69             local checked = config.check_delegations_default | 
| bsw@988 | 70             ui.tag{ tag = "input", attr = { | 
| bsw@988 | 71               type = "radio", | 
| bsw@988 | 72               id = "delegation_" .. delegation.id .. "_confirm", | 
| bsw@988 | 73               name = "delegation_" .. delegation.id, | 
| bsw@988 | 74               value = "confirm", | 
| bsw@988 | 75               checked = checked == "confirm" and "checked" or nil | 
| bsw@988 | 76             } } | 
| bsw@988 | 77             ui.tag{ | 
| bsw@988 | 78               tag = "label", | 
| bsw@988 | 79               attr = { ["for"] = "delegation_" .. delegation.id .. "_confirm" }, | 
| bsw@988 | 80               content = _"confirm" | 
| bsw@988 | 81             } | 
| bsw@988 | 82             ui.tag{ tag = "input", attr = { | 
| bsw@988 | 83               type = "radio", | 
| bsw@988 | 84               id = "delegation_" .. delegation.id .. "_revoke", | 
| bsw@988 | 85               name = "delegation_" .. delegation.id, | 
| bsw@988 | 86               value = "revoke", | 
| bsw@988 | 87               checked = checked == "revoke" and "checked" or nil | 
| bsw@988 | 88             } } | 
| bsw@988 | 89             ui.tag{ | 
| bsw@988 | 90               tag = "label", | 
| bsw@988 | 91               attr = { ["for"] = "delegation_" .. delegation.id .. "_revoke" }, | 
| bsw@988 | 92               content = _"revoke" | 
| bsw@988 | 93             } | 
| bsw@988 | 94           end} | 
| 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 | 
| bsw@988 | 103     slot.put("<br />") | 
| bsw@988 | 104 | 
| bsw@999 | 105     ui.submit{ text = _"Finish delegation check" } | 
| bsw@988 | 106 | 
| bsw@988 | 107   end | 
| bsw@988 | 108 } |