2011-03-09 13:13:36 +00:00
|
|
|
|
module ApplicationHelper
|
2015-02-09 22:14:11 +00:00
|
|
|
|
|
|
|
|
|
def submit_button_tag(icon_class: 'fa-check', text: nil)
|
|
|
|
|
text ||= I18n.t('layout.save')
|
|
|
|
|
button_tag type: :submit,
|
|
|
|
|
data: {'disable-with' => I18n.t('layout.processing')},
|
|
|
|
|
class: 'btn btn-primary' do
|
|
|
|
|
content_tag(:i, nil, class: ['fa', icon_class]) << ' '<< text
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2012-02-29 14:04:04 +00:00
|
|
|
|
def layout_class
|
|
|
|
|
case
|
2012-05-02 10:18:07 +01:00
|
|
|
|
when controller_name == 'issues' && action_name == 'new'
|
2012-03-01 17:33:46 +00:00
|
|
|
|
'right nopadding'
|
2012-05-02 10:18:07 +01:00
|
|
|
|
when controller_name == 'build_lists' && ['new', 'create'].include?(action_name)
|
2012-02-29 14:04:04 +00:00
|
|
|
|
nil
|
2012-05-25 16:56:26 +01:00
|
|
|
|
when controller_name == 'platforms' && ['build_all', 'mass_builds'].include?(action_name)
|
2012-05-28 11:28:19 +01:00
|
|
|
|
'right slim'
|
2012-05-02 10:18:07 +01:00
|
|
|
|
when controller_name == 'platforms' && action_name == 'show'
|
2012-03-11 23:08:50 +00:00
|
|
|
|
'right bigpadding'
|
2012-05-02 10:18:07 +01:00
|
|
|
|
when controller_name == 'platforms' && action_name == 'clone'
|
2012-03-13 15:05:33 +00:00
|
|
|
|
'right middlepadding'
|
2012-07-20 17:06:31 +01:00
|
|
|
|
when controller_name == 'contacts' && action_name == 'sended'
|
|
|
|
|
'all feedback_sended'
|
2012-03-01 17:33:46 +00:00
|
|
|
|
else
|
|
|
|
|
content_for?(:sidebar) ? 'right' : 'all'
|
2012-02-29 14:04:04 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
2012-03-29 19:34:45 +01:00
|
|
|
|
|
2012-05-05 17:15:49 +01:00
|
|
|
|
def top_menu_class(base)
|
|
|
|
|
(controller_name.include?('build_lists') ? controller_name : params[:controller]).include?(base.to_s) ? 'active' : nil
|
|
|
|
|
end
|
|
|
|
|
|
2015-02-07 00:37:52 +00:00
|
|
|
|
# Public: Get icon css class.
|
|
|
|
|
#
|
|
|
|
|
# base - the tab (Symbol).
|
|
|
|
|
#
|
|
|
|
|
# Returns String css class.
|
|
|
|
|
def top_menu_icon(base)
|
|
|
|
|
case base
|
|
|
|
|
when :platforms
|
|
|
|
|
'fa-linux'
|
|
|
|
|
when :projects
|
|
|
|
|
'fa-cube'
|
|
|
|
|
when :build_lists
|
|
|
|
|
'fa-cogs'
|
2016-06-15 19:22:50 +01:00
|
|
|
|
when :product_build_lists
|
|
|
|
|
'fa-product-hunt'
|
2015-02-07 00:37:52 +00:00
|
|
|
|
when :groups
|
|
|
|
|
'fa-users'
|
|
|
|
|
when :statistics
|
|
|
|
|
'fa-area-chart'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def title_object(object)
|
2012-03-30 13:30:39 +01:00
|
|
|
|
name = object.class == Group ? object.uname : object.name
|
|
|
|
|
object_name = t "activerecord.models.#{object.class.name.downcase}"
|
|
|
|
|
case object.class.name
|
2015-02-26 02:01:47 +00:00
|
|
|
|
when 'Project'
|
2012-03-30 13:30:39 +01:00
|
|
|
|
"#{object_name} #{object.owner.uname}/#{object.name}"
|
2015-02-26 02:01:47 +00:00
|
|
|
|
when 'Platform'
|
|
|
|
|
if object.main?
|
|
|
|
|
"#{object_name} #{object.name}"
|
|
|
|
|
else
|
|
|
|
|
"#{object_name} #{object.owner.uname}/#{object.name}"
|
|
|
|
|
end
|
2012-03-30 13:30:39 +01:00
|
|
|
|
when 'Repository', 'Product'
|
|
|
|
|
"#{object_name} #{object.name} - #{title_object object.platform}"
|
|
|
|
|
when 'Group'
|
|
|
|
|
"#{object_name} #{object.uname}"
|
|
|
|
|
else object.class.name
|
|
|
|
|
end
|
|
|
|
|
end
|
2012-08-29 15:58:58 +01:00
|
|
|
|
|
2012-09-24 18:34:14 +01:00
|
|
|
|
def local_alert(text, type = 'error')
|
|
|
|
|
html = "<div class='flash'><div class='alert #{type}'> #{text}"
|
2014-01-21 04:51:49 +00:00
|
|
|
|
html << link_to('×', '#', class: 'close close-alert', 'data-dismiss' => 'alert')
|
2012-09-24 18:34:14 +01:00
|
|
|
|
html << '</div></div>'
|
|
|
|
|
end
|
2013-08-22 14:55:44 +01:00
|
|
|
|
|
|
|
|
|
# Why 42? Because it is the Answer!
|
|
|
|
|
def short_message(message, length = 42)
|
2014-01-21 04:51:49 +00:00
|
|
|
|
truncate(message, length: length, omission: '…')
|
2013-08-22 14:55:44 +01:00
|
|
|
|
end
|
2013-09-01 13:06:42 +01:00
|
|
|
|
|
|
|
|
|
def datetime_moment(date, options = {})
|
|
|
|
|
tag = options[:tag] || :div
|
|
|
|
|
klass = "datetime_moment #{options[:class]}"
|
2014-12-11 17:39:13 +00:00
|
|
|
|
content_tag(tag, nil, class: klass, origin_datetime: date)
|
2013-09-01 13:06:42 +01:00
|
|
|
|
end
|
2014-07-09 12:56:21 +01:00
|
|
|
|
|
|
|
|
|
def alert_class(type)
|
2015-03-04 23:09:50 +00:00
|
|
|
|
case type
|
2014-10-27 20:14:49 +00:00
|
|
|
|
when 'error', 'alert'
|
2014-07-09 17:21:03 +01:00
|
|
|
|
'alert-danger'
|
|
|
|
|
when 'notice'
|
|
|
|
|
'alert-success'
|
|
|
|
|
else
|
|
|
|
|
"alert-#{type}"
|
|
|
|
|
end
|
2014-07-09 12:56:21 +01:00
|
|
|
|
end
|
2011-03-09 13:13:36 +00:00
|
|
|
|
end
|