Add filtering for tradeable seeds (#4111)

* feat: Add filtering for tradeable seeds

This change introduces a new feature to filter seeds based on their tradeability.

- Adds a link on the homepage to view all tradeable seeds.
- Modifies the seeds controller to support filtering by `tradeable_to`, allowing multiple values to be selected.
- Adds links to the seeds index page to filter by the various `tradeable_to` values.

* Update index.html.haml

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com>
This commit is contained in:
google-labs-jules[bot]
2025-08-10 15:44:01 +09:30
committed by GitHub
parent 6ae2de7e47
commit d383c8e2e4
3 changed files with 14 additions and 1 deletions

View File

@@ -19,6 +19,10 @@ class SeedsController < DataController
where['parent_planting'] = @planting.id
end
if params[:tradeable_to].present?
where['tradeable_to'] = params[:tradeable_to]
end
@show_all = (params[:all] == '1')
where['finished'] = false unless @show_all

View File

@@ -51,7 +51,8 @@
%section.seeds
= cute_icon
= render 'seeds'
%p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn btn-block'
%p.text-right
= link_to "#{t('home.seeds.view_all')} »", seeds_path(tradeable_to: ['locally', 'nationally', 'internationally']), class: 'btn btn-block'
.col-12.col-lg-6
%section.discussion.text-center
= cute_icon

View File

@@ -17,6 +17,14 @@
= check_box_tag 'active', 'all', @show_all
include finished
%hr/
%section.filters
%h2 Tradeable
%ul.nav.flex-column
%li.nav-item= link_to "All tradable seeds", seeds_path(tradeable_to: ['locally', 'nationally', 'internationally'])
- Seed::TRADABLE_TO_VALUES.each do |value|
- unless value == 'nowhere'
%li.nav-item= link_to value.capitalize, seeds_path(tradeable_to: value)
%hr/
- if @owner
= render @owner
- if @crop