Module: RailsDb::ApplicationHelper
- Includes:
- FontAwesome::Rails::IconHelper
- Defined in:
- app/helpers/rails_db/application_helper.rb
Instance Method Summary collapse
- #link_to_add_fields(name, f, type) ⇒ Object
- #main_content_classes ⇒ Object
- #paginate_table_entries(entries) ⇒ Object
- #rails_db_tables ⇒ Object
- #show_sidebar? ⇒ Boolean
- #sidebar_classes ⇒ Object
- #title(str) ⇒ Object
Instance Method Details
#link_to_add_fields(name, f, type) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/helpers/rails_db/application_helper.rb', line 9 def link_to_add_fields(name, f, type) new_object = f.object.send "build_#{type}" id = "new_#{type}" fields = f.send("#{type}_fields", new_object, child_index: id) do |builder| render(type.to_s + "_fields", f: builder) end link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")}) end |
#main_content_classes ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/helpers/rails_db/application_helper.rb', line 26 def main_content_classes if 'large-9 push-3 columns collapsed' else 'large-12 push-0 columns expanded' end end |
#paginate_table_entries(entries) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/rails_db/application_helper.rb', line 45 def paginate_table_entries(entries) params.delete(:id) return if entries.total_pages == 1 prev_page_text = "#{fa_icon('arrow-left')} Previous".html_safe next_page_text = "Next #{fa_icon('arrow-right')}".html_safe html = '<div class="pagination">' if entries.previous_page html << link_to(prev_page_text, params.merge({ action: :data, page: entries.previous_page }), { remote: true, class: 'page' }) end html << "#{page_links_for_pagination(entries)}" if entries.next_page html << link_to(next_page_text, params.merge({ action: :data, page: entries.next_page }), { remote: true, class: 'page' }) end html << '</div>' sanitize(html) end |
#rails_db_tables ⇒ Object
5 6 7 |
# File 'app/helpers/rails_db/application_helper.rb', line 5 def rails_db_tables RailsDb::Database.accessible_tables end |
#show_sidebar? ⇒ Boolean
34 35 36 37 |
# File 'app/helpers/rails_db/application_helper.rb', line 34 def return true if controller_name == 'dashboard' && action_name == 'index' ['sidebar_visible'] == 'true' end |
#sidebar_classes ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/rails_db/application_helper.rb', line 18 def if 'large-3 large-pull-9 columns' else 'large-3 large-pull-9 columns hide' end end |
#title(str) ⇒ Object
39 40 41 42 43 |
# File 'app/helpers/rails_db/application_helper.rb', line 39 def title(str) content_for :title do raw("#{str}"[0].upcase + "#{str}"[1..-1]) end end |