# HG changeset patch # User bsw # Date 1605093828 -3600 # Node ID dcacc0b98d7061d0fe826d03093dea72dabee5aa # Parent 32b9e4070777e52e585ff750c44664909d290bad Fixed filter for issue list of units without privilege diff -r 32b9e4070777 -r dcacc0b98d70 app/main/issue/_filters.lua --- a/app/main/issue/_filters.lua Wed Nov 11 11:11:59 2020 +0100 +++ b/app/main/issue/_filters.lua Wed Nov 11 12:23:48 2020 +0100 @@ -5,6 +5,12 @@ local member = param.get("member", "table") local phase = request.get_param{ name = "phase" } +local selected_unit_id = config.single_unit_id or request.get_param{ name = "unit" } +if selected_unit_id == "all" then + selected_unit_id = nil +end +local selected_unit = Unit:by_id(selected_unit_id) + local filters = {} local admission_order_field = "filter_issue_order.order_in_unit" @@ -66,7 +72,12 @@ end } + local selected_unit_found = false + for i, unit in ipairs(units) do + if selected_unit and unit.id == selected_unit.id then + selected_unit_found = true + end filter[#filter+1] = { name = tostring(unit.id), label = unit.name, @@ -75,19 +86,31 @@ selector:add_where{ "__filter_area.unit_id = ?", unit.id } end } - end + if not selected_unit_found and selected_unit then + filter[#filter+1] = { + name = tostring(selected_unit.id), + label = selected_unit.name, + selector_modifier = function(selector) + selector:join("area", "__filter_area", "__filter_area.id = issue.area_id AND __filter_area.active") + selector:add_where{ "__filter_area.unit_id = ?", selected_unit.id } + end + } + end + +--[[ + filter.selector_modifier = function(selector) + selector:join("area", "__filter_area", "__filter_area.id = issue.area_id AND __filter_area.active") + selector:add_where{ "__filter_area.unit_id = ?", 81 } + end +--]] + filters[#filters+1] = filter end -- areas - local selected_unit_id = config.single_unit_id or request.get_param{ name = "unit" } - if selected_unit_id == "all" then - selected_unit_id = nil - end - local selected_unit = Unit:by_id(selected_unit_id) if not config.single_area_id and selected_unit then diff -r 32b9e4070777 -r dcacc0b98d70 env/ui/filters.lua --- a/env/ui/filters.lua Wed Nov 11 11:11:59 2020 +0100 +++ b/env/ui/filters.lua Wed Nov 11 12:23:48 2020 +0100 @@ -15,6 +15,9 @@ end for idx, filter in ipairs(args) do local filter_name = filter.name or "filter" + if filter.selector_modifier then + filter.selector_modifier(args.selector) + end local current_option_name = atom.string:load(request.get_param{ name = filter_name }) if not current_option_name then current_option_name = param.get(filter_name)