active-list 4.2.4 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/VERSION +1 -1
  3. data/{lib → app}/assets/images/active-list.png +0 -0
  4. data/app/assets/images/active-list.svg +415 -0
  5. data/{lib/assets/javascripts/active-list.jquery.js → app/assets/javascripts/active_list.jquery.js} +2 -2
  6. data/app/assets/stylesheets/active_list.css.scss +7 -0
  7. data/{lib/active-list/compass/stylesheets/active-list/_background.scss → app/assets/stylesheets/active_list/background.scss} +10 -8
  8. data/{lib/active-list/compass/stylesheets/active-list/_minimal.scss → app/assets/stylesheets/active_list/minimal.scss} +16 -16
  9. data/{lib/active-list/compass/stylesheets/active-list/_theme.scss → app/assets/stylesheets/active_list/theme.scss} +37 -37
  10. data/lib/active-list.rb +1 -37
  11. data/lib/active_list.rb +43 -0
  12. data/lib/active_list/action_pack.rb +46 -0
  13. data/lib/active_list/definition.rb +17 -0
  14. data/lib/active_list/definition/abstract_column.rb +54 -0
  15. data/lib/active_list/definition/action_column.rb +76 -0
  16. data/lib/active_list/definition/association_column.rb +80 -0
  17. data/lib/active_list/definition/attribute_column.rb +58 -0
  18. data/lib/active_list/definition/check_box_column.rb +17 -0
  19. data/lib/active_list/definition/data_column.rb +88 -0
  20. data/lib/active_list/definition/empty_column.rb +10 -0
  21. data/lib/active_list/definition/field_column.rb +20 -0
  22. data/lib/active_list/definition/status_column.rb +10 -0
  23. data/lib/active_list/definition/table.rb +159 -0
  24. data/lib/active_list/definition/text_field_column.rb +10 -0
  25. data/lib/active_list/exporters.rb +28 -0
  26. data/lib/active_list/exporters/abstract_exporter.rb +55 -0
  27. data/lib/active_list/exporters/csv_exporter.rb +32 -0
  28. data/lib/active_list/exporters/excel_csv_exporter.rb +38 -0
  29. data/lib/active_list/exporters/open_document_spreadsheet_exporter.rb +82 -0
  30. data/lib/active_list/generator.rb +122 -0
  31. data/lib/active_list/generator/finder.rb +150 -0
  32. data/lib/active_list/helpers.rb +33 -0
  33. data/lib/{active-list → active_list}/rails/engine.rb +3 -2
  34. data/lib/active_list/renderers.rb +25 -0
  35. data/lib/active_list/renderers/abstract_renderer.rb +29 -0
  36. data/lib/active_list/renderers/simple_renderer.rb +356 -0
  37. metadata +74 -55
  38. data/lib/active-list/action_pack.rb +0 -48
  39. data/lib/active-list/columns/action_column.rb +0 -83
  40. data/lib/active-list/columns/data_column.rb +0 -151
  41. data/lib/active-list/columns/field_column.rb +0 -29
  42. data/lib/active-list/compass/stylesheets/_active-list.scss +0 -7
  43. data/lib/active-list/definition.rb +0 -103
  44. data/lib/active-list/exporters.rb +0 -71
  45. data/lib/active-list/exporters/csv_exporter.rb +0 -30
  46. data/lib/active-list/exporters/excel_csv_exporter.rb +0 -36
  47. data/lib/active-list/exporters/open_document_spreadsheet_exporter.rb +0 -81
  48. data/lib/active-list/finder.rb +0 -134
  49. data/lib/active-list/generator.rb +0 -88
  50. data/lib/active-list/renderers.rb +0 -28
  51. data/lib/active-list/renderers/simple_renderer.rb +0 -335
  52. data/lib/assets/stylesheets/active-list.css.scss +0 -7
