Sha256: 25024b258cf5a6936538d6608a228e32139cd3c80b25cdf7d40d4a0beb34d155

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

module NotificationRendererHelper

    def render_notification notification, renderer = NotificationRenderer.configuration.default_renderer, attribute, notifications_count
        notification.update_attributes read: true if NotificationRenderer.configuration.auto_read
        render "notifications/#{notification.type}/#{renderer}", notification: notification, attribute: attribute, notifications_count: notifications_count
    end

    def render_notifications notifications, renderer = NotificationRenderer.configuration.default_renderer
        content_tag :div, class: 'notification-renderer notifications' do
            notifications.each do |notification|
                render_notification notification, renderer
            end
        end
    end

    def render_notifications_grouped notifications, group_by, renderer = NotificationRenderer.configuration.default_renderer
        content_tag :div, class: 'notification-renderer notifications' do
            notifications.grouping(group_by)&.each do |attribute, notifications|
                render_notification notifications.last, renderer, attribute, notifications.count
            end
        end
    end

    def notification_grouped?
        local_assigns[:attribute]
    end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
notification-renderer-1.2.2 app/helpers/notification_renderer_helper.rb
notification-renderer-1.2.1 app/helpers/notification_renderer_helper.rb
notification-renderer-1.2.0 app/helpers/notification_renderer_helper.rb
notification-renderer-1.1.2 app/helpers/notification_renderer_helper.rb
notification-renderer-1.1.1 app/helpers/notification_renderer_helper.rb
notification-renderer-1.1.0 app/helpers/notification_renderer_helper.rb
notification-renderer-1.0.0 app/helpers/notification_renderer_helper.rb
notification-renderer-1.0.0.beta11 app/helpers/notification_renderer_helper.rb