liquid_feedback_frontend
changeset 1828:caa6c71dd22a
Show units as tree in member administration
author | bsw |
---|---|
date | Thu Feb 03 12:16:11 2022 +0100 (2022-02-03) |
parents | a5e1de39e19a |
children | 4d27edb80e89 |
files | app/main/admin/member_edit.lua model/unit.lua |
line diff
1.1 --- a/app/main/admin/member_edit.lua Thu Feb 03 12:05:42 2022 +0100 1.2 +++ b/app/main/admin/member_edit.lua Thu Feb 03 12:16:11 2022 +0100 1.3 @@ -12,8 +12,8 @@ 1.4 end 1.5 end 1.6 1.7 -local function field_boolean(id, name, checked, label) 1.8 - ui.container{ content = function() 1.9 +local function field_boolean(id, name, checked, label, depth) 1.10 + ui.container{ attr = { style = "margin-left: " .. (depth -1) * 20 .. "px;" }, content = function() 1.11 ui.tag{ tag = "label", attr = { 1.12 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect", 1.13 ["for"] = id 1.14 @@ -45,18 +45,7 @@ 1.15 1.16 ui.titleAdmin(_"Member") 1.17 1.18 -local units_selector = Unit:new_selector() 1.19 - :add_where("active") 1.20 - 1.21 - 1.22 -if member then 1.23 - units_selector 1.24 - :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", member.id }) 1.25 - :add_field("privilege.voting_right", "voting_right") 1.26 - :add_order_by("unit.name") 1.27 -end 1.28 - 1.29 -local units = units_selector:exec() 1.30 +local units = Unit:get_flattened_tree{ include_inactive = inactive, include_hidden = true, member_id = member.id } 1.31 1.32 ui.grid{ content = function() 1.33 1.34 @@ -106,7 +95,7 @@ 1.35 end 1.36 1.37 for i, unit in ipairs(units) do 1.38 - field_boolean("checkbox_unit_" .. unit.id, "unit_" .. unit.id, unit.voting_right, unit.name) 1.39 + field_boolean("checkbox_unit_" .. unit.id, "unit_" .. unit.id, unit.voting_right, unit.name, unit.depth) 1.40 1.41 end 1.42 slot.put("<br />")
2.1 --- a/model/unit.lua Thu Feb 03 12:05:42 2022 +0100 2.2 +++ b/model/unit.lua Thu Feb 03 12:16:11 2022 +0100 2.3 @@ -104,6 +104,11 @@ 2.4 if not args or not args.include_hidden then 2.5 units_selector:add_where("attr->'hidden' ISNULL OR NOT (attr->'hidden' = 'true')") 2.6 end 2.7 + if args.member_id then 2.8 + units_selector 2.9 + :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", args.member_id }) 2.10 + :add_field("privilege.voting_right", "voting_right") 2.11 + end 2.12 local units = units_selector:exec() 2.13 local unit_tree = {} 2.14 for i, unit in ipairs(units) do