@@ -1,88 +0,0 @@
1
- # encoding: UTF-8
2
- require "active-list/finder"
3
- require "active-list/exporters"
4
- require "active-list/renderers"
5
-
6
- module ActiveList
7
-
8
- class Table
9
-
10
- def view_method_name
11
- @options[:view_method_name]
12
- end
13
-
14
- def controller_method_name
15
- @options[:controller_method_name]
16
- end
17
-
18
- def records_variable_name
19
- @options[:records_variable_name]
20
- end
21
-
22
- def renderer
23
- ActiveList.renderers[@options[:renderer]]
24
- end
25
-
26
-
27
- def generate_controller_method_code
28
- code = "# encoding: utf-8\n"
29
- code << "def #{self.controller_method_name}\n"
30
- code << self.session_initialization_code.gsub(/^/, ' ')
31
- code << " respond_to do |format|\n"
32
- code << " format.html do\n"
33
- code << " if request.xhr?\n"
34
- code << self.renderer.remote_update_code(self).gsub(/^/, ' ')
35
- code << " else\n"
36
- code << " render(:inline=>'<%=#{self.view_method_name}-%>', :layout=>true)\n"
37
- code << " end\n"
38
- code << " end\n"
39
- for format, exporter in ActiveList.exporters
40
- code << " format.#{format} do\n"
41
- code << exporter.send_data_code(self).gsub(/^/, ' ')
42
- code << " end\n"
43
- end
44
- code << " end\n"
45
- code << "end\n"
46
- # code.split("\n").each_with_index{|l, x| puts((x+1).to_s.rjust(4)+": "+l)}
47
- return code
48
- end
49
-
50
- def generate_view_method_code
51
- code = "# encoding: utf-8\n"
52
- code << "def #{self.view_method_name}(options={}, &block)\n"
53
- code << self.session_initialization_code.gsub(/^/, ' ')
54
- code << self.renderer.build_table_code(self).gsub(/^/, ' ')
55
- code << "end\n"
56
- # code.split("\n").each_with_index{|l, x| puts((x+1).to_s.rjust(4)+": "+l)}
57
- return code
58
- end
59
-
60
-
61
- def session_initialization_code
62
- code = "options = {} unless options.is_a? Hash\n"
63
- code << "options = (params||{}).merge(options)\n"
64
- # Session values
65
- code << "session[:list] = {} unless session[:list].is_a? Hash\n"
66
- code << "session[:list][:#{self.view_method_name}] = {} unless session[:list][:#{self.view_method_name}].is_a? Hash\n"
67
- code << "list_params = session[:list][:#{self.view_method_name}]\n"
68
- code << "list_params[:hidden_columns] = [] unless list_params[:hidden_columns].is_a? Array\n"
69
- for parameter, convertor in @parameters.sort{|a,b| a[0].to_s <=> b[0].to_s}
70
- expr = "options.delete('#{self.name}_#{parameter}') || options.delete('#{parameter}') || list_params[:#{parameter}]"
71
- expr += " || #{@options[parameter]}" unless @options[parameter].blank?
72
- code << "list_params[:#{parameter}] = (#{expr}).#{convertor}\n"
73
- end
74
- # Order
75
- code << "order = #{self.options[:order] ? self.options[:order].inspect : 'nil'}\n"
76
- code << "if (col = {"+self.sortable_columns.collect{|c| "'#{c.id}'=>'#{c.name}'"}.join(', ')+"}[list_params[:sort]])\n"
77
- code << " list_params[:dir] ||= 'asc'\n"
78
- code << " if list_params[:dir] == 'asc' or list_params[:dir] == 'desc'\n"
79
- code << " order = #{@model.name}.connection.quote_column_name(col)+' '+list_params[:dir]\n"
80
- code << " end\n"
81
- code << "end\n"
82
-
83
- return code
84
- end
85
-
86
-
87
- end
88
- end
@@ -1,28 +0,0 @@
1
- require 'active_support/core_ext/module/attribute_accessors'
2
-
3
- module ActiveList
4
-
5
- mattr_reader :renderers
6
- @@renderers = {}
7
-
8
- def self.register_renderer(name, renderer)
9
- raise ArgumentError.new("A renderer must be ActiveList::Renderer") unless renderer.ancestors.include? ActiveList::Renderer
10
- @@renderers[name] = renderer.new
11
- end
12
-
13
- class Renderer
14
-
15
- def remote_update_code(table)
16
- raise NotImplementedError.new("#{self.class.name}#remote_update_code is not implemented.")
17
- end
18
-
19
- def build_data_code(table)
20
- raise NotImplementedError.new("#{self.class.name}#build_table_code is not implemented.")
21
- end
22
-
23
- end
24
-
25
- end
26
-
27
-
28
- require "active-list/renderers/simple_renderer"
@@ -1,335 +0,0 @@
1
- module ActiveList
2
-
3
- class SimpleRenderer < ActiveList::Renderer
4
-
5
- DATATYPE_ABBREVIATION = {
6
- :binary => :bin,
7
- :boolean => :bln,
8
- :date => :dat,
9
- :datetime => :dtt,
10
- :decimal => :dec,
11
- :float =>:flt,
12
- :integer =>:int,
13
- :string =>:str,
14
- :text => :txt,
15
- :time => :tim,
16
- :timestamp => :dtt
17
- }
18
-
19
- def remote_update_code(table)
20
- code = "if params[:column] and params[:visibility]\n"
21
- code << " column = params[:column].to_s\n"
22
- code << " list_params[:hidden_columns].delete(column) if params[:visibility] == 'shown'\n"
23
- code << " list_params[:hidden_columns] << column if params[:visibility] == 'hidden'\n"
24
- code << " head :ok\n"
25
- code << "elsif params[:only]\n"
26
- code << " render(:inline=>'<%=#{table.view_method_name}(:only => params[:only])-%>')\n"
27
- code << "else\n"
28
- code << " render(:inline=>'<%=#{table.view_method_name}-%>')\n"
29
- code << "end\n"
30
- return code
31
- end
32
-
33
- def build_table_code(table)
34
- record = "r"
35
- child = "c"
36
-
37
- colgroup = columns_definition_code(table)
38
- header = header_code(table)
39
- extras = extras_code(table)
40
- tbody = columns_to_cells(table, :body, :record=>record)
41
-
42
- code = table.select_data_code
43
- code << "tbody = '<tbody data-total=\"'+#{table.records_variable_name}_count.to_s+'\""
44
- if table.paginate?
45
- code << " data-per-page=\"'+#{table.records_variable_name}_limit.to_s+'\""
46
- code << " data-pages-count=\"'+#{table.records_variable_name}_last.to_s+'\""
47
- # code << " data-page-label=\"'+::I18n.translate('list.pagination.showing_x_to_y_of_total', :x => (#{table.records_variable_name}_offset + 1), :y => (#{table.records_variable_name}_offset+#{table.records_variable_name}_limit), :total => #{table.records_variable_name}_count)+'\""
48
- end
49
- code << ">'\n"
50
- code << "if #{table.records_variable_name}_count > 0\n"
51
- code << " reset_cycle('list')\n"
52
- code << " for #{record} in #{table.records_variable_name}\n"
53
- line_class = "cycle('odd', 'even', :name=>'list')+' r'+#{record}.id.to_s"
54
- line_class << "+' '+("+table.options[:line_class].to_s.gsub(/RECORD/, record)+').to_s' unless table.options[:line_class].nil?
55
- code << " tbody << content_tag(:tr, (#{tbody}).html_safe, :class=>#{line_class})\n"
56
- if table.options[:children].is_a? Symbol
57
- children = table.options[:children].to_s
58
- child_tbody = columns_to_cells(table, :children, :record=>child)
59
- code << " for #{child} in #{record}.#{children}\n"
60
- code << " tbody << content_tag(:tr, (#{child_tbody}).html_safe, {:class=>#{line_class}+' child'})\n"
61
- code << " end\n"
62
- end
63
- code << " end\n"
64
- code << "else\n"
65
- code << " tbody << '<tr class=\"empty\"><td colspan=\"#{table.columns.size+1}\">' + ::I18n.translate('list.no_records') + '</td></tr>'\n"
66
- code << "end\n"
67
- code << "tbody << '</tbody>'\n"
68
- code << "return tbody.html_safe if options[:only] == 'body' or options[:only] == 'tbody'\n"
69
-
70
- code << "html = ''\n"
71
- code << "html << '<div id=\"#{table.name}\" data-list-source=\"'+h(url_for(options.merge(:action => '#{table.controller_method_name}')))+'\" class=\"active-list\""
72
- code << " data-list-current-page=\"' + #{table.records_variable_name}_page.to_s + '\" data-list-page-size=\"' + #{table.records_variable_name}_limit.to_s + '\""
73
- code << " data-list-sort-by=\"' + list_params[:sort].to_s + '\" data-list-sort-dir=\"' + list_params[:dir].to_s + '\""
74
- code << ">'\n"
75
- code << "html << '<table class=\"list\">'\n"
76
- code << "html << (#{header})\n"
77
- code << "if block_given?\n"
78
- code << " html << '<tfoot>'+capture("+table.columns.collect{|c| {:name=>c.name, :id=>c.id}}.inspect+", &block)+'</tfoot>'\n"
79
- code << "end\n"
80
- code << "html << tbody\n"
81
- code << "html << '</table>'\n"
82
- code << "html << #{extras}\n" if extras
83
- code << "html << '</div>'\n"
84
- code << "return html.html_safe\n"
85
- return code
86
- end
87
-
88
-
89
-
90
- def columns_to_cells(table, nature, options={})
91
- columns = table.columns
92
- code = ''
93
- record = options[:record]||'RECORD'
94
- for column in columns
95
- if nature==:header
96
- raise Exception.new("Ohohoh")
97
- else
98
- case column.class.name
99
- when DataColumn.name
100
- style = column.options[:style]||''
101
- style = style.gsub(/RECORD/, record)+"+" if style.match(/RECORD/)
102
- style << "'"
103
- if nature!=:children or (not column.options[:children].is_a? FalseClass and nature==:children)
104
- datum = column.datum_code(record, nature==:children)
105
- if column.datatype == :boolean
106
- datum = "content_tag(:div, '', :class=>'checkbox-'+("+datum.to_s+" ? 'true' : 'false'))"
107
- end
108
- if [:date, :datetime, :timestamp].include? column.datatype
109
- datum = "(#{datum}.nil? ? '' : ::I18n.localize(#{datum}))"
110
- end
111
- if !column.options[:currency].is_a?(FalseClass) and (currency = column.options[:currency]) # column.datatype == :decimal and
112
- currency = currency[nature] if currency.is_a?(Hash)
113
- currency = :currency if currency.is_a?(TrueClass)
114
- currency = "RECORD.#{currency}" if currency.is_a?(Symbol)
115
- raise Exception.new("Option :currency is not valid. Hash, Symbol or true/false") unless currency.is_a?(String)
116
- currency.gsub!(/RECORD/, record)
117
- datum = "(#{datum}.nil? ? '' : ::I18n.localize(#{datum}, :currency => #{currency}))"
118
- elsif column.datatype == :decimal
119
- datum = "(#{datum}.nil? ? '' : ::I18n.localize(#{datum}))"
120
- elsif column.enumerize?
121
- datum = "(#{datum}.nil? ? '' : #{datum}.text)"
122
- end
123
- if column.options[:url].is_a?(TrueClass) and nature==:body
124
- datum = "(#{datum}.blank? ? '' : link_to(#{datum}, {:controller=>:#{column.class_name.underscore.pluralize}, :action=>:show, :id=>#{column.record_expr(record)+'.id'}}))"
125
- elsif column.options[:url].is_a?(Hash) and nature==:body
126
- column.options[:url][:id] ||= column.record_expr(record)+'.id'
127
- column.options[:url][:action] ||= :show
128
- column.options[:url][:controller] ||= column.class_name.underscore.pluralize.to_sym
129
- url = column.options[:url].collect{|k, v| ":#{k}=>"+(v.is_a?(String) ? v.gsub(/RECORD/, record) : v.inspect)}.join(", ")
130
- datum = "(#{datum}.blank? ? '' : link_to(#{datum}, url_for(#{url})))"
131
- elsif column.options[:mode] == :download# and !datum.nil?
132
- datum = "(#{datum}.blank? ? '' : link_to(tg('download'), url_for_file_column("+record+",'#{column.name}')))"
133
- elsif column.options[:mode]||column.name == :email
134
- # datum = 'link_to('+datum+', "mailto:#{'+datum+'}")'
135
- datum = "(#{datum}.blank? ? '' : mail_to(#{datum}))"
136
- elsif column.options[:mode]||column.name == :website
137
- datum = "(#{datum}.blank? ? '' : link_to("+datum+", "+datum+"))"
138
- elsif column.name==:color
139
- style << "background: #'+"+column.datum_code(record)+"+';"
140
- elsif column.name.to_s.match(/(^|\_)currency$/) and column.datatype == :string and column.limit == 3
141
- datum = "(#{datum}.blank? ? '' : ::I18n.currency_label(#{datum}))"
142
- elsif column.name==:language and column.datatype == :string and column.limit <= 8
143
- datum = "(#{datum}.blank? ? '' : ::I18n.translate('languages.'+#{datum}))"
144
- elsif column.name==:country and column.datatype == :string and column.limit <= 8
145
- datum = "(#{datum}.blank? ? '' : (image_tag('countries/'+#{datum}.to_s+'.png')+' '+::I18n.translate('countries.'+#{datum})).html_safe)"
146
- elsif column.datatype == :string
147
- datum = "h("+datum+")"
148
- end
149
- else
150
- datum = 'nil'
151
- end
152
- code << "content_tag(:td, #{datum}, :class=>\"#{column_classes(column)}\""
153
- code << ", :style=>"+style+"'" unless style[1..-1].blank?
154
- code << ")"
155
- when CheckBoxColumn.name
156
- code << "content_tag(:td,"
157
- if nature==:body
158
- code << "hidden_field_tag('#{table.name}['+#{record}.id.to_s+'][#{column.name}]', 0, :id=>nil)+"
159
- code << "check_box_tag('#{table.name}['+#{record}.id.to_s+'][#{column.name}]', 1, #{column.options[:value] ? column.options[:value].to_s.gsub(/RECORD/, record) : record+'.'+column.name.to_s}, :id=>'#{table.name}_'+#{record}.id.to_s+'_#{column.name}')"
160
- else
161
- code << "''"
162
- end
163
- code << ", :class=>\"#{column_classes(column)}\")"
164
- when TextFieldColumn.name
165
- code << "content_tag(:td,"
166
- if nature==:body
167
- code << "text_field_tag('#{table.name}['+#{record}.id.to_s+'][#{column.name}]', #{column.options[:value] ? column.options[:value].to_s.gsub(/RECORD/, record) : record+'.'+column.name.to_s}, :id=>'#{table.name}_'+#{record}.id.to_s+'_#{column.name}'#{column.options[:size] ? ', :size=>'+column.options[:size].to_s : ''})"
168
- else
169
- code << "''"
170
- end
171
- code << ", :class=>\"#{column_classes(column)}\")"
172
- when ActionColumn.name
173
- code << "content_tag(:td, "+(nature==:body ? column.operation(record) : "''")+", :class=>\"#{column_classes(column)}\")"
174
- else
175
- code << "content_tag(:td, '&#160;&#8709;&#160;'.html_safe)"
176
- end
177
- code << "+\n " # unless code.blank?
178
- end
179
- end
180
- if nature==:header
181
- code << "'<th class=\"spe\">#{menu_code(table)}</th>'"
182
- else
183
- code << "content_tag(:td)"
184
- end
185
-
186
- return code
187
- end
188
-
189
-
190
- # Produces main menu code
191
- def menu_code(table)
192
- menu = "<div class=\"list-menu\">"
193
- menu << "<a class=\"list-menu-start\"><span class=\"icon\"></span><span class=\"text\">' + h(::I18n.translate('list.menu').gsub(/\'/,'&#39;')) + '</span></a>"
194
- menu << "<ul>"
195
- if table.paginate?
196
- # Per page
197
- list = [5, 10, 20, 50, 100, 200]
198
- list << table.options[:per_page].to_i if table.options[:per_page].to_i > 0
199
- list = list.uniq.sort
200
- menu << "<li class=\"parent\">"
201
- menu << "<a class=\"pages\"><span class=\"icon\"></span><span class=\"text\">' + ::I18n.translate('list.items_per_page').gsub(/\'/,'&#39;') + '</span></a><ul>"
202
- for n in list
203
- menu << "<li data-list-change-page-size=\"#{n}\" '+(list_params[:per_page] == #{n} ? ' class=\"check\"' : '')+'><a><span class=\"icon\"></span><span class=\"text\">'+h(::I18n.translate('list.x_per_page', :count=>#{n}))+'</span></a></li>"
204
- end
205
- menu << "</ul></li>"
206
- end
207
-
208
- # Column selector
209
- menu << "<li class=\"parent\">"
210
- menu << "<a class=\"columns\"><span class=\"icon\"></span><span class=\"text\">' + ::I18n.translate('list.columns').gsub(/\'/,'&#39;') + '</span></a><ul>"
211
- for column in table.data_columns
212
- menu << "<li data-list-toggle-column=\"#{column.id}\" class=\"'+(list_params[:hidden_columns].include?('#{column.id}') ? 'unchecked' : 'checked')+'\"><a><span class=\"icon\"></span><span class=\"text\">'+h(#{column.header_code})+'</span></a></li>"
213
- end
214
- menu << "</ul></li>"
215
-
216
- # Separator
217
- menu << "<li class=\"separator\"></li>"
218
- # Exports
219
- for format, exporter in ActiveList.exporters
220
- menu << "<li class=\"export #{exporter.name}\">' + link_to(params.merge(:action=>:#{table.controller_method_name}, :sort=>list_params[:sort], :dir=>list_params[:dir], :format=>'#{format}')) { '<span class=\"icon\"></span>'.html_safe + content_tag('span', ::I18n.translate('list.export_as', :exported=>::I18n.translate('list.export.formats.#{format}')).gsub(/\'/,'&#39;'), :class=>'text')} + '</li>"
221
- end
222
- menu << "</ul></div>"
223
- return menu
224
- end
225
-
226
- # Produces the code to create the header line using top-end menu for columns
227
- # and pagination management
228
- def header_code(table)
229
- code = "'<thead><tr>"
230
- for column in table.columns
231
- code << "<th data-list-column=\"#{column.id}\""
232
- code << " data-list-column-cells=\"#{column.simple_id}\""
233
- code << " data-list-column-sort=\"'+(list_params[:sort]!='#{column.id}' ? 'asc' : list_params[:dir] == 'asc' ? 'desc' : 'asc')+'\"" if column.sortable?
234
- code << " class=\"#{column_classes(column, true, true)}\""
235
- code << ">"
236
- code << "<span class=\"text\">'+h(#{column.header_code})+'</span>"
237
- code << "<span class=\"icon\"></span>"
238
- code << "</th>"
239
- end
240
- code << "<th class=\"spe\">#{menu_code(table)}</th>"
241
- code << "</tr></thead>'"
242
- return code
243
- end
244
-
245
- # Produces the code to create bottom menu and pagination
246
- def extras_code(table)
247
- code, pagination = nil, ''
248
-
249
- if table.paginate?
250
- current_page = "#{table.records_variable_name}_page"
251
- last_page = "#{table.records_variable_name}_last"
252
-
253
- pagination << "<div class=\"pagination\">"
254
- pagination << "<a href=\"#\" data-list-move-to-page=\"1\" class=\"first-page\"' + (#{current_page} != 1 ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.first') + '</a>"
255
- pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{current_page} - 1).to_s + '\" class=\"previous-page\"' + (#{current_page} != 1 ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.previous') + '</a>"
256
-
257
- x = '@@PAGE-NUMBER@@'
258
- y = '@@PAGE-COUNT@@'
259
- 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=\"'+#{table.records_variable_name}_page.to_s+'\">').html_safe).gsub('#{y}', #{table.records_variable_name}_last.to_s) + '</span>"
260
-
261
- pagination << "<a href=\"#\" data-list-move-to-page=\"' + (#{current_page} + 1).to_s + '\" class=\"next-page\"' + (#{current_page} != #{last_page} ? '' : ' disabled=\"true\"') + '><i></i>' + ::I18n.translate('list.pagination.next')+'</a>"
262
- 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>"
263
-
264
- pagination << "<span class=\"separator\"></span>"
265
-
266
- pagination << "<span class=\"status\">'+::I18n.translate('list.pagination.showing_x_to_y_of_total', :x => (#{table.records_variable_name}_offset + 1), :y => ((#{table.records_variable_name}_last==#{table.records_variable_name}_page) ? #{table.records_variable_name}_count : #{table.records_variable_name}_offset+#{table.records_variable_name}_limit), :total => #{table.records_variable_name}_count)+'</span>"
267
- pagination << "</div>"
268
-
269
- code = "(#{table.records_variable_name}_last > 1 ? '<div class=\"extras\">#{pagination}</div>' : '').html_safe"
270
- end
271
-
272
- return code
273
- end
274
-
275
- # Not used
276
- def columns_definition_code(table)
277
- code = table.columns.collect do |column|
278
- "<col id=\\\"#{column.unique_id}\\\" class=\\\"#{column_classes(column, true)}\\\" data-cells-class=\\\"#{column.simple_id}\\\" href=\\\"\#\{url_for(:action=>:#{table.controller_method_name}, :column=>#{column.id.to_s.inspect})\}\\\" />"
279
- end.join
280
- return "\"#{code}\""
281
- end
282
-
283
- # Finds all default styles for column
284
- def column_classes(column, without_id=false, without_interpolation=false)
285
- classes, conds = [], []
286
- conds << [:sor, "list_params[:sort]=='#{column.id}'"] if column.sortable?
287
- conds << [:hidden, "list_params[:hidden_columns].include?('#{column.id}')"] if column.is_a? DataColumn
288
- classes << column.options[:class].to_s.strip unless column.options[:class].blank?
289
- classes << column.simple_id unless without_id
290
- if column.is_a? ActionColumn
291
- classes << :act
292
- elsif column.is_a? DataColumn
293
- classes << :col
294
- classes << DATATYPE_ABBREVIATION[column.datatype]
295
- classes << :url if column.options[:url].is_a?(Hash)
296
- classes << column.name if [:code, :color, :country].include? column.name.to_sym
297
- if column.options[:mode] == :download
298
- classes << :dld
299
- elsif column.options[:mode]||column.name == :email
300
- classes << :eml
301
- elsif column.options[:mode]||column.name == :website
302
- classes << :web
303
- end
304
- elsif column.is_a? TextFieldColumn
305
- classes << :tfd
306
- elsif column.is_a? CheckBoxColumn
307
- classes << :chk
308
- else
309
- classes << :unk
310
- end
311
- html = classes.join(' ').strip
312
- if conds.size > 0
313
- if without_interpolation
314
- html << "' + "
315
- html << conds.collect do |c|
316
- "(#{c[1]} ? ' #{c[0]}' : '')"
317
- end.join(' + ')
318
- html << " + '"
319
- else
320
- html << conds.collect do |c|
321
- "\#\{' #{c[0]}' if #{c[1]}\}"
322
- end.join
323
- end
324
- end
325
- return html
326
- end
327
-
328
-
329
- end
330
-
331
-
332
- end
333
-
334
-
335
- ActiveList.register_renderer(:simple_renderer, ActiveList::SimpleRenderer)