EvoBal/app/controllers/emails_controller.rb

33 lines
930 B
Ruby
Raw Normal View History

2020-12-28 13:02:56 +01:00
class EmailsController < ApplicationController
# GET /emails
def index
2021-01-30 21:59:25 +01:00
@emails = Email.order(date: :desc).page(params[:page])
2020-12-28 13:02:56 +01:00
end
# GET /emails/1
def show
2021-03-07 11:24:00 +01:00
@email = Email.find(params[:id])
2020-12-28 13:02:56 +01:00
end
# DELETE /emails/1
def destroy
2021-03-07 11:24:00 +01:00
@email = Email.find(params[:id])
@email.destroy
2021-01-31 12:16:37 +01:00
redirect_to emails_url, notice: 'Email was successfully destroyed.'
2020-12-28 13:02:56 +01:00
end
2021-03-21 09:24:32 +01:00
def batch
case params[:batch_action]
when "mark_inbox"
Email.where(id: params[:ids]).update_all(inbox: true)
flash[:notice] = "#{helpers.pluralize(params[:ids].count,"email","emails")} have been marked « inbox »"
when "mark_not_inbox"
Email.where(id: params[:ids]).update_all(inbox: false)
flash[:notice] = "#{helpers.pluralize(params[:ids].count,"email","emails")} have been marked « not inbox »"
end
return_url = params[:return_url].presence || emails_url
redirect_to return_url
end
2020-12-28 13:02:56 +01:00
end