Module: BroadcastMessagesHelper
- Included in:
- Admin::BroadcastMessagesController
- Defined in:
- app/helpers/broadcast_messages_helper.rb
Instance Method Summary collapse
- #broadcast_message(message, opts = {}) ⇒ Object
- #broadcast_message_status(broadcast_message) ⇒ Object
- #broadcast_message_style(broadcast_message) ⇒ Object
- #broadcast_type_options ⇒ Object
- #current_broadcast_banner_messages ⇒ Object
- #current_broadcast_notification_message ⇒ Object
- #render_broadcast_message(broadcast_message) ⇒ Object
Instance Method Details
#broadcast_message(message, opts = {}) ⇒ Object
17 18 19 20 21 |
# File 'app/helpers/broadcast_messages_helper.rb', line 17 def (, opts = {}) return unless .present? render "shared/broadcast_message", { message: , opts: opts } end |
#broadcast_message_status(broadcast_message) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/broadcast_messages_helper.rb', line 39 def () if .active? 'Active' elsif .ended? 'Expired' else 'Pending' end end |
#broadcast_message_style(broadcast_message) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/broadcast_messages_helper.rb', line 23 def () return '' if .notification? style = [] if .color.present? style << "background-color: #{.color}" end if .font.present? style << "color: #{.font}" end style.join('; ') end |
#broadcast_type_options ⇒ Object
61 62 63 |
# File 'app/helpers/broadcast_messages_helper.rb', line 61 def BroadcastMessage.broadcast_types.keys.map { |w| [w.humanize, w] } end |
#current_broadcast_banner_messages ⇒ Object
4 5 6 7 8 |
# File 'app/helpers/broadcast_messages_helper.rb', line 4 def BroadcastMessage.(request.path).select do || ["hide_broadcast_message_#{.id}"].blank? end end |
#current_broadcast_notification_message ⇒ Object
10 11 12 13 14 15 |
# File 'app/helpers/broadcast_messages_helper.rb', line 10 def = BroadcastMessage.(request.path).select do || ["hide_broadcast_message_#{.id}"].blank? end .last end |
#render_broadcast_message(broadcast_message) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/broadcast_messages_helper.rb', line 49 def () if .notification? Banzai.render_field_and_post_process(, :message, { current_user: current_user, skip_project_check: true, broadcast_message_placeholders: true }).html_safe else Banzai.render_field(, :message).html_safe end end |