debian-mirror-gitlab/app/helpers/broadcast_messages_helper.rb

55 lines
1.3 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
module BroadcastMessagesHelper
2020-03-09 13:42:32 +05:30
def current_broadcast_banner_messages
BroadcastMessage.current_banner_messages(request.path)
2020-01-01 13:55:28 +05:30
end
2020-03-09 13:42:32 +05:30
def current_broadcast_notification_message
not_hidden_messages = BroadcastMessage.current_notification_messages(request.path).select do |message|
cookies["hide_broadcast_notification_message_#{message.id}"].blank?
end
not_hidden_messages.last
end
def broadcast_message(message, opts = {})
return unless message.present?
2020-03-09 13:42:32 +05:30
render "shared/broadcast_message", { message: message, opts: opts }
end
def broadcast_message_style(broadcast_message)
2020-03-09 13:42:32 +05:30
return '' if broadcast_message.notification?
2018-12-05 23:21:45 +05:30
style = []
2015-09-11 14:41:01 +05:30
if broadcast_message.color.present?
style << "background-color: #{broadcast_message.color}"
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
if broadcast_message.font.present?
style << "color: #{broadcast_message.font}"
2015-09-11 14:41:01 +05:30
end
2018-12-05 23:21:45 +05:30
style.join('; ')
end
def broadcast_message_status(broadcast_message)
if broadcast_message.active?
'Active'
elsif broadcast_message.ended?
'Expired'
else
'Pending'
end
2014-09-02 18:07:02 +05:30
end
2016-04-02 18:10:28 +05:30
2016-11-03 12:29:30 +05:30
def render_broadcast_message(broadcast_message)
Banzai.render_field(broadcast_message, :message).html_safe
2016-04-02 18:10:28 +05:30
end
2020-03-09 13:42:32 +05:30
def broadcast_type_options
BroadcastMessage.broadcast_types.keys.map { |w| [w.humanize, w] }
end
2014-09-02 18:07:02 +05:30
end