From 06bed6edc4b7c1205a79320e5de374d7f5845a71 Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 3 Jul 2024 15:17:26 +0400 Subject: [PATCH] notification --- app/controllers/scores_controller.rb | 7 ++- app/views/layouts/_coucou.html.erb | 3 ++ app/views/layouts/_notification.html.erb | 57 +++++++++++++----------- 3 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 app/views/layouts/_coucou.html.erb diff --git a/app/controllers/scores_controller.rb b/app/controllers/scores_controller.rb index 5ca0b43..6514923 100644 --- a/app/controllers/scores_controller.rb +++ b/app/controllers/scores_controller.rb @@ -42,8 +42,11 @@ class ScoresController < ApplicationController # DELETE /scores/1 def destroy - @score.destroy! - redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other + # @score.destroy! + # redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other + + flash.now[:alert] = "this is 'destroyed!'" + render turbo_stream: turbo_stream.replace('notification', partial: 'layouts/notification') end private diff --git a/app/views/layouts/_coucou.html.erb b/app/views/layouts/_coucou.html.erb new file mode 100644 index 0000000..cd5c884 --- /dev/null +++ b/app/views/layouts/_coucou.html.erb @@ -0,0 +1,3 @@ +NOTIFICATION + +COUCOU \ No newline at end of file diff --git a/app/views/layouts/_notification.html.erb b/app/views/layouts/_notification.html.erb index 4edb1bb..cda0640 100644 --- a/app/views/layouts/_notification.html.erb +++ b/app/views/layouts/_notification.html.erb @@ -1,28 +1,35 @@ -<% if flash.count.positive? %> - -<%end%> + if (notice.length>0){ + console.info(`TOAST notice: ${notice}`) + Toastify({ text: notice, ...noticeOptions }).showToast(); + notice='' + } + if (alert.length>0){ + console.warn(`TOAST alert: ${alert}`) + Toastify({ text: alert, ...alertOptions }).showToast(); + alert='' + } + + <% end %> +<% end %>