mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 23:53:15 +01:00
Use form builder for search form
This commit is contained in:
parent
19616d215e
commit
7d2314fb6d
3 changed files with 12 additions and 16 deletions
|
@ -7,12 +7,8 @@ end
|
||||||
|
|
||||||
class SearchController < ApplicationController
|
class SearchController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@search_definition = PaperSearch.new(query: params[:q],
|
@search_definition = PaperSearch.new(params[:paper_search])
|
||||||
paper_type: params[:paper_type],
|
@search_definition.sort_by ||= "score"
|
||||||
originator: params[:originator],
|
|
||||||
sort_by: params[:paper_search][:sort_by])
|
|
||||||
|
|
||||||
# @search = PaperSearch.new params[:paper_search]
|
|
||||||
|
|
||||||
@response = Paper.search(@search_definition)
|
@response = Paper.search(@search_definition)
|
||||||
@papers = @response.page(params[:page]).results
|
@papers = @response.page(params[:page]).results
|
||||||
|
|
|
@ -11,14 +11,14 @@ module SearchHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_select(name, desc, facets, selected)
|
def filter_select(builder, name, desc, facets, selected)
|
||||||
capture do
|
capture do
|
||||||
concat(label name, desc)
|
concat(label name, desc)
|
||||||
concat(
|
concat(
|
||||||
select_tag name,
|
builder.select name,
|
||||||
options_from_collection_for_select(facets, :term, :term_with_count, selected),
|
options_from_collection_for_select(facets, :term, :term_with_count, selected),
|
||||||
include_blank: true,
|
{ include_blank: true },
|
||||||
onchange: "this.form.submit();"
|
{ onchange: "this.form.submit();" }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
= form_for(@search_definition, url: search_path, method: :get) do |f|
|
= form_for @search_definition, url: search_path, method: :get do |f|
|
||||||
= text_field_tag(:q, @search_definition.query, placeholder: 'Suche…', autofocus: true)
|
= f.text_field :query, placeholder: 'Suche…', autofocus: true
|
||||||
fieldset
|
fieldset
|
||||||
legend Ergebnisse filtern
|
legend Ergebnisse filtern
|
||||||
.row
|
.row
|
||||||
.small-4.columns
|
.small-4.columns
|
||||||
= filter_select("paper_type", "Typ", @paper_type_facets, @search_definition.paper_type)
|
= filter_select(f, "paper_type", "Typ", @paper_type_facets, @search_definition.paper_type)
|
||||||
.small-4.columns
|
.small-4.columns
|
||||||
= filter_select("originator", "Einreicher", @originator_facets, @search_definition.originator)
|
= filter_select(f, "originator", "Einreicher", @originator_facets, @search_definition.originator)
|
||||||
.small-4.columns.end
|
.small-4.columns.end
|
||||||
label Sortierung
|
label Sortierung
|
||||||
= f.radio_button :sort_by, :date
|
= f.radio_button :sort_by, :date, onchange: "this.form.submit();"
|
||||||
label for="sort_by_date" Nach Datum
|
label for="sort_by_date" Nach Datum
|
||||||
= f.radio_button :sort_by, :score
|
= f.radio_button :sort_by, :score, onchange: "this.form.submit();"
|
||||||
label for="sort_by_score" Nach Relevanz
|
label for="sort_by_score" Nach Relevanz
|
||||||
|
|
Loading…
Reference in a new issue