% exceptions ||= ['created_at', 'updated_at', 'deleted_at'] %> <% excluded_columns ||= [] %> <% additional_columns ||= [] %> <% additional_actions ||= [] %> <% sort_fields ||= [] %> <% sort_all ||= false %> <% card_color ||= 'primary' %> <% table_class ||= 'table table-striped bootstrap-table' %> <% show_columns ||= [] %> <% hide_actions ||= false %> <% hide ||= %w[new back delete_right] %> <% size ||= "xs" %> <% 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?('.') %> <% mname = column_name.split('.')[-2]&.camelize %> <% cname = column_name.split('.')[-1] %> <% model = Kernel.const_get(mname) %> <%= sort_link(@q, column_name.split('.').join('_'), column_title || "#{model.model_name.human} (#{model.human_attribute_name(cname)})") %> <% elsif /_id$/ =~ column_name %> <%= sort_link(@q, column_name, column_title || list.klass.human_attribute_name(column_name.split("_id")[0])) %> <% elsif /_cents$/ =~ column_name %> <%= sort_link(@q, column_name, column_title || list.klass.human_attribute_name(column_name.split("_cents")[0])) %> <% elsif /_currency$/ =~ column_name %> <% elsif column_name == 'id' %> <%= sort_link(@q, column_name, column_title || '#') %> <% else %> <%= sort_link(@q, column_name, column_title || list.klass.human_attribute_name(column_name)) %> <% end %> <% else %> <% if column_name.include?('.') %> <% s_name = column_title || column_method || column_name %> <%= "#{s_name.split('.')[-2]&.camelize} (#{s_name.split('.')[-1]})" %> <% elsif /_id$/ =~ column_name %> <%= column_title || list.klass.human_attribute_name(column_name.split("_id")[0]) %> <% elsif /_cents$/ =~ column_name %> <%= column_title || list.klass.human_attribute_name(column_name.split("_cents")[0]) %> <% elsif /_currency$/ =~ column_name %> <% elsif column_name == 'id' %> <%= column_title || "#" %> <% else %> <%= column_title || list.klass.human_attribute_name(column_name) %> <% end %> <% end %> | <% end %> <% unless hide_actions %>Ações | <% end %>
---|---|
<% if column_name.include?('.') %> <% if column_method.nil? %> <% o = object %> <% column_name.split('.').each{|m| o = o.send(m) if o } %> <%= o %> <% else %> <%= object.send(column_method) %> <% end %> <% 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 %> <% if column_format %> <%= l(object.send(column_name), format: (column_format.is_a?(Symbol) ? column_format : column_format.to_sym)) %> <% else %> <%=l object.send(column_name) %> <% end %> <% 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-#{card_color} 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/btn_action_links', object: object, additional_actions: additional_actions, hide: hide, size: size %> | <% end %>