From 2faf99c54b53938df3b68a3e99c724bba3658d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 28 Dec 2020 14:10:20 +0100 Subject: [PATCH] Extract advanced search into a component --- app/assets/stylesheets/advanced_search.scss | 30 ++++++++++++++++ app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/layout.scss | 35 ------------------- .../advanced_search_component.html.erb} | 2 +- .../shared/advanced_search_component.rb | 31 ++++++++++++++++ app/helpers/search_helper.rb | 24 ------------- app/views/budgets/investments/index.html.erb | 2 +- app/views/debates/index.html.erb | 2 +- app/views/proposals/index.html.erb | 2 +- 9 files changed, 66 insertions(+), 63 deletions(-) create mode 100644 app/assets/stylesheets/advanced_search.scss rename app/{views/shared/_advanced_search.html.erb => components/shared/advanced_search_component.html.erb} (97%) create mode 100644 app/components/shared/advanced_search_component.rb delete mode 100644 app/helpers/search_helper.rb diff --git a/app/assets/stylesheets/advanced_search.scss b/app/assets/stylesheets/advanced_search.scss new file mode 100644 index 000000000..367b3c579 --- /dev/null +++ b/app/assets/stylesheets/advanced_search.scss @@ -0,0 +1,30 @@ +.advanced-search { + float: left; + margin: $line-height 0; + position: inherit; + + @include breakpoint(medium) { + float: right; + margin-bottom: 0; + margin-top: $line-height / 4; + position: absolute; + right: 0; + } +} + +.advanced-search-form { + + @include breakpoint(medium) { + > .column { + padding: 0; + } + } + + select { + height: $line-height * 2; + } + + .column.end.clear { + clear: both; + } +} diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 38c4185fc..b03ac1368 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -6,6 +6,7 @@ @import "icons"; @import "mixins"; @import "admin"; +@import "advanced_search"; @import "layout"; @import "participation"; @import "milestones"; diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 4f229794e..6e46858cd 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -8,7 +8,6 @@ // 06. Forms // 07. Callout // 08. User account -// 09. Search // 10. Official levels // 11. Tables // 12. Social @@ -1480,40 +1479,6 @@ form { } } -// 09. Search -// ---------- - -.advanced-search { - float: left; - margin: $line-height 0; - position: inherit; - - @include breakpoint(medium) { - float: right; - margin-bottom: 0; - margin-top: $line-height / 4; - position: absolute; - right: 0; - } -} - -.advanced-search-form { - - @include breakpoint(medium) { - > .column { - padding: 0; - } - } - - select { - height: $line-height * 2; - } - - .column.end.clear { - clear: both; - } -} - // 10. Officials levels // -------------------- diff --git a/app/views/shared/_advanced_search.html.erb b/app/components/shared/advanced_search_component.html.erb similarity index 97% rename from app/views/shared/_advanced_search.html.erb rename to app/components/shared/advanced_search_component.html.erb index 95a45c5a5..e5333a321 100644 --- a/app/views/shared/_advanced_search.html.erb +++ b/app/components/shared/advanced_search_component.html.erb @@ -4,7 +4,7 @@
<%= form_tag request.path, id: "advanced_search_form", method: :get do %> - - <%= render "shared/advanced_search" %> + <%= render Shared::AdvancedSearchComponent.new %> <%= render "shared/order_links", i18n_namespace: "debates.index" %> diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index 73470cc84..c28790495 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -73,7 +73,7 @@ <% end %> <% unless params[:retired].present? || params[:selected].present? %> - <%= render "shared/advanced_search" %> + <%= render Shared::AdvancedSearchComponent.new %> <% end %> <% unless params[:selected].present? %>