Module: Zena::Use::Action::Common
- Included in:
- ControllerMethods, ViewMethods, ZafuMethods
- Defined in:
- lib/zena/use/action.rb
Instance Method Summary collapse
-
#node_action_link(action, node_zip, opts = {}) ⇒ Object
This method renders an action link without using Rails actions so that we can feed it with erb from Zafu.
Instance Method Details
#node_action_link(action, node_zip, opts = {}) ⇒ Object
This method renders an action link without using Rails actions so that we can feed it with erb from Zafu.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/zena/use/action.rb', line 8 def node_action_link(action, node_zip, opts={}) publish = opts[:publish] text = opts[:text].blank? ? _("btn_#{action}") : opts[:text] title = opts[:title] || _("btn_title_#{action}") query = publish ? ["?=#{publish}"] : [] if %w{edit drive add_doc}.include?(action) case action when 'edit' url = "/nodes/#{node_zip}/versions/0/edit" when 'drive' url = "/nodes/#{node_zip}/edit" when 'add_doc' url = "/documents/new" query << "parent_id=#{node_zip}" end id = "#{current_site.host.gsub('.', '_')}_#{node_zip}_#{action}" url = query.empty? ? url : "#{url}?#{query.join('&')}" tag = "<a href='#{url}' target='_blank' title='#{title}' onclick=\"Zena.open_window('#{url}', '#{id}', event);return false;\">" else query = query.empty? ? '' : "?#{query.join('&')}" tag = "<a href='/nodes/#{node_zip}/versions/0/#{action}#{query}' onclick='Zena.m(this, \"put\");return false;' title ='#{title}'>" end "#{tag}#{text}</a>" end |