Skip to content

Commit

Permalink
Preview param bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JosueMagnus12 committed Dec 23, 2023
1 parent df9d573 commit abb7a55
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
1 change: 0 additions & 1 deletion app/components/navbar/component.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ nav id="main-navbar" data-controller="navbar--component" class="#{non_sticky_pat
= inline_svg_tag 'logo.svg', size:'130*32'
.navbar.navbar--desktop
ul class="flex items-center"
/ - raise
= link_to root_path
= inline_svg_tag 'logo.svg', size:'130*32', class:'mr-2 mid:mr-7 lg:mr-11'
div class="flex w-full"
Expand Down
27 changes: 10 additions & 17 deletions app/controllers/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,28 @@ class SearchesController < ApplicationController
skip_before_action :authenticate_user!

def show
if params['not_preview'].present?
set_search_pills_data
@search = params['search'].present? ? Search.new(create_params) : Search.new
@search.save
@pagy, @results = pagy(@search.results)
puts @search.errors.full_messages if @search.results.any?
else
unless request.referrer&.include? search_url
@search = Search.new
render '_preview', locals: { src: set_turbo_frame_src }
render '_preview'
end

set_search_pills_data
@search = params['search'].present? ? Search.new(create_params) : Search.new
@search.save
@pagy, @results = pagy(@search.results)
puts @search.errors.full_messages if @search.results.any?

authorize @search
end

def create_params
params.require(:search).permit(:distance, :city, :state, :lat, :lon,
:open_now, :open_weekends, :keyword, :not_preview,
:open_now, :open_weekends, :keyword,
:zipcode, causes: [], services: {}, beneficiary_groups: {})
end

private

def set_turbo_frame_src
if params['search'].present?
search_path(search: create_params, not_preview: true)
else
search_path(not_preview: true)
end
end

def set_search_pills_data
set_causes
set_services
Expand Down
4 changes: 2 additions & 2 deletions app/views/searches/_preview.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
controller: 'search modal', \
'search-target': 'form'}) do |f|
= render SearchBar::Component.new(form: f, search: @search)
= turbo_frame_tag "search-pills", src: local_assigns[:src] do
= turbo_frame_tag "search-pills", src: search_path() do
div class="w-full bg-gray-9"
div
div data-tabs-active-tab=("border-b-4 border-blue-medium")
Expand All @@ -33,7 +33,7 @@
| Advanced Filters
span class="relative hidden w-2 h-2 rounded-full bg-salmon ml-1 mb-2" id="appliedIcon"

= turbo_frame_tag "search-locations", src: local_assigns[:src] do
= turbo_frame_tag "search-locations", src: search_path() do
div class="md:flex w-full md:h-85vh" data-controller="tabs" data-tabs-active-tab="border-blue-dark bg-blue-dark text-white" data-tabs-inactive-tab="border-gray-6 bg-transparent text-gray-3"
div class="w-full md:border-r max-w-sm border-gray-7"
div class="fixed inset-0 flex items-center justify-center hidden min-h-screen overflow-y-auto animated fadeIn" data-action="click->modal#closeBackground keyup@window->modal#closeWithKeyboard" data-modal-target="container" style=("z-index: 9999;")
Expand Down
1 change: 0 additions & 1 deletion app/views/searches/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
= turbo_frame_tag "search-pills" do
= render SearchPills::Component.new(causes: @top_10_causes, services: @top_10_services, beneficiary_subcategories: @top_10_beneficiary_subcategories, params: params)
= turbo_frame_tag "search-locations" do
= hidden_field :not_preview, nil, value: true
div class="flex flex-row justify-center w-full md:h-85vh" data-controller="tabs" data-tabs-active-tab="border-blue-dark bg-blue-dark text-white" data-tabs-inactive-tab="border-gray-6 bg-transparent text-gray-3"
div class="flex flex-row justify-center w-full min-h-full"
div class="flex flex-col w-full md:border-r max-w-sm border-gray-7"
Expand Down

0 comments on commit abb7a55

Please sign in to comment.