Module: PhantomHelpers::ViewHelpers::LinkHelper
- Defined in:
- lib/phantom_helpers/view_helpers/link_helper.rb
Instance Method Summary collapse
- #ajax_link_to_back(resource, options = {}) ⇒ Object
- #ajax_link_to_delete(resource, options = {}) ⇒ Object
- #ajax_link_to_edit(resource, options = {}) ⇒ Object
- #ajax_link_to_make_primary(resource, options = {}) ⇒ Object
-
#ajax_link_to_new(text, resource, options = {}) ⇒ Object
needs id, because it is unique.
- #ajax_link_to_recovery(resource, options = {}) ⇒ Object
- #ajax_link_to_restore(resource, options = {}) ⇒ Object
- #ajax_link_to_show(resource, options = {}) ⇒ Object
- #ajax_soft_delete(resource, options = {}) ⇒ Object
- #button(text, resource, options = {}) ⇒ Object
- #link_to_add_fields(name, f, association) ⇒ Object
- #link_to_back(resource, options = {}) ⇒ Object
- #link_to_cancel(options = {}) ⇒ Object
- #link_to_delete(resource, options = {}) ⇒ Object
- #link_to_delete_with_text(resource, options = {}) ⇒ Object
- #link_to_download(resource, options = {}) ⇒ Object
-
#link_to_edit(resource, options = {}) ⇒ Object
Edit button with only pencil image - without text.
- #link_to_edit_with_custom_text(text, resource, options = {}) ⇒ Object
-
#link_to_edit_with_text(resource, options = {}) ⇒ Object
Edit button with text "Edit" and pencil image.
- #link_to_export(text, resource, options = {}) ⇒ Object
- #link_to_file(text, resource, options = {}) ⇒ Object
- #link_to_import(text, resource, options = {}) ⇒ Object
- #link_to_index(resource, options = {}) ⇒ Object
- #link_to_modal_cancel(options = {}) ⇒ Object
- #link_to_modal_delete(options = {}) ⇒ Object
-
#link_to_new(text, resource, options = {}) ⇒ Object
needs id.
- #link_to_report(resource, options = {}) ⇒ Object
- #link_to_show(resource, options = {}) ⇒ Object
- #link_to_soft_delete_with_text(resource, options = {}) ⇒ Object
- #link_to_upload(options = {}) ⇒ Object
- #link_to_upload_image(resource, options = {}) ⇒ Object
- #manage_buttons_for(resource, options = {}) ⇒ Object
- #primary_button(text, resource, options = {}) ⇒ Object
- #primary_checkbox ⇒ Object
- #submit_button(text, options = {}) ⇒ Object
Instance Method Details
#ajax_link_to_back(resource, options = {}) ⇒ Object
237 238 239 240 241 242 243 244 245 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 237 def ajax_link_to_back(resource, = {}) 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() link_to name, resource, attributes end |
#ajax_link_to_delete(resource, options = {}) ⇒ Object
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 127 def ajax_link_to_delete(resource, = {}) 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() link_to name, resource, attributes end |
#ajax_link_to_edit(resource, options = {}) ⇒ Object
171 172 173 174 175 176 177 178 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 171 def ajax_link_to_edit(resource, = {}) name = ("<span class='glyphicon glyphicon-pencil'></span>").html_safe attributes = { :remote => true, :class => "btn btn-xs btn-warning js-edit-link" }.merge() link_to name, resource, attributes end |
#ajax_link_to_make_primary(resource, options = {}) ⇒ Object
162 163 164 165 166 167 168 169 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 162 def ajax_link_to_make_primary(resource, = {}) attributes = { :remote => true, :method => :post, :data => { :confirm => t(:'phantom_helpers.are_you_sure') }, }.merge() link_to primary_checkbox, resource, attributes end |
#ajax_link_to_new(text, resource, options = {}) ⇒ Object
needs id, because it is unique
63 64 65 66 67 68 69 70 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 63 def ajax_link_to_new(text, resource, = {}) name = ("<span class='glyphicon glyphicon-plus'></span> " + text).html_safe attributes = { :remote => true, :class => "btn btn-primary" }.merge() link_to name, resource, attributes end |
#ajax_link_to_recovery(resource, options = {}) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 80 def ajax_link_to_recovery(resource, = {}) name = content_tag(:span, nil, class: 'glyphicon glyphicon-repeat') attributes = { remote: true, class: "btn btn-xs btn-success recovery-link" }.merge() link_to name, resource, attributes end |
#ajax_link_to_restore(resource, options = {}) ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 89 def ajax_link_to_restore(resource, = {}) name = content_tag(:span, nil, class: 'glyphicon glyphicon-repeat') attributes = { remote: true, method: :patch, class: "btn btn-xs btn-success recovery-link" }.merge() link_to name, resource, attributes end |
#ajax_link_to_show(resource, options = {}) ⇒ Object
202 203 204 205 206 207 208 209 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 202 def ajax_link_to_show(resource, = {}) name = ("<span class='glyphicon glyphicon-eye-open'></span>").html_safe attributes = { :remote => true, :class => "btn btn-xs btn-info show-link" }.merge() link_to name, resource, attributes end |
#ajax_soft_delete(resource, options = {}) ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 147 def ajax_soft_delete(resource, = {}) 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() link_to name, resource, attributes end |
#button(text, resource, options = {}) ⇒ Object
14 15 16 17 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 14 def (text, resource, = {}) attributes = {:class => "btn btn-default"}.merge() link_to text, resource, attributes end |
#link_to_add_fields(name, f, association) ⇒ Object
5 6 7 8 9 10 11 12 |
# 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 = {}) ⇒ Object
247 248 249 250 251 252 253 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 247 def link_to_back(resource, = {}) 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() link_to name, resource, attributes end |
#link_to_cancel(options = {}) ⇒ Object
219 220 221 222 223 224 225 226 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 219 def link_to_cancel( = {}) 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() link_to text, '#', attributes end |
#link_to_delete(resource, options = {}) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 99 def link_to_delete(resource, = {}) name = ("<span class='glyphicon glyphicon-remove'></span>").html_safe attributes = { :method => :delete, :class => 'btn btn-xs btn-danger delete-link' }.merge() link_to name, resource, attributes end |
#link_to_delete_with_text(resource, options = {}) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 108 def link_to_delete_with_text(resource, = {}) attributes = { :method => :delete, :data => {confirm: t(:'phantom_helpers.confirm_delete')}, :class => 'btn btn-danger' }.merge() link_to t(:'phantom_helpers.delete'), resource, attributes end |
#link_to_download(resource, options = {}) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 30 def link_to_download(resource, = {}) name = content_tag(:span, nil, class: 'glyphicon glyphicon-download') attributes = { class: "btn btn-xs btn-success download-link" }.merge() link_to name, resource, attributes end |
#link_to_edit(resource, options = {}) ⇒ Object
Edit button with only pencil image - without text
181 182 183 184 185 186 187 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 181 def link_to_edit(resource, = {}) name = ("<span class='glyphicon glyphicon-edit'></span>").html_safe attributes = { :class => "btn btn-xs btn-inverse edit-link", }.merge() link_to name, resource, attributes end |
#link_to_edit_with_custom_text(text, resource, options = {}) ⇒ Object
196 197 198 199 200 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 196 def link_to_edit_with_custom_text(text, resource, = {}) name = ('<span class="glyphicon glyphicon-pencil"></span> '+ text).html_safe attributes = {:class => "col-xs-12 btn btn-warning edit-link"}.merge() link_to name, resource, attributes end |
#link_to_edit_with_text(resource, options = {}) ⇒ Object
Edit button with text "Edit" and pencil image
190 191 192 193 194 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 190 def link_to_edit_with_text(resource, = {}) name = ('<span class="glyphicon glyphicon-pencil"></span> '+t(:'phantom_helpers.edit')).html_safe attributes = {:class => "col-xs-12 btn btn-warning edit-link"}.merge() link_to name, resource, attributes end |
#link_to_export(text, resource, options = {}) ⇒ Object
56 57 58 59 60 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 56 def link_to_export(text, resource, = {}) name = ('<span class="glyphicon glyphicon-download"></span> '+ text).html_safe attributes = {:class => 'btn btn-default'}.merge() link_to name, resource, attributes end |
#link_to_file(text, resource, options = {}) ⇒ Object
24 25 26 27 28 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 24 def link_to_file(text, resource, = {}) name = ("<span class='glyphicon glyphicon-file'></span> " + text).html_safe attributes = {:class => "btn btn-primary"}.merge() link_to name, resource, attributes end |
#link_to_import(text, resource, options = {}) ⇒ Object
50 51 52 53 54 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 50 def link_to_import(text, resource, = {}) name = ('<span class="glyphicon glyphicon-upload"></span> '+ text).html_safe attributes = {:class => 'btn btn-default'}.merge() link_to name, resource, attributes end |
#link_to_index(resource, options = {}) ⇒ Object
255 256 257 258 259 260 261 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 255 def link_to_index(resource, = {}) 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() link_to name, resource, attributes end |
#link_to_modal_cancel(options = {}) ⇒ Object
228 229 230 231 232 233 234 235 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 228 def link_to_modal_cancel( = {}) name = t(:'phantom_helpers.cancel') attributes = { :class => "col-xs-12 btn btn-warning modal-cancel-link", :'data-dismiss' => "modal" }.merge() link_to name, '#', attributes end |
#link_to_modal_delete(options = {}) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 138 def link_to_modal_delete( = {}) name = ("<span class='glyphicon glyphicon-trash'></span>").html_safe attributes = { :class => 'btn btn-danger modal-delete-link col-xs-12', :data => {:confirm => nil} }.merge() link_to name, nil, attributes end |
#link_to_new(text, resource, options = {}) ⇒ Object
needs id
73 74 75 76 77 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 73 def link_to_new(text, resource, = {}) name = ("<span class='glyphicon glyphicon-plus'></span> " + text).html_safe attributes = {:class => "btn btn-primary"}.merge() link_to name, resource, attributes end |
#link_to_report(resource, options = {}) ⇒ Object
263 264 265 266 267 268 269 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 263 def link_to_report(resource, = {}) 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() link_to name, resource, attributes end |
#link_to_show(resource, options = {}) ⇒ Object
211 212 213 214 215 216 217 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 211 def link_to_show(resource, = {}) name = ("<span class='glyphicon glyphicon-eye-open'></span>").html_safe attributes = { :class => "btn btn-xs btn-info show-link" }.merge() link_to name, resource, attributes end |
#link_to_soft_delete_with_text(resource, options = {}) ⇒ Object
118 119 120 121 122 123 124 125 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 118 def link_to_soft_delete_with_text(resource, = {}) attributes = { :method => :patch, :data => {confirm: t(:'phantom_helpers.confirm_delete')}, :class => 'btn btn-danger' }.merge() link_to t(:'phantom_helpers.delete'), resource, attributes end |
#link_to_upload(options = {}) ⇒ Object
44 45 46 47 48 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 44 def link_to_upload( = {}) text = ("<span class='glyphicon glyphicon-upload'></span> " + t(:'phantom_helpers.picture.upload')).html_safe attributes = {:class => "btn btn-default"}.merge() (content_tag('span', text), attributes) end |
#link_to_upload_image(resource, options = {}) ⇒ Object
38 39 40 41 42 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 38 def link_to_upload_image(resource, = {}) name = ("<span class='glyphicon glyphicon-camera'></span> " + t(:'phantom_helpers.picture.change')).html_safe attributes = {:class => "btn btn-default col-xs-12"}.merge() link_to name, resource, attributes end |
#manage_buttons_for(resource, options = {}) ⇒ Object
280 281 282 283 284 285 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 280 def (resource, = {}) id = extract_id(resource) concat link_to_show(resource, :id => "show-#{id}-link") unless except?(:show, ) concat link_to_edit [:edit] + [resource].flatten, :id => "edit-#{id}-link", :remote => true unless except?(:edit, ) ajax_link_to_delete resource, :id => "delete-#{id}-link" unless except?(:delete, ) end |
#primary_button(text, resource, options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 19 def (text, resource, = {}) attributes = {:class => "btn btn-primary"}.merge() link_to text, resource, attributes end |
#primary_checkbox ⇒ Object
158 159 160 |
# 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 = {}) ⇒ Object
271 272 273 274 275 276 277 278 |
# File 'lib/phantom_helpers/view_helpers/link_helper.rb', line 271 def (text, ={}) text = ('<span class="glyphicon glyphicon-ok-circle"></span> '+ text).html_safe attributes = { :type => 'submit', :class => 'col-xs-12 btn btn-success button' }.merge() (content_tag('span', text), attributes) end |