From 6bf60cd8cb8746528d030b56f428ddba9f6097da Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Thu, 9 May 2019 05:58:00 +0200 Subject: [PATCH] devise views improoved --- app/controllers/application_controller.rb | 4 +- app/views/devise/passwords/edit.html.erb | 46 ++-- app/views/devise/passwords/new.html.erb | 31 ++- app/views/devise/sessions/new.html.erb | 5 +- .../devise/shared/_error_messages.html.erb | 6 +- app/views/layouts/application.html.erb | 6 +- config/locales/devise.pl.yml | 10 +- config/locales/pl/pl.yml | 240 ++++++++++++++++++ 8 files changed, 295 insertions(+), 53 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7d556f8..54a27d9 100644 --- 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 :authenticate_user! + before_action :authenticate_user! layout :layout_by_resource @@ -9,5 +9,5 @@ class ApplicationController < ActionController::Base def layout_by_resource devise_controller? ? 'devise' : 'application' - end + end end diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb index cf3d281..09e0607 100644 --- a/app/views/devise/passwords/edit.html.erb +++ b/app/views/devise/passwords/edit.html.erb @@ -1,25 +1,29 @@ -

Change your password

+
+
+
+
+
+

<%= t('devise.passwords.edit.change_your_password') %>

+
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put, class: 'user' }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + <%= f.hidden_field :reset_password_token %> -<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> - <%= render "devise/shared/error_messages", resource: resource %> - <%= f.hidden_field :reset_password_token %> +
+ <%= f.password_field :password, autofocus: true, autocomplete: "new-password", placeholder: t('devise.passwords.edit.new_password'), class: 'form-control form-control-user' %> + <% if @minimum_password_length %> + <%= t('devise.shared.minimum_password_length', count: @minimum_password_length) %>
+ <% end %> +
-
- <%= f.label :password, "New password" %>
- <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum)
+
+ <%= f.password_field :password_confirmation, autocomplete: "off", placeholder: t('devise.passwords.edit.confirm_new_password'), class: 'form-control form-control-user' %> +
+ + <%= f.submit t('devise.passwords.edit.change_my_password'), class: 'btn btn-primary btn-user btn-block' %> <% end %> - <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %> +
+ <%= render "devise/shared/links" %>
- -
- <%= f.label :password_confirmation, "Confirm new password" %>
- <%= f.password_field :password_confirmation, autocomplete: "off" %> -
- -
- <%= f.submit "Change my password" %> -
-<% end %> - -<%= render "devise/shared/links" %> +
+
diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb index 9b486b8..85c5f5f 100644 --- a/app/views/devise/passwords/new.html.erb +++ b/app/views/devise/passwords/new.html.erb @@ -1,16 +1,21 @@ -

Forgot your password?

+
+
+
+
+
+

<%= t('devise.passwords.new.forgot_your_password') %>

+
-<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> - <%= render "devise/shared/error_messages", resource: resource %> + <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post, class: 'user' }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> +
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: 'Email', class: 'form-control form-control-user' %> +
-
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> + <%= f.submit t('devise.passwords.new.send_me_reset_password_instructions'), class: 'btn btn-primary btn-user btn-block' %> + <% end %> +
+ <%= render "devise/shared/links" %> +
- -
- <%= f.submit "Send me reset password instructions" %> -
-<% end %> - -<%= render "devise/shared/links" %> +
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 3bab851..15589ac 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,13 +1,12 @@ -
-

Witaj!

+

<%= t('welcome') %>

- <%= form_for(resource, as: resource_name, url: session_path(resource_name), html: {class: 'user'}) do |f| %> + <%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: 'user' }) do |f| %>
<%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: 'Email', class: 'form-control form-control-user' %>
diff --git a/app/views/devise/shared/_error_messages.html.erb b/app/views/devise/shared/_error_messages.html.erb index ba7ab88..fb71d4b 100644 --- a/app/views/devise/shared/_error_messages.html.erb +++ b/app/views/devise/shared/_error_messages.html.erb @@ -1,11 +1,11 @@ <% if resource.errors.any? %> -
-

+

    <% resource.errors.full_messages.each do |message| %>
  • <%= message %>
  • diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ce8e3ad..6442e5a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -123,10 +123,8 @@ Activity Log - - - Logout - + <%= link_to(raw(" #{t('logout')}"), destroy_user_session_path, method: :delete, class: "dropdown-item") %> +
