From 007698d5c4f67306af3ad9d5d1bca4efb6a4e99c Mon Sep 17 00:00:00 2001 From: Torsten Date: Fri, 9 Dec 2022 17:19:57 +0200 Subject: [PATCH] flash messages, formhandler (not sending yet) --- app/views/layouts/_header.haml | 2 +- app/views/layouts/_messages.haml | 29 +++++++++++++++++++++++++++++ app/views/layouts/application.haml | 5 +++-- config/application.rb | 2 ++ lib/form_handler.rb | 10 ++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 app/views/layouts/_messages.haml create mode 100644 lib/form_handler.rb diff --git a/app/views/layouts/_header.haml b/app/views/layouts/_header.haml index 1ee2580..96ee187 100644 --- a/app/views/layouts/_header.haml +++ b/app/views/layouts/_header.haml @@ -1,5 +1,5 @@ %header.bg-white{"aria-label" => "Site Header"} - .mx-auto.max-w-screen-xl.px-4.sm:px-6.lg:px-8 + .mx-auto.max-w-screen-xl.px-8.mb-6.mt-6.sm:px-6.lg:px-10 .flex.h-16.items-center.justify-between .flex-1.md:flex.md:items-center.md:gap-6 %a.block.text-teal-600{:href => "/"} diff --git a/app/views/layouts/_messages.haml b/app/views/layouts/_messages.haml new file mode 100644 index 0000000..dc550e9 --- /dev/null +++ b/app/views/layouts/_messages.haml @@ -0,0 +1,29 @@ +-if flash.alert + #flash + .m-20.rounded.border-l-4.border-red-500.bg-red-50.p-4{:role => "alert"} + %strong.block.font-medium.text-red-700 Oops + %p.mt-2.text-sm.text-red-700 + =flash.alert + +-if flash.notice + #flash + .m-20.rounded-xl.border.border-gray-100.p-4.shadow-xl{:role => "alert"} + .flex.items-start.gap-4 + %span.text-green-600 + %svg.h-6.w-6{:fill => "none", :stroke => "currentColor", "stroke-width" => "1.5", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"} + %path{:d => "M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z", "stroke-linecap" => "round", "stroke-linejoin" => "round"} + .flex-1 + %strong.block.font-medium.text-gray-900 Ok + %p.mt-1.text-sm.text-gray-700 + = flash.notice + +:javascript + function hideNotice() { + const notification = document.querySelector('#flash') + if (notification) { + setInterval(function() { + notification.classList.add('collapse'); + }, 5000); + } + } + hideNotice(); diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index 1faafd6..3fe6391 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -11,6 +11,7 @@ = javascript_importmap_tags %body - =render "layouts/header" + = render "layouts/header" + = render "layouts/merged_messages" = yield - =render "layouts/footer" + = render "layouts/footer" diff --git a/config/application.rb b/config/application.rb index 6b6e3a5..d89e752 100644 --- a/config/application.rb +++ b/config/application.rb @@ -30,5 +30,7 @@ module HubfeenixFi # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") + + config.autoload_paths << Rails.root.join('lib') end end diff --git a/lib/form_handler.rb b/lib/form_handler.rb new file mode 100644 index 0000000..35bbd50 --- /dev/null +++ b/lib/form_handler.rb @@ -0,0 +1,10 @@ +class FormHandler + + def handle_form(section , data ) + puts "Section on page : #{section.page.name}" + data.each do |name , value| + puts "#{name}: #{value}" + end + end + +end