Sha256: 10cdf3ea63b5a2c7a09272631d2325db5fc8730d3eb2930321a6160460766074

Contents?: true

Size: 1.87 KB

Versions: 25

Compression:

Stored size: 1.87 KB

Contents

module MessageTrain
  module CollectivesHelper

    def collective_boxes_widget(collective, box_user)
      render partial: 'message_train/collectives/widget', locals: { collective: collective, box_user: box_user }
    end

    def collective_nav_item(box, box_user)
      text = collective_name(box.parent)
      if box.parent.allows_receiving_by? box_user
        division = :in
      elsif box.parent.allows_sending_by? box_user
        division = :sent
      else
        return
      end
      link = message_train.collective_box_path(box.parent.path_part, division)
      unread_count = box.unread_count
      if unread_count > 0
        text << badge(unread_count.to_s, 'info pull-right')
      end
      nav_item text.html_safe, link
    end

    def collective_list_item(box, html_options = {})
      render partial: 'message_train/collectives/list_item', locals: { box: box, html_options: html_options, unread_count: box.unread_count }
    end

    def collective_boxes_dropdown_list(box_user)
      total_unread_count = {}
      show = {}
      box_user.collective_boxes.each do |table_sym, collectives|
        total_unread_count[table_sym] = collectives.collect { |collective_box| collective_box.unread_count }.sum
        show[table_sym] = collectives.select { |collective_box| collective_box.parent.allows_sending_by?(box_user) || collective_box.parent.allows_receiving_by?(box_user) }.any?
      end
      render partial: 'message_train/collectives/dropdown_list', locals: { collective_boxes: box_user.collective_boxes, total_unread_count: total_unread_count, show: show, box_user: box_user }
    end

    def collective_name(collective)
      collective.send(MessageTrain.configuration.name_columns[collective.class.table_name.to_sym])
    end

    def collective_slug(collective)
      collective.send(MessageTrain.configuration.slug_columns[collective.class.table_name.to_sym])
    end

  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
message_train-0.5.2 app/helpers/message_train/collectives_helper.rb
message_train-0.5.1 app/helpers/message_train/collectives_helper.rb
message_train-0.5.0 app/helpers/message_train/collectives_helper.rb
message_train-0.4.6 app/helpers/message_train/collectives_helper.rb
message_train-0.4.5 app/helpers/message_train/collectives_helper.rb
message_train-0.4.4 app/helpers/message_train/collectives_helper.rb
message_train-0.4.3 app/helpers/message_train/collectives_helper.rb
message_train-0.4.2 app/helpers/message_train/collectives_helper.rb
message_train-0.4.1 app/helpers/message_train/collectives_helper.rb
message_train-0.4.0 app/helpers/message_train/collectives_helper.rb
message_train-0.3.1 app/helpers/message_train/collectives_helper.rb
message_train-0.3.0 app/helpers/message_train/collectives_helper.rb
message_train-0.2.12 app/helpers/message_train/collectives_helper.rb
message_train-0.2.11 app/helpers/message_train/collectives_helper.rb
message_train-0.2.10 app/helpers/message_train/collectives_helper.rb
message_train-0.2.9 app/helpers/message_train/collectives_helper.rb
message_train-0.2.8 app/helpers/message_train/collectives_helper.rb
message_train-0.2.7 app/helpers/message_train/collectives_helper.rb
message_train-0.2.6 app/helpers/message_train/collectives_helper.rb
message_train-0.2.5 app/helpers/message_train/collectives_helper.rb