# 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
module PhantomHelpers::ViewHelpers::LinkHelper
Public Instance Methods
ajax_link_to_back(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 237 def ajax_link_to_back(resource, options = {}) name = ('<span class="glyphicon glyphicon-share-alt"></span> ' + t(:'phantom_helpers.back')).html_safe attributes = { :class => "col-xs-12 btn btn-warning back-link back-modal-link", :remote => true }.merge(options) link_to name, resource, attributes end
ajax_link_to_delete(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 127 def ajax_link_to_delete(resource, options = {}) name = ("<span class='glyphicon glyphicon-remove'></span>").html_safe attributes = { :remote => true, :method => :delete, :data => { :confirm => t(:'phantom_helpers.are_you_sure') }, :class => 'btn btn-xs btn-danger delete-link' }.merge(options) link_to name, resource, attributes end
ajax_link_to_edit(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 171 def ajax_link_to_edit(resource, options = {}) name = ("<span class='glyphicon glyphicon-pencil'></span>").html_safe attributes = { :remote => true, :class => "btn btn-xs btn-warning js-edit-link" }.merge(options) link_to name, resource, attributes end
ajax_link_to_make_primary(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 162 def ajax_link_to_make_primary(resource, options = {}) attributes = { :remote => true, :method => :post, :data => { :confirm => t(:'phantom_helpers.are_you_sure') }, }.merge(options) link_to primary_checkbox, resource, attributes end
ajax_link_to_new(text, resource, options = {})
click to toggle source
needs id, because it is unique
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 63 def ajax_link_to_new(text, resource, options = {}) name = ("<span class='glyphicon glyphicon-plus'></span> " + text).html_safe attributes = { :remote => true, :class => "btn btn-primary" }.merge(options) link_to name, resource, attributes end
ajax_link_to_recovery(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 80 def ajax_link_to_recovery(resource, options = {}) name = content_tag(:span, nil, class: 'glyphicon glyphicon-repeat') attributes = { remote: true, class: "btn btn-xs btn-success recovery-link" }.merge(options) link_to name, resource, attributes end
ajax_link_to_restore(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 89 def ajax_link_to_restore(resource, options = {}) name = content_tag(:span, nil, class: 'glyphicon glyphicon-repeat') attributes = { remote: true, method: :patch, class: "btn btn-xs btn-success recovery-link" }.merge(options) link_to name, resource, attributes end
ajax_link_to_show(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 202 def ajax_link_to_show(resource, options = {}) name = ("<span class='glyphicon glyphicon-eye-open'></span>").html_safe attributes = { :remote => true, :class => "btn btn-xs btn-info show-link" }.merge(options) link_to name, resource, attributes end
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
link_to_add_fields(name, f, association)
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 5 def link_to_add_fields(name, f, association) new_object = f.object.send(association).klass.new id = new_object.object_id fields = f.fields_for(association, new_object, child_index: id) do |builder| render(association.to_s.singularize + "_fields", f: builder) end link_to(("<span class='glyphicon glyphicon-plus glyphicon-white'></span> " + name).html_safe, '#', :class => "btn btn-primary add_fields", data: {id: id, fields: fields.gsub("\n", "")}) end
link_to_back(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 247 def link_to_back(resource, options = {}) name = ('<span class="glyphicon glyphicon-share-alt"></span> '+ t(:'phantom_helpers.back')).html_safe attributes = { :class => 'col-xs-12 btn btn-default back-link' }.merge(options) link_to name, resource, attributes end
link_to_cancel(options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 219 def link_to_cancel(options = {}) text = ('<span class="glyphicon glyphicon-ban-circle"></span> '+ t(:'phantom_helpers.cancel')).html_safe attributes = { :class => "col-xs-12 btn btn-warning cancel-link", :'data-dismiss' => "modal" }.merge(options) link_to text, '#', attributes end
link_to_delete(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 99 def link_to_delete(resource, options = {}) name = ("<span class='glyphicon glyphicon-remove'></span>").html_safe attributes = { :method => :delete, :class => 'btn btn-xs btn-danger delete-link' }.merge(options) link_to name, resource, attributes end
link_to_delete_with_text(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 108 def link_to_delete_with_text(resource, options = {}) attributes = { :method => :delete, :data => {confirm: t(:'phantom_helpers.confirm_delete')}, :class => 'btn btn-danger' }.merge(options) link_to t(:'phantom_helpers.delete'), resource, attributes end
link_to_download(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 30 def link_to_download(resource, options = {}) name = content_tag(:span, nil, class: 'glyphicon glyphicon-download') attributes = { class: "btn btn-xs btn-success download-link" }.merge(options) link_to name, resource, attributes end
link_to_edit(resource, options = {})
click to toggle source
Edit button with only pencil image - without text
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 181 def link_to_edit(resource, options = {}) name = ("<span class='glyphicon glyphicon-edit'></span>").html_safe attributes = { :class => "btn btn-xs btn-inverse edit-link", }.merge(options) link_to name, resource, attributes end
link_to_edit_with_custom_text(text, resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 196 def link_to_edit_with_custom_text(text, resource, options = {}) name = ('<span class="glyphicon glyphicon-pencil"></span> '+ text).html_safe attributes = {:class => "col-xs-12 btn btn-warning edit-link"}.merge(options) link_to name, resource, attributes end
link_to_edit_with_text(resource, options = {})
click to toggle source
Edit button with text “Edit” and pencil image
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 190 def link_to_edit_with_text(resource, options = {}) name = ('<span class="glyphicon glyphicon-pencil"></span> '+t(:'phantom_helpers.edit')).html_safe attributes = {:class => "col-xs-12 btn btn-warning edit-link"}.merge(options) link_to name, resource, attributes end
link_to_export(text, resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 56 def link_to_export(text, resource, options = {}) name = ('<span class="glyphicon glyphicon-download"></span> '+ text).html_safe attributes = {:class => 'btn btn-default'}.merge(options) link_to name, resource, attributes end
link_to_file(text, resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 24 def link_to_file(text, resource, options = {}) name = ("<span class='glyphicon glyphicon-file'></span> " + text).html_safe attributes = {:class => "btn btn-primary"}.merge(options) link_to name, resource, attributes end
link_to_import(text, resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 50 def link_to_import(text, resource, options = {}) name = ('<span class="glyphicon glyphicon-upload"></span> '+ text).html_safe attributes = {:class => 'btn btn-default'}.merge(options) link_to name, resource, attributes end
link_to_index(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 255 def link_to_index(resource, options = {}) name = ('<span class="glyphicon glyphicon-share-alt"></span> '+ t(:'phantom_helpers.index')).html_safe attributes = { :class => 'col-xs-12 btn btn-default index-link' }.merge(options) link_to name, resource, attributes end
link_to_modal_cancel(options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 228 def link_to_modal_cancel(options = {}) name = t(:'phantom_helpers.cancel') attributes = { :class => "col-xs-12 btn btn-warning modal-cancel-link", :'data-dismiss' => "modal" }.merge(options) link_to name, '#', attributes end
link_to_modal_delete(options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 138 def link_to_modal_delete(options = {}) name = ("<span class='glyphicon glyphicon-trash'></span>").html_safe attributes = { :class => 'btn btn-danger modal-delete-link col-xs-12', :data => {:confirm => nil} }.merge(options) link_to name, nil, attributes end
link_to_new(text, resource, options = {})
click to toggle source
needs id
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 73 def link_to_new(text, resource, options = {}) name = ("<span class='glyphicon glyphicon-plus'></span> " + text).html_safe attributes = {:class => "btn btn-primary"}.merge(options) link_to name, resource, attributes end
link_to_report(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 263 def link_to_report(resource, options = {}) name = ('<span class="glyphicon glyphicon-download-alt"></span> '+ t(:'phantom_helpers.report')).html_safe attributes = { :class => 'col-xs-12 btn btn-default report-link' }.merge(options) link_to name, resource, attributes end
link_to_show(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 211 def link_to_show(resource, options = {}) name = ("<span class='glyphicon glyphicon-eye-open'></span>").html_safe attributes = { :class => "btn btn-xs btn-info show-link" }.merge(options) link_to name, resource, attributes end
link_to_soft_delete_with_text(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 118 def link_to_soft_delete_with_text(resource, options = {}) attributes = { :method => :patch, :data => {confirm: t(:'phantom_helpers.confirm_delete')}, :class => 'btn btn-danger' }.merge(options) link_to t(:'phantom_helpers.delete'), resource, attributes end
link_to_upload(options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 44 def link_to_upload(options = {}) text = ("<span class='glyphicon glyphicon-upload'></span> " + t(:'phantom_helpers.picture.upload')).html_safe attributes = {:class => "btn btn-default"}.merge(options) button_tag(content_tag('span', text), attributes) end
link_to_upload_image(resource, options = {})
click to toggle source
# File lib/phantom_helpers/view_helpers/link_helper.rb, line 38 def link_to_upload_image(resource, options = {}) name = ("<span class='glyphicon glyphicon-camera'></span> " + t(:'phantom_helpers.picture.change')).html_safe attributes = {:class => "btn btn-default col-xs-12"}.merge(options) link_to name, 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
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