Module: TwitterBuilderHelper
- Defined in:
- app/helpers/twitter_builder_helper.rb
Defined Under Namespace
Classes: ActionsColumnDefinition, ColumnDefinition, TableBuilder
Constant Summary
collapse
- ALIGN_CLASSES =
{left: 't-left', center: 't-center', right: 't-right'}
Instance Method Summary
collapse
Instance Method Details
#actions(&block) ⇒ Object
143
144
145
146
|
# File 'app/helpers/twitter_builder_helper.rb', line 143
def actions &block
content = capture(self, &block)
content_tag :div, content, class: 'well'
end
|
#back_action(name = I18n.t('admin.common.return'), path = back_uri) ⇒ Object
227
228
229
|
# File 'app/helpers/twitter_builder_helper.rb', line 227
def back_action name = I18n.t('admin.common.return'), path = back_uri
link_to name, path, class: 'btn btn-default'
end
|
#cancel_action(path, name = I18n.t('admin.common.cancel')) ⇒ Object
223
224
225
|
# File 'app/helpers/twitter_builder_helper.rb', line 223
def cancel_action path, name = I18n.t('admin.common.cancel')
link_to name, path, class: 'btn btn-default'
end
|
#create_link(path) ⇒ Object
203
204
205
206
|
# File 'app/helpers/twitter_builder_helper.rb', line 203
def create_link path
content = "<i class='glyphicon glyphicon-plus'></i> #{I18n.t('admin.common.new')}".html_safe
link_to content, path, class: 'btn btn-success'
end
|
#delete_link(path) ⇒ Object
218
219
220
221
|
# File 'app/helpers/twitter_builder_helper.rb', line 218
def delete_link path
content = "<i class='glyphicon glyphicon-trash'></i>".html_safe
link_to content, path, data: {confirm: I18n.t('admin.common.sure')}, method: :delete, class: 'btn btn-danger btn-xs', title: I18n.t('admin.common.delete')
end
|
#edit_link(path) ⇒ Object
213
214
215
216
|
# File 'app/helpers/twitter_builder_helper.rb', line 213
def edit_link path
content = "<i class='glyphicon glyphicon-pencil'></i>".html_safe
link_to content, path, class: 'btn btn-default btn-xs', title: I18n.t('admin.common.edit')
end
|
#field_set(title = nil, &block) ⇒ Object
137
138
139
140
141
|
# File 'app/helpers/twitter_builder_helper.rb', line 137
def field_set title = nil, &block
content = capture(self, &block)
content = content_tag(:legend, title) + content if title
content_tag :fieldset, content
end
|
#fixed_actions(&block) ⇒ Object
152
153
154
155
|
# File 'app/helpers/twitter_builder_helper.rb', line 152
def fixed_actions &block
panel_tag = actions(&block)
content_tag :div, panel_tag, class: 'action-bar'
end
|
#flash_alert_messages ⇒ Object
171
172
173
174
175
176
177
178
179
180
181
182
183
|
# File 'app/helpers/twitter_builder_helper.rb', line 171
def flash_alert_messages
r = if flash[:alert]
"<div class='row'>
<div class='col-md-8 col-md-offset-2'>
<div class='alert alert-danger'>
<button data-dismiss='alert' class='close' type='button'>×</button>
<p>#{h(flash[:alert])}</p>
</div>
</div>
</div>"
end
r && r.html_safe
end
|
#flash_messages ⇒ Object
199
200
201
|
# File 'app/helpers/twitter_builder_helper.rb', line 199
def flash_messages
[flash_warning_messages, flash_success_messages].compact.join.html_safe
end
|
#flash_success_messages ⇒ Object
185
186
187
188
189
190
191
192
193
194
195
196
197
|
# File 'app/helpers/twitter_builder_helper.rb', line 185
def flash_success_messages
r = if flash[:admin_success]
"<div class='row'>
<div class='col-md-8 col-md-offset-2'>
<div class='alert alert-success'>
<button data-dismiss='alert' class='close' type='button'>×</button>
<p>#{h(flash[:admin_success])}</p>
</div>
</div>
</div>"
end
r && r.html_safe
end
|
#flash_warning_messages ⇒ Object
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'app/helpers/twitter_builder_helper.rb', line 157
def flash_warning_messages
r = if flash[:admin_warning]
"<div class='row'>
<div class='col-md-8 col-md-offset-2'>
<div class='alert alert-danger'>
<button data-dismiss='alert' class='close' type='button'>×</button>
<p>#{h(flash[:admin_warning])}</p>
</div>
</div>
</div>"
end
r && r.html_safe
end
|
#sort_link(path) ⇒ Object
208
209
210
211
|
# File 'app/helpers/twitter_builder_helper.rb', line 208
def sort_link path
content = "<i class='glyphicon glyphicon-random'></i> #{I18n.t('admin.common.sort')}".html_safe
link_to content, path, class: 'btn btn-primary'
end
|
#standard_actions(form) ⇒ Object
148
149
150
|
# File 'app/helpers/twitter_builder_helper.rb', line 148
def standard_actions(form)
fixed_actions { form.save + form.apply + form.cancel }
end
|
#table_for(a_class) ⇒ Object
231
232
233
|
# File 'app/helpers/twitter_builder_helper.rb', line 231
def table_for a_class
TableBuilder.new(self, a_class)
end
|
#td_class(column) ⇒ Object
246
247
248
249
250
251
|
# File 'app/helpers/twitter_builder_helper.rb', line 246
def td_class(column)
klass = []
klass << column.col_class
klass << ALIGN_CLASSES[column.align] if column.align
klass.join(' ')
end
|
#th_class(column) ⇒ Object
235
236
237
238
239
240
|
# File 'app/helpers/twitter_builder_helper.rb', line 235
def th_class(column)
klass = []
klass << "col-xs-#{column.cols}" if column.cols
klass << ALIGN_CLASSES[column.align] if column.align
klass.join(' ')
end
|
#tr_class(row_class, item) ⇒ Object
242
243
244
|
# File 'app/helpers/twitter_builder_helper.rb', line 242
def tr_class(row_class, item)
row_class && row_class.call(item)
end
|
132
133
134
135
|
# File 'app/helpers/twitter_builder_helper.rb', line 132
def (name, *args, &block)
options = args.
form_for(name, *(args << options.deep_merge(builder: TwitterFormBuilder, html: {class: 'form-horizontal'})), &block)
end
|