From 8c3bbd2152e60ae96aadada8c97a9a4d89b77749 Mon Sep 17 00:00:00 2001 From: jendiamond Date: Thu, 6 Jul 2023 12:21:30 -0700 Subject: [PATCH] working cookie --- .../stylesheets/base/layout/body/_body.scss | 23 ++--- app/controllers/application_controller.rb | 19 ++++- app/views/layouts/blacklight/base.html.erb | 85 +++++-------------- .../shared/header/_header_navbar.html.erb | 11 --- config/routes.rb | 2 +- 5 files changed, 50 insertions(+), 90 deletions(-) diff --git a/app/assets/stylesheets/base/layout/body/_body.scss b/app/assets/stylesheets/base/layout/body/_body.scss index a3bd7aa3..3a76f516 100644 --- a/app/assets/stylesheets/base/layout/body/_body.scss +++ b/app/assets/stylesheets/base/layout/body/_body.scss @@ -54,31 +54,33 @@ } } -/* --------------- */ - -// Terms of User Modal -// terms_of_use_90day +// Terms of Use Modal - appears every 90 days /* The Modal (background) */ .modal { - position: fixed; /* Stay in place */ - top: 0; - left: 0; + position: absolute; /* Stay in place */ + top: 15%; + left: 25%; display: none; /* Hidden by default */ align-self: center; overflow: auto; /* Enable scroll if needed */ - max-width: 500px; + max-width: 600px; height: 100%; /* Full height */ z-index: 5; /* Sit on top */ + + @media (max-width: 767px) { + top: 0; + left: 0; + } } /* Modal Content/Box */ .modal-content { margin: 4% auto; - padding: 25%; + padding: 30%; width: 92%; background-color: #fff; - border: 1.5px solid #f7f2ea; + border: 1px solid #87331a; } .modal__terms-of-use { @@ -96,6 +98,7 @@ align-self: flex-start; color: #87331a; text-transform: uppercase; + @media (max-width: 800px) { font-size: $text-20; } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 53423e8e..31478173 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class ApplicationController < ActionController::Base - before_action :display_banner?, :sinai_authn_check, :add_legacy_views, :cors_preflight_check, :set_default_sort, :set_term_of_use_cookie, :terms_of_use_modal_check + before_action :display_banner?, :sinai_authn_check, :add_legacy_views, :cors_preflight_check, :set_default_sort, :display_term_of_use? after_action :cors_set_access_control_headers def add_legacy_views @@ -95,16 +95,27 @@ def set_auth_cookies } end + # TERMS OF USE MODAL + def term_of_use_cookie? + cookies[:set_modal] + end + def set_term_of_use_cookie cookies[:set_modal] = { value: 'Set this Modal', - expires: Time.zone.now + 1.minutes + expires: Time.zone.now + 90.days } end - def terms_of_use_modal_check - return true if cookies[:sinai_authenticated_3day] = 'true' + def display_term_of_use? + if term_of_use_cookie? + @term_of_use_modal_option = "none" + else + @term_of_use_modal_option = "block" + set_term_of_use_cookie + end end + # End Terms of Use Modal def create_encrypted_string cipher.encrypt diff --git a/app/views/layouts/blacklight/base.html.erb b/app/views/layouts/blacklight/base.html.erb index 90d0fc00..c720b3a2 100644 --- a/app/views/layouts/blacklight/base.html.erb +++ b/app/views/layouts/blacklight/base.html.erb @@ -43,59 +43,33 @@ <% end %>
> + <%= render partial: 'shared/header/header_navbar' %> <%= render 'catalog/banners/homepage_banner' %> - <% if cookies[:sinai_authenticated_3day] %> - <% if cookies[:set_modal] %> - - - - CURRENT USER: <%= current_user %> | - SIGNED IN: <%= user_signed_in? %> | - USER SESSION: <%= user_session %> | - <% if cookies[:sinai_authenticated_3day] %> - <%= cookies[:sinai_authenticated_3day] %> - <% end %> - - <% if cookies[:set_modal] %> - Set Modal: <%= cookies[:set_modal] %> - | <%= :terms_of_use_modal? %> - <% end %> - - <% if :terms_of_use_modal_check %> - :terms_of_use_modal_check is true - <% end %> - - - @@ -117,29 +92,11 @@ diff --git a/app/views/shared/header/_header_navbar.html.erb b/app/views/shared/header/_header_navbar.html.erb index bca70cff..f804ce2d 100644 --- a/app/views/shared/header/_header_navbar.html.erb +++ b/app/views/shared/header/_header_navbar.html.erb @@ -11,17 +11,6 @@