rails_admin_filter_by_id 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +24 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml +2 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml +4 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_page.html.haml +4 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml +4 -0
- data/app/views/rails_admin/main/_card.html.haml +17 -0
- data/app/views/rails_admin/main/filter_by_id.html.haml +104 -0
- data/config/initializers/list_filtered_by_id_actions.rb +5 -0
- data/config/locales/filter_by_id.en.yml +11 -0
- data/config/locales/filter_by_id.it.yml +11 -0
- data/lib/rails_admin_filter_by_id.rb +99 -0
- data/lib/rails_admin_filter_by_id/engine.rb +12 -0
- data/lib/rails_admin_filter_by_id/version.rb +3 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f14c02aa22740afdfc8235429927480efaac7d836a04766373a4ff244dc5105d
|
4
|
+
data.tar.gz: f02bd9541052df005f18381d43e3e7372f9b6e200170a238e7c40f2c50c2c50a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 520b0591ed234e991131c16ef91172181f77507b205c4a170df2d05d67e1dff700701622ad57643ea5e88fa702fde05dcfbf80e8a0de7670f22bd6117264a3c0
|
7
|
+
data.tar.gz: db23cd7e0794622bb5fc8c39b5a4207f84b1369e2e2475a5043d70d947acf46e5588014626e9ed901a65d96c6638f0588f4ace4bb1366d145bfa26fc3b746a49
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Gabriele Tassoni
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'RailsAdminFilterById'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
load 'rails/tasks/statistics.rake'
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
Bundler::GemHelper.install_tasks
|
24
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
%div.panel.panel-success
|
2
|
+
%div.panel-heading
|
3
|
+
%ul.inline.list-inline.pull-right
|
4
|
+
= menu_for :member, @abstract_model, object, true
|
5
|
+
%h4.panel-title
|
6
|
+
= check_box_tag "bulk_ids[]", object.id, false
|
7
|
+
%a{:"data-toggle" => "collapse", href: "#object-id-#{object.id}"}
|
8
|
+
= (object.display_name rescue false || object.title rescue false || object.name rescue false || object.code rescue false)
|
9
|
+
%div{id: "object-id-#{object.id}", class: "panel-collapse collapse"}
|
10
|
+
%div.panel-body
|
11
|
+
- properties.map{ |property| property.bind(:object, object) }.each do |property|
|
12
|
+
- key = capitalize_first_letter(property.label)
|
13
|
+
- value = property.pretty_value
|
14
|
+
%p.card-text{class: "#{property.css_class} #{property.type_css_class}", title: strip_tags(value.to_s)}
|
15
|
+
%strong
|
16
|
+
= key + ":"
|
17
|
+
= value
|
@@ -0,0 +1,104 @@
|
|
1
|
+
:ruby
|
2
|
+
query = params[:query]
|
3
|
+
params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export, :_pjax)
|
4
|
+
params.delete(:query) if params[:query].blank?
|
5
|
+
params.delete(:sort_reverse) unless params[:sort_reverse] == 'true'
|
6
|
+
sort_reverse = params[:sort_reverse]
|
7
|
+
sort = params[:sort]
|
8
|
+
params.delete(:sort) if params[:sort] == @model_config.list.sort_by.to_s
|
9
|
+
export_action = RailsAdmin::Config::Actions.find(:export, { controller: self.controller, abstract_model: @abstract_model })
|
10
|
+
export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model)
|
11
|
+
description = RailsAdmin.config(@abstract_model.model_name).description
|
12
|
+
properties = @model_config.list.with(controller: self.controller, view: self, object: @abstract_model.model.new).visible_fields
|
13
|
+
|
14
|
+
- content_for :contextual_tabs do
|
15
|
+
= bulk_menu
|
16
|
+
|
17
|
+
%style
|
18
|
+
- properties.select{ |p| p.column_width.present? }.each do |property|
|
19
|
+
= "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }"
|
20
|
+
= "#list td.#{property.css_class} { max-width: #{property.column_width}px; }"
|
21
|
+
#list
|
22
|
+
.well.well-sm
|
23
|
+
- if filterable_fields.present?
|
24
|
+
.dropdown.pull-right{style: "margin-left:0.5em"}
|
25
|
+
%button.btn.btn-primary.dropdown-toggle#dropdownFilters{type: "button", :"data-toggle" => "dropdown", :"aria-haspopup" => "true", :"aria-expanded" => "true"}
|
26
|
+
= t('admin.misc.add_filter')
|
27
|
+
%b.caret
|
28
|
+
%ul.dropdown-menu#filters{:"aria-labelledby" => "dropdownFilters"}
|
29
|
+
- filterable_fields.each do |field|
|
30
|
+
- field_options = case field.type
|
31
|
+
- when :enum
|
32
|
+
- options_for_select(field.with(object: @abstract_model.model.new).enum)
|
33
|
+
- else
|
34
|
+
- ''
|
35
|
+
%li
|
36
|
+
%a{href: '#', :"data-field-label" => field.label, :"data-field-name" => field.name, :"data-field-options" => field_options.html_safe, :"data-field-type" => field.type, :"data-field-value" => "", :"data-field-datetimepicker-format" => (field.try(:parser) && field.parser.to_momentjs)}= capitalize_first_letter(field.label)
|
37
|
+
|
38
|
+
.dropdown.pull-right{style: "margin-left:0.5em"}
|
39
|
+
%button.btn.btn-primary.dropdown-toggle#dropdownOrder{type: "button", :"data-toggle" => "dropdown", :"aria-haspopup" => "true", :"aria-expanded" => "true"}
|
40
|
+
= t('admin.misc.order_by')
|
41
|
+
%b.caret
|
42
|
+
%ul.dropdown-menu{:"aria-labelledby" => "dropdownOrder"}
|
43
|
+
- properties.each do |property|
|
44
|
+
- selected = (sort == property.name.to_s)
|
45
|
+
- if property.sortable
|
46
|
+
- sort_location = index_path params.except('sort_reverse').except('page').merge(sort: property.name).merge(selected && sort_reverse != "true" ? {sort_reverse: "true"} : {})
|
47
|
+
- sort_direction = (sort_reverse == 'true' ? "sort-alpha-asc" : "sort-alpha-desc" if selected)
|
48
|
+
%li
|
49
|
+
%a{href:"#", class: "#{property.sortable && "header pjax" || nil} #{sort_direction if property.sortable && sort_direction} #{property.css_class} #{property.type_css_class}", :'data-href' => (property.sortable && sort_location), rel: "tooltip", title: "#{property.hint}"}
|
50
|
+
%span{class: "fa fa-#{sort_direction}"}
|
51
|
+
= capitalize_first_letter(property.label)
|
52
|
+
|
53
|
+
- unless @model_config.list.scopes.empty?
|
54
|
+
.dropdown.pull-right{style: "margin-left:0.5em"}
|
55
|
+
%button.btn.btn-primary.dropdown-toggle#dropdownScopes{type: "button", :"data-toggle" => "dropdown", :"aria-haspopup" => "true", :"aria-expanded" => "true"}
|
56
|
+
= t('admin.misc.scopes')
|
57
|
+
%b.caret
|
58
|
+
%ul.dropdown-menu{:"aria-labelledby" => "dropdownScopes"}
|
59
|
+
- @model_config.list.scopes.each_with_index do |scope, index|
|
60
|
+
- scope = '_all' if scope.nil?
|
61
|
+
%li{class: "#{'active' if scope.to_s == params[:scope] || (params[:scope].blank? && index == 0)}"}
|
62
|
+
%a{href: index_path(params.merge(scope: scope, page: nil)), class: 'pjax'}= I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize))
|
63
|
+
|
64
|
+
- if export_action
|
65
|
+
.pull-right{style: "margin-left:0.5em"}
|
66
|
+
%a.btn.btn-primary{href: export_path(params.except('set').except('page'))}
|
67
|
+
= t("admin.export.found")
|
68
|
+
|
69
|
+
= form_tag(index_path(params.except(*%w[page f query])), method: :get, class: "pjax-form form-inline") do
|
70
|
+
.input-group
|
71
|
+
%input.form-control.input-small{name: "query", type: "search", value: query, placeholder: t("admin.misc.filter")}
|
72
|
+
%span.input-group-btn
|
73
|
+
%button.btn.btn-primary{type: 'submit', :'data-disable-with' => '<i class="icon-white icon-refresh"></i> '.html_safe + t('admin.misc.refresh')}
|
74
|
+
%i.icon-white.icon-refresh
|
75
|
+
= t('admin.misc.refresh')
|
76
|
+
%button#remove_filter.btn.btn-info{title: "Reset filters"}
|
77
|
+
%i.icon-white.icon-remove
|
78
|
+
%hr.filters_box{style: "display:#{ordered_filters.empty? ? 'none' : 'block'}"}
|
79
|
+
%span#filters_box
|
80
|
+
|
81
|
+
= form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: "form" do
|
82
|
+
= hidden_field_tag :bulk_action
|
83
|
+
|
84
|
+
- if description.present?
|
85
|
+
.well.well-sm
|
86
|
+
= description
|
87
|
+
|
88
|
+
- @objects.each do |object|
|
89
|
+
= render partial: "card", locals: {object: object, properties: properties, sort: sort, sort_reverse: sort_reverse}
|
90
|
+
|
91
|
+
- if @objects.respond_to?(:total_count)
|
92
|
+
- total_count = @objects.total_count.to_i
|
93
|
+
.row
|
94
|
+
.col-md-6= paginate(@objects, theme: 'ra-twitter-bootstrap', remote: true)
|
95
|
+
.row
|
96
|
+
.col-md-6= link_to(t("admin.misc.show_all"), index_path(params.merge(all: true)), class: "show-all btn btn-default clearfix pjax") unless total_count > 100 || total_count <= @objects.to_a.size
|
97
|
+
.clearfix.total-count= "#{total_count} #{@model_config.pluralize(total_count).downcase}"
|
98
|
+
- else
|
99
|
+
.clearfix.total-count= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}"
|
100
|
+
|
101
|
+
:javascript
|
102
|
+
jQuery(function($) {
|
103
|
+
#{ordered_filter_string}
|
104
|
+
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
it:
|
3
|
+
admin:
|
4
|
+
actions:
|
5
|
+
filter_by_id:
|
6
|
+
title: "Particolari Filtrati"
|
7
|
+
menu: "Filtra i particolari per %{model_label} '%{object_label}'"
|
8
|
+
breadcrumb: "Particolari Filtrati"
|
9
|
+
link: "Filtra i Particolari"
|
10
|
+
bulk_link: "Filtra i Partciolari selezionati %{model_label_plural}"
|
11
|
+
done: "Particolari Filtrati"
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require "rails_admin_filter_by_id/engine"
|
2
|
+
|
3
|
+
module RailsAdminFilterById
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'rails_admin/config/actions'
|
7
|
+
|
8
|
+
module RailsAdmin
|
9
|
+
module Config
|
10
|
+
module Actions
|
11
|
+
class FilterById < Base
|
12
|
+
RailsAdmin::Config::Actions.register(self)
|
13
|
+
|
14
|
+
register_instance_option :object_level do
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
register_instance_option :object_level do
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
# This ensures the action only shows up for Users
|
23
|
+
register_instance_option :visible? do
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
# You may or may not want pjax for your action
|
28
|
+
register_instance_option :pjax? do
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
32
|
+
register_instance_option :collection do
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
register_instance_option :controller do
|
37
|
+
Proc.new do
|
38
|
+
@objects = list_entries.where(params[:key] => {id: params[:value]})
|
39
|
+
# @objects
|
40
|
+
# render :index Copio l'index di rails_admin
|
41
|
+
unless @model_config.list.scopes.empty?
|
42
|
+
if params[:scope].blank?
|
43
|
+
unless @model_config.list.scopes.first.nil?
|
44
|
+
@objects = @objects.send(@model_config.list.scopes.first)
|
45
|
+
end
|
46
|
+
elsif @model_config.list.scopes.collect(&:to_s).include?(params[:scope])
|
47
|
+
@objects = @objects.send(params[:scope].to_sym)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
respond_to do |format|
|
52
|
+
format.html do
|
53
|
+
render @action.template_name, status: (flash[:error].present? ? :not_found : 200)
|
54
|
+
end
|
55
|
+
|
56
|
+
format.json do
|
57
|
+
output = begin
|
58
|
+
if params[:compact]
|
59
|
+
primary_key_method = @association ? @association.associated_primary_key : @model_config.abstract_model.primary_key
|
60
|
+
label_method = @model_config.object_label_method
|
61
|
+
@objects.collect { |o| {id: o.send(primary_key_method).to_s, label: o.send(label_method).to_s} }
|
62
|
+
else
|
63
|
+
@objects.to_json(@schema)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
if params[:send_data]
|
67
|
+
send_data output, filename: "#{params[:model_name]}_#{DateTime.now.strftime('%Y-%m-%d_%Hh%Mm%S')}.json"
|
68
|
+
else
|
69
|
+
render json: output, root: false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
format.xml do
|
74
|
+
output = @objects.to_xml(@schema)
|
75
|
+
if params[:send_data]
|
76
|
+
send_data output, filename: "#{params[:model_name]}_#{DateTime.now.strftime('%Y-%m-%d_%Hh%Mm%S')}.xml"
|
77
|
+
else
|
78
|
+
render xml: output
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
format.csv do
|
83
|
+
header, encoding, output = CSVConverter.new(@objects, @schema).to_csv(params[:csv_options])
|
84
|
+
if params[:send_data]
|
85
|
+
send_data output,
|
86
|
+
type: "text/csv; charset=#{encoding}; #{'header=present' if header}",
|
87
|
+
disposition: "attachment; filename=#{params[:model_name]}_#{DateTime.now.strftime('%Y-%m-%d_%Hh%Mm%S')}.csv"
|
88
|
+
else
|
89
|
+
render text: output
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module RailsAdminFilterById
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
# appending migrations to the main app's ones
|
4
|
+
initializer :append_migrations do |app|
|
5
|
+
unless app.root.to_s.match root.to_s
|
6
|
+
config.paths["db/migrate"].expanded.each do |expanded_path|
|
7
|
+
app.config.paths["db/migrate"] << expanded_path
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_admin_filter_by_id
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabriele Tassoni
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thecore
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
description: Uses a where condition to set objects based on commission.id, deck.id,
|
28
|
+
etc.
|
29
|
+
email:
|
30
|
+
- gabrieletassoni@taris.it
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- MIT-LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml
|
39
|
+
- app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml
|
40
|
+
- app/views/kaminari/ra-twitter-bootstrap/_page.html.haml
|
41
|
+
- app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml
|
42
|
+
- app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml
|
43
|
+
- app/views/rails_admin/main/_card.html.haml
|
44
|
+
- app/views/rails_admin/main/filter_by_id.html.haml
|
45
|
+
- config/initializers/list_filtered_by_id_actions.rb
|
46
|
+
- config/locales/filter_by_id.en.yml
|
47
|
+
- config/locales/filter_by_id.it.yml
|
48
|
+
- lib/rails_admin_filter_by_id.rb
|
49
|
+
- lib/rails_admin_filter_by_id/engine.rb
|
50
|
+
- lib/rails_admin_filter_by_id/version.rb
|
51
|
+
homepage: http://www.taris.it
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
metadata: {}
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubygems_version: 3.0.1
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Filters chosen items before listing.
|
74
|
+
test_files: []
|