diff --git a/config/locales/devise.pl.yml b/config/locales/devise.pl.yml index c88b65b..3e5355e 100644 --- a/config/locales/devise.pl.yml +++ b/config/locales/devise.pl.yml @@ -110,7 +110,7 @@ pl: signed_up_but_unconfirmed: Wiadomość z linkiem aktywacyjnym została wysłana na podany adres e-mail. Otwórz link w celu aktywacji konta. update_needs_confirmation: Konto zostało zaktualizowane, musimy jednak potwierdzić nowy adres e-mail. Sprawdź swoją skrzynkę pocztową i otwórz link aktywacyjny, aby ukończyć zmianę adresu. updated: Konto zostało pomyślnie zaktualizowane. - updated_but_not_signed_in: + updated_but_not_signed_in: sessions: already_signed_out: Wylogowano pomyślnie. new: @@ -126,11 +126,7 @@ pl: sign_in: Zaloguj się sign_in_with_provider: Zaloguj się przez %{provider} sign_up: Zarejestruj się - minimum_password_length: - few: "(minimum %{count} znaki)" - many: "(minimum %{count} znaków)" - one: "(minimum %{count} znak)" - other: "(minimum %{count} znaku)" + minimum_password_length: "minimalna ilość znaków: %{count}" unlocks: new: resend_unlock_instructions: Wyślij instrukcje odblokowania konta @@ -148,4 +144,4 @@ pl: few: "%{resource} nie został zapisany z powodu %{count} błędów:" many: "%{resource} nie został zapisany z powodu %{count} błędów:" one: "%{resource} nie został zapisany z powodu jednego błędu:" - other: "%{resource} nie został zapisany z powodu %{count} błędów:" \ No newline at end of file + other: "%{resource} nie został zapisany z powodu %{count} błędów:" diff --git a/config/locales/pl/pl.yml b/config/locales/pl/pl.yml index 4472a37..f958a12 100644 --- a/config/locales/pl/pl.yml +++ b/config/locales/pl/pl.yml @@ -1,4 +1,5 @@ pl: + welcome: 'Witaj!' logout: 'Wyloguj' login: 'Zaloguj' add: 'Dodaj' @@ -31,3 +32,242 @@ pl: forgot_password: 'Zapomniane hasło?' no_account: 'Nie masz konta?' spikon_inv: 'Zapraszamy do Spikon!' + activerecord: + errors: + messages: + record_invalid: 'Negatywne sprawdzenie poprawności: %{errors}' + restrict_dependent_destroy: + has_one: Nie może zostać usunięte, gdyż istnieje zależny od niego %{record} + has_many: Nie może zostać usunięte, gdyż istnieją zależne od niego %{record} + date: + abbr_day_names: + - nie + - pon + - wto + - śro + - czw + - pią + - sob + abbr_month_names: + - + - sty + - lut + - mar + - kwi + - maj + - cze + - lip + - sie + - wrz + - paź + - lis + - gru + day_names: + - niedziela + - poniedziałek + - wtorek + - środa + - czwartek + - piątek + - sobota + formats: + default: "%d-%m-%Y" + long: "%B %d, %Y" + short: "%d %b" + month_names: + - + - styczeń + - luty + - marzec + - kwiecień + - maj + - czerwiec + - lipiec + - sierpień + - wrzesień + - październik + - listopad + - grudzień + order: + - :day + - :month + - :year + datetime: + distance_in_words: + about_x_hours: + one: około godziny + few: około %{count} godziny + many: około %{count} godzin + other: około %{count} godzin + about_x_months: + one: około miesiąca + few: około %{count} miesiące + many: około %{count} miesięcy + other: około %{count} miesięcy + about_x_years: + one: około rok + few: około %{count} lata + many: około %{count} lat + other: około %{count} lat + almost_x_years: + one: prawie rok + few: prawie %{count} lata + many: prawie %{count} lat + other: prawie %{count} lat + half_a_minute: pół minuty + less_than_x_seconds: + one: mniej niż sekundę + few: mniej niż %{count} sekundy + many: mniej niż %{count} sekund + other: mniej niż %{count} sekund + less_than_x_minutes: + one: mniej niż minutę + few: mniej niż %{count} minuty + many: mniej niż %{count} minut + other: mniej niż %{count} minut + over_x_years: + one: ponad rok + few: ponad %{count} lata + many: ponad %{count} lat + other: ponad %{count} lat + x_seconds: + one: 1 sekunda + few: "%{count} sekundy" + many: "%{count} sekund" + other: "%{count} sekund" + x_minutes: + one: 1 minuta + few: "%{count} minuty" + many: "%{count} minut" + other: "%{count} minut" + x_days: + one: 1 dzień + few: "%{count} dni" + many: "%{count} dni" + other: "%{count} dni" + x_months: + one: 1 miesiąc + few: "%{count} miesiące" + many: "%{count} miesięcy" + other: "%{count} miesięcy" + prompts: + second: Sekundy + minute: Minuta + hour: Godzina + day: Dzień + month: Miesiąc + year: Rok + errors: + format: "%{attribute} %{message}" + messages: + accepted: musi zostać zaakceptowane + blank: nie może być puste + confirmation: nie zgadza się z polem %{attribute} + empty: nie może być puste + equal_to: musi być równe %{count} + even: musi być parzyste + exclusion: jest zarezerwowane + greater_than: musi być większe od %{count} + greater_than_or_equal_to: musi być większe lub równe %{count} + inclusion: nie znajduje się na liście dopuszczalnych wartości + invalid: jest nieprawidłowe + less_than: musi być mniejsze od %{count} + less_than_or_equal_to: musi być mniejsze lub równe %{count} + not_a_number: nie jest liczbą + not_an_integer: musi być liczbą całkowitą + odd: musi być nieparzyste + other_than: musi być inna niż %{count} + present: musi być puste + required: musi istnieć + taken: zostało już zajęte + too_long: + one: jest za długie (maksymalnie jeden znak) + few: jest za długie (maksymalnie %{count} znaki) + many: jest za długie (maksymalnie %{count} znaków) + other: jest za długie (maksymalnie %{count} znaków) + too_short: + one: jest za krótkie (przynajmniej jeden znak) + few: jest za krótkie (przynajmniej %{count} znaki) + many: jest za krótkie (przynajmniej %{count} znaków) + other: jest za krótkie (przynajmniej %{count} znaków) + wrong_length: + one: ma nieprawidłową długość (powinna wynosić jeden znak) + few: ma nieprawidłową długość (powinna wynosić %{count} znaki) + many: ma nieprawidłową długość (powinna wynosić %{count} znaków) + other: ma nieprawidłową długość (powinna wynosić %{count} znaków) + template: + body: 'Błędy dotyczą następujących pól:' + header: + one: "%{model} nie został zachowany z powodu jednego błędu" + few: "%{model} nie został zachowany z powodu %{count} błędów" + many: "%{model} nie został zachowany z powodu %{count} błędów" + other: "%{model} nie został zachowany z powodu %{count} błędów" + helpers: + select: + prompt: Proszę wybrać + submit: + create: Utwórz %{model} + submit: Zapisz %{model} + update: Aktualizuj %{model} + number: + currency: + format: + delimiter: " " + format: "%n %u" + precision: 2 + separator: "," + significant: false + strip_insignificant_zeros: true + unit: zł + format: + delimiter: " " + precision: 3 + separator: "," + significant: false + strip_insignificant_zeros: false + human: + decimal_units: + format: "%n %u" + units: + billion: Miliard + million: Milion + quadrillion: Biliard + thousand: Tysiąc + trillion: Bilion + unit: '' + format: + delimiter: '' + precision: 3 + significant: true + strip_insignificant_zeros: true + storage_units: + format: "%n %u" + units: + byte: + one: bajt + few: bajty + many: bajtów + other: bajty + gb: GB + kb: KB + mb: MB + tb: TB + percentage: + format: + delimiter: '' + format: "%n%" + precision: + format: + delimiter: '' + support: + array: + last_word_connector: " oraz " + two_words_connector: " i " + words_connector: ", " + time: + am: przed południem + formats: + default: "%a, %d %b %Y %H:%M:%S %z" + long: "%B %d, %Y %H:%M" + short: "%d %b %H:%M" + pm: po południu