Class: WcoEmail::ConversationsController
- Inherits:
-
ApplicationController
- Object
- Wco::ApplicationController
- ApplicationController
- WcoEmail::ConversationsController
- Defined in:
- app/controllers/wco_email/conversations_controller.rb
Instance Method Summary collapse
-
#addtag ⇒ Object
many tags to many convs.
- #edit ⇒ Object
- #index ⇒ Object
-
#merge ⇒ Object
merge conv1 into conv2, and delete conv1.
- #rmtag ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#addtag ⇒ Object
many tags to many convs
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/wco_email/conversations_controller.rb', line 10 def addtag :addtag, WcoEmail::Conversation inbox = Wco::Tag.inbox outs = @convs.map do |conv| conv..push @tags conv..delete( inbox ) if params[:is_move] conv.save end flash_notice "Outcomes: #{outs}" render json: { status: 'ok' } # redirect_to request.referrer # || root_path end |
#edit ⇒ Object
25 26 27 28 |
# File 'app/controllers/wco_email/conversations_controller.rb', line 25 def edit @conversation = ::WcoEmail::Conversation.find( params[:id] ) :edit, @conversation end |
#index ⇒ Object
30 31 32 33 |
# File 'app/controllers/wco_email/conversations_controller.rb', line 30 def index :index, WcoEmail::Conversation @conversations, @messages, @tag = WcoEmail::Conversation.( params, current_profile ) end |
#merge ⇒ Object
merge conv1 into conv2, and delete conv1
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/wco_email/conversations_controller.rb', line 36 def merge :merge, WcoEmail::Conversation conv1 = WcoEmail::Conversation.find params[:id1] conv2 = WcoEmail::Conversation.find params[:id2] conv1..map do |msg| msg.update conversation: conv2 end conv1..map do |tag| conv2..push tag end conv1.leads.map do |lead| conv2.leads.push lead end conv2.save! conv1.delete flash_notice "Probably ok" redirect_to action: :show, id: conv2.id end |
#rmtag ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/wco_email/conversations_controller.rb', line 56 def rmtag :addtag, WcoEmail::Conversation outs = @convs.map do |conv| @tags.map do |tag| conv..delete( tag ) end conv.save end flash_notice "Outcomes: #{outs}" render json: { status: 'ok' } # redirect_to request.referrer || root_path end |
#show ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/wco_email/conversations_controller.rb', line 70 def show @conversation = ::WcoEmail::Conversation.find( params[:id] ) :show, @conversation @messages = @conversation.( ).order_by( date: :asc ).page( params[:messages_page ] ).per( @current_profile.per_page ) @conversation.update_attributes({ status: Conv::STATUS_READ }) @conversation..unread.update_all({ read_at: Time.now }) # @other_convs = WcoEmail::Message.where( :message_id.in => @messages.map( &:in_reply_to_id ) # ).where( :conversation_id.ne => @conversation.id # ).map( &:conversation_id ).uniq # other_convs_by_subj = WcoEmail::Conversation.where( subject: @conversation.subject # ).where( :conversation_id.ne => @conversation.id # ).map( &:id ) # if @other_convs.present? || other_convs_by_subj.present? # @other_convs = WcoEmail::Conversation.find( @other_convs + other_convs_by_subj ) # end end |
#update ⇒ Object
93 94 95 96 97 98 99 100 101 102 |
# File 'app/controllers/wco_email/conversations_controller.rb', line 93 def update @conversation = ::WcoEmail::Conversation.find( params[:id] ) :update, @conversation if @conversation.update( params[:conversation].permit! ) flash_notice 'ok' else flash_alert @conversation end redirect_to action: 'show', id: @conversation.id end |