/gist:d6670c23d6f08e35812e Secret
Created
July 9, 2014 09:49
Star
You must be signed in to star a gist
render parital to method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- platform.pagination.template = self | |
- referral_id = nil | |
- if flash[:referral_entry] && referral_entry = flash[:referral_entry].clone.symbolize_keys | |
- referral_id = (referral_entry[:platform] == platform.name && referral_entry[:id]) | |
- if platform.custom_partial | |
= render partial: "bhf/platform/#{platform.custom_partial}", locals: {platform: platform, referral_id: referral_id} | |
- else | |
%table.data_table{id: "#{platform.name}_platform", class: (platform.custom_columns? ? :custom_columns : :default_columns)} | |
%caption | |
%h4= platform.title | |
%p.info= platform.pagination.info platform | |
- unless platform.hide_create | |
%p.create= link_to new_t(platform), new_entry_path(platform.name), class: :alt_button | |
- unless platform.custom_partial | |
= render partial: 'search', locals: {platform: platform} if platform.search? | |
%thead | |
%tr | |
- if platform.sortable | |
%th.drag | |
- platform.columns.each do |column| | |
%th{class: "#{column.macro} #{column.display_type} #{order_class(column.db_name, platform.name)}"} | |
= link_to_if column.reorderble, column.title, current_order_path(column.db_name, platform.name) | |
%th.action | |
%tfoot | |
%tr | |
%td{colspan: platform.columns_count} | |
= platform.pagination.create(platform) unless platform.sortable | |
%tbody.quick_edit_block{class: ('js_sortable' if platform.sortable), data: {sort_url: sort_entries_path(platform.name)}} | |
- if platform.objects.any? | |
- platform.objects.each do |object| | |
- edit_link = platform.hide_edit ? "##{object.id}_#{platform.name}" : edit_entry_path(platform.name, object) | |
- custom_link = send(platform.custom_link, platform.name, object) if platform.custom_link | |
%tr.quick_edit_entry{id: "#{object.id}_#{platform.name}", class: ('animate live_edit initial_referral' if referral_id == object.id)} | |
- if platform.sortable | |
%td.drag | |
%span.handle.icon | |
- platform.columns.each do |column| | |
- css_classes = [column.macro, column.display_type] | |
- column_value = object.send(column.name) | |
- if column.display_type == :primary_key && column_value.to_s.length > 6 | |
- css_classes << :key_long | |
%td{class: css_classes} | |
- value = if column.display_type != :boolean && column_value.blank? | |
- ' '.html_safe | |
- else | |
- if column.display_type == :string | |
- column_value | |
- else | |
- template = lookup_context.find_template "#{column.macro}/#{column.display_type}", ['bhf/table'], true | |
- template.render(self, {column_value: column_value, object: object}) | |
-# render(partial: "bhf/table/#{column.macro}/#{column.display_type}", locals: {column_value: column_value, object: object}) | |
= link_to value, (platform.custom_link ? custom_link : edit_link), class: ('quick_edit' if !platform.custom_link && platform.table_quick_edit) | |
%td.action{class: ('wider' if platform.show_duplicate && !platform.hide_edit && !platform.hide_delete)} | |
- if platform.show_duplicate | |
- dt = duplicate_t(platform) | |
= link_to dt, duplicate_entry_path(platform.name, object), class: 'icon duplicate', method: :post, title: dt | |
- unless platform.hide_edit | |
= link_to edit_t(platform), edit_link, class: 'icon edit' | |
- unless platform.hide_delete | |
= link_to delete_t(platform), entry_path(platform.name, object), method: :delete, remote: true, class: 'icon delete js_delete', data: {confirm: t('bhf.helpers.promts.confirm', platform_title: platform.title_singular)} | |
- else | |
%td.no_entries{colspan: platform.columns_count} | |
= t 'bhf.pagination.info', name_zero: platform.title, count: 0 | |
- unless platform.hide_create | |
= link_to new_t(platform), new_entry_path(platform.name) | |
%template.quick_edit_template{type: 'text/template'} | |
%tr.quick_edit_entry{id: "{object_id}_#{platform.name}"} | |
- edit_link = edit_entry_path(platform.name, '{object_id}') | |
- if platform.sortable | |
%td.drag | |
%span.handle.icon | |
- platform.columns.each do |column| | |
- css_classes = [column.macro, column.display_type] | |
- custom_link = send(platform.custom_link, platform.name, '{object_id}') if platform.custom_link | |
%td{class: css_classes} | |
= link_to "{#{column.name}}", (platform.custom_link ? custom_link : edit_link), class: ('quick_edit' unless platform.custom_link) | |
%td.action{class: ('wider' if platform.show_duplicate && !platform.hide_edit && !platform.hide_delete)} | |
- if platform.show_duplicate | |
- dt = duplicate_t(platform) | |
= link_to dt, duplicate_entry_path(platform.name, '{object_id}'), class: 'icon duplicate', method: :post, title: dt | |
- unless platform.hide_edit | |
= link_to edit_t(platform), edit_link, class: 'icon edit' | |
- unless platform.hide_delete | |
= link_to delete_t(platform), entry_path(platform.name, '{object_id}'), method: :delete, remote: true, class: 'icon delete js_delete', data: {confirm: t('bhf.helpers.promts.confirm', platform_title: platform.title_singular)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment