bsw@263: local unit_id = param.get("unit_id", atom.integer) bsw@263: local unit = Unit:by_id(unit_id) bsw@263: bsw@193: local show_not_in_use = param.get("show_not_in_use", atom.boolean) or false bsw/jbe@0: bsw@263: local areas = Area:build_selector{ unit_id = unit_id, active = not show_not_in_use }:exec() bsw/jbe@0: bsw/jbe@0: bsw@595: ui.title(_("Area list of '#{unit_name}'", { unit_name = unit.name })) bsw/jbe@0: bsw@193: bsw@595: ui.actions(function() bsw@263: bsw@193: if show_not_in_use then bsw@193: ui.link{ bsw@193: text = _"Show areas in use", bsw@193: module = "admin", bsw@263: view = "area_list", bsw@263: params = { unit_id = unit_id } bsw@193: } bsw@193: bsw@193: else bsw@193: ui.link{ bsw@193: text = _"Create new area", bsw@193: module = "admin", bsw@263: view = "area_show", bsw@263: params = { unit_id = unit_id } bsw@193: } bsw@595: bsw@595: slot.put(" · ") bsw@595: bsw@193: ui.link{ bsw@193: text = _"Show areas not in use", bsw@193: module = "admin", bsw@193: view = "area_list", bsw@263: params = { show_not_in_use = true, unit_id = unit_id } bsw@193: } bsw@193: end bsw@193: bsw@193: end) bsw@193: bsw/jbe@0: bsw/jbe@0: ui.list{ bsw/jbe@0: records = areas, bsw/jbe@0: columns = { bsw@193: bsw@193: { label = _"Area", name = "name" }, bsw@193: bsw@193: { content = function(record) bsw/jbe@0: if app.session.member.admin then bsw/jbe@0: ui.link{ bsw/jbe@0: attr = { class = { "action admin_only" } }, bsw/jbe@0: text = _"Edit", bsw/jbe@0: module = "admin", bsw/jbe@0: view = "area_show", bsw/jbe@0: id = record.id bsw/jbe@0: } bsw/jbe@0: end bsw/jbe@0: end bsw/jbe@0: } bsw@193: bsw/jbe@0: } bsw/jbe@0: }