Module: GakuHelpers::ViewHelpers::LinkHelper

Defined in:
lib/gaku_helpers/view_helpers/link_helper.rb

Instance Method Summary collapse

Instance Method Details



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, options = {})
  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(options)

  link_to name, resource, attributes
end


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, options = {})
  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(options)
  link_to name, resource, attributes
end


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, options = {})
  name = ("<i class='icon-white icon-pencil'></i>").html_safe
  attributes = {
    :remote => true,
    :class => "mr-xs btn btn-mini btn-warning edit-link"
  }.merge(options)
  link_to name, resource, attributes
end


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, options = {})
  attributes = {
    :remote => true,
    :method => :post,
    :data => { :confirm => t(:'gaku_helpers.are_you_sure') },
  }.merge(options)
  link_to primary_checkbox, resource, attributes
end

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, options = {})
  name = ("<i class='icon-white icon-plus'></i> " + text).html_safe
  attributes = {
    :remote => true,
    :class => "btn btn-primary mr-s"
  }.merge(options)
  link_to name, resource, attributes
end


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, options = {})
  name = (:i, nil, :class => 'icon-white icon-repeat')
  attributes = {
    :remote => true,
    :class => "mr-xs btn btn-mini btn-warning recovery-link"
  }.merge(options)
  link_to name, resource, attributes
end


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, options = {})
  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(options)
  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, options = {})
  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(options)
  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 button(text, resource, options = {})
  attributes = {:class => "btn mr-s"}.merge(options)
  link_to text, resource, attributes
end


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


215
216
217
218
219
220
221
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 215

def link_to_back(resource, options = {})
  name = ('<i class="icon-share-alt"></i> '+ t(:'gaku_helpers.back')).html_safe
  attributes = {
    :class => 'span6 btn back-link'
  }.merge(options)
  link_to name, resource, attributes
end


187
188
189
190
191
192
193
194
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 187

def link_to_cancel(options = {})
  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(options)
  link_to text, '#', attributes
end


86
87
88
89
90
91
92
93
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 86

def link_to_delete(resource, options = {})
  name = ("<i class='icon-white icon-remove'></i>").html_safe
  attributes = {
    :method => :delete,
    :class => 'btn btn-mini btn-danger delete-link'
  }.merge(options)
  link_to name, resource, attributes
end

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, options = {})
  name = ("<i class='icon-white icon-edit'></i>").html_safe
  attributes = {
    :class => "mr-xs btn btn-mini btn-inverse edit-link",
  }.merge(options)
  link_to name, resource, attributes
end


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, options = {})
  name = ('<i class="icon-pencil"></i> '+ text).html_safe
  attributes = {:class => "span12 btn edit-link"}.merge(options)
  link_to name, resource, attributes
end

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, options = {})
  name = ('<i class="icon-pencil"></i> '+t(:'gaku_helpers.edit')).html_safe
  attributes = {:class => "span12 btn edit-link"}.merge(options)
  link_to name, resource, attributes
end


48
49
50
51
52
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 48

def link_to_export(text, resource, options = {})
  name = ('<i class="icon-download"></i> '+ text).html_safe
  attributes = {:class => 'mr-s btn'}.merge(options)
  link_to name, resource, attributes
end


24
25
26
27
28
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 24

def link_to_file(text, resource, options = {})
  name = ("<i class='icon-white icon-file'></i> " + text).html_safe
  attributes = {:class => "btn btn-primary"}.merge(options)
  link_to name, resource, attributes
end


42
43
44
45
46
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 42

def link_to_import(text, resource, options = {})
  name = ('<i class="icon-upload"></i> '+ text).html_safe
  attributes = {:class => 'mr-s btn'}.merge(options)
  link_to name, resource, attributes
end


196
197
198
199
200
201
202
203
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 196

def link_to_modal_cancel(options = {})
  name = t(:'gaku_helpers.cancel')
  attributes = {
    :class => "span6 btn btn-warning modal-cancel-link",
    :'data-dismiss' => "modal"
  }.merge(options)
  link_to name, '#', attributes
end


106
107
108
109
110
111
112
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 106

def link_to_modal_delete(resource, options = {})
  name = ("<i class='icon-white icon-trash'></i>").html_safe
  attributes = {
    :class => 'btn btn-danger modal-delete-link span12'
  }.merge(options)
  link_to name, resource, attributes
end

needs id



65
66
67
68
69
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 65

def link_to_new(text, resource, options = {})
  name = ("<i class='icon-white icon-plus'></i> " + text).html_safe
  attributes = {:class => "btn btn-primary"}.merge(options)
  link_to name, resource, attributes
end


179
180
181
182
183
184
185
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 179

def link_to_show(resource, options = {})
  name = ("<i class='icon-white icon-eye-open'></i>").html_safe
  attributes = {
    :class => "mr-xs btn btn-mini btn-info show-link"
  }.merge(options)
  link_to name, resource, attributes
end


36
37
38
39
40
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 36

def link_to_upload(options = {})
  text = ("<i class='icon-upload'></i> " + t(:'gaku_helpers.picture.upload')).html_safe
  attributes = {:class => "btn span12 mr-s"}.merge(options)
  button_tag(('span', text), attributes)
end


30
31
32
33
34
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 30

def link_to_upload_image(resource, options = {})
  name = ("<i class='icon-camera'></i> " + t(:'gaku_helpers.picture.change')).html_safe
  attributes = {:class => "btn span12 mr-s"}.merge(options)
  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 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 = {}) ⇒ Object



19
20
21
22
# File 'lib/gaku_helpers/view_helpers/link_helper.rb', line 19

def primary_button(text, resource, options = {})
  attributes = {:class => "btn btn-primary mr-s"}.merge(options)
  link_to text, resource, attributes
end

#primary_checkboxObject



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 submit_button(text, options={})
  attributes = {:type => 'submit'}.merge(options)
  button_tag(('span', text), attributes)
end