mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 17:05:29 +08:00
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:
parent
f76d88063d
commit
878514af6e
@ -1,5 +1,5 @@
|
||||
<SearchAdvancedCategoryChooser
|
||||
@value={{this.category}}
|
||||
@onChange={{this.onChange}}
|
||||
@options={{hash filterable=true}}
|
||||
@options={{hash filterable=true disabled=this.filter.disabled}}
|
||||
/>
|
@ -7,5 +7,6 @@
|
||||
autoInsertNoneItem=this.filter.auto_insert_none_item
|
||||
filterable=true
|
||||
none="admin.dashboard.report_filter_any"
|
||||
disabled=this.filter.disabled
|
||||
}}
|
||||
/>
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user