From cdb1637bb00eb442380e8732544fbe3db948d47f Mon Sep 17 00:00:00 2001 From: Torsten Date: Wed, 21 Dec 2022 18:04:09 +0200 Subject: [PATCH] fix devise templates --- app/views/devise/confirmations/new.html.haml | 11 +++----- app/views/devise/passwords/edit.html.haml | 2 +- app/views/devise/passwords/new.html.haml | 11 +++----- app/views/devise/registrations/edit.html.haml | 14 ++++------ app/views/devise/registrations/new.html.haml | 26 ++++++++--------- app/views/devise/sessions/new.html.haml | 28 ++++++++----------- .../devise/shared/_error_messages.html.haml | 6 ++-- app/views/devise/shared/_links.html.haml | 21 ++++++-------- app/views/devise/unlocks/new.html.haml | 12 +++----- 9 files changed, 52 insertions(+), 79 deletions(-) diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index e91cc38..d49cb44 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -1,13 +1,10 @@ .flex.justify-center .w-full.max-w-xs %h1.font-hairline.mb-6.text-center Resend Confirmation Instructions - = form_for(resource, | - as: resource_name, | - url: main_app.confirmation_path(resource_name), | - html: { | - method: :post, | - class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | - }) do |f| | + = form_for(resource, as: resource_name, + url: confirmation_path(resource_name), + html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" , + method: :post }) do |f| = render "devise/shared/error_messages", resource: resource .mb-4 = f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm" diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index 7a3349f..96d699a 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -4,7 +4,7 @@ = form_for(resource, as: resource_name, html: { method: :put, class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" }, - url: member_password_path(resource_name) ) do |f| + url: password_path(resource_name) ) do |f| = render "devise/shared/error_messages", resource: resource = f.hidden_field :reset_password_token .mb-4 diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index 3758e38..7ebbece 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -1,13 +1,10 @@ .flex.justify-center .w-full.max-w-xs %h1.font-hairline.mb-6.text-center Forgot your password? - = form_for(resource, | - as: resource_name, | - url: main_app.password_path(resource_name), | - html: { | - method: :post, | - class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | - }) do |f| | + = form_for(resource, as: resource_name, + html: { method: :post, + class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" } , + url: password_path(resource_name) ) do |f| = render "devise/shared/error_messages", resource: resource .mb-4 = f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm" diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index 3f23b2b..1c4b8fa 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -2,14 +2,10 @@ .w-full.max-w-xs %h1.font-hairline.mb-6.text-center Edit #{resource_name.to_s.humanize} - = form_for(resource, | - as: resource_name, | - url: main_app.registration_path(resource_name), | - html: { | - method: :put, | - class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | - } | - ) do |f| | + = form_for(resource, as: resource_name, + html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md", + method: :put } , + url: registration_path(resource_name) ) do |f| = render "devise/shared/error_messages", resource: resource .mb-4 = f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm" @@ -40,5 +36,5 @@ = f.submit "Update", class: "button bg-blue-500 hover:bg-blue-700 font-bold text-white focus:outline-none py-2 px-4 rounded focus:shadow-outline w-full" %p Unhappy? - %span= button_to "Delete my account", main_app.registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete + %span= button_to "Delete my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete = link_to "Back", :back diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index eedef3a..36fe783 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,26 +1,22 @@ .flex.justify-center .w-full.max-w-xs %h1.font-hairline.mb-6.text-center Sign Up - = form_for(resource, | - as: resource_name, | - url: main_app.registration_path(resource_name), | - html: { | - class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | - } | - ) do |f| | + = form_for(resource, as: resource_name, + html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" } , + url: registration_path(resource_name) ) do |f| = render "devise/shared/error_messages", resource: resource .mb-4 = f.label :name, class: "block font-bold mb-2 text-gray-700 text-sm" - = f.text_field :name, | - autocomplete: "name", | - placeholder: "Pekka Juustonen", | - class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline" | + = f.text_field :name, + autocomplete: "name", + placeholder: "Pekka Juustonen", + class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline" .mb-4 = f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm" - = f.email_field :email, | - autocomplete: "email", | - placeholder: "user@example.com", | - class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline" | + = f.email_field :email, + autocomplete: "email", + placeholder: "user@example.com", + class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline" .mb-4 = f.label :password, class: "block font-bold mb-2 text-gray-700 text-sm" - if @minimum_password_length diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 24441f3..8f10d69 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,30 +1,26 @@ .flex.justify-center .w-full.max-w-xs %h1.font-hairline.mb-6.text-center Log In - = form_for(resource, | - as: resource_name, | - url: main_app.session_path(resource_name), | - html: { | - class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | - } | - ) do |f| | + = form_for(resource, url: session_path(resource_name), + html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" }, + as: resource_name ) do |f| = render "devise/shared/error_messages", resource: resource .mb-4 = f.label :email, class: "block text-gray-700 text-sm font-bold mb-2" - = f.email_field :email, autofocus: true, autocomplete: "email", | - class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight foucs:outline-none focus:shadow-outline" | + = f.email_field :email, autofocus: true, autocomplete: "email", + class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight foucs:outline-none focus:shadow-outline" .mb-4 = f.label :password, class: "block text-gray-700 text-sm font-bold mb-2" - = f.password_field :password, | - autocomplete: "current-password", | - class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" | + = f.password_field :password, + autocomplete: "current-password", + class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" - if devise_mapping.rememberable? .mb-4 = f.check_box :remember_me, class: "mr-2 leading-tight" - = f.label :remember_me, | - class: "align-baseline inline-block text-gray-700 text-sm" | + = f.label :remember_me, + class: "align-baseline inline-block text-gray-700 text-sm" .mb-4 - = f.submit "Log in", | - class: "button bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline w-full" | + = f.submit "Log in", + class: "button bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline w-full" = render "devise/shared/links" = render "devise/shared/form_footer" diff --git a/app/views/devise/shared/_error_messages.html.haml b/app/views/devise/shared/_error_messages.html.haml index 8eecee3..6e6b0f8 100644 --- a/app/views/devise/shared/_error_messages.html.haml +++ b/app/views/devise/shared/_error_messages.html.haml @@ -1,9 +1,9 @@ - if resource.errors.any? #error_explanation %h2.bg-red-100.border-l-4.border-red-500.mb-4.p-4.text-red-700.font-bold - = I18n.t("errors.messages.not_saved", | - count: resource.errors.count, | - resource: resource.class.model_name.human.downcase) | + = I18n.t("errors.messages.not_saved", + count: resource.errors.count, + resource: resource.class.model_name.human.downcase) %ul - resource.errors.full_messages.each do |message| %li= message diff --git a/app/views/devise/shared/_links.html.haml b/app/views/devise/shared/_links.html.haml index fe7b151..8f9f5a1 100644 --- a/app/views/devise/shared/_links.html.haml +++ b/app/views/devise/shared/_links.html.haml @@ -1,25 +1,20 @@ - if controller_name != 'sessions' - = link_to "Log in", main_app.new_member_session_path(resource_name), | - class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | - %br/ -- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' - = link_to "Forgot Password?", main_app.new_member_password_path(resource_name), | + = link_to "Log in", new_session_path(resource_name), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ - if devise_mapping.registerable? && controller_name != 'registrations' - = link_to "Sign up", main_app.new_member_registration_path(resource_name), | + = link_to "Sign up", new_registration_path(resource_name), | + class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | + %br/ +- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' + = link_to "Forgot Password?", new_password_path(resource_name), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ - if devise_mapping.confirmable? && controller_name != 'confirmations' - = link_to "Didn't receive confirmation info?", main_app.new_member_confirmation_path(resource_name), | + = link_to "Didn't receive confirmation info?", new_confirmation_path(resource_name), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' - = link_to "Didn't receive unlock info?", main_app.new_member_unlock_path(resource_name), | + = link_to "Didn't receive unlock info?", new_unlock_path(resource_name), | class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | %br/ -- if devise_mapping.omniauthable? - - resource_class.omniauth_providers.each do |provider| - = link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", main_app.omniauth_authorize_path(resource_name, provider), | - class: "inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800" | - %br/ diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index d60592c..2445e8a 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -1,14 +1,10 @@ .flex.justify-center .w-full.max-w-xs %h1.font-hairline.mb-6.text-center Resend Unlock Info - = form_for(resource, | - as: resource_name, | - url: main_app.unlock_path(resource_name), | - html: { | - method: :post, | - class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" | - } | - ) do |f| | + = form_for(resource, as: resource_name, + html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" , + method: :post } + url: unlock_path(resource_name) ) do |f| = render "devise/shared/error_messages", resource: resource .mb-4 = f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm"