Class: ActivityNotification::NotificationsController

Inherits:
Object
  • Object
show all
Includes:
PolymorphicHelpers, StoreController
Defined in:
app/controllers/activity_notification/notifications_controller.rb

Direct Known Subclasses

NotificationsWithDeviseController

Constant Summary collapse

DEFAULT_VIEW_DIRECTORY =
"default"

Instance Method Summary collapse

Methods included from StoreController

#store_controller_for_activity_notification

Instance Method Details

#controller_path ⇒ Object

No action routing This method is called from target_view_path method This method can be overriden



56
57
58
# File 'app/controllers/activity_notification/notifications_controller.rb', line 56

def controller_path
  "activity_notification/notifications"
end

#destroy ⇒ Object

DELETE /:target_type/:target_id/notifcations/:id



32
33
34
35
36
# File 'app/controllers/activity_notification/notifications_controller.rb', line 32

def destroy
  @notification.destroy
  @notifications = load_notification_index(params[:filter], params[:limit]) if params[:reload].to_s.to_boolean(true)
  return_back_or_ajax(params[:filter], params[:limit])
end

#index ⇒ Object

GET /:target_type/:target_id/notifcations



12
13
14
15
16
17
18
# File 'app/controllers/activity_notification/notifications_controller.rb', line 12

def index
  @notifications = load_notification_index(params[:filter], params[:limit]) if params[:reload].to_s.to_boolean(true)
  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @notifications.to_json(include: [:target, :notifiable, :group]) }
  end
end

#move ⇒ Object

GET /:target_type/:target_id/notifcations/:id/move



48
49
50
51
# File 'app/controllers/activity_notification/notifications_controller.rb', line 48

def move
  @notification.open! if params[:open].to_s.to_boolean(false)
  redirect_to @notification.notifiale_path
end

#open ⇒ Object

POST /:target_type/:target_id/notifcations/:id/open



39
40
41
42
43
44
45
# File 'app/controllers/activity_notification/notifications_controller.rb', line 39

def open
  @notification.open!
  @notifications = load_notification_index(params[:filter], params[:limit]) if params[:reload].to_s.to_boolean(true)
  params[:move].to_s.to_boolean(false) ? 
    move : 
    return_back_or_ajax(params[:filter], params[:limit])
end

#open_all ⇒ Object

POST /:target_type/:target_id/notifcations/open_all



21
22
23
24
25
# File 'app/controllers/activity_notification/notifications_controller.rb', line 21

def open_all
  @target.open_all_notifications
  @notifications = load_notification_index(params[:filter], params[:limit]) if params[:reload].to_s.to_boolean(true)
  return_back_or_ajax(params[:filter], params[:limit])
end

#show ⇒ Object

GET /:target_type/:target_id/notifcations/:id



28
29
# File 'app/controllers/activity_notification/notifications_controller.rb', line 28

def show
end

#target_view_path ⇒ Object

No action routing This method needs to be public since it is called from view helper



62
63
64
65
66
67
68
# File 'app/controllers/activity_notification/notifications_controller.rb', line 62

def target_view_path
  target_type = @target.to_resources_name
  view_path = [controller_path, target_type].join('/')
  lookup_context.exists?(action_name, view_path) ?
    view_path :
    [controller_path, DEFAULT_VIEW_DIRECTORY].join('/')
end