Class: ActivityNotification::NotificationsController
- Inherits:
-
Object
- Object
- ActivityNotification::NotificationsController
- Includes:
- PolymorphicHelpers, StoreController
- Defined in:
- app/controllers/activity_notification/notifications_controller.rb
Overview
Controller to manage notifications.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_VIEW_DIRECTORY =
"default"
Instance Method Summary collapse
-
#controller_path ⇒ String
Returns controller path.
-
#destroy(params) ⇒ Responce
Deletes a notification.
-
#index(params) ⇒ Responce
Shows notification index of the target.
-
#open(params) ⇒ Responce
Moves to notifiable_path of the notification.
-
#open(params) ⇒ Responce
Opens a notification.
-
#open_all(params) ⇒ Responce
Opens all notifications of the target.
-
#show(params) ⇒ Responce
Shows a notification.
-
#target_view_path ⇒ Object
Returns path of the target view templates.
Methods included from StoreController
#store_controller_for_activity_notification
Instance Method Details
#controller_path ⇒ String
Returns controller path. This method has no action routing and is called from target_view_path method. This method can be overriden.
124 125 126 |
# File 'app/controllers/activity_notification/notifications_controller.rb', line 124 def controller_path "activity_notification/notifications" end |
#destroy(params) ⇒ Responce
Deletes a notification.
DELETE /:target_type/:target_id/notifcations/:id
80 81 82 83 |
# File 'app/controllers/activity_notification/notifications_controller.rb', line 80 def destroy @notification.destroy return_back_or_ajax end |
#index(params) ⇒ Responce
Shows notification index of the target.
GET /:target_type/:target_id/notifcations
30 31 32 33 34 35 36 37 |
# File 'app/controllers/activity_notification/notifications_controller.rb', line 30 def index @notifications = load_notification_index() 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 |
#open(params) ⇒ Responce
Moves to notifiable_path of the notification.
GET /:target_type/:target_id/notifcations/:id/move
115 116 117 118 |
# File 'app/controllers/activity_notification/notifications_controller.rb', line 115 def move @notification.open! if params[:open].to_s.to_boolean(false) redirect_to @notification.notifiable_path end |
#open(params) ⇒ Responce
Opens a notification.
POST /:target_type/:target_id/notifcations/:id/open
97 98 99 100 101 102 103 |
# File 'app/controllers/activity_notification/notifications_controller.rb', line 97 def open with_members = !(params[:with_group_members].to_s.to_boolean(false) || params[:without_grouping].to_s.to_boolean(false)) @notification.open!(with_members: with_members) params[:move].to_s.to_boolean(false) ? move : return_back_or_ajax end |
#open_all(params) ⇒ Responce
Opens all notifications of the target.
POST /:target_type/:target_id/notifcations/open_all
54 55 56 57 |
# File 'app/controllers/activity_notification/notifications_controller.rb', line 54 def open_all @target.open_all_notifications(params) return_back_or_ajax end |
#show(params) ⇒ Responce
Shows a notification.
GET /:target_type/:target_id/notifcations/:id
65 66 |
# File 'app/controllers/activity_notification/notifications_controller.rb', line 65 def show end |
#target_view_path ⇒ Object
Returns path of the target view templates. This method has no action routing and needs to be public since it is called from view helper.
130 131 132 133 134 135 136 |
# File 'app/controllers/activity_notification/notifications_controller.rb', line 130 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 |