Skip to content

Commit

Permalink
Add search bar for tracks (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickskyline committed May 29, 2024
1 parent d3ef0dd commit 71edec5
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 16 deletions.
10 changes: 10 additions & 0 deletions app/assets/stylesheets/tracks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,14 @@
.author {
color: #787476;
}

.form-group {
display: flex;
align-items: center;
}

.form-group .form-control {
flex: 1;
margin-right: 5px;
}
}
5 changes: 5 additions & 0 deletions app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def index
@tracks = current_season.tracks
end

if params[:query].present?
regex = Regexp.new("^#{Regexp.escape(params[:query])}", Regexp::IGNORECASE)
@tracks = @tracks.where(name: { '$regex' => regex })
end

@tracks = Kaminari.paginate_array(@tracks).page(params[:page]).per(12)

respond_with @tracks do |format|
Expand Down
2 changes: 1 addition & 1 deletion app/views/cars/advanced.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.sticky-top.search-bar
.row
.col-xl-11.col-lg-10.col-md-10.col-xs-9.col-8.sticky-top
%input#input.form-control{placeholder: t("rva.cars.shared.placeholder"), type: "text"}/
%input#input.form-control{placeholder: t("misc.placeholder.search"), type: "text"}/
.col-xl-1.col-lg-2.col-md-2.col-xs-3.col-4
= render :partial => "car_category_selector"

Expand Down
2 changes: 1 addition & 1 deletion app/views/cars/amateur.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.sticky-top.search-bar
.row
.col-xl-11.col-lg-10.col-md-10.col-xs-9.col-8.sticky-top
%input#input.form-control{placeholder: t("rva.cars.shared.placeholder"), type: "text"}/
%input#input.form-control{placeholder: t("misc.placeholder.search"), type: "text"}/
.col-xl-1.col-lg-2.col-md-2.col-xs-3.col-4
= render :partial => "car_category_selector"

Expand Down
2 changes: 1 addition & 1 deletion app/views/cars/clockwork.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.sticky-top.search-bar
.row
.col-xl-11.col-lg-10.col-md-10.col-xs-9.col-8.sticky-top
%input#input.form-control{placeholder: t("rva.cars.shared.placeholder"), type: "text"}/
%input#input.form-control{placeholder: t("misc.placeholder.search"), type: "text"}/
.col-xl-1.col-lg-2.col-md-2.col-xs-3.col-4
= render :partial => "car_category_selector"

Expand Down
2 changes: 1 addition & 1 deletion app/views/cars/pro.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.sticky-top.search-bar
.row
.col-xl-11.col-lg-10.col-md-10.col-xs-9.col-8.sticky-top
%input#input.form-control{placeholder: t("rva.cars.shared.placeholder"), type: "text"}/
%input#input.form-control{placeholder: t("misc.placeholder.search"), type: "text"}/
.col-xl-1.col-lg-2.col-md-2.col-xs-3.col-4
= render :partial => "car_category_selector"

Expand Down
2 changes: 1 addition & 1 deletion app/views/cars/rookie.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.sticky-top.search-bar
.row
.col-xl-11.col-lg-10.col-md-10.col-xs-9.col-8.sticky-top
%input#input.form-control{placeholder: t("rva.cars.shared.placeholder"), type: "text"}/
%input#input.form-control{placeholder: t("misc.placeholder.search"), type: "text"}/
.col-xl-1.col-lg-2.col-md-2.col-xs-3.col-4
= render :partial => "car_category_selector"

Expand Down
2 changes: 1 addition & 1 deletion app/views/cars/semipro.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.sticky-top.search-bar
.row
.col-xl-11.col-lg-10.col-md-10.col-xs-9.col-8.sticky-top
%input#input.form-control{placeholder: t("rva.cars.shared.placeholder"), type: "text"}/
%input#input.form-control{placeholder: t("misc.placeholder.search"), type: "text"}/
.col-xl-1.col-lg-2.col-md-2.col-xs-3.col-4
= render :partial => "car_category_selector"

Expand Down
2 changes: 1 addition & 1 deletion app/views/cars/superpro.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
.sticky-top.search-bar
.row
.col-xl-11.col-lg-10.col-md-10.col-xs-9.col-8.sticky-top
%input#input.form-control{placeholder: t("rva.cars.shared.placeholder"), type: "text"}/
%input#input.form-control{placeholder: t("misc.placeholder.search"), type: "text"}/
.col-xl-1.col-lg-2.col-md-2.col-xs-3.col-4
= render :partial => "car_category_selector"

