Module: Crm::SmsMessagesHelper
- Defined in:
- app/helpers/crm/sms_messages_helper.rb
Instance Method Summary collapse
- #sms_message_command_options(sms_message) ⇒ Object
- #sms_message_recipient_link(sms_message) ⇒ Object
- #sms_message_sender_link(sms_message) ⇒ Object
- #sms_message_status_label(sms_message) ⇒ Object
- #sms_participants_collection ⇒ Object
Instance Method Details
#sms_message_command_options(sms_message) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/crm/sms_messages_helper.rb', line 2 def () links = [] if can?(:update, ) if .outbound? links << link_to(fa_icon('share', text: 'Resend'), (, return_path: @return_path), data: { turbo_method: :post }) if .draft? links << link_to(fa_icon('pen-to-square', text: 'Edit'), (, return_path: @return_path)) end end end if .inbound? links << link_to(fa_icon('reply', text: 'Reply'), (sms_message: { sender: .recipient, sender_party_id: .recipient_party_id, recipient: .sender, recipient_party_id: .sender_party_id }, mark_as_read_sms_message_id: .id, return_path: @return_path)) links << link_to(fa_icon('envelope-open', text: (.unread ? 'Mark Read' : 'Mark Unread')), (, return_path: @return_path), data: { turbo_method: :post } ) if .sender_blocked? links << link_to(fa_icon('check', text: 'Unblock Sender'), (, return_path: @return_path), data: { turbo_method: :post }) else links << link_to(fa_icon('ban', text: 'Block Sender'), (, return_path: @return_path), data: { turbo_method: :post }) if can?(:destroy, ) links << link_to(fa_icon('ban', text: 'Delete and Block Sender'), (, return_path: @return_path), data: { turbo_confirm: 'Are you sure? this will delete this message and block sender', turbo_method: :delete }) end end end if .inbound? && can?(:update, ) links << link_to(fa_icon('share-from-square', text: 'Forward'), (, return_path: @return_path)) end if can?(:destroy, ) links << link_to(fa_icon('trash', text: 'Delete'), (, return_path: @return_path), data: { turbo_confirm: "Are you sure?", turbo_method: :delete }) end links end |
#sms_message_recipient_link(sms_message) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/helpers/crm/sms_messages_helper.rb', line 81 def () capture do if .recipient_do_not_text concat link_to(fa_icon('ban', class: 'text-danger'), do_not_call_path(.recipient_do_not_text)) concat tag.del(link_to(number_to_phone(.recipient), (q: { between_participants: [.recipient]}))) else concat link_to(number_to_phone(.recipient), (q: { between_participants: [.recipient]})) end if .recipient_party concat ' • ' concat link_to(party_icon(.recipient_party), polymorphic_path(.recipient_party, tab: "sms")) end end end |
#sms_message_sender_link(sms_message) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/helpers/crm/sms_messages_helper.rb', line 63 def () capture do if .sender_do_not_text concat link_to(fa_icon('ban', class: 'text-danger'), do_not_call_path(.sender_do_not_text)) concat tag.del(link_to(number_to_phone(.sender), (q: { between_participants: [.sender]}))) elsif .sender_blocked? concat fa_icon('ban', text: 'Sender Blocked', class: 'text-danger') concat tag.del(link_to(number_to_phone(.sender), (q: { between_participants: [.sender]}))) else concat link_to(number_to_phone(.sender), (q: { between_participants: [.sender]})) end if .sender_party concat ' • ' concat link_to(party_icon(.sender_party), polymorphic_path(.sender_party, tab: "sms")) end end end |
#sms_message_status_label(sms_message) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/helpers/crm/sms_messages_helper.rb', line 46 def () label_class = { draft: 'light', queued: 'warning', sent: 'info', delivered: 'success', exception: 'danger', received_queue: 'info', received: 'info' }[.state.to_sym] || 'info' if .outbound? display_state = .human_state_name.upcase + fa_icon('arrow-right-long', class: 'ms-2') else display_state = fa_icon('arrow-left-long', class: 'me-2') + .human_state_name.upcase end content_tag :span, display_state.html_safe, class: "badge bg-#{label_class}" end |
#sms_participants_collection ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'app/helpers/crm/sms_messages_helper.rb', line 96 def sms_participants_collection # Create the participant collection based on passed in filters combined with our employee sms numbers participant_collection = SmsMessage.global_numbers_for_select + Employee.all_active_employees_sms_numbers(format_for_select: true) filter_participant_collection = (params.dig(:q, :recipient_or_sender_in) || []).map(&:presence).compact.uniq unlisted_participants = filter_participant_collection - participant_collection.map(&:last) participant_collection += unlisted_participants.map{|n| [n,n]} participant_collection = participant_collection.map(&:presence).compact.uniq end |