feat: enhance city status management in dashboard
- Change table to display cities based on popularity - Modify button logic to toggle between "停用" (disable) and "激活" (activate) based on current city status This update improves the usability of the Ahoy Dashboard by providing clearer management options for city statuses. Users can now easily activate or deactivate cities from the dashboard, enhancing overall administrative efficiency.
This commit is contained in:
parent
76a8275af6
commit
a60f1bfe38
@ -74,16 +74,23 @@ ActiveAdmin.register_page "Ahoy Dashboard" do
|
||||
columns do
|
||||
column do
|
||||
panel "城市排名" do
|
||||
table_for City.least_popular_active do
|
||||
table_for City.by_popularity do
|
||||
column("城市") { |city| link_to(city.name, admin_city_path(city)) }
|
||||
column("访问量") { |city| city.view_count }
|
||||
column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
|
||||
# column("状态") { |city| status_tag(city.active? ? "活跃" : "停用") }
|
||||
column("操作") { |city|
|
||||
button_to "停用",
|
||||
admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id),
|
||||
method: :post,
|
||||
data: { confirm: "确定要停用 #{city.name} 吗?" }
|
||||
if city.active?
|
||||
button_to "停用",
|
||||
admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id),
|
||||
method: :post,
|
||||
data: { confirm: "确定要停用 #{city.name} 吗?" }
|
||||
else
|
||||
button_to "激活",
|
||||
admin_ahoy_dashboard_toggle_city_status_path(city_id: city.id),
|
||||
method: :post,
|
||||
data: { confirm: "确定要激活 #{city.name} 吗?" }
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user