administrate_ransack 0.1.14 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/administrate_ransack/_filters.html.erb +13 -40
- data/app/views/administrate_ransack/components/_field_belongs_to.html.erb +6 -0
- data/app/views/administrate_ransack/components/_field_boolean.html.erb +3 -0
- data/app/views/administrate_ransack/components/_field_date.html.erb +3 -0
- data/app/views/administrate_ransack/components/_field_datetime.html.erb +3 -0
- data/app/views/administrate_ransack/components/_field_has_many.html.erb +11 -0
- data/app/views/administrate_ransack/components/_field_number.html.erb +2 -0
- data/app/views/administrate_ransack/components/_field_other.html.erb +6 -0
- data/app/views/administrate_ransack/components/_field_select.html.erb +2 -0
- data/app/views/administrate_ransack/components/_field_string.html.erb +4 -0
- data/app/views/administrate_ransack/components/_filter_buttons.html.erb +4 -0
- data/lib/administrate_ransack/version.rb +1 -1
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d5b6b6df33ceb539a8c0abfead4d35fc568deec8019fbe4357fa4e7c49a7ec4
|
4
|
+
data.tar.gz: cd1434bf426ffe46b9ee4d8ec34c92aa6c12b2f973dcf1088e81d63568af1240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c04a5d614096bd32d044440a55f6f76738525f5ffa88b020d6745cf89328242823154b6d77e356c981b7f9ce7093d55711a77eac72bc42a6a6bc3f844d2d47e3
|
7
|
+
data.tar.gz: 8de7bda5e911657aeb149c251038078164a4632b8dc2163a4ac08736770bb50b63a5ce1f9f8b37d6f6d60e0ce94000375b0a7baec487a414ae02a9662c2551f2
|
@@ -29,61 +29,34 @@
|
|
29
29
|
<% attribute_types.each do |field, type| %>
|
30
30
|
<% next if field == :id %>
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
<% label = attribute_labels.include?(field) ? attribute_labels[field] : field %>
|
33
|
+
<% input_type = type.is_a?(Administrate::Field::Deferred) ? type.deferred_class.to_s : type.to_s %>
|
34
|
+
<div class="filter <%= input_type.parameterize %>">
|
34
35
|
<% case input_type %>
|
35
36
|
<% when 'Administrate::Field::BelongsTo' %>
|
36
37
|
<% association = @ransack_results.klass.reflections[field.to_s] %>
|
37
|
-
|
38
|
-
<% label = association.klass.method_defined?(:admin_label) ? :admin_label : :to_s %>
|
39
|
-
<% collection = association.klass.send(association.klass.respond_to?(:admin_scope) ? :admin_scope : :all) %>
|
40
|
-
<%= f.label(attribute_labels.include?(field) ? attribute_labels[field] : field) %>
|
41
|
-
<%= f.collection_select "#{field}_id_eq", collection, :id, label, include_blank: true %>
|
42
|
-
<% end %>
|
38
|
+
<%= render 'administrate_ransack/components/field_belongs_to', form: f, field: field, label: label, association: association %>
|
43
39
|
<% when 'Administrate::Field::Boolean' %>
|
44
|
-
<%= f
|
45
|
-
<%= f.select "#{field}_eq", [[t('administrate_ransack.filters.no'), false], [t('administrate_ransack.filters.yes'), true]], include_blank: true %>
|
40
|
+
<%= render 'administrate_ransack/components/field_boolean', form: f, field: field, label: label %>
|
46
41
|
<% when 'Administrate::Field::Date' %>
|
47
|
-
<%= f
|
48
|
-
<%= f.date_field "#{field}_gteq" %>
|
49
|
-
<%= f.date_field "#{field}_lteq" %>
|
42
|
+
<%= render 'administrate_ransack/components/field_date', form: f, field: field, label: label %>
|
50
43
|
<% when 'Administrate::Field::DateTime' %>
|
51
|
-
<%= f
|
52
|
-
<%= f.datetime_field "#{field}_gteq" %>
|
53
|
-
<%= f.datetime_field "#{field}_lteq" %>
|
44
|
+
<%= render 'administrate_ransack/components/field_datetime', form: f, field: field, label: label %>
|
54
45
|
<% when 'Administrate::Field::Email', 'Administrate::Field::String', 'Administrate::Field::Text' %>
|
55
|
-
<%= f
|
56
|
-
<%= f.search_field "#{field}_cont" %>
|
46
|
+
<%= render 'administrate_ransack/components/field_string', form: f, field: field, label: label %>
|
57
47
|
<% when 'Administrate::Field::Number' %>
|
58
|
-
<%= f
|
59
|
-
<%= f.number_field "#{field}_eq" %>
|
48
|
+
<%= render 'administrate_ransack/components/field_number', form: f, field: field, label: label %>
|
60
49
|
<% when 'Administrate::Field::HasMany' %>
|
61
50
|
<% association = @ransack_results.klass.reflections[field.to_s] %>
|
62
|
-
|
63
|
-
<% label = association.klass.method_defined?(:admin_label) ? :admin_label : :to_s %>
|
64
|
-
<% collection = association.klass.send(association.klass.respond_to?(:admin_scope) ? :admin_scope : :all) %>
|
65
|
-
<%= f.label(attribute_labels.include?(field) ? attribute_labels[field] : field) %>
|
66
|
-
<%= f.collection_check_boxes "#{field}_id_in", collection, :id, label do |b| %>
|
67
|
-
<%= b.label do %>
|
68
|
-
<%= b.check_box %>
|
69
|
-
<span><%= b.object.send(label) %></span>
|
70
|
-
<% end %>
|
71
|
-
<% end %>
|
72
|
-
<% end %>
|
51
|
+
<%= render 'administrate_ransack/components/field_has_many', form: f, field: field, label: label, association: association %>
|
73
52
|
<% when 'Administrate::Field::Select' %>
|
74
|
-
<%= f
|
75
|
-
<%= f.select "#{field}_eq", type.options[:collection], include_blank: true %>
|
53
|
+
<%= render 'administrate_ransack/components/field_select', form: f, field: field, label: label, type: type %>
|
76
54
|
<% else %>
|
77
|
-
|
78
|
-
<!-- unsupported Field::Polymorphic -->
|
79
|
-
<!-- unsupported Field::Password -->
|
55
|
+
<%= render 'administrate_ransack/components/field_other', form: f, field: field, label: label, type: type %>
|
80
56
|
<% end %>
|
81
57
|
</div>
|
82
58
|
<% end %>
|
83
59
|
</div>
|
84
60
|
|
85
|
-
|
86
|
-
<%= f.submit t('administrate_ransack.filters.search'), name: nil %>
|
87
|
-
<%= link_to t('administrate_ransack.filters.clear_filters'), clear_filters_path, class: 'btn-clear-filters' %>
|
88
|
-
</div>
|
61
|
+
<%= render 'administrate_ransack/components/filter_buttons', form: f, clear_filters_path: clear_filters_path %>
|
89
62
|
<% end %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<% if association %>
|
2
|
+
<% desc = association.klass.method_defined?(:admin_label) ? :admin_label : :to_s %>
|
3
|
+
<% collection = association.klass.send(association.klass.respond_to?(:admin_scope) ? :admin_scope : :all) %>
|
4
|
+
<%= form.label(label) %>
|
5
|
+
<%= form.collection_select "#{field}_id_eq", collection, :id, desc, include_blank: true %>
|
6
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% if association %>
|
2
|
+
<% desc = association.klass.method_defined?(:admin_label) ? :admin_label : :to_s %>
|
3
|
+
<% collection = association.klass.send(association.klass.respond_to?(:admin_scope) ? :admin_scope : :all) %>
|
4
|
+
<%= form.label(label) %>
|
5
|
+
<%= form.collection_check_boxes "#{field}_id_in", collection, :id, desc do |b| %>
|
6
|
+
<%= b.label do %>
|
7
|
+
<%= b.check_box %>
|
8
|
+
<span><%= b.object.send(desc) %></span>
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate_ransack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|
@@ -203,6 +203,16 @@ files:
|
|
203
203
|
- README.md
|
204
204
|
- Rakefile
|
205
205
|
- app/views/administrate_ransack/_filters.html.erb
|
206
|
+
- app/views/administrate_ransack/components/_field_belongs_to.html.erb
|
207
|
+
- app/views/administrate_ransack/components/_field_boolean.html.erb
|
208
|
+
- app/views/administrate_ransack/components/_field_date.html.erb
|
209
|
+
- app/views/administrate_ransack/components/_field_datetime.html.erb
|
210
|
+
- app/views/administrate_ransack/components/_field_has_many.html.erb
|
211
|
+
- app/views/administrate_ransack/components/_field_number.html.erb
|
212
|
+
- app/views/administrate_ransack/components/_field_other.html.erb
|
213
|
+
- app/views/administrate_ransack/components/_field_select.html.erb
|
214
|
+
- app/views/administrate_ransack/components/_field_string.html.erb
|
215
|
+
- app/views/administrate_ransack/components/_filter_buttons.html.erb
|
206
216
|
- config/locales/en.yml
|
207
217
|
- lib/administrate_ransack.rb
|
208
218
|
- lib/administrate_ransack/engine.rb
|