module PhantomHelpers::ViewHelpers::LinkHelper

Public Instance Methods

ajax_soft_delete(resource, options = {}) click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 147
def ajax_soft_delete(resource, options = {})
  name = ("<span class='glyphicon glyphicon-remove'></span>").html_safe
  attributes = {
    :remote => true,
    :method => :patch,
    :data => { :confirm => t(:'phantom_helpers.are_you_sure') },
    :class => 'btn btn-xs btn-danger delete-link'
  }.merge(options)
  link_to name, resource, attributes
end
button(text, resource, options = {}) click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 14
def button(text, resource, options = {})
  attributes = {:class => "btn btn-default"}.merge(options)
  link_to text, resource, attributes
end
manage_buttons_for(resource, options = {}) click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 280
def manage_buttons_for(resource, options = {})
  id = extract_id(resource)
  concat link_to_show(resource, :id => "show-#{id}-link") unless except?(:show, options)
  concat link_to_edit [:edit] + [resource].flatten, :id => "edit-#{id}-link", :remote => true unless except?(:edit, options)
  ajax_link_to_delete resource, :id => "delete-#{id}-link" unless except?(:delete, options)
end
primary_button(text, resource, options = {}) click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 19
def primary_button(text, resource, options = {})
  attributes = {:class => "btn btn-primary"}.merge(options)
  link_to text, resource, attributes
end
primary_checkbox() click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 158
def primary_checkbox
  ("<span class='glyphicon glyphicon-ok'></span>").html_safe
end
submit_button(text, options={}) click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 271
def submit_button(text, options={})
  text = ('<span class="glyphicon glyphicon-ok-circle"></span> '+ text).html_safe
  attributes = {
    :type => 'submit',
    :class => 'col-xs-12 btn btn-success button'
  }.merge(options)
  button_tag(content_tag('span', text), attributes)
end

Private Instance Methods

except?(button_symbol, options) click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 289
def except?(button_symbol, options)
  [options[:except]].flatten.include?(button_symbol)
end
extract_id(resource) click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 293
def extract_id(resource)
  if resource.kind_of?(Array)
    resource_id = String.new
    resource.each_with_index do |r, index|
      resource_id << '-' unless index == 0
      resource_id << proper_id(r)
    end
    resource_id
  else
    proper_id(resource)
  end
end
proper_id(resource) click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 306
def proper_id(resource)
  resource.class.to_s.underscore.split('/')[1].dasherize
end