bsw@829: local inactive = param.get("inactive", atom.boolean) bsw@829: bsw@829: local units = Unit:get_flattened_tree{ include_inactive = inactive } bsw@263: bsw@595: ui.title(_"Unit list") bsw@263: bsw@595: ui.actions(function() bsw@263: ui.link{ bsw@263: text = _"Create new unit", bsw@263: module = "admin", bsw@263: view = "unit_edit" bsw@263: } bsw@829: slot.put(" · ") bsw@829: if inactive then bsw@829: ui.link{ bsw@829: text = _"Hide active units", bsw@829: module = "admin", bsw@829: view = "unit_list" bsw@829: } bsw@829: else bsw@829: ui.link{ bsw@829: text = _"Show inactive units", bsw@829: module = "admin", bsw@829: view = "unit_list", bsw@829: params = { inactive = true } bsw@829: } bsw@829: end bsw@263: end) bsw@263: bsw@263: ui.list{ bsw@263: records = units, bsw@263: columns = { bsw@263: { bsw@263: content = function(unit) bsw@829: for i = 1, unit.depth - 1 do bsw@829: slot.put("     ") bsw@829: end bsw@829: local style = "" bsw@829: if not unit.active then bsw@829: style = "text-decoration: line-through;" bsw@829: end bsw@513: ui.link{ bsw@829: attr = { style = "font-weight: bold;" .. style }, bsw@829: text = unit.name, bsw@513: module = "admin", view = "unit_edit", id = unit.id bsw@513: } bsw@829: slot.put(" · ") bsw@513: ui.link{ bsw@513: text = _"Edit areas", bsw@513: module = "admin", view = "area_list", params = { unit_id = unit.id } bsw@513: } bsw@263: end bsw@263: } bsw@263: } bsw@263: }