Allow managing versions of cookies consent

This can be useful when adding a new cookie or making
modifications that require asking the user again.
This commit is contained in:
taitus
2024-12-09 16:36:06 +01:00
parent 5ffaf7a80e
commit 018b00cd6e
10 changed files with 35 additions and 16 deletions

View File

@@ -3,6 +3,7 @@
<%= render Admin::Settings::TableComponent.new(setting_name: "feature") do %>
<%= render Admin::Settings::RowComponent.new("feature.cookies_consent", type: :feature, tab: tab) %>
<%= render Admin::Settings::RowComponent.new("cookies_consent.more_info_link", type: :text, tab: tab) %>
<%= render Admin::Settings::RowComponent.new("cookies_consent.version_name", type: :text, tab: tab) %>
<% end %>
<%= render Admin::Cookies::Vendors::TableComponent.new %>

View File

@@ -8,6 +8,6 @@ class Layout::CookiesConsent::BannerComponent < Layout::CookiesConsent::BaseComp
private
def cookies_consent_unset?
cookies["cookies_consent"].blank?
cookies["cookies_consent_#{version_name}"].blank?
end
end

View File

@@ -10,4 +10,8 @@ class Layout::CookiesConsent::BaseComponent < ApplicationComponent
def vendors
Cookies::Vendor.all
end
def version_name
Setting["cookies_consent.version_name"].to_s.strip
end
end

View File

@@ -1,4 +1,8 @@
<section id="cookies_consent_management" class="cookies-consent-management reveal" data-reveal aria-labelledby="modal_heading">
<section id="cookies_consent_management"
class="cookies-consent-management reveal"
data-reveal
aria-labelledby="modal_heading"
data-version-name="<%= version_name %>">
<header>
<h2 id="modal_heading"><%= t("cookies_management.title") %></h2>
<button class="close-button" aria-label="<%= t("admin.shared.close_modal") %>" type="button" data-close>