Module: Admin::BaseHelper
- Includes:
- ActionView::Helpers::DateHelper
- Defined in:
- app/helpers/admin/base_helper.rb
Instance Method Summary collapse
- #button_to_delete(item) ⇒ Object
- #button_to_edit(item) ⇒ Object
- #button_to_short_url(item) ⇒ Object
- #class_for_admin_state(sidebar, this_position) ⇒ Object
- #display_pagination(collection, cols, _first = "", _last = "") ⇒ Object
- #menu_item(name, url) ⇒ Object
- #plugin_options(kind) ⇒ Object
- #show_actions(item) ⇒ Object
- #text_filter_options ⇒ Object
- #toggle_element(element, label = t("generic.change")) ⇒ Object
- #twitter_available?(blog, user) ⇒ Boolean
Instance Method Details
#button_to_delete(item) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/helpers/admin/base_helper.rb', line 59 def (item) confirm_text = t("admin.shared.destroy.are_you_sure", element: item.class.model_name.human.downcase) link_to(t("generic.delete"), { action: "destroy", id: item.id }, { class: "btn btn-danger btn-xs btn-action", method: :delete, data: { confirm: confirm_text } }) end |
#button_to_edit(item) ⇒ Object
53 54 55 56 57 |
# File 'app/helpers/admin/base_helper.rb', line 53 def (item) link_to(t("generic.edit"), { action: "edit", id: item.id }, { class: "btn btn-primary btn-xs btn-action" }) end |
#button_to_short_url(item) ⇒ Object
68 69 70 71 72 73 |
# File 'app/helpers/admin/base_helper.rb', line 68 def (item) return "" if item.short_url.nil? link_to(t("generic.short_url"), item.short_url, class: "btn btn-success btn-xs btn-action") end |
#class_for_admin_state(sidebar, this_position) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/admin/base_helper.rb', line 10 def class_for_admin_state(, this_position) case .admin_state when :active "active alert-info" when :will_change_position if this_position == .active_position "will_change ghost" else "will_change alert-warning" end else raise .admin_state.inspect end end |
#display_pagination(collection, cols, _first = "", _last = "") ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/helpers/admin/base_helper.rb', line 45 def display_pagination(collection, cols, _first = "", _last = "") return if collection.count == 0 tag.tr do tag.td(paginate(collection), class: "paginate", colspan: cols) end end |
#menu_item(name, url) ⇒ Object
79 80 81 82 83 84 85 |
# File 'app/helpers/admin/base_helper.rb', line 79 def (name, url) if current_page? url tag.li(link_to(name, "#"), class: "active") else tag.li(link_to(name, url)) end end |
#plugin_options(kind) ⇒ Object
31 32 33 34 35 |
# File 'app/helpers/admin/base_helper.rb', line 31 def (kind) PublifyPlugins::Keeper.available_plugins(kind).map do |plugin| [plugin.name, plugin.to_s] end end |
#show_actions(item) ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/helpers/admin/base_helper.rb', line 37 def show_actions(item) tag.div(class: "action", style: "") do safe_join [(item), (item), (item)], " " end end |
#text_filter_options ⇒ Object
25 26 27 28 29 |
# File 'app/helpers/admin/base_helper.rb', line 25 def TextFilter.all.map do |filter| [filter.description, filter.name] end end |
#toggle_element(element, label = t("generic.change")) ⇒ Object
6 7 8 |
# File 'app/helpers/admin/base_helper.rb', line 6 def toggle_element(element, label = t("generic.change")) link_to label, "##{element}", data: { toggle: :collapse } end |
#twitter_available?(blog, user) ⇒ Boolean
75 76 77 |
# File 'app/helpers/admin/base_helper.rb', line 75 def twitter_available?(blog, user) blog.has_twitter_configured? && user.has_twitter_configured? end |