From d383c8e2e4ffc89076af8d089c869d9fa15b456f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 10 Aug 2025 15:44:01 +0930 Subject: [PATCH] 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 --- app/controllers/seeds_controller.rb | 4 ++++ app/views/home/index.html.haml | 3 ++- app/views/seeds/index.html.haml | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index 89ab9daff..2425554d5 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -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 diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 929b40bd9..01a4d6b26 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -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 diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index e50747b46..a05f54362 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -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