forked from jejacks0n/protoadmin
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up view helpers, aka fix bugs by following convention
* don't nest view helpers in module for no reason * rename view helpers per the convention * add explicit csrf tags helper instead of applicationhelper * isolate_namespace !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- Loading branch information
1 parent
5b8aeb4
commit 59ed4ab
Showing
9 changed files
with
62 additions
and
72 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Adminsimple | ||
module FlashHelper | ||
def flash_messages | ||
messages = '' | ||
[:alert, :notice].each do |prop| | ||
messages << flash_message(prop) if flash[prop].present? | ||
end | ||
messages.html_safe | ||
end | ||
|
||
def flash_message(prop = :notice) | ||
close_button = content_tag(:button, '×'.html_safe, class: 'close', data: {dismiss: 'alert'}) | ||
content = content_tag(:strong, "#{prop.to_s.titleize}! ") + flash[prop] | ||
content_tag(:div, "#{content}#{close_button}".html_safe, class: "alert alert-#{prop}") | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Adminsimple | ||
module PageHeaderHelper | ||
def page_header(options = {}, &block) | ||
options[:id] ||= "adminsimple_page_header" | ||
options[:title] ||= controller.controller_name.to_s | ||
content = block ? capture(&block) : nil | ||
locals = {content: content, title: options.delete(:title)} | ||
content_tag(:div, render(partial: 'adminsimple/modules/page_header', locals: locals), options) | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Adminsimple | ||
module RescuedCsrfMetaTagsHelper | ||
def rescued_csrf_meta_tags | ||
csrf_meta_tags | ||
rescue ArgumentError | ||
request.reset_session | ||
csrf_meta_tags | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Adminsimple | ||
module WidgetBoxHelper | ||
def widget_box(options = {}, &block) | ||
options[:class] = options[:class] ? "#{options[:class]} adminsimple-widget-box" : 'adminsimple-widget-box' | ||
|
||
if options[:icon] == :checkbox | ||
options[:icon] = content_tag(:input, '', type: 'checkbox') | ||
elsif options[:icon].present? | ||
options[:icon] = content_tag(:i, '', class: "icon-#{options[:icon]}") | ||
end | ||
|
||
if options[:label].is_a?(Hash) | ||
labels = options[:label].map { |key, value| content_tag(:span, value, class: "label label-#{key}") } | ||
options[:label] = labels.join('').html_safe | ||
elsif options[:label].present? | ||
options[:label] = content_tag(:span, options[:label], class: 'label') | ||
end | ||
|
||
locals = {content: capture(&block), title: options.delete(:title), icon: options.delete(:icon), label: options.delete(:label)} | ||
content_tag(:div, render(partial: 'adminsimple/modules/widget_box', locals: locals), options) | ||
end | ||
end | ||
end |
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