Module: NotificationHelper
- Included in:
- Kuppayam::BaseController
- Defined in:
- app/helpers/notification_helper.rb
Instance Method Summary collapse
- #configure_notification ⇒ Object
- #default_notification_configuration ⇒ Object
-
#set_notification(success, title, message) ⇒ Object
This function will set a notification message depending up on the request type (ajax - xml http or direct http) Example set_notification(“Success”, “The message has been sent successfully”) set_notification(“Success”, “Permission denied”).
- #set_resource_notification(obj) ⇒ Object
Instance Method Details
#configure_notification ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/helpers/notification_helper.rb', line 11 def configure_notification if defined?(@notification) @notification.reverse_merge!(default_notification_configuration) else @notification = default_notification_configuration end end |
#default_notification_configuration ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/notification_helper.rb', line 3 def default_notification_configuration { success: false, title: "<NOT SET>", message: "<NO MESSAGE SET>" } end |
#set_notification(success, title, message) ⇒ Object
This function will set a notification message depending up on the request type (ajax - xml http or direct http) Example
set_notification("Success", "The message has been sent successfully")
set_notification("Success", "Permission denied")
23 24 25 26 27 |
# File 'app/helpers/notification_helper.rb', line 23 def set_notification(success, title, ) @notification[:success] = success @notification[:title] = title @notification[:message] = end |
#set_resource_notification(obj) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/notification_helper.rb', line 29 def set_resource_notification(obj) if obj.errors.any? @notification[:success] = false @notification[:title] = I18n.translate("status.error") @notification[:message] = obj.errors..join("<br>") else @notification[:success] = true @notification[:title] = I18n.translate("status.success") @notification[:message] = I18n.translate("success.saved", item: default_item_name.titleize) end end |