diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index c3a28c55..fce6e71f 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -26,7 +26,7 @@ class AccountsController < ApplicationController format.html { redirect_to accounts_path, notice: t(".success") } format.turbo_stream do render turbo_stream: [ - turbo_stream.append("notification-tray", partial: "shared/notification", locals: { type: "success", content: t(".success") }), + turbo_stream.append("notification-tray", partial: "shared/notification", locals: { type: "success", content: { body: t(".success") } }), turbo_stream.replace("account_#{@account.id}", partial: "accounts/account", locals: { account: @account }) ] end @@ -58,7 +58,7 @@ class AccountsController < ApplicationController respond_to do |format| format.html { redirect_to account_path(@account), notice: t(".success") } format.turbo_stream do - render turbo_stream: turbo_stream.append("notification-tray", partial: "shared/notification", locals: { type: "success", content: t(".success") }) + render turbo_stream: turbo_stream.append("notification-tray", partial: "shared/notification", locals: { type: "success", content: { body: t(".success") } }) end end end diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index 99ff1ca8..5e7322ad 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -78,7 +78,7 @@ class TransactionsController < ApplicationController format.html { redirect_to transaction_url(@transaction), notice: t(".success") } format.turbo_stream do render turbo_stream: [ - turbo_stream.append("notification-tray", partial: "shared/notification", locals: { type: "success", content: t(".success") }), + turbo_stream.append("notification-tray", partial: "shared/notification", locals: { type: "success", content: { body: t(".success") } }), turbo_stream.replace("transaction_#{@transaction.id}", partial: "transactions/transaction", locals: { transaction: @transaction }) ] end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c39022b5..87913e3c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -17,7 +17,7 @@ module ApplicationHelper content = tag.p(text) content = capture &block if block_given? - render partial: "shared/notification", locals: { type: options[:type], content: content } + render partial: "shared/notification", locals: { type: options[:type], content: { body: content } } end # Wrap view with <%= modal do %> ... <% end %> to have it open in a modal diff --git a/app/views/shared/_notification.html.erb b/app/views/shared/_notification.html.erb index df31010d..3b3c0871 100644 --- a/app/views/shared/_notification.html.erb +++ b/app/views/shared/_notification.html.erb @@ -1,23 +1,42 @@ -<%# locals: (type: "success", content:) -%> +<%# locals: (type: "success", content: { title: '', body: ''}, action: { label:'' , url:'' }, options: { auto_dismiss: true }) -%> + <% if options[:auto_dismiss] %> +
+ + + + +
+ <% end %> + <% end -%> + +
diff --git a/app/views/valuations/create.turbo_stream.erb b/app/views/valuations/create.turbo_stream.erb index d57f724f..b56905ef 100644 --- a/app/views/valuations/create.turbo_stream.erb +++ b/app/views/valuations/create.turbo_stream.erb @@ -1,4 +1,4 @@ <%= turbo_stream.replace Valuation.new, body: turbo_frame_tag(dom_id(Valuation.new)) %> -<%= turbo_stream.append "notification-tray", partial: "shared/notification", locals: { type: "success", content: "Valuation created" } %> +<%= turbo_stream.append "notification-tray", partial: "shared/notification", locals: { type: "success", content: { body: "Valuation created" } } %> <%= turbo_stream.replace "valuations_list", partial: "accounts/account_valuation_list", locals: { valuation_series: @account.valuations.to_series } %> <%= turbo_stream.replace "sync_message", partial: "accounts/sync_message", locals: { is_syncing: true } %> diff --git a/app/views/valuations/destroy.turbo_stream.erb b/app/views/valuations/destroy.turbo_stream.erb index b0bd00ec..40cfb7ab 100644 --- a/app/views/valuations/destroy.turbo_stream.erb +++ b/app/views/valuations/destroy.turbo_stream.erb @@ -1,4 +1,4 @@ <%= turbo_stream.remove @valuation %> -<%= turbo_stream.append "notification-tray", partial: "shared/notification", locals: { type: "success", content: "Valuation deleted" } %> +<%= turbo_stream.append "notification-tray", partial: "shared/notification", locals: { type: "success", content: { body: "Valuation deleted" } } %> <%= turbo_stream.replace "valuations_list", partial: "accounts/account_valuation_list", locals: { valuation_series: @account.valuations.to_series } %> <%= turbo_stream.replace "sync_message", partial: "accounts/sync_message", locals: { is_syncing: true } %> diff --git a/config/locales/views/shared/en.yml b/config/locales/views/shared/en.yml index 9f9d8088..191dfbc2 100644 --- a/config/locales/views/shared/en.yml +++ b/config/locales/views/shared/en.yml @@ -21,6 +21,8 @@ en: back is by re-entering it manually via a new entry

" title: Delete Entry? shared: + notification: + dismiss: Dismiss upgrade_notification: app_upgraded: The app has been upgraded to %{version}. dismiss: Dismiss