Class: ActiveList::Renderers::SimpleRenderer
- Inherits:
-
AbstractRenderer
- Object
- AbstractRenderer
- ActiveList::Renderers::SimpleRenderer
- Includes:
- Helpers
- Defined in:
- lib/active_list/renderers/simple_renderer.rb
Constant Summary collapse
- DATATYPE_ABBREVIATION =
{ binary: :bin, boolean: :bln, date: :dat, datetime: :dtt, decimal: :dec, measure: :dec, float: :flt, integer: :int, string: :str, text: :txt, time: :tim, timestamp: :dtt }.freeze
Instance Attribute Summary
Attributes inherited from AbstractRenderer
Instance Method Summary collapse
- #build_table_code(options = {}) ⇒ Object
-
#column_classes(column, without_id = false, without_interpolation = false) ⇒ Object
Finds all default styles for column.
- #columns_to_cells(nature, options = {}) ⇒ Object
-
#extras_codes ⇒ Object
Produces the code to create bottom menu and pagination.
-
#header_code ⇒ Object
Produces the code to create the header line using top-end menu for columns and pagination management.
-
#menu_code ⇒ Object
Produces main menu code.
- #remote_update_code ⇒ Object
- #uid ⇒ Object
Methods included from Helpers
#recordify, #recordify!, #urlify
Methods inherited from AbstractRenderer
#build_data_code, #initialize, #var_name
Constructor Details
This class inherits a constructor from ActiveList::Renderers::AbstractRenderer
Instance Method Details
#build_table_code(options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/active_list/renderers/simple_renderer.rb', line 37 def build_table_code( = {}) record = 'r' # colgroup = columns_definition_code header = header_code extras = extras_codes code = "#{generator.select_data_code}(options)\n" # Hack for Rails 5 code << "__params = params.permit!\n" code << "#{var_name(:tbody)} = '<tbody data-total=\"' + #{var_name(:count)}.to_s + '\"" if table.paginate? code << " data-per-page=\"' + #{var_name(:limit)}.to_s + '\"" code << " data-pages-count=\"' + #{var_name(:last)}.to_s + '\"" end code << ">'\n" code << "if #{var_name(:count)} > 0\n" code << " #{generator.records_variable_name}.each do |#{record}|\n" code << " #{var_name(:attrs)} = {id: 'r' + #{record}.id.to_s}\n" code << " if #{var_name(:params)}[:data]\n" code << " #{var_name(:params)}[:data] = [#{var_name(:params)}[:data]] unless #{var_name(:params)}[:data].is_a?(Array)\n" code << " #{var_name(:params)}[:data].each do |attr|\n" code << " #{var_name(:attrs)}['data-' + attr.gsub('_', '-')] = #{record}.send(attr)\n" code << " end\n" code << " end\n" if table.[:line_class] code << " #{var_name(:attrs)}[:class] = (#{recordify!(table.options[:line_class], record)}).to_s\n" code << " #{var_name(:attrs)}[:class] << ' focus' if __params['#{table.name}-id'].to_i == #{record}.id\n" else code << " #{var_name(:attrs)}[:class] = 'focus' if __params['#{table.name}-id'].to_i == #{record}.id\n" end code << " #{var_name(:tbody)} << content_tag(:tr, #{var_name(:attrs)}) do\n" code << columns_to_cells(:body, record: record).dig(3) code << " end\n" # if table.options[:children].is_a? Symbol # children = table.options[:children].to_s # code << " for #{child} in #{record}.#{children}\n" # code << " #{var_name(:tbody)} << content_tag(:tr, :class => #{line_class}+' child') do\n" # code << columns_to_cells(:children, table.children, record: child).dig(4) # code << " end\n" # code << " end\n" # end code << " end\n" if table.columns.any?(&:computable?) code << " #{var_name(:tbody)} << content_tag(:tr, id: :'computation-results') do\n" code << " computation_row = ''\n" code << " computation_row << '<td></td>'\n" if table.selectable? table.columns.each do |column| value = '' code << ' computation_row << "<td' if column.computable? code << " data-list-result-for='#{column.short_id}'" value = "<div><span><strong>#{I18n.translate("list.results.#{column.computation_method}")}:</strong></span>" value << "<span id='list-computation-result'></span></div>" end if column.is_a? ActiveList::Definition::DataColumn code << "\#\{' class=\"#{column.short_id}' + (#{var_name(:params)}[:hidden_columns].include?(:#{column.name}) ? ' hidden\"' : '\"')\}" end code << '>' code << value code << "</td>\"\n" end code << " computation_row.html_safe\n" code << " end\n" end code << "else\n" code << " #{var_name(:tbody)} << '<tr class=\"empty\"><td colspan=\"#{table.columns.size + 1}\">' + ::I18n.translate('list.no_records') + '</td></tr>'\n" code << "end\n" code << "#{var_name(:tbody)} << '</tbody>'\n" code << "return #{var_name(:tbody)}.html_safe if options[:only] == 'table-body'\n" # Build content code << "#{var_name(:content)} = ''\n" if extras.any? # code << "#{var_name(:content)} << #{extras}\n" unless extras.blank? code << "options[:content_for] ||= {}\n" code << "#{var_name(:extras)} = ''\n" extras.each do |name, ecode| next if name == :footer_pagination code << "if options[:content_for][:#{name}]\n" code << " content_for(options[:content_for][:#{name}], (#{ecode}).html_safe)\n" code << "else\n" code << " #{var_name(:extras)} << #{ecode}\n" code << "end\n" end code << "#{var_name(:content)} << content_tag(:div, (#{var_name(:extras)}).html_safe, class: 'list-control') unless #{var_name(:extras)}.blank?\n" end code << "#{var_name(:content)} << '<div class=\"list-data\"><table class=\"list\"" if table.paginate? code << " data-list-current-page=\"' + #{var_name(:page)}.to_s + '\" data-list-page-size=\"' + #{var_name(:limit)}.to_s + '\"" end code << " data-list-sort-by=\"' + #{var_name(:params)}[:sort].to_s + '\" data-list-sort-dir=\"' + #{var_name(:params)}[:dir].to_s + '\"" code << ">'\n" code << "#{var_name(:content)} << (#{header})\n" code << "if block_given?\n" code << " #{var_name(:content)} << '<tfoot>' + capture(" + table.columns.collect { |c| { name: c.name, id: c.id } }.inspect + ", &block).to_s + '</tfoot>'\n" code << "end\n" code << "#{var_name(:content)} << #{var_name(:tbody)}\n" code << "#{var_name(:content)} << '</table></div>'\n" if table.[:footer_pagination] code << " footer_code = ''\n" code << " if options[:content_for][:footer_pagination]\n" code << " footer_code << content_for(options[:content_for][:pagination])\n" code << " else\n" code << " footer_code << (#{extras[:footer_pagination]})\n" code << " end\n" code << " #{var_name(:content)} << content_tag(:div, (footer_code).html_safe, class: 'list-control') unless footer_code.blank?\n" end # code << "return #{var_name(:content)}.html_safe if options[:only] == 'content'\n" # Build whole code << "return ('<div id=\"#{uid}\" data-list-source=\"'+h(url_for(options.merge(:action => '#{generator.controller_method_name}')))+'\" data-list-redirect=\"' + __params[:redirect].to_s + '\" class=\"active-list\">' + #{var_name(:content)} + '</div>').html_safe\n" # File.open('debug-activelist', 'w') { |file| file.write code } code end |
#column_classes(column, without_id = false, without_interpolation = false) ⇒ Object
Finds all default styles for column
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/active_list/renderers/simple_renderer.rb', line 451 def column_classes(column, without_id = false, without_interpolation = false) classes = [] conds = [] conds << [:sor, "#{var_name(:params)}[:sort] == '#{column.sort_id}'".c] if column.sortable? if column.is_a? ActiveList::Definition::DataColumn conds << [:hidden, "#{var_name(:params)}[:hidden_columns].include?(:#{column.name})".c] elsif column.condition conds << [:hidden, "h(#{column.condition}) == 'false'".c] end classes << column.[:class].to_s.strip unless column.[:class].blank? classes << column.short_id unless without_id if column.is_a? ActiveList::Definition::ActionColumn classes << :act elsif column.is_a? ActiveList::Definition::StatusColumn classes << :status elsif column.is_a? ActiveList::Definition::DataColumn classes << :col classes << DATATYPE_ABBREVIATION[column.datatype] classes << :url if column.[:url].is_a?(Hash) classes << column.label_method if i[code color].include? column.label_method.to_sym if column.[:mode] == :download classes << :dld elsif column.[:mode] || column.label_method == :email classes << :eml elsif column.[:mode] || column.label_method == :website classes << :web end elsif column.is_a? ActiveList::Definition::TextFieldColumn classes << :tfd elsif column.is_a? ActiveList::Definition::CheckBoxColumn classes << :chk else classes << :unk end html = classes.join(' ').strip if conds.any? if without_interpolation html << "' + " html << conds.collect do |c| "(#{c[1]} ? ' #{c[0]}' : '')" end.join(' + ') html << " + '" else html << conds.collect do |c| "\#\{' #{c[0]}' if #{c[1]}\}" end.join end end html end |
#columns_to_cells(nature, options = {}) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/active_list/renderers/simple_renderer.rb', line 158 def columns_to_cells(nature, = {}) code = '' unless i[body children].include?(nature) raise ArgumentError, 'Nature is invalid' end record = [:record] || 'record_of_the_death' if table.selectable? code << "content_tag(:td, class: 'list-selector') do\n" code << " tag(:input, type: 'checkbox', value: #{record}.id, data: {list_selector: #{record}.id})\n" code << "end +\n" end children_mode = !!(nature == :children) for column in table.columns value_code = '' title_value_code = '' if column.is_a? ActiveList::Definition::EmptyColumn value_code = 'nil' elsif column.is_a? ActiveList::Definition::StatusColumn title_value_code = nil value_code = column.datum_code(record, children_mode) title_code = column.tooltip_title_code(record, children_mode) levels = %w[go caution stop] lights = levels.collect do |light| "content_tag(:span, '', :class => #{light.inspect})" end.join(' + ') # Expected value are :valid, :warning, :error value_code = "content_tag(:span, #{lights}, :class => 'lights lights-' + (#{levels.inspect}.include?(#{value_code}.to_s) ? #{value_code}.to_s : 'undefined'), data: { toggle: :tooltip, placement: :top }, title: #{title_code})" elsif column.is_a? ActiveList::Definition::DataColumn if column.[:children].is_a?(FalseClass) && children_mode value_code = 'nil' else value_code = column.datum_code(record, children_mode) if column.datatype == :boolean title_value_code = value_code value_code = "content_tag(:div, '', :class => 'checkbox-'+(" + value_code.to_s + " ? 'true' : 'false'))" elsif i[date datetime measure].include? column.datatype value_code = "(#{value_code}.nil? ? '' : #{value_code}.l)" elsif [:item].include? column.datatype value_code = "(#{value_code}.nil? ? '' : #{value_code}.human_name)" end if !column.[:currency].is_a?(FalseClass) && currency = column.[:currency] currency = currency[nature] if currency.is_a?(Hash) currency = :currency if currency.is_a?(TrueClass) # currency = "#{record}.#{currency}".c if currency.is_a?(Symbol) currency = "#{column.record_expr(record)}.#{currency}".c if currency.is_a?(Symbol) value_code = "(#{value_code}.nil? || #{value_code}.zero? ? ('#{column.options[:default]}'.present? ? '#{column.options[:default]}' : '') : #{value_code}.l(currency: #{currency.inspect}))" elsif column.datatype == :decimal value_code = "(#{value_code}.nil? ? '' : #{value_code}.l)" elsif column.enumerize? value_code = "(#{value_code}.nil? ? '' : #{value_code}.text)" end if column.[:url] && nature == :body column.[:url] = {} unless column.[:url].is_a?(Hash) column.[:url][:id] ||= (column.record_expr(record) + '.id').c column.[:url][:action] ||= :show default_controller = column.class_name.is_a?(CodeString) ? column.class_name : column.class_name.tableize.to_sym column.[:url][:controller] ||= default_controller namespace = column.[:url].delete(:namespace) url = column.[:url].collect { |k, v| "#{k}: " + urlify(k, v, record, namespace) }.join(', ') title_value_code = value_code value_code = "(#{value_code}.blank? ? '' : link_to(#{value_code}.to_s, #{url}))" elsif column.[:mode] || column.label_method == :email title_value_code = value_code value_code = "(#{value_code}.blank? ? '' : mail_to(#{value_code}))" elsif column.[:mode] || column.label_method == :website title_value_code = value_code value_code = "(#{value_code}.blank? ? '' : link_to(" + value_code + ', ' + value_code + '))' elsif column.label_method == :color title_value_code = value_code value_code = "content_tag(:div, #{column.datum_code(record)}, style: 'background: #'+" + column.datum_code(record) + ')' elsif column.label_method.to_s.match(/(^|\_)currency$/) && column.datatype == :string value_code = "(Nomen::Currency[#{value_code}] ? Nomen::Currency[#{value_code}].human_name : #{value_code})" elsif column.label_method.to_s.match(/(^|\_)language$/) && column.datatype == :string value_code = "(Nomen::Language[#{value_code}] ? Nomen::Language[#{value_code}].human_name : #{value_code})" elsif column.label_method.to_s.match(/(^|\_)country$/) && column.datatype == :string value_code = "(Nomen::Country[#{value_code}] ? (image_tag('countries/' + #{value_code}.to_s + '.png') + ' ' + Nomen::Country[#{value_code}].human_name).html_safe : #{value_code})" else # if column.datatype == :string value_code = "h(#{value_code}.to_s)" title_value_code = nil end value_code = "if #{record}\n#{value_code.dig}end" if column.is_a?(ActiveList::Definition::AssociationColumn) end elsif column.is_a?(ActiveList::Definition::CheckBoxColumn) title_value_code = nil if nature == :body form_name = column.form_name || "'#{table.name}[' + #{record}.id.to_s + '][#{column.name}]'".c value = 'nil' if column.form_value value = recordify(column.form_value, record) else value = 1 value_code << "hidden_field_tag(#{form_name.inspect}, 0, id: nil) + \n" end value_code << "check_box_tag(#{form_name.inspect}, #{value}, #{recordify!(column.options[:value] || column.name, record)})" # , id: '#{table.name}_'+#{record}.id.to_s+'_#{column.name}' else value_code << 'nil' end elsif column.is_a?(ActiveList::Definition::TextFieldColumn) title_value_code = nil form_name = column.form_name || "'#{table.name}[' + #{record}.id.to_s + '][#{column.name}]'".c 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}' elsif column.is_a?(ActiveList::Definition::ActionColumn) title_value_code = nil next unless column.use_single? value_code = (nature == :body ? column.operation(record) : 'nil') else value_code = "' ∅ '.html_safe" end title_attr_code = if title_value_code.nil? '' elsif title_value_code.blank? ":title => (#{value_code})," else ":title => (#{title_value_code})," end code << "content_tag(:td, #{title_attr_code} :class => \"#{column_classes(column)}\"," code << " data: { 'list-column-header' => '#{column.short_id}'" code << ", 'list-cell-value' => \"\#{#{column.datum_value(record, children_mode)}.to_f}\"" if column.computable? code << " } ) do\n" code << value_code.dig code << "end +\n" end # if nature == :header # code << "'<th class=\"spe\">#{menu_code}</th>'" # else # code << "content_tag(:td)" # end code << "''.html_safe" # code << "content_tag(:td)" code.c end |
#extras_codes ⇒ Object
Produces the code to create bottom menu and pagination
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/active_list/renderers/simple_renderer.rb', line 376 def extras_codes code = [] codes = {} if table.global_action_columns.any? actions = '' actions << "<span class=\"list-actions\" data-list-ref=\"#{uid}\">'" for column in table.global_action_columns actions << " + link_to(content_tag(:i) + h(' ' + :#{column.name}.t(scope: 'rest.actions')), #{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]}})" end actions << " + '</span>" code << "'#{actions}'" codes[:actions] = "'#{actions}'" end code << "'#{menu_code}'" codes[:settings] = "'#{menu_code}'" if table.paginate? pagination = '' current_page = var_name(:page).to_s last_page = var_name(:last).to_s pagination << "<span class=\"list-pagination\" data-list-ref=\"#{uid}\">" pagination << "<span class=\"status\">' + 'list.pagination.x_to_y_of_total'.t(x: (#{var_name(:offset)} + (#{var_name(:count)} > 0 ? 1 : 0)), y: ((#{var_name(:last)} == #{var_name(:page)}) ? #{var_name(:count)} : #{var_name(:offset)} + #{var_name(:limit)}), total: #{var_name(:count)}) + '</span>" pagination << '<span class="paginator">' 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>" 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>" pagination << '</span>' pagination << '</span>' code << "'#{pagination}'" codes[:pagination] = "'#{pagination}'" if table.[:footer_pagination] pagination = '' current_page = var_name(:page).to_s last_page = var_name(:last).to_s pagination << "<span class=\"list-footer-pagination\" data-list-ref=\"#{uid}\">" pagination << "<span class=\"status\">' + 'list.pagination.x_to_y_of_total'.t(x: (#{var_name(:offset)} + (#{var_name(:count)} > 0 ? 1 : 0)), y: ((#{var_name(:last)} == #{var_name(:page)}) ? #{var_name(:count)} : #{var_name(:offset)} + #{var_name(:limit)}), total: #{var_name(:count)}) + '</span>" pagination << '<span class="paginator">' 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>" 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>" pagination << '</span>' pagination << '</span>' code << "'#{pagination}'" codes[:footer_pagination] = "'#{pagination}'" end end codes end |
#header_code ⇒ Object
Produces the code to create the header line using top-end menu for columns and pagination management
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/active_list/renderers/simple_renderer.rb', line 336 def header_code code = '' code << "'<thead><tr>" if table.selectable? code << '<th class="list-selector"><input type="checkbox" data-list-selector="all" /></th>' disclaimer = '<tr class="selected-count" style="display: none;"><th colspan="1000">\'+ "list.selected".t + \'</th></tr>' end table.columns.each do |column| next if column.is_a?(ActiveList::Definition::ActionColumn) && !column.use_single? code << "<th data-list-column=\"#{column.options[:icon_name] || column.sort_id}\"" code << " data-list-column-cells=\"#{column.short_id}\"" code << " data-list-column-sort=\"'+(#{var_name(:params)}[:sort] != '#{column.sort_id}' ? 'asc' : #{var_name(:params)}[:dir] == 'asc' ? 'desc' : 'asc')+'\"" if column.sortable? code << " data-list-column-computation=\"#{column.computation_method}\"" if column.computable? if table.selectable? && column.is_a?(ActiveList::Definition::DataColumn) && (column.[:currency] || column.computable?) unit = "''" precision = "''" if column.[:currency] unit = "Nomen::Currency.find(#{column.currency_for(generator.records_variable_name + '.first').inspect} || 'EUR').symbol.to_s" precision = "Nomen::Currency.find(#{column.currency_for(generator.records_variable_name + '.first').inspect} || 'EUR').precision.to_s" elsif column.computable? unit = "#{generator.records_variable_name}.first.#{column.value_method}.symbol" precision = "'2'" end code << " data-list-column-unit-symbol=\"' + (#{generator.records_variable_name}.any? ? #{unit} : '') + '\"" code << " data-list-column-unit-precision=\"' + (#{generator.records_variable_name}.any? ? #{precision} : '') + '\"" end code << " class=\"#{column_classes(column, true, true)}\"" code << '>' code << "' + h(#{column.header_code}) + '" code << '<i></i>' code << '</th>' end # code << "<th class=\"spe\">#{menu_code}</th>" code << '</tr>' code << (disclaimer || '') code << "</thead>'" code end |
#menu_code ⇒ Object
Produces main menu code
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/active_list/renderers/simple_renderer.rb', line 299 def = "<span class=\"list-settings\" data-list-ref=\"#{uid}\">" << "<a class=\"settings-start\"><i></i>' + h('list.menu'.t) + '</a>" << '<ul>' if table.paginate? # Per page list = [5, 10, 20, 50, 100, 200] list << table.[:per_page].to_i if table.[:per_page].to_i > 0 list = list.uniq.sort << '<li class="parent">' << "<a class=\"pages\"><i></i>' + h('list.items_per_page'.t) + '</a><ul>" list.each do |n| << "<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>" end << '</ul></li>' end # Column selector << '<li class="parent">' << "<a class=\"columns\"><i></i>' + h('list.columns'.t) + '</a><ul>" for column in table.data_columns << "<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>" end << '</ul></li>' # Separator << '<li class="separator"></li>' # Exports ActiveList.exporters.each do |format, _exporter| << "<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>" end << '</ul></span>' end |
#remote_update_code ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_list/renderers/simple_renderer.rb', line 21 def remote_update_code code = "if params[:column] && params[:visibility]\n" code << " column = params[:column].to_sym\n" # Removes potentially unwanted columns code << " #{var_name(:params)}[:hidden_columns].delete_if{|c| !#{table.data_columns.map(&:name).inspect}.include?(c)}\n" code << " #{var_name(:params)}[:hidden_columns].delete(column) if params[:visibility] == 'shown'\n" code << " #{var_name(:params)}[:hidden_columns] << column if params[:visibility] == 'hidden'\n" code << " head :ok\n" code << "elsif params[:only]\n" code << " render(inline: '<%=#{generator.view_method_name}(only: params[:only])-%>')\n" code << "else\n" code << " render(inline: '<%=#{generator.view_method_name}-%>')\n" code << "end\n" code end |
#uid ⇒ Object
438 439 440 |
# File 'lib/active_list/renderers/simple_renderer.rb', line 438 def uid "#{table.name}-list" end |