% exceptions ||= ['created_at', 'updated_at', 'deleted_at'] %> <% excluded_columns ||= [] %> <% additional_columns ||= [] %> <% additional_actions ||= [] %> <% hide_actions ||= false %> <% sort_fields ||= [] %> <% sort_all ||= false %> <% table_class ||= 'datatables styletable' %> <% box_class ||= 'primary' %> <% card_class ||= 'primary' %> <% show_columns ||= [] %> <% hide_read_action ||= false %> <% hide_edit_action ||= false %> <% hide_destroy_action ||= false %> <% if show_columns.empty? %> <% show_columns = list.klass.column_names - exceptions - excluded_columns + additional_columns %> <% end %>
<% if sort_all || sort_fields.include?(column_name) %> <% if column_name.include?('.') %> <% s_name = column_method || column_name %> <%= sort_link(@q, s_name.split('.').join('_'), "#{s_name.split('.')[-2]&.camelize} (#{s_name.split('.')[-1]})") %> <% elsif /_id$/ =~ column_name %> <%= sort_link(@q, column_name, list.klass.human_attribute_name(column_name.split("_id")[0])) %> <% elsif /_cents$/ =~ column_name %> <%= sort_link(@q, column_name, list.klass.human_attribute_name(column_name.split("_cents")[0])) %> <% elsif /_currency$/ =~ column_name %> <% elsif column_name == 'id' %> <%= sort_link(@q, column_name, '#') %> <% else %> <%= sort_link(@q, column_name, list.klass.human_attribute_name(column_name)) %> <% end %> <% else %> <% if column_name.include?('.') %> <% s_name = column_method || column_name %> <%= "#{s_name.split('.')[-2]&.camelize} (#{s_name.split('.')[-1]})" %> <% elsif /_id$/ =~ column_name %> <%= list.klass.human_attribute_name(column_name.split("_id")[0]) %> <% elsif /_cents$/ =~ column_name %> <%= list.klass.human_attribute_name(column_name.split("_cents")[0]) %> <% elsif /_currency$/ =~ column_name %> <% elsif column_name == 'id' %> # <% else %> <%= list.klass.human_attribute_name(column_name) %> <% end %> <% end %> | <% end %> <% unless hide_actions %>Ações | <% end %>
---|---|
<% if column_name.include?('.') %> <% o = object %> <% column_name.split('.').each{|m| o = o.send(m) if o } %> <%= o %> <% elsif object.send(column_name).class == Date or object.send(column_name).class == DateTime or object.send(column_name).class == ActiveSupport::TimeWithZone or object.send(column_name).class == Time %> <%=l object.send(column_name) %> <% elsif object.send(column_name).respond_to? 'attached?' %> <% if object.send(column_name).class == ActiveStorage::Attached::One %> <% if object.send(column_name).attached? %> <%= link_to rails_blob_path(object.send(column_name)), class: "btn btn-#{box_class} #{card_class} btn-xs", target: '_blank' do %> Arquivo <% end %> <% end %> <% end %> <% elsif /_id$/ =~ column_name && object.respond_to?(column_name.split('_id')[0]) %> <%= object.send(column_name.split("_id")[0])&.name %> <% elsif /_cents$/ =~ column_name %> <%= number_to_currency object.send(column_name.split("_cents")[0]) %> <% elsif /_currency$/ =~ column_name %> <% elsif column_name.include?(".") %> <%= eval("object.#{column_name}") %> <% elsif column_name == 'id' %> <%= link_to object.id, object %> <% else %> <%= object.send(column_method || column_name) %> <% end %> | <% end %> <% unless hide_actions %><%= render 'shared/action_links', object: object, additional_actions: additional_actions, hide_read_action: hide_read_action, hide_edit_action: hide_edit_action, hide_destroy_action: hide_destroy_action %> | <% end %>