Sha256: f667235220d6800c8e26be126c1cce742895ea0852792c0c8e0c6971cd62dcd6
Contents?: true
Size: 1.28 KB
Versions: 10
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true # Admin::NotificationsController module Admin class NotificationsController < Admin::AdminController before_action :set_notification, only: %i[update destroy] def index @pagy, @notifications = pagy(current_user.notifications.order(created_at: :desc), items: 20) end def update case params[:read] when "0" @notification.update(read_at: nil) @toast = "Notification marked unread." when "1" @notification.update(read_at: Time.zone.now) @toast = "Notification marked read." end respond_to do |format| format.html { redirect_to admin_notifications_url } format.js end end def destroy @notification.file.purge @notification.destroy respond_to do |format| format.html { redirect_to admin_notifications_url, notice: "Notification was successfully destroyed." } format.json { head :no_content } end end def batch return unless params[:read] == "all" current_user.notifications.mark_as_read! flash[:success] = "All notifications marked as read." redirect_to admin_notifications_url end private def set_notification @notification = Notification.find(params[:id]) end end end
Version data entries
10 entries across 10 versions & 1 rubygems