Sha256: a0cc0e2f9d7e30b986fc53b8a14b8dd9f35994801952f831de1e00ed2e3eb115

Contents?: true

Size: 1.66 KB

Versions: 19

Compression:

Stored size: 1.66 KB

Contents

module MessageTrain
  # Messages helper
  module MessagesHelper
    def message_class(box, message)
      css_classes = []

      css_classes << if message.is_unread_for?(@box_user)
                       'unread panel-info'
                     else
                       'read'
                     end

      message.draft && css_classes << 'draft'

      if box.division == :trash
        !message.is_trashed_for?(@box_user) && css_classes << 'hide'
      else
        !message.is_untrashed_for?(@box_user) && css_classes << 'hide'
      end
      css_classes.join(' ')
    end

    def message_trashed_toggle(message)
      render(
        partial: 'message_train/messages/trashed_toggle',
        locals: { message: message }
      )
    end

    def message_read_toggle(message)
      render(
        partial: 'message_train/messages/read_toggle',
        locals: { message: message }
      )
    end

    def message_deleted_toggle(message)
      render(
        partial: 'message_train/messages/deleted_toggle',
        locals: { message: message }
      )
    end

    def message_recipients(message)
      message.recipients.collect { |x| box_participant_name(x) }.to_sentence
    end

    private

    def message_toggle(message, icon, mark_to_set, title, options = {})
      options[:remote] = true
      options[:id] = "mark_#{mark_to_set}_#{message.id}"
      options[:class] = 'mark-link'
      options[:method] = :put
      options[:title] = title
      render(
        partial: 'message_train/messages/toggle',
        locals: {
          message: message,
          icon: icon,
          mark_to_set: mark_to_set,
          options: options
        }
      )
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
message_train-0.6.17 app/helpers/message_train/messages_helper.rb
message_train-0.6.16 app/helpers/message_train/messages_helper.rb
message_train-0.6.15 app/helpers/message_train/messages_helper.rb
message_train-0.6.14 app/helpers/message_train/messages_helper.rb
message_train-0.6.13 app/helpers/message_train/messages_helper.rb
message_train-0.6.12 app/helpers/message_train/messages_helper.rb
message_train-0.6.11 app/helpers/message_train/messages_helper.rb
message_train-0.6.10 app/helpers/message_train/messages_helper.rb
message_train-0.6.9 app/helpers/message_train/messages_helper.rb
message_train-0.6.8 app/helpers/message_train/messages_helper.rb
message_train-0.6.7 app/helpers/message_train/messages_helper.rb
message_train-0.6.6 app/helpers/message_train/messages_helper.rb
message_train-0.6.5 app/helpers/message_train/messages_helper.rb
message_train-0.6.4 app/helpers/message_train/messages_helper.rb
message_train-0.6.3 app/helpers/message_train/messages_helper.rb
message_train-0.6.2 app/helpers/message_train/messages_helper.rb
message_train-0.6.1 app/helpers/message_train/messages_helper.rb
message_train-0.6.0 app/helpers/message_train/messages_helper.rb
message_train-0.5.3 app/helpers/message_train/messages_helper.rb