standard_view 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3b47dc891219d4f611bacd257c6524cefa49cd5000fd567602b7e1875bdd212
4
- data.tar.gz: 0bc34d4c60ac97fb29d70790379cf7e93f89ca32a5e477c872e217f23e603d72
3
+ metadata.gz: 62f8b997437730cd005a5e84de2037af5d588cf589f6ef412fedfd1ac3eb4714
4
+ data.tar.gz: 730047005e6d791328033a9dc2e938e97cc9c071c407d72465d43201cd5689fd
5
5
  SHA512:
6
- metadata.gz: 63c859ba9522261002df6aba53ac7af4572390d7494984cad8805a604079741d2563a94772cbf60006f61f02c135e90c8a12c56013a69872541b0660bd8b42ee
7
- data.tar.gz: 39afb75ab28fefc64022ee6e9d05c930588dbe239aab507bf592e0e34a795570582e87b39537c38df25efd1fa4f0a3f8e5cc283c602f614e0580b6ed048bdb14
6
+ metadata.gz: 97e68d3e09d2aef86136217f922758a993b9d98743bf3b9901824a9b620331bd386b226ddbef020688ddb99b8cb977a7939808e351ab0e8ac86b3d8eebdff5b0
7
+ data.tar.gz: 8052a5f7456591ffe524025c086786c7405502da3d800082542eaaad8511887ec806676c08801c11d225145a6744b9741047219f5fe494cd8cfd859bbfac0fe2
@@ -0,0 +1,20 @@
1
+ <% has_default = facet.default_filter? %>
2
+ <% without_filter = params[:filter].blank? %>
3
+ <% is_all = has_default ? params[:all].present? : without_filter %>
4
+ <ul class="nav nav-pills justify-content-end">
5
+ <li class="nav-item">
6
+ <span class="nav-link"><%= icon_for(:filter) %></span>
7
+ </li>
8
+ <li class="nav-item">
9
+ <% all_params = {}.tap { |h| h[:all] = true if has_default } %>
10
+ <%= link_to t("common.all"), params.permit(:page).merge(all_params), class: "nav-link #{"active" if is_all}" %>
11
+ </li>
12
+ <% list.filter_values.each do |value, label| %>
13
+ <% is_default = value == facet.default_filter.to_s %>
14
+ <% is_active = is_default ? (without_filter && !is_all) : params[:filter] == value %>
15
+ <% filter_params = {}.tap { |h| h[:filter] = value unless is_default } %>
16
+ <li class="nav-item">
17
+ <%= link_to label, params.permit(:page).merge(filter_params), class: "nav-link #{"active" if is_active}" %>
18
+ </li>
19
+ <% end %>
20
+ </ul>
@@ -9,7 +9,8 @@
9
9
  <% if local_assigns[:facet].nil? %>
10
10
  <% facet_name = is_nested ? action_name : controller_name %>
11
11
  <% facet_class = local_assigns[:facet_class].presence || "#{facet_name.singularize.camelize}Facet".constantize %>
12
- <% facet = facet_class.new(current_page: current_page, source: facet_source) %>
12
+ <% filter_arguments = { filter_by: params[:filter], all: params[:all].present? } %>
13
+ <% facet = facet_class.new(current_page: current_page, source: facet_source, **filter_arguments) %>
13
14
  <% end %>
14
15
 
15
16
  <% if local_assigns[:list].nil? %>
@@ -52,26 +53,15 @@
52
53
 
53
54
  <% unless content_for?(:page_content) %>
54
55
  <% content_for(:page_content) do %>
55
- <%# if content_for?(:subnav_content) || uses_filter %>
56
- <%#= content_for(:subnav_content) if content_for?(:subnav_content) %>
56
+ <% if content_for?(:subnav_content) || list.filter_field? %>
57
+ <%= content_for(:subnav_content) if content_for?(:subnav_content) %>
58
+ <%= render "filter", list: list, facet: facet if list.filter_field? %>
57
59
 
58
- <%# if uses_filter %>
59
- <%#= render "filter", field: filter_by, default: local_assigns[:filter_default], model: collection.model %>
60
- <%# end %>
61
- <!-- <hr>-->
62
- <%# end %>
60
+ <hr>
61
+ <% end %>
63
62
 
64
63
  <div class="row">
65
64
  <div class="col-12">
66
- <%# filtered_collection = collection %>
67
- <%# if uses_filter %>
68
- <%# if params[:filter].present? %>
69
- <%# filtered_collection = filtered_collection.public_send(params[:filter].to_sym) %>
70
- <%# elsif has_filter_default && !params[:all].present? %>
71
- <%# filtered_collection = filtered_collection.public_send(filter_default) %>
72
- <%# end %>
73
- <%# end %>
74
-
75
65
  <%= render "standard_view/paginated_collection", list: list, is_filtered: facet.filtered? %>
76
66
  </div>
77
67
  </div>
@@ -1,5 +1,6 @@
1
1
  en:
2
2
  common:
3
+ all: All
3
4
  new: New
4
5
  edit: Edit
5
6
  overview: Overview
@@ -27,3 +28,4 @@ en:
27
28
  title: Edit %{title}
28
29
  icons:
29
30
  masthead_nav_menu: user
31
+ filter: filter
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StandardView
4
- VERSION = "0.1.14"
4
+ VERSION = "0.1.15"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard_view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Garside
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-04 00:00:00.000000000 Z
12
+ date: 2020-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 0.3.7
34
+ version: 0.3.9
35
35
  - - "<"
36
36
  - !ruby/object:Gem::Version
37
37
  version: '1.0'
@@ -41,7 +41,7 @@ dependencies:
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: 0.3.7
44
+ version: 0.3.9
45
45
  - - "<"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.0'
@@ -276,6 +276,7 @@ files:
276
276
  - app/helpers/standard_view/navigation_helper.rb
277
277
  - app/views/application/_attribute_card_value.html.erb
278
278
  - app/views/application/_attributes_card.html.erb
279
+ - app/views/application/_filter.html.erb
279
280
  - app/views/application/_flash_messages.html.erb
280
281
  - app/views/application/_icon.html.erb
281
282
  - app/views/application/_javascripts.html.erb