From afa911284cd61b2e486492045b7398d05b4a1894 Mon Sep 17 00:00:00 2001 From: Meutel Date: Mon, 3 Aug 2015 11:54:44 +0200 Subject: [PATCH] factorize filter --- app/views/authors/_index.html.erb | 6 ++---- app/views/books/_index.html.erb | 19 ++++++------------- app/views/layouts/_filter.html.erb | 12 ++++++++++++ app/views/layouts/_initials.html.erb | 2 +- app/views/series/_index.html.erb | 6 ++---- 5 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 app/views/layouts/_filter.html.erb diff --git a/app/views/authors/_index.html.erb b/app/views/authors/_index.html.erb index 2033cd3..b01423f 100644 --- a/app/views/authors/_index.html.erb +++ b/app/views/authors/_index.html.erb @@ -1,6 +1,6 @@ -<%= render 'layouts/initials' %> -<%= will_paginate class: "center" %> +<%= render'layouts/filter' %> +<%= will_paginate class: "center" %> @@ -13,6 +13,4 @@ <% end %>
Name
- <%= will_paginate class: "center" %> -<%= render 'layouts/perpage' %> diff --git a/app/views/books/_index.html.erb b/app/views/books/_index.html.erb index 634492d..89ffd06 100644 --- a/app/views/books/_index.html.erb +++ b/app/views/books/_index.html.erb @@ -1,15 +1,10 @@ -
-
-

Filter

-
-
-<% isLatest = session[:sort] == "latest" %> -<%= link_to "Latest", url_for(sort: (isLatest ? "alpha" : "latest")), class: "btn btn-default btn-sm " + (isLatest ? " active" : ""), remote: true %> -<%= render'layouts/initials' %> -
-
-<%= will_paginate class: "center" %> +<% content_for :latest_filter do + isLatest = session[:sort] == "latest" %> + <%= link_to "Latest", url_for(sort: (isLatest ? "alpha" : "latest")), class: "btn btn-default btn-sm " + (isLatest ? " active" : ""), remote: true %> +<% end %> +<%= render'layouts/filter' %> +<%= will_paginate class: "center" %> @@ -33,6 +28,4 @@ <% end %>
Name
- <%= will_paginate class: "center" %> -<%= render'layouts/perpage' %> diff --git a/app/views/layouts/_filter.html.erb b/app/views/layouts/_filter.html.erb new file mode 100644 index 0000000..c9a2247 --- /dev/null +++ b/app/views/layouts/_filter.html.erb @@ -0,0 +1,12 @@ +
+
+ <%= link_to "#filterContent", data: { toggle: "collapse" } do %> +

Filter

+ <% end %> +
+
+ <%= yield(:latest_filter) %> + <%= render'layouts/initials' %> + <%= render'layouts/perpage' %> +
+
diff --git a/app/views/layouts/_initials.html.erb b/app/views/layouts/_initials.html.erb index 651863d..cfb6ff6 100644 --- a/app/views/layouts/_initials.html.erb +++ b/app/views/layouts/_initials.html.erb @@ -1,6 +1,6 @@ <% initials = ['0'] + ('A'..'Z').to_a %>
-