Expand Down
6 changes: 6 additions & 0 deletions app/views/tracks/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
= render :partial => "application/subnav", :locals => {:season => current_season}

#tracks
= form_tag(tracks_path, method: :get) do
.form-group
= text_field_tag :query, params[:query], class: 'form-control', placeholder: t("misc.placeholder.search")
= button_tag type: 'submit', class: 'btn' do
%i.fa.fa-search

= paginate @tracks

- if @tracks.none?
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ en:
class-selector:
title: "Classes"
shared:
placeholder: "Search..."
no-cars: "No cars to display"
edit:
title: "Editing Car"
Expand Down Expand Up @@ -1088,6 +1087,8 @@ en:
upload: "You may only upload CSV files."
season: "You must select a Season."
category: "You must select a Category."
placeholder:
search: "Search..."

# Kaminari
helpers:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en_gb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ en-GB:
class-selector:
title: "Classes"
shared:
placeholder: "Search..."
no-cars: "No cars to display"
edit:
title: "Editing Car"
Expand Down Expand Up @@ -1036,6 +1035,8 @@ en-GB:
upload: "You may only upload CSV files."
season: "You must select a Season."
category: "You must select a Category."
placeholder:
search: "Search..."
#Kaminari
helpers:
page_entries_info:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ es:
class-selector:
title: "Clases"
shared:
placeholder: "Buscar..."
no-cars: "No cars to display"
edit:
title: "Editing Car"
Expand Down Expand Up @@ -1033,6 +1032,8 @@ es:
upload: "You may only upload CSV files."
season: "You must select a Season."
category: "You must select a Category."
placeholder:
search: "Buscar..."
#Kaminari
helpers:
page_entries_info:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/es_ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ es-AR:
class-selector:
title: "Categorías"
shared:
placeholder: "Buscar..."
no-cars: "No hay autos que mostrar"
edit:
title: "Editando auto"
Expand Down Expand Up @@ -1033,6 +1032,8 @@ es-AR:
upload: "Solo podés subir archivos CSV."
season: "Debes seleccionar una temporada."
category: "You must select a Category."
placeholder:
search: "Buscar..."
#Kaminari
helpers:
page_entries_info:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/es_cl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ es-CL:
class-selector:
title: "Clases"
shared:
placeholder: "Buscar..."
no-cars: "No hay autos para mostrar"
edit:
title: "Editando auto"
Expand Down Expand Up @@ -1035,6 +1034,8 @@ es-CL:
upload: "Sólo puedes subir archivos CSV."
season: "Debes seleccionar una temporada."
category: "Debe seleccionar una categoría."
placeholder:
search: "Buscar..."
#Kaminari
helpers:
page_entries_info:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ it:
class-selector:
title: "Classi"
shared:
placeholder: "Cerca..."
no-cars: "No cars to display"
edit:
title: "Editing Car"
Expand Down Expand Up @@ -1033,6 +1032,8 @@ it:
upload: "You may only upload CSV files."
season: "You must select a Season."
category: "You must select a Category."
placeholder:
search: "Cerca..."
#Kaminari
helpers:
page_entries_info:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ ko:
class-selector:
title: "Classes"
shared:
placeholder: "Search..."
no-cars: "No cars to display"
edit:
title: "Editing Car"
Expand Down Expand Up @@ -1030,6 +1029,8 @@ ko:
upload: "You may only upload CSV files."
season: "You must select a Season."
category: "You must select a Category."
placeholder:
search: "Search..."
#Kaminari
helpers:
page_entries_info:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/lol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ lol:
class-selector:
title: "clazzes"
shared:
placeholder: "Surch..."
no-cars: "Nu kaz to show"
edit:
title: "Editin' kaa"
Expand Down Expand Up @@ -1036,6 +1035,8 @@ lol:
upload: "U mei olny uplod CSV thinz."
season: "U mus cwoos a seesun."
category: "U mus cwoos a kain."
placeholder:
search: "Surch..."
#Kaminari
helpers:
page_entries_info:
Expand Down
3 changes: 2 additions & 1 deletion config/locales/pt_br.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ pt:
class-selector:
title: "Classes"
shared:
placeholder: "Buscando..."
no-cars: "Sem carro para exibir"
edit:
title: "Editando carro"
Expand Down Expand Up @@ -1033,6 +1032,8 @@ pt:
upload: "Você deve selecionar somente arquivos CSV."
season: "Você deve selecionar uma temporada."
category: "Você deve selecionar uma categoria."
placeholder:
search: "Buscando..."
#Kaminari
helpers:
page_entries_info:
Expand Down

0 comments on commit 71edec5

Please sign in to comment.