DEV: Add ability to set disabled option on report filters (#31351)

This update adds the ability to conditionally control the `disabled`
property of the input on report filters.
This commit is contained in:
Keegan George 2025-02-14 12:13:33 -08:00 committed by GitHub
parent f76d88063d
commit 878514af6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<SearchAdvancedCategoryChooser
@value={{this.category}}
@onChange={{this.onChange}}
@options={{hash filterable=true}}
@options={{hash filterable=true disabled=this.filter.disabled}}
/>

View File

@ -7,5 +7,6 @@
autoInsertNoneItem=this.filter.auto_insert_none_item
filterable=true
none="admin.dashboard.report_filter_any"
disabled=this.filter.disabled
}}
/>

View File

@ -149,14 +149,17 @@ class Report
available_filters.delete(name)
end
def add_category_filter
def add_category_filter(options = {})
category_id = filters[:category].to_i if filters[:category].present?
add_filter("category", type: "category", default: category_id)
add_filter("category", { type: "category", default: category_id }.merge(options))
return if category_id.blank?
include_subcategories = filters[:include_subcategories]
include_subcategories = !!ActiveRecord::Type::Boolean.new.cast(include_subcategories)
add_filter("include_subcategories", type: "bool", default: include_subcategories)
add_filter(
"include_subcategories",
{ type: "bool", default: include_subcategories }.merge(options),
)
[category_id, include_subcategories]
end