-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix partials to support all ransack predicates
- Loading branch information
Showing
19 changed files
with
127 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
app/views/administrate_ransack/components/_field_belongs_to.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<% association = model.reflections[field.to_s] %> | ||
<% if association %> | ||
<% field_key = model.ransackable_scopes.include?(field) ? field : "#{field}_id_eq" %> | ||
<% desc = association.klass.method_defined?(:admin_label) ? :admin_label : :to_s %> | ||
<% collection = association.klass.send(association.klass.respond_to?(:admin_scope) ? :admin_scope : :all) %> | ||
<% field_key = AdministrateRansack.ransack?(model, {field => "1,2"}) ? field : "#{field}_id_eq" %> | ||
<% label ||= AdministrateRansack.ransack?(model, {field => "1,2"}) ? field : "#{field}_id" %> | ||
<% resource_field = type.new(field, nil, Administrate::Page::Collection.new(@dashboard), resource: model.new) %> | ||
<% collection = resource_field.associated_resource_options %> | ||
<%= form.label(label, class: 'filter-label') %> | ||
<%= form.collection_select(field_key, collection, :id, desc, include_blank: true) %> | ||
<%= form.select("#{field}_id_eq", collection, { include_blank: true }, { class: 'selectize' }) %> | ||
<% end %> |
4 changes: 2 additions & 2 deletions
4
app/views/administrate_ransack/components/_field_boolean.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<% field_key = model.ransackable_scopes.include?(field) ? field : "#{field}_eq" %> | ||
<% field_key = AdministrateRansack.ransack?(model, {field => "true"}) ? field : "#{field}_eq" %> | ||
<% values = [[t('administrate_ransack.filters.no'), false], [t('administrate_ransack.filters.yes'), true]] %> | ||
<%= form.label(label, class: 'filter-label') %> | ||
<%= form.label(label || field, class: 'filter-label') %> | ||
<%= form.select(field_key, values, include_blank: true) %> |
4 changes: 2 additions & 2 deletions
4
app/views/administrate_ransack/components/_field_date.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/views/administrate_ransack/components/_field_datetime.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 7 additions & 9 deletions
16
app/views/administrate_ransack/components/_field_has_many.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 7 additions & 4 deletions
11
app/views/administrate_ransack/components/_field_number.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<% field_key = model.ransackable_scopes.include?(field) ? field : "#{field}_eq" %> | ||
<%= form.label(label, class: 'filter-label') %> | ||
<%= form.number_field(field_key) %> | ||
<%= form.label(label || field, class: 'filter-label') %> | ||
<% if AdministrateRansack.ransack?(model, {field => "1"}) %> | ||
<%= form.number_field "#{field}" %> | ||
<% else %> | ||
<%= form.number_field "#{field}_gteq" %> | ||
<%= form.number_field "#{field}_lteq" %> | ||
<% end %> |
11 changes: 9 additions & 2 deletions
11
app/views/administrate_ransack/components/_field_other.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/views/administrate_ransack/components/_field_select.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<% field_key = model.ransackable_scopes.include?(field) ? field : "#{field}_eq" %> | ||
<% collection = (type.respond_to?(:options) ? type.options[:collection] : []) || [] %> | ||
<%= form.label(label, class: 'filter-label') %> | ||
<%= form.label(label || field, class: 'filter-label') %> | ||
<%= form.select(field_key, collection, include_blank: true) %> |
13 changes: 9 additions & 4 deletions
13
app/views/administrate_ransack/components/_field_string.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
<% field_key = model.ransackable_scopes.include?(field) ? field : "#{field}_cont" %> | ||
<%= form.label(label, class: 'filter-label') %> | ||
<%= form.search_field(field_key) %> | ||
<% if AdministrateRansack.ransack?(model, {field => "valid"}) %> | ||
<%= form.label(label || field, class: 'filter-label') %> | ||
<%= form.search_field(field) %> | ||
<% elsif AdministrateRansack.ransack?(model, {"#{field}_cont" => "valid"}) %> | ||
<%= form.label(label || "#{field}_cont", class: 'filter-label') %> | ||
<%= form.search_field("#{field}_cont") %> | ||
<% else %> | ||
<%# render nothing %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<section class="main-content__body main-content__body--flush"> | ||
<%= render( | ||
"collection", | ||
collection_presenter: page, | ||
collection_field_name: resource_name, | ||
page: page, | ||
resources: resources, | ||
table_title: "page-title" | ||
) %> | ||
<%= paginate resources, param_name: '_page' %> | ||
</section> | ||
|
||
<%= render( | ||
'administrate_ransack/filters', | ||
attribute_types: @dashboard.class::RANSACK_TYPES | ||
) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters