Module: GakuHelpers::ViewHelpers::LinkHelper
- Defined in:
- lib/gaku_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_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_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_modal_cancel(options = {}) ⇒ Object
- #link_to_modal_delete(resource, options = {}) ⇒ Object
-
#link_to_new(text, resource, options = {}) ⇒ Object
needs id.
- #link_to_show(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
needs id.
Instance Method Details
#ajax_link_to_back(resource, options = {}) ⇒ Object
205 206 207 208 209 210 211 212 213 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 205 def ajax_link_to_back(resource, = {}) name = ('<i class="icon-white icon-share-alt"></i> ' + t(:'gaku_helpers.back')).html_safe attributes = { :class => "span6 btn btn-warning back-link back-modal-link", :remote => true }.merge() link_to name, resource, attributes end |
#ajax_link_to_delete(resource, options = {}) ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 95 def ajax_link_to_delete(resource, = {}) name = ("<i class='icon-white icon-remove'></i>").html_safe attributes = { :remote => true, :method => :delete, :data => { :confirm => t(:'gaku_helpers.are_you_sure') }, :class => 'btn btn-mini btn-danger delete-link' }.merge() link_to name, resource, attributes end |
#ajax_link_to_edit(resource, options = {}) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 138 def ajax_link_to_edit(resource, = {}) name = ("<i class='icon-white icon-pencil'></i>").html_safe attributes = { :remote => true, :class => "mr-xs btn btn-mini btn-warning edit-link" }.merge() link_to name, resource, attributes end |
#ajax_link_to_make_primary(resource, options = {}) ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 129 def ajax_link_to_make_primary(resource, = {}) attributes = { :remote => true, :method => :post, :data => { :confirm => t(:'gaku_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
55 56 57 58 59 60 61 62 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 55 def ajax_link_to_new(text, resource, = {}) name = ("<i class='icon-white icon-plus'></i> " + text).html_safe attributes = { :remote => true, :class => "btn btn-primary mr-s" }.merge() link_to name, resource, attributes end |
#ajax_link_to_recovery(resource, options = {}) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 77 def ajax_link_to_recovery(resource, = {}) name = content_tag(:i, nil, :class => 'icon-white icon-repeat') attributes = { :remote => true, :class => "mr-xs btn btn-mini btn-warning recovery-link" }.merge() link_to name, resource, attributes end |
#ajax_link_to_show(resource, options = {}) ⇒ Object
170 171 172 173 174 175 176 177 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 170 def ajax_link_to_show(resource, = {}) name = ("<i class='icon-white icon-eye-open'></i>").html_safe attributes = { :remote => true, :class => "mr-xs btn btn-mini btn-info show-link" }.merge() link_to name, resource, attributes end |
#ajax_soft_delete(resource, options = {}) ⇒ Object
114 115 116 117 118 119 120 121 122 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 114 def ajax_soft_delete(resource, = {}) name = ("<i class='icon-white icon-remove'></i>").html_safe attributes = { :remote => true, :data => { :confirm => t(:'gaku_helpers.are_you_sure') }, :class => 'btn btn-mini btn-danger delete-link' }.merge() link_to name, resource, attributes end |
#button(text, resource, options = {}) ⇒ Object
14 15 16 17 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 14 def (text, resource, = {}) attributes = {:class => "btn mr-s"}.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/gaku_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(("<i class='icon-plus icon-white'></i> " + name).html_safe, '#', :class => "btn btn-primary add_fields", data: {id: id, fields: fields.gsub("\n", "")}) end |
#link_to_back(resource, options = {}) ⇒ Object
215 216 217 218 219 220 221 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 215 def link_to_back(resource, = {}) name = ('<i class="icon-share-alt"></i> '+ t(:'gaku_helpers.back')).html_safe attributes = { :class => 'span6 btn back-link' }.merge() link_to name, resource, attributes end |
#link_to_cancel(options = {}) ⇒ Object
187 188 189 190 191 192 193 194 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 187 def link_to_cancel( = {}) text = ('<i class="icon-white icon-ban-circle"></i> '+ t(:'gaku_helpers.cancel')).html_safe attributes = { :class => "span6 btn btn-warning cancel-link", :'data-dismiss' => "modal" }.merge() link_to text, '#', attributes end |
#link_to_delete(resource, options = {}) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 86 def link_to_delete(resource, = {}) name = ("<i class='icon-white icon-remove'></i>").html_safe attributes = { :method => :delete, :class => 'btn btn-mini btn-danger delete-link' }.merge() link_to name, resource, attributes end |
#link_to_edit(resource, options = {}) ⇒ Object
Edit button with only pencil image - without text
149 150 151 152 153 154 155 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 149 def link_to_edit(resource, = {}) name = ("<i class='icon-white icon-edit'></i>").html_safe attributes = { :class => "mr-xs btn btn-mini btn-inverse edit-link", }.merge() link_to name, resource, attributes end |
#link_to_edit_with_custom_text(text, resource, options = {}) ⇒ Object
164 165 166 167 168 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 164 def link_to_edit_with_custom_text(text, resource, = {}) name = ('<i class="icon-pencil"></i> '+ text).html_safe attributes = {:class => "span12 btn 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
158 159 160 161 162 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 158 def link_to_edit_with_text(resource, = {}) name = ('<i class="icon-pencil"></i> '+t(:'gaku_helpers.edit')).html_safe attributes = {:class => "span12 btn edit-link"}.merge() link_to name, resource, attributes end |
#link_to_export(text, resource, options = {}) ⇒ Object
48 49 50 51 52 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 48 def link_to_export(text, resource, = {}) name = ('<i class="icon-download"></i> '+ text).html_safe attributes = {:class => 'mr-s btn'}.merge() link_to name, resource, attributes end |
#link_to_file(text, resource, options = {}) ⇒ Object
24 25 26 27 28 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 24 def link_to_file(text, resource, = {}) name = ("<i class='icon-white icon-file'></i> " + text).html_safe attributes = {:class => "btn btn-primary"}.merge() link_to name, resource, attributes end |
#link_to_import(text, resource, options = {}) ⇒ Object
42 43 44 45 46 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 42 def link_to_import(text, resource, = {}) name = ('<i class="icon-upload"></i> '+ text).html_safe attributes = {:class => 'mr-s btn'}.merge() link_to name, resource, attributes end |
#link_to_modal_cancel(options = {}) ⇒ Object
196 197 198 199 200 201 202 203 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 196 def link_to_modal_cancel( = {}) name = t(:'gaku_helpers.cancel') attributes = { :class => "span6 btn btn-warning modal-cancel-link", :'data-dismiss' => "modal" }.merge() link_to name, '#', attributes end |
#link_to_modal_delete(resource, options = {}) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 106 def link_to_modal_delete(resource, = {}) name = ("<i class='icon-white icon-trash'></i>").html_safe attributes = { :class => 'btn btn-danger modal-delete-link span12' }.merge() link_to name, resource, attributes end |
#link_to_new(text, resource, options = {}) ⇒ Object
needs id
65 66 67 68 69 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 65 def link_to_new(text, resource, = {}) name = ("<i class='icon-white icon-plus'></i> " + text).html_safe attributes = {:class => "btn btn-primary"}.merge() link_to name, resource, attributes end |
#link_to_show(resource, options = {}) ⇒ Object
179 180 181 182 183 184 185 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 179 def link_to_show(resource, = {}) name = ("<i class='icon-white icon-eye-open'></i>").html_safe attributes = { :class => "mr-xs btn btn-mini btn-info show-link" }.merge() link_to name, resource, attributes end |
#link_to_upload(options = {}) ⇒ Object
36 37 38 39 40 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 36 def link_to_upload( = {}) text = ("<i class='icon-upload'></i> " + t(:'gaku_helpers.picture.upload')).html_safe attributes = {:class => "btn span12 mr-s"}.merge() (content_tag('span', text), attributes) end |
#link_to_upload_image(resource, options = {}) ⇒ Object
30 31 32 33 34 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 30 def link_to_upload_image(resource, = {}) name = ("<i class='icon-camera'></i> " + t(:'gaku_helpers.picture.change')).html_safe attributes = {:class => "btn span12 mr-s"}.merge() link_to name, resource, attributes end |
#manage_buttons_for(resource, options = {}) ⇒ Object
232 233 234 235 236 237 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 232 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/gaku_helpers/view_helpers/link_helper.rb', line 19 def (text, resource, = {}) attributes = {:class => "btn btn-primary mr-s"}.merge() link_to text, resource, attributes end |
#primary_checkbox ⇒ Object
125 126 127 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 125 def primary_checkbox ("<i class='icon-white icon-ok'></i>").html_safe end |
#submit_button(text, options = {}) ⇒ Object
needs id
72 73 74 75 |
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 72 def (text, ={}) attributes = {:type => 'submit'}.merge() (content_tag('span', text), attributes) end |