2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-12-09 00:34:51 -05:00
|
|
|
module BroadcastMessagesHelper
|
2017-06-15 09:47:33 -04:00
|
|
|
def broadcast_message(message)
|
2015-12-31 16:42:56 -05:00
|
|
|
return unless message.present?
|
|
|
|
|
2019-04-25 07:40:34 -04:00
|
|
|
content_tag :div, dir: 'auto', class: 'broadcast-message', style: broadcast_message_style(message) do
|
2016-10-06 18:01:42 -04:00
|
|
|
icon('bullhorn') << ' ' << render_broadcast_message(message)
|
2015-12-31 16:42:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def broadcast_message_style(broadcast_message)
|
2018-08-18 07:19:57 -04:00
|
|
|
style = []
|
2015-05-21 17:49:06 -04:00
|
|
|
|
|
|
|
if broadcast_message.color.present?
|
2015-12-31 16:42:56 -05:00
|
|
|
style << "background-color: #{broadcast_message.color}"
|
2013-12-09 00:34:51 -05:00
|
|
|
end
|
2015-05-21 17:49:06 -04:00
|
|
|
|
|
|
|
if broadcast_message.font.present?
|
2015-12-31 16:42:56 -05:00
|
|
|
style << "color: #{broadcast_message.font}"
|
2015-05-21 17:49:06 -04:00
|
|
|
end
|
|
|
|
|
2018-08-18 07:19:57 -04:00
|
|
|
style.join('; ')
|
2013-12-09 00:34:51 -05:00
|
|
|
end
|
2016-01-13 11:46:32 -05:00
|
|
|
|
|
|
|
def broadcast_message_status(broadcast_message)
|
|
|
|
if broadcast_message.active?
|
|
|
|
'Active'
|
|
|
|
elsif broadcast_message.ended?
|
|
|
|
'Expired'
|
|
|
|
else
|
|
|
|
'Pending'
|
|
|
|
end
|
|
|
|
end
|
2016-02-03 23:01:04 -05:00
|
|
|
|
2016-10-06 18:01:42 -04:00
|
|
|
def render_broadcast_message(broadcast_message)
|
|
|
|
Banzai.render_field(broadcast_message, :message).html_safe
|
2016-02-03 23:01:04 -05:00
|
|
|
end
|
2013-12-09 00:34:51 -05:00
|
|
|
end
|