Module: Orange::Pulp::ScaffoldHelpers
- Defined in:
- lib/orange-core/resources/scaffold.rb
Instance Method Summary collapse
-
#form_link(text, link, confirm = false, opts = {}) ⇒ Object
Creates a button that appears to be a link but does form submission with custom method (_method param in POST) This is to avoid issues of a destructive get.
-
#view(model_name, *args) ⇒ Object
Calls view for an orange resource.
-
#view_attribute(prop, model_name, *args) ⇒ Object
Returns a scaffolded attribute.
Instance Method Details
#form_link(text, link, confirm = false, opts = {}) ⇒ Object
Creates a button that appears to be a link but does form submission with custom method (_method param in POST) This is to avoid issues of a destructive get.
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/orange-core/resources/scaffold.rb', line 105 def form_link(text, link, confirm = false, opts = {}) text = "<img src='#{opts[:img]}' alt='#{text}' />" if opts[:img] css = opts[:class]? opts[:class] : 'form_button_link' meth = (opts[:method]? "<input type='hidden' name='_method' value='#{opts[:method]}' />" : '') if confirm "<form action='#{link}' method='post' class='mini' onsubmit='return confirm(\"#{confirm}\")'><button class='link_button'><a href='#' class='#{css}'>#{text}</a></button>#{meth}</form>" else "<form action='#{link}' method='post' class='mini'><button class='link_button'><a href='#' class='#{css}'>#{text}</a></button>#{meth}</form>" end end |
#view(model_name, *args) ⇒ Object
Calls view for an orange resource.
117 118 119 |
# File 'lib/orange-core/resources/scaffold.rb', line 117 def view(model_name, *args) orange[model_name].view(self, *args) end |
#view_attribute(prop, model_name, *args) ⇒ Object
Returns a scaffolded attribute
122 123 124 |
# File 'lib/orange-core/resources/scaffold.rb', line 122 def view_attribute(prop, model_name, *args) orange[:scaffold].scaffold_attribute(self, prop, model_name, *args) end |