rails_admin_grid 0.0.1 → 0.0.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 +4 -4
- data/app/views/rails_admin/main/grid.html.haml +26 -70
- data/lib/rails_admin_grid/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c4f08e190fc53acc1e6b62550716852709a30f2
|
4
|
+
data.tar.gz: 9845b65a29e9b89b0be5471b429f8a7e405404e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d42cd6b41010edd8a55f87144c27a59f29fca39ae83d7f1f52862d02886e90bd0d244a8d28ba1ccbb6b8ed586a47a6d10f46e913ab4bbb8c8b180bce8fe36b5d
|
7
|
+
data.tar.gz: 098774a8607be3c4baee1935b8c26bf8789b6ad7727e09f7b6a6be993ed4d3b7661cdfd8cff901d0a7a2bd74b6e4b4a8e1b79d5b753b355df7921f6a5e43e1f6
|
@@ -1,5 +1,4 @@
|
|
1
1
|
:ruby
|
2
|
-
require 'rails_admin/config/fields/types/datetime.rb'
|
3
2
|
query = params[:query]
|
4
3
|
params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export, :_pjax)
|
5
4
|
params.delete(:query) if params[:query].blank?
|
@@ -7,107 +6,62 @@
|
|
7
6
|
sort_reverse = params[:sort_reverse]
|
8
7
|
sort = params[:sort]
|
9
8
|
params.delete(:sort) if params[:sort] == @model_config.grid.sort_by.to_s
|
10
|
-
|
11
9
|
export_action = RailsAdmin::Config::Actions.find(:export, { controller: self.controller, abstract_model: @abstract_model })
|
12
10
|
export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model)
|
13
|
-
|
14
11
|
description = RailsAdmin.config(@abstract_model.model_name).description
|
15
12
|
properties = @model_config.grid.with(controller: self.controller, view: self, object: @abstract_model.model.new).visible_fields
|
16
13
|
# columns paginate
|
17
|
-
@filterable_fields = @model_config.grid.fields.select(&:filterable?)
|
18
14
|
sets = get_column_sets(properties)
|
19
15
|
properties = sets[params[:set].to_i] || []
|
20
16
|
other_left = ((params[:set].to_i - 1) >= 0) && sets[params[:set].to_i - 1].present?
|
21
17
|
other_right = sets[params[:set].to_i + 1].present?
|
22
|
-
@index = 0
|
23
|
-
@ordered_filters = (params[:f] || @model_config.grid.filters).inject({}) { |memo, filter|
|
24
|
-
field_name = filter.is_a?(Array) ? filter.first : filter
|
25
|
-
(filter.is_a?(Array) ? filter.last : { (@index += 1) => { "v" => '' } }) .each do |index, filter_hash|
|
26
|
-
unless filter_hash['disabled']
|
27
|
-
memo[index] = { field_name => filter_hash }
|
28
|
-
else
|
29
|
-
params[:f].delete(field_name)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
memo
|
33
|
-
}.to_a.sort_by(&:first)
|
34
|
-
|
35
|
-
@ordered_filter_string = @ordered_filters.map do |duplet|
|
36
|
-
filter_index = duplet[0]
|
37
|
-
filter_for_field = duplet[1]
|
38
|
-
filter_name = filter_for_field.keys.first
|
39
|
-
filter_hash = filter_for_field.values.first
|
40
|
-
field = @filterable_fields.find{ |field| field.name == filter_name.to_sym }
|
41
|
-
unless field
|
42
|
-
fail "#{filter_name} is not currently filterable; filterable fields are #{@filterable_fields.map(&:name).join(', ')}"
|
43
|
-
end
|
44
|
-
field_options = case field.type
|
45
|
-
when :enum
|
46
|
-
options_for_select(field.with(object: @abstract_model.model.new).enum, filter_hash['v'])
|
47
|
-
else
|
48
|
-
''
|
49
|
-
end
|
50
|
-
%{
|
51
|
-
$.filters.append(#{field.label.to_json}, #{field.name.to_json}, #{field.type.to_json}, #{filter_hash['v'].to_json}, #{filter_hash['o'].to_json}, #{field_options.to_json}, #{filter_index.to_json});
|
52
|
-
}
|
53
|
-
end.join.html_safe if @ordered_filters
|
54
|
-
|
55
18
|
|
56
|
-
|
19
|
+
- content_for :contextual_tabs do
|
57
20
|
= bulk_menu
|
58
|
-
- if
|
21
|
+
- if filterable_fields.present?
|
59
22
|
%li.dropdown{style: 'float:right'}
|
60
23
|
%a.dropdown-toggle{href: '#', :'data-toggle' => "dropdown"}
|
61
24
|
= t('admin.misc.add_filter')
|
62
25
|
%b.caret
|
63
26
|
%ul.dropdown-menu#filters{style: 'left:auto; right:0;'}
|
64
|
-
-
|
27
|
+
- filterable_fields.each do |field|
|
65
28
|
- field_options = case field.type
|
66
29
|
- when :enum
|
67
30
|
- options_for_select(field.with(object: @abstract_model.model.new).enum)
|
68
31
|
- else
|
69
32
|
- ''
|
70
33
|
%li
|
71
|
-
%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" => ""}= capitalize_first_letter(field.label)
|
34
|
+
%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)
|
72
35
|
|
73
|
-
#list
|
74
|
-
%script
|
75
|
-
jQuery(function($) {
|
76
|
-
$.filters.options.regional = {
|
77
|
-
datePicker: {
|
78
|
-
dateFormat: #{raw I18n.t("admin.misc.filter_date_format", default: I18n.t("admin.misc.filter_date_format", locale: :en)).to_json},
|
79
|
-
dayNames: #{raw RailsAdmin::Config::Fields::Types::Datetime.day_names.to_json},
|
80
|
-
dayNamesShort: #{raw RailsAdmin::Config::Fields::Types::Datetime.abbr_day_names.to_json},
|
81
|
-
dayNamesMin: #{raw RailsAdmin::Config::Fields::Types::Datetime.abbr_day_names.to_json},
|
82
|
-
firstDay: "1",
|
83
|
-
monthNames: #{raw RailsAdmin::Config::Fields::Types::Datetime.month_names.to_json},
|
84
|
-
monthNamesShort: #{raw RailsAdmin::Config::Fields::Types::Datetime.abbr_month_names.to_json}
|
85
|
-
}
|
86
|
-
}
|
87
36
|
|
88
|
-
|
37
|
+
:javascript
|
38
|
+
jQuery(function($) {
|
39
|
+
#{ordered_filter_string}
|
40
|
+
});
|
89
41
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
42
|
+
%style
|
43
|
+
- properties.select{ |p| p.column_width.present? }.each do |property|
|
44
|
+
= "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }"
|
45
|
+
= "#list td.#{property.css_class} { max-width: #{property.column_width}px; }"
|
46
|
+
:css
|
47
|
+
.center-vert {
|
48
|
+
position: relative;
|
49
|
+
top: 50%;
|
50
|
+
transform: translateY(-50%);
|
51
|
+
}
|
52
|
+
#list
|
101
53
|
= form_tag(grid_path(params.except(*%w[page f query])), method: :get, class: "pjax-form form-inline") do
|
102
54
|
.well
|
103
55
|
%span#filters_box
|
104
|
-
%hr.filters_box{style: "display:#{
|
56
|
+
%hr.filters_box{style: "display:#{ordered_filters.empty? ? 'none' : 'block'}"}
|
105
57
|
.input-group
|
106
58
|
%input.form-control.input-small{name: "query", type: "search", value: query, placeholder: t("admin.misc.filter")}
|
107
59
|
%span.input-group-btn
|
108
60
|
%button.btn.btn-primary{type: "submit", :'data-disable-with' => "<i class='icon-white icon-refresh'></i> ".html_safe + t("admin.misc.refresh")}
|
109
61
|
%i.icon-white.icon-refresh
|
110
62
|
= t("admin.misc.refresh")
|
63
|
+
%button#remove_filter.btn.btn-info{title: "Reset filters"}
|
64
|
+
%i.icon-white.icon-remove
|
111
65
|
- if export_action
|
112
66
|
%span{style: 'float:right'}= link_to wording_for(:link, export_action), export_path(params.except('set').except('page')), class: 'btn btn-info'
|
113
67
|
|
@@ -121,7 +75,8 @@
|
|
121
75
|
= form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: "form" do
|
122
76
|
= hidden_field_tag :bulk_action
|
123
77
|
- if description.present?
|
124
|
-
|
78
|
+
%p
|
79
|
+
%strong= description
|
125
80
|
|
126
81
|
.container-fluid
|
127
82
|
- @objects.each_slice(4) do |object_row|
|
@@ -152,5 +107,6 @@
|
|
152
107
|
.row
|
153
108
|
.col-md-6= link_to(t("admin.misc.show_all"), grid_path(params.merge(all: true)), class: "show-all btn btn-default clearfix pjax") unless total_count > 100 || total_count <= @objects.to_a.size
|
154
109
|
.clearfix.total-count= "#{total_count} #{@model_config.pluralize(total_count).downcase}"
|
110
|
+
|
155
111
|
- else
|
156
|
-
.clearfix.total-count= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}"
|
112
|
+
.clearfix.total-count= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_grid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Colavita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rails_admin
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.8.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.8.0
|
41
41
|
description: RailsAdminGrid is a custom action for RailsAdmin that displays objects
|
42
42
|
in a grid with thumbnails. It provides an alternative to the default list view provided
|
43
43
|
in RailsAdmin.
|