active_list 6.0.1 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/active_list.jquery.js.coffee +188 -0
- data/app/assets/stylesheets/active_list/background.scss +28 -23
- data/app/assets/stylesheets/active_list/minimal.scss +68 -73
- data/app/assets/stylesheets/active_list/theme.scss +163 -165
- data/lib/active_list.rb +2 -4
- data/lib/active_list/definition/action_column.rb +56 -10
- data/lib/active_list/definition/table.rb +21 -0
- data/lib/active_list/exporters/csv_exporter.rb +2 -2
- data/lib/active_list/exporters/excel_csv_exporter.rb +1 -3
- data/lib/active_list/rails.rb +2 -0
- data/lib/active_list/rails/engine.rb +4 -2
- data/lib/active_list/rails/integration.rb +46 -0
- data/lib/active_list/renderers/simple_renderer.rb +71 -36
- data/lib/active_list/version.rb +1 -1
- data/locales/eng.yml +1 -0
- data/test/dummy/Gemfile +1 -1
- data/test/dummy/Gemfile.lock +76 -78
- data/test/dummy/db/seeds.rb +6 -0
- data/test/people_controller_test.rb +7 -0
- data/test/test_helper.rb +1 -1
- metadata +8 -29
- data/app/assets/javascripts/active_list.jquery.js +0 -136
- data/lib/active_list/action_pack.rb +0 -46
- data/test/dummy/app/assets/javascripts/contacts.js.coffee +0 -3
- data/test/dummy/app/assets/javascripts/people.js.coffee +0 -3
- data/test/dummy/app/assets/stylesheets/contacts.css.scss +0 -3
- data/test/dummy/app/assets/stylesheets/people.css.scss +0 -3
data/lib/active_list.rb
CHANGED
@@ -3,11 +3,10 @@ require 'action_dispatch'
|
|
3
3
|
require 'rails'
|
4
4
|
# require 'compass-rails'
|
5
5
|
require 'code_string'
|
6
|
+
require 'i18n-complements'
|
6
7
|
|
7
8
|
module ActiveList
|
8
9
|
|
9
|
-
CSV = ::CSV
|
10
|
-
|
11
10
|
# Build and returns a short UID
|
12
11
|
def self.new_uid
|
13
12
|
@@last_uid ||= 0
|
@@ -22,7 +21,6 @@ module ActiveList
|
|
22
21
|
autoload :Renderers, 'active_list/renderers'
|
23
22
|
autoload :Exporters, 'active_list/exporters'
|
24
23
|
autoload :Generator, 'active_list/generator'
|
25
|
-
autoload :ActionPack, 'active_list/action_pack'
|
26
24
|
|
27
25
|
mattr_reader :renderers
|
28
26
|
@@renderers = {}
|
@@ -58,4 +56,4 @@ unless "string".respond_to? :dig
|
|
58
56
|
end
|
59
57
|
|
60
58
|
|
61
|
-
require 'active_list/rails
|
59
|
+
require 'active_list/rails'
|
@@ -6,25 +6,68 @@ module ActiveList
|
|
6
6
|
class ActionColumn < AbstractColumn
|
7
7
|
include ActiveList::Helpers
|
8
8
|
|
9
|
+
USE_MODES = [:none, :single, :many, :both]
|
10
|
+
|
11
|
+
def initialize(table, name, options = {})
|
12
|
+
super(table, name, options)
|
13
|
+
@use_mode = (@options.delete(:on) || :single).to_sym
|
14
|
+
unless USE_MODES.include?(@use_mode)
|
15
|
+
raise "Invalid use mode: #{@use_mode.inspect}"
|
16
|
+
end
|
17
|
+
if @name.to_s == "destroy" and !@options.has_key?(:method)
|
18
|
+
@options[:method] = :delete
|
19
|
+
end
|
20
|
+
if @name.to_s == "destroy" and !@options.has_key?(:confirm)
|
21
|
+
@options[:confirm] ||= :are_you_sure_you_want_to_delete
|
22
|
+
end
|
23
|
+
@options[:if] ||= :destroyable? if @name.to_s == "destroy"
|
24
|
+
@options[:if] ||= :editable? if @name.to_s == "edit"
|
25
|
+
@options[:confirm] = :are_you_sure if @options[:confirm].is_a?(TrueClass)
|
26
|
+
end
|
27
|
+
|
28
|
+
def use_single?
|
29
|
+
@use_mode == :single or @use_mode == :both
|
30
|
+
end
|
31
|
+
|
32
|
+
def use_many?
|
33
|
+
@use_mode == :many or @use_mode == :both
|
34
|
+
end
|
35
|
+
|
36
|
+
def use_none?
|
37
|
+
@use_mode == :none
|
38
|
+
end
|
39
|
+
|
40
|
+
def global?
|
41
|
+
self.use_none? or self.use_many?
|
42
|
+
end
|
43
|
+
|
9
44
|
def header_code
|
10
45
|
"''".c
|
11
46
|
end
|
12
47
|
|
48
|
+
def default_url(use_mode = :many)
|
49
|
+
url = @options[:url] ||= {}
|
50
|
+
url[:controller] ||= (@options[:controller] || table.model.name.tableize)
|
51
|
+
url[:action] ||= @name.to_s
|
52
|
+
if @options.has_key? :format
|
53
|
+
url[:format] = @options[:format]
|
54
|
+
end
|
55
|
+
if use_many? and use_mode == :many
|
56
|
+
url[:id] ||= "##IDS##"
|
57
|
+
end
|
58
|
+
return url
|
59
|
+
end
|
60
|
+
|
13
61
|
def operation(record = 'record_of_the_death')
|
14
|
-
@options[:method] = :delete if @name.to_s == "destroy" and !@options.has_key?(:method)
|
15
|
-
@options[:confirm] ||= :are_you_sure_you_want_to_delete if @name.to_s == "destroy" and !@options.has_key?(:confirm)
|
16
|
-
@options[:if] ||= :destroyable? if @name.to_s == "destroy"
|
17
|
-
@options[:if] ||= :editable? if @name.to_s == "edit"
|
18
|
-
@options[:confirm] = :are_you_sure if @options[:confirm].is_a?(TrueClass)
|
19
62
|
link_options = ""
|
20
63
|
if @options[:confirm]
|
21
64
|
link_options << ", 'data-confirm' => #{(@options[:confirm]).inspect}.t(scope: 'labels')"
|
22
65
|
end
|
23
|
-
if @options[
|
24
|
-
link_options << ", :
|
66
|
+
if @options[:method]
|
67
|
+
link_options << ", method: :#{@options[:method].to_s.underscore}"
|
25
68
|
end
|
26
69
|
action = @name
|
27
|
-
format = @options[:format] ? ", :
|
70
|
+
format = @options[:format] ? ", format: '#{@options[:format]}'" : ""
|
28
71
|
if @options[:remote]
|
29
72
|
raise StandardError, "Sure to use :remote ?"
|
30
73
|
# remote_options = @options.dup
|
@@ -39,6 +82,9 @@ module ActiveList
|
|
39
82
|
# code += ", {title: #{action.inspect}.tl}"
|
40
83
|
# code += ")"
|
41
84
|
elsif @options[:actions]
|
85
|
+
unless use_single?
|
86
|
+
raise StandardError, "Only compatible with single actions"
|
87
|
+
end
|
42
88
|
unless @options[:actions].is_a? Hash
|
43
89
|
raise StandardError, "options[:actions] have to be a Hash."
|
44
90
|
end
|
@@ -58,8 +104,8 @@ module ActiveList
|
|
58
104
|
url[:id] ||= "RECORD.id".c
|
59
105
|
url.delete_if{|k, v| v.nil?}
|
60
106
|
url = "{" + url.collect{|k, v| "#{k}: " + urlify(v, record)}.join(", ")+format+"}"
|
61
|
-
code = "{class: '#{@name}'"+link_options+"}"
|
62
|
-
code = "link_to(content_tag(:i) + h('#{action}'.t(scope: 'labels')), "+url+", "+code+")"
|
107
|
+
code = "{class: '#{@name}'" + link_options+"}"
|
108
|
+
code = "link_to(content_tag(:i) + h(' ' + '#{action}'.t(scope: 'labels')), " + url + ", " + code + ")"
|
63
109
|
end
|
64
110
|
if @options[:if]
|
65
111
|
code = "if " + recordify!(@options[:if], record) + "\n" + code.dig + "end"
|
@@ -13,6 +13,7 @@ module ActiveList
|
|
13
13
|
@options[:renderer] ||= :simple_renderer
|
14
14
|
@options[:per_page] = 20 if @options[:per_page].to_i <= 0
|
15
15
|
@options[:page] = 1 if @options[:page].to_i <= 0
|
16
|
+
@selector = @options.delete(:selector)
|
16
17
|
@columns = []
|
17
18
|
@id = ActiveList.new_uid
|
18
19
|
end
|
@@ -44,6 +45,22 @@ module ActiveList
|
|
44
45
|
@paginate
|
45
46
|
end
|
46
47
|
|
48
|
+
def has_many_records_action?
|
49
|
+
many_records_action_columns.any?
|
50
|
+
end
|
51
|
+
|
52
|
+
def many_records_action_columns
|
53
|
+
action_columns.select(&:use_many?)
|
54
|
+
end
|
55
|
+
|
56
|
+
def global_action_columns
|
57
|
+
action_columns.select(&:global?)
|
58
|
+
end
|
59
|
+
|
60
|
+
def selectable?
|
61
|
+
@selector
|
62
|
+
end
|
63
|
+
|
47
64
|
# Retrieves all columns in database
|
48
65
|
def table_columns
|
49
66
|
cols = self.model_columns.map(&:name)
|
@@ -54,6 +71,10 @@ module ActiveList
|
|
54
71
|
@columns.select{|c| c.is_a? DataColumn}
|
55
72
|
end
|
56
73
|
|
74
|
+
def action_columns
|
75
|
+
@columns.select{|c| c.is_a? ActionColumn}
|
76
|
+
end
|
77
|
+
|
57
78
|
def hidden_columns
|
58
79
|
self.data_columns.select(&:hidden?)
|
59
80
|
end
|
@@ -15,13 +15,13 @@ module ActiveList
|
|
15
15
|
def send_data_code
|
16
16
|
record = "r"
|
17
17
|
code = generator.select_data_code(paginate: false)
|
18
|
-
code << "data =
|
18
|
+
code << "data = ::CSV.generate do |csv|\n"
|
19
19
|
code << " csv << [#{columns_to_array(:header).join(', ')}]\n"
|
20
20
|
code << " for #{record} in #{generator.records_variable_name}\n"
|
21
21
|
code << " csv << [#{columns_to_array(:body, record: record).join(', ')}]\n"
|
22
22
|
code << " end\n"
|
23
23
|
code << "end\n"
|
24
|
-
code << "send_data(data, type: #{self.mime_type.to_s.inspect}, disposition: 'inline', filename: #{table.model.name}.model_name.human.gsub(/[^a-z0-9]/i,'_') + '.#{self.file_extension}')\n"
|
24
|
+
code << "send_data(data, type: #{self.mime_type.to_s.inspect}, disposition: 'inline', filename: #{table.model.name}.model_name.human.gsub(/[^a-z0-9]/i, '_') + '.#{self.file_extension}')\n"
|
25
25
|
return code.c
|
26
26
|
end
|
27
27
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
# Register XCSV format unless is already set
|
4
2
|
Mime::Type.register("text/csv", :xcsv) unless defined? Mime::XCSV
|
5
3
|
|
@@ -21,7 +19,7 @@ module ActiveList
|
|
21
19
|
record = "r"
|
22
20
|
code = generator.select_data_code(paginate: false)
|
23
21
|
encoding = "CP1252"
|
24
|
-
code << "data =
|
22
|
+
code << "data = ::CSV.generate(col_sep: ';') do |csv|\n"
|
25
23
|
code << " csv << [#{columns_to_array(:header, encoding: encoding).join(', ')}]\n"
|
26
24
|
code << " for #{record} in #{generator.records_variable_name}\n"
|
27
25
|
code << " csv << [#{columns_to_array(:body, record: record, encoding: encoding).join(', ')}]\n"
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module ActiveList
|
2
2
|
module Rails
|
3
|
+
|
3
4
|
class Engine < ::Rails::Engine
|
4
5
|
engine_name "active_list"
|
5
6
|
initializer "active_list.integrate_methods" do |app|
|
6
|
-
::ActionController::Base.send(:include, ActiveList::
|
7
|
-
::ActionView::Base.send(:include, ActiveList::
|
7
|
+
::ActionController::Base.send(:include, ActiveList::Rails::Integration::ActionController)
|
8
|
+
::ActionView::Base.send(:include, ActiveList::Rails::Integration::ViewsHelper)
|
8
9
|
files = Dir[File.join(File.dirname(__FILE__), "..", "..", "..", "locales", "*.yml")]
|
9
10
|
::I18n.load_path.concat(files)
|
10
11
|
end
|
11
12
|
end
|
13
|
+
|
12
14
|
end
|
13
15
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module ActiveList
|
2
|
+
module Rails
|
3
|
+
module Integration
|
4
|
+
|
5
|
+
module ActionController
|
6
|
+
|
7
|
+
def self.included(base) #:nodoc:
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
|
13
|
+
# Permits to define and generate methods to manage dynamic
|
14
|
+
# table ActiveList
|
15
|
+
def list(*args, &block)
|
16
|
+
options = args.extract_options!
|
17
|
+
options[:controller] = self
|
18
|
+
args << options
|
19
|
+
generator = ActiveList::Generator.new(*args, &block)
|
20
|
+
class_eval(generator.controller_method_code, __FILE__, __LINE__)
|
21
|
+
ActionView::Base.send(:class_eval, generator.view_method_code, __FILE__, __LINE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
module ViewsHelper
|
29
|
+
|
30
|
+
# Calls the generated view helper
|
31
|
+
def list(*args, &block)
|
32
|
+
options = args.extract_options!
|
33
|
+
name = args.shift
|
34
|
+
kontroller = self.controller.class
|
35
|
+
begin
|
36
|
+
helper_method = "_#{kontroller.controller_name}_#{__method__}_#{name || kontroller.controller_name}_tag".to_sym
|
37
|
+
kontroller = kontroller.superclass
|
38
|
+
end until self.respond_to?(helper_method)
|
39
|
+
return self.send(helper_method, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -75,25 +75,27 @@ module ActiveList
|
|
75
75
|
code << "end\n"
|
76
76
|
|
77
77
|
code << "#{var_name(:tbody)} << '</tbody>'\n"
|
78
|
-
code << "return #{var_name(:tbody)}.html_safe if options[:only] == 'body'
|
79
|
-
|
80
|
-
|
81
|
-
code << "
|
78
|
+
code << "return #{var_name(:tbody)}.html_safe if options[:only] == 'table-body'\n"
|
79
|
+
|
80
|
+
# Build content
|
81
|
+
code << "#{var_name(:content)} = ''\n"
|
82
|
+
code << "#{var_name(:content)} << #{extras}\n" unless extras.blank?
|
83
|
+
code << "#{var_name(:content)} << '<table class=\"list\""
|
82
84
|
if table.paginate?
|
83
85
|
code << " data-list-current-page=\"' + #{var_name(:page)}.to_s + '\" data-list-page-size=\"' + #{var_name(:limit)}.to_s + '\""
|
84
86
|
end
|
85
87
|
code << " data-list-sort-by=\"' + #{var_name(:params)}[:sort].to_s + '\" data-list-sort-dir=\"' + #{var_name(:params)}[:dir].to_s + '\""
|
86
88
|
code << ">'\n"
|
87
|
-
code << "
|
88
|
-
code << "html << (#{header})\n"
|
89
|
+
code << "#{var_name(:content)} << (#{header})\n"
|
89
90
|
code << "if block_given?\n"
|
90
|
-
code << "
|
91
|
+
code << " #{var_name(:content)} << '<tfoot>' + capture(" + table.columns.collect{|c| {name: c.name, id: c.id}}.inspect + ", &block).to_s + '</tfoot>'\n"
|
91
92
|
code << "end\n"
|
92
|
-
code << "
|
93
|
-
code << "
|
94
|
-
code << "
|
95
|
-
|
96
|
-
|
93
|
+
code << "#{var_name(:content)} << #{var_name(:tbody)}\n"
|
94
|
+
code << "#{var_name(:content)} << '</table>'\n"
|
95
|
+
code << "return #{var_name(:content)}.html_safe if options[:only] == 'content'\n"
|
96
|
+
|
97
|
+
# Build whole
|
98
|
+
code << "return ('<div id=\"#{table.name}\" data-list-source=\"'+h(url_for(options.merge(:action => '#{generator.controller_method_name}')))+'\" class=\"active-list\">' + #{var_name(:content)} + '</div>').html_safe\n"
|
97
99
|
return code
|
98
100
|
end
|
99
101
|
|
@@ -104,10 +106,16 @@ module ActiveList
|
|
104
106
|
unless [:body, :children].include?(nature)
|
105
107
|
raise ArgumentError, "Nature is invalid"
|
106
108
|
end
|
109
|
+
record = options[:record] || 'record_of_the_death'
|
110
|
+
if table.selectable?
|
111
|
+
code << "content_tag(:td, class: 'list-selector') do\n"
|
112
|
+
code << " tag(:input, type: 'checkbox', value: #{record}.id, data: {list_selector: #{record}.id})\n"
|
113
|
+
code << "end +\n"
|
114
|
+
end
|
115
|
+
|
107
116
|
children_mode = !!(nature == :children)
|
108
117
|
for column in table.columns
|
109
118
|
value_code = ""
|
110
|
-
record = options[:record] || 'record_of_the_death'
|
111
119
|
if column.is_a? ActiveList::Definition::EmptyColumn
|
112
120
|
value_code = 'nil'
|
113
121
|
elsif column.is_a? ActiveList::Definition::StatusColumn
|
@@ -187,6 +195,7 @@ module ActiveList
|
|
187
195
|
form_name = column.form_name || "'#{table.name}[' + #{record}.id.to_s + '][#{column.name}]'".c
|
188
196
|
value_code = (nature == :body ? "text_field_tag(#{form_name.inspect}, #{recordify!(column.options[:value] || column.name, record)}#{column.options[:size] ? ', size: ' + column.options[:size].to_s : ''})" : "nil") # , id: '#{table.name}_'+#{record}.id.to_s + '_#{column.name}'
|
189
197
|
elsif column.is_a?(ActiveList::Definition::ActionColumn)
|
198
|
+
next unless column.use_single?
|
190
199
|
value_code = (nature == :body ? column.operation(record) : "nil")
|
191
200
|
else
|
192
201
|
value_code = "' ∅ '.html_safe"
|
@@ -201,15 +210,16 @@ module ActiveList
|
|
201
210
|
# code << "content_tag(:td)"
|
202
211
|
# end
|
203
212
|
|
204
|
-
code << "
|
213
|
+
code << "''.html_safe"
|
214
|
+
# code << "content_tag(:td)"
|
205
215
|
return code.c
|
206
216
|
end
|
207
217
|
|
208
218
|
|
209
219
|
# Produces main menu code
|
210
220
|
def menu_code
|
211
|
-
menu = "<
|
212
|
-
menu << "<a class=\"
|
221
|
+
menu = "<span class=\"settings\">"
|
222
|
+
menu << "<a class=\"settings-start\"><i></i>' + h('list.menu'.t) + '</a>"
|
213
223
|
menu << "<ul>"
|
214
224
|
if table.paginate?
|
215
225
|
# Per page
|
@@ -217,18 +227,18 @@ module ActiveList
|
|
217
227
|
list << table.options[:per_page].to_i if table.options[:per_page].to_i > 0
|
218
228
|
list = list.uniq.sort
|
219
229
|
menu << "<li class=\"parent\">"
|
220
|
-
menu << "<a class=\"pages\"><
|
230
|
+
menu << "<a class=\"pages\"><i></i>' + h('list.items_per_page'.t) + '</a><ul>"
|
221
231
|
for n in list
|
222
|
-
menu << "<li data-list-change-page-size=\"#{n}\" '+(#{var_name(:params)}[:per_page] == #{n} ? ' class=\"check\"' : '')+'><a><
|
232
|
+
menu << "<li data-list-change-page-size=\"#{n}\" '+(#{var_name(:params)}[:per_page] == #{n} ? ' class=\"check\"' : '') + '><a><i></i>' + h('list.x_per_page'.t(count: #{n})) + '</a></li>"
|
223
233
|
end
|
224
234
|
menu << "</ul></li>"
|
225
235
|
end
|
226
236
|
|
227
237
|
# Column selector
|
228
238
|
menu << "<li class=\"parent\">"
|
229
|
-
menu << "<a class=\"columns\"><
|
239
|
+
menu << "<a class=\"columns\"><i></i>' + h('list.columns'.t) + '</a><ul>"
|
230
240
|
for column in table.data_columns
|
231
|
-
menu << "<li data-list-toggle-column=\"#{column.name}\" class=\"'+(#{var_name(:params)}[:hidden_columns].include?(:#{column.name}) ? 'unchecked' : 'checked')+'\"><a><
|
241
|
+
menu << "<li data-list-toggle-column=\"#{column.name}\" class=\"' + (#{var_name(:params)}[:hidden_columns].include?(:#{column.name}) ? 'unchecked' : 'checked') + '\"><a><i></i>' + h(#{column.header_code}) + '</a></li>"
|
232
242
|
end
|
233
243
|
menu << "</ul></li>"
|
234
244
|
|
@@ -236,9 +246,9 @@ module ActiveList
|
|
236
246
|
menu << "<li class=\"separator\"></li>"
|
237
247
|
# Exports
|
238
248
|
for format, exporter in ActiveList.exporters
|
239
|
-
menu << "<li class=\"export
|
249
|
+
menu << "<li class=\"export export-#{format}\">' + link_to(content_tag(:i) + h('list.export_as'.t(exported: :#{format}.t(scope: 'list.export.formats'))), params.merge(action: :#{generator.controller_method_name}, sort: #{var_name(:params)}[:sort], dir: #{var_name(:params)}[:dir], format: '#{format}')) + '</li>"
|
240
250
|
end
|
241
|
-
menu << "</ul></
|
251
|
+
menu << "</ul></span>"
|
242
252
|
return menu
|
243
253
|
end
|
244
254
|
|
@@ -246,46 +256,71 @@ module ActiveList
|
|
246
256
|
# and pagination management
|
247
257
|
def header_code
|
248
258
|
code = "'<thead><tr>"
|
259
|
+
if table.selectable?
|
260
|
+
code << "<th class=\"list-selector\"></th>"
|
261
|
+
end
|
249
262
|
for column in table.columns
|
263
|
+
next if column.is_a?(ActiveList::Definition::ActionColumn) and !column.use_single?
|
250
264
|
code << "<th data-list-column=\"#{column.sort_id}\""
|
251
265
|
code << " data-list-column-cells=\"#{column.short_id}\""
|
252
266
|
code << " data-list-column-sort=\"'+(#{var_name(:params)}[:sort] != '#{column.sort_id}' ? 'asc' : #{var_name(:params)}[:dir] == 'asc' ? 'desc' : 'asc')+'\"" if column.sortable?
|
253
267
|
code << " class=\"#{column_classes(column, true, true)}\""
|
254
268
|
code << ">"
|
255
|
-
code << "
|
256
|
-
code << "<
|
269
|
+
code << "' + h(#{column.header_code}) + '"
|
270
|
+
code << "<i></i>"
|
257
271
|
code << "</th>"
|
258
272
|
end
|
259
|
-
code << "<th class=\"spe\">#{menu_code}</th>"
|
273
|
+
# code << "<th class=\"spe\">#{menu_code}</th>"
|
260
274
|
code << "</tr></thead>'"
|
261
275
|
return code
|
262
276
|
end
|
263
277
|
|
264
278
|
# Produces the code to create bottom menu and pagination
|
265
279
|
def extras_code
|
266
|
-
code
|
280
|
+
code = []
|
281
|
+
|
282
|
+
if table.global_action_columns.any?
|
283
|
+
actioner = ""
|
284
|
+
actioner << "<span class=\"actioner\">'"
|
285
|
+
for column in table.global_action_columns
|
286
|
+
actioner << " + link_to(content_tag(:i) + h(' ' + :#{column.name.to_s}.t(scope: 'labels')), #{column.default_url.inspect}, class: 'btn btn-#{column.name}'#{', style: "display: none"' unless column.use_none?}#{', method: "' + column.options[:method].to_s + '"' if column.options[:method]}, data: {list_actioner: :#{column.use_none? ? 'none' : 'many'}#{', confirm: :' + column.options[:confirm].to_s + '.t(scope: "labels")' if column.options[:confirm]}})"
|
287
|
+
end
|
288
|
+
actioner << " + '</span>"
|
289
|
+
code << "'#{actioner}'"
|
290
|
+
end
|
291
|
+
|
292
|
+
code << "'#{menu_code}'"
|
267
293
|
|
268
294
|
if table.paginate?
|
295
|
+
pagination = ""
|
269
296
|
current_page = "#{var_name(:page)}"
|
270
297
|
last_page = "#{var_name(:last)}"
|
271
298
|
|
272
|
-
pagination << "<
|
273
|
-
pagination << "<
|
274
|
-
|
299
|
+
pagination << "<span class=\"pagination\">"
|
300
|
+
pagination << "<span class=\"status\">' + 'list.pagination.x_to_y_of_total'.t(x: (#{var_name(:offset)} + 1), y: ((#{var_name(:last)} == #{var_name(:page)}) ? #{var_name(:count)} : #{var_name(:offset)} + #{var_name(:limit)}), total: #{var_name(:count)}) + '</span>"
|
301
|
+
|
302
|
+
pagination << "<span class=\"paginator\">"
|
303
|
+
|
304
|
+
pagination << "<a href=\"#\" data-list-move-to-page=\"1\" class=\"btn first-page\"' + (#{current_page} != 1 ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.first') + '</a>"
|
305
|
+
pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{current_page} - 1).to_s + '\" class=\"btn previous-page\"' + (#{current_page} != 1 ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.previous') + '</a>"
|
275
306
|
|
276
307
|
x = '@@PAGE-NUMBER@@'
|
277
308
|
y = '@@PAGE-COUNT@@'
|
278
|
-
pagination << "<span class=\"paginator\">'+::I18n.translate('list.page_x_on_y', :default => '%{x} / %{y}', :x => '#{x}', :y => '#{y}').html_safe.gsub('#{x}', ('<input type=\"number\" size=\"4\" data-list-move-to-page=\"value\" value=\"'+#{var_name(:page)}.to_s+'\">').html_safe).gsub('#{y}', #{var_name(:last)}.to_s) + '</span>"
|
309
|
+
# pagination << "<span class=\"paginator\">'+::I18n.translate('list.page_x_on_y', :default => '%{x} / %{y}', :x => '#{x}', :y => '#{y}').html_safe.gsub('#{x}', ('<input type=\"number\" size=\"4\" data-list-move-to-page=\"value\" value=\"'+#{var_name(:page)}.to_s+'\">').html_safe).gsub('#{y}', #{var_name(:last)}.to_s) + '</span>"
|
310
|
+
# pagination << "<input type=\"number\" size=\"4\" data-list-move-to-page=\"value\" value=\"' + #{var_name(:page)}.to_s + '\">"
|
311
|
+
|
312
|
+
pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{current_page} + 1).to_s + '\" class=\"btn next-page\"' + (#{current_page} != #{last_page} ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.next')+'</a>"
|
313
|
+
pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{last_page}).to_s + '\" class=\"btn last-page\"' + (#{current_page} != #{last_page} ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.last')+'</a>"
|
314
|
+
pagination << "</span>"
|
279
315
|
|
280
|
-
pagination << "<
|
281
|
-
pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{last_page}).to_s + '\" class=\"last-page\"' + (#{current_page} != #{last_page} ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.last')+'</a>"
|
316
|
+
# pagination << "<span class=\"separator\"></span>"
|
282
317
|
|
283
|
-
pagination << "<span class=\"separator\"></span>"
|
284
318
|
|
285
|
-
|
286
|
-
|
319
|
+
code << "'#{pagination}'"
|
320
|
+
end
|
287
321
|
|
288
|
-
|
322
|
+
unless code.empty?
|
323
|
+
code = "content_tag(:div, (#{code.join(' + ')}).html_safe, class: 'list-control')"
|
289
324
|
end
|
290
325
|
|
291
326
|
return code
|