Basic site flow improvements and devise handling

This commit is contained in:
2014-07-16 11:20:11 +02:00
parent de298a529b
commit a302123c6b
20 changed files with 134 additions and 85 deletions
@@ -1,18 +0,0 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require_directory .
//= require_self
@@ -0,0 +1,5 @@
#= require jquery
#= require jquery_ujs
#= require_directory .
#= require_self
$(document).on 'click', '.flash-box', -> $(@).slideUp()
@@ -1,4 +1,5 @@
//= require_self //= require_self
//= require_directory . //= require_directory .
@import ./foundation_and_overrides @import ./foundation_and_overrides
@import ./elements/*
@import ./structure @import ./structure
@@ -0,0 +1,3 @@
ul.devise-nav
+inline-list
@@ -0,0 +1,7 @@
.flash-box
&.alert
+alert($bg: $alert-color)
&.notice
+alert
.close
+alert-close
@@ -0,0 +1,46 @@
.form-row
@extend .row
.form-label
@media #{$small-only}
+grid-column($columns:10, $center:true)
@media #{$medium-only}
+grid-column($columns:4, $offset:1)
@media #{$large-up}
+grid-column(3)
.form-field
@media #{$small-only}
+grid-column($columns:10, $center:true, $last-column:true)
@media #{$medium-only}
+grid-column($columns:4, $last-column:true)
@media #{$large-up}
+grid-column($columns: 3, $last-column:true)
&.full
@media #{$large-up}
+grid-column($columns: 9, $last-column:true)
&.form-actions
padding-top: 12px
.form-errors
$form-error-color: #822
color: $form-error-color
h3
color: $form-error-color
font-size: 1.2em
body
label
&.number
display: inline-block
padding: 4px 10px
input
&.number
width: 60px
display: inline-block
.apply-filter
+button($bg: $primary-color, $padding: $button-tny)
.error
input, textarea
border-color: $alert-color
.new-session-button
+button
input[type="number"]
text-align: right
+5 -1
View File
@@ -4,6 +4,10 @@ class ApplicationController < ActionController::Base
before_action :force_reloads before_action :force_reloads
end end
layout :layout_by_resource layout :layout_by_resource
#before_action do
#flash.now[:notice] = "Test notice"
#flash.now[:alert] = "Test alert"
#end
#protect_from_forgery #protect_from_forgery
rescue_from SimplyStored::RecordNotFound, with: :show_404 rescue_from SimplyStored::RecordNotFound, with: :show_404
@@ -26,7 +30,7 @@ private
I18n.locale = (params[:locale].presence || I18n.default_locale).to_sym I18n.locale = (params[:locale].presence || I18n.default_locale).to_sym
end end
def layout_by_resource def layout_by_resource(*args)
#if devise_controller? #if devise_controller?
#return 'obtain_token' if session[:user_return_to].present? # resource_name == :user ???? #return 'obtain_token' if session[:user_return_to].present? # resource_name == :user ????
#return 'theme1' if session[:supplier_return_to].present? #return 'theme1' if session[:supplier_return_to].present?
+1 -1
View File
@@ -1,3 +1,3 @@
class PagesController < ApplicationController class PagesController < ::ApplicationController
include Cmtool::Includes::PagesController include Cmtool::Includes::PagesController
end end
+5 -1
View File
@@ -1,7 +1,11 @@
module DeviseHelper module DeviseHelper
def devise_error_messages! def devise_error_messages!
if resource.errors.present? if resource.errors.present?
content_tag(:div, content_tag(:h2, t("errors.messages.not_saved.#{resource.errors.size == 1 ? 'one' : 'other'}", count: resource.errors.size)) +content_tag(:ul, resource.errors.full_messages.map{|m| content_tag(:li, m)}.join.html_safe), class: 'alert alert-error') content_tag(:div,
content_tag(:h3, t("errors.messages.not_saved.#{resource.errors.size == 1 ? 'one' : 'other'}", count: resource.errors.size)) +
content_tag(:ul, resource.errors.full_messages.map{|m| content_tag(:li, m)}.join.html_safe),
class: 'form-errors'
)
end end
end end
end end
+2 -1
View File
@@ -39,8 +39,9 @@ class Supplier
view :by_email, key: :email view :by_email, key: :email
validates :name, presence: true validates :name, presence: true
validates :email, email: true
validates :iens_profile, numericality: {allow_blank: true} validates :iens_profile, numericality: {allow_blank: true}
validates :password, confirmation: true validates :password, confirmation: true, presence: {if: ->(r){ r.new_record? }}
def location=(val) def location=(val)
lat, lng = val.is_a?(Array) ? val : val.strip.split(/[ ,]+/).map(&:to_f) lat, lng = val.is_a?(Array) ? val : val.strip.split(/[ ,]+/).map(&:to_f)
+1 -1
View File
@@ -1,4 +1,4 @@
ul.nav.nav-pills ul.nav.nav-pills.devise-nav
- if controller_name != 'sessions' - if controller_name != 'sessions'
li= link_to t('devise.sessions.button'), new_session_path(resource_name), class: [:devise, :btn] li= link_to t('devise.sessions.button'), new_session_path(resource_name), class: [:devise, :btn]
+4 -4
View File
@@ -10,6 +10,7 @@ html lang="en"
/[if lt IE 9] /[if lt IE 9]
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js" = javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
= stylesheet_link_tag "theme1/application", :media => "all" = stylesheet_link_tag "theme1/application", :media => "all"
= javascript_include_tag 'theme1/application'
link href="/favicon.ico" rel="shortcut icon" link href="/favicon.ico" rel="shortcut icon"
link href='http://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css' link href='http://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'
@@ -45,11 +46,11 @@ html lang="en"
.main-inner .main-inner
.general-alerts .general-alerts
- if flash[:alert].present? - if flash[:alert].present?
.alert-box.warning .flash-box.alert
div= flash[:alert] div= flash[:alert]
a.close data-dismiss="alert" &#215; a.close data-dismiss="alert" &#215;
- if flash[:notice].present? - if flash[:notice].present?
.alert-box .flash-box.notice
div= flash[:notice] div= flash[:notice]
a.close data-dismiss="alert" &#215; a.close data-dismiss="alert" &#215;
= yield :page_title = yield :page_title
@@ -58,5 +59,4 @@ html lang="en"
.footer-shadow .footer-shadow
.container .container
.footer-content= render 'footer' .footer-content= render 'footer'
.footer-bottom &copy; Qwaiter 2013 .footer-bottom &copy; Qwaiter 2014
= javascript_include_tag "application"
+4 -4
View File
@@ -40,13 +40,13 @@ html lang="en"
.container .container
.main-inner .main-inner
- if flash[:alert].present? - if flash[:alert].present?
.alert.alert-error .flash-box.alert
a.close data-dismiss="alert" &#215;
div= flash[:alert] div= flash[:alert]
- if flash[:notice].present?
.alert.alert-success
a.close data-dismiss="alert" &#215; a.close data-dismiss="alert" &#215;
- if flash[:notice].present?
.flash-box.notice
div= flash[:notice] div= flash[:notice]
a.close data-dismiss="alert" &#215;
- if @page && @page.title.present? - if @page && @page.title.present?
h1.page-title= @page.title h1.page-title= @page.title
= yield = yield
@@ -2,11 +2,8 @@ h2= t('devise.confirmations.title')
= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), html: { method: :post, class: 'form-horizontal' }) do |f| = form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), html: { method: :post, class: 'form-horizontal' }) do |f|
= devise_error_messages! = devise_error_messages!
.control-group = f.row :email do
= f.label :email, class: 'control-label' .form-label= f.label :email, class: 'control-label'
.controls .form-field= f.email_field :email
= f.email_field :email .form-row.form-actions= f.submit t('devise.confirmations.submit_text'), class: 'button'
.control-group
.controls= f.submit t('devise.confirmations.submit_text'), class: 'btn-primary'
= render "links" = render "links"
+7 -9
View File
@@ -2,13 +2,11 @@ h2= t('devise.passwords.edit.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal', method: :put}) do |f| = form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal', method: :put}) do |f|
= devise_error_messages! = devise_error_messages!
= f.hidden_field :reset_password_token = f.hidden_field :reset_password_token
.control-group .form-row
= f.label :password, class: 'control-label' .form-label= f.label :password
.controls= f.password_field :password .form-field= f.password_field :password
.control-group = f.row :password_confirmation do
= f.label :password_confirmation, class: 'control-label' .form-label= f.label :password_confirmation
.controls= f.password_field :password_confirmation .form-field= f.password_field :password_confirmation
.control-group .form-row= f.submit t('devise.passwords.edit.button'), class: 'button'
.controls
= f.submit t('devise.passwords.edit.button'), class: 'btn btn-primary'
= render "links" = render "links"
+4 -6
View File
@@ -1,10 +1,8 @@
h2= t('devise.passwords.title') h2= t('devise.passwords.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal'}) do |f| = form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages! = devise_error_messages!
.control-group = f.row :email do
= f.label :email, class: 'control-label' .form-label= f.label :email, class: 'control-label'
.controls= f.email_field :email .form-field= f.email_field :email
.control-group .form-row.form-actions= f.submit t('devise.passwords.button'), class: 'button'
.controls
= f.submit t('devise.passwords.button'), class: 'btn btn-primary'
= render "links" = render "links"
+13 -14
View File
@@ -6,18 +6,17 @@ p
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: 'form-horizontal'}) do |f| = form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages! = devise_error_messages!
.control-group .control-group
= f.label :name, class: 'control-label' = f.row :name do
.controls= f.text_field :name .form-label= f.label :name, class: 'control-label'
.control-group .form-field= f.text_field :name
= f.label :email, class: 'control-label' = f.row :email do
.controls= f.email_field :email .form-label= f.label :email, class: 'control-label'
.control-group .form-field= f.email_field :email
= f.label :password, class: 'control-label' = f.row :password do
.controls= f.password_field :password .form-label= f.label :password, class: 'control-label'
.control-group .form-field= f.password_field :password
= f.label :password_confirmation, class: 'control-label' = f.row :password_confirmation do
.controls= f.password_field :password_confirmation .form-label= f.label :password_confirmation, class: 'control-label'
.control-group .form-field= f.password_field :password_confirmation
.controls .form-row.form-actions= f.submit t('devise.registrations.button'), class: 'button'
= f.submit t('devise.registrations.button'), class: 'btn btn-primary'
= render "links" = render "links"
+6 -11
View File
@@ -1,19 +1,14 @@
h2= t('devise.sessions.title') h2= t('devise.sessions.title')
= form_for(resource, :as => resource_name, :url => session_path(resource_name), html: {class: 'form-horizontal'}) do |f| = form_for(resource, :as => resource_name, :url => session_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages! = devise_error_messages!
.control-group = f.row :email do
= f.label :email, class: 'control-label' .form-label= f.label :email
.controls= f.email_field :email .form-field= f.email_field :email
.control-group .form-row
= f.label :password, class: 'control-label'
.controls= f.password_field :password
.control-group
.controls
= f.label :remember_me do = f.label :remember_me do
= f.check_box :remember_me = f.check_box :remember_me
|&nbsp; |&nbsp;
= t('devise.sessions.remember_me') = t('devise.sessions.remember_me')
.control-group .form-row
.controls = f.submit t('devise.sessions.button'), class: 'new-session-button'
= f.submit t('devise.sessions.button'), class: 'btn btn-primary'
= render "links" = render "links"
@@ -11,5 +11,13 @@ class CustomFormBuilder < ActionView::Helpers::FormBuilder
) )
t.content_tag(:div, elements.inject(&:+), class: 'form-actions') t.content_tag(:div, elements.inject(&:+), class: 'form-actions')
end end
def row(attribute, options={}, &block)
t = @template
classes = []
classes << 'form-row'
classes << attribute
classes << 'error' if object.errors[attribute].present?
t.content_tag(:div, t.capture(&block), class: classes)
end
end end
ActionView::Base.default_form_builder = CustomFormBuilder ActionView::Base.default_form_builder = CustomFormBuilder
+4 -3
View File
@@ -29,7 +29,7 @@ nl:
inactive: 'Your account was not activated yet.' inactive: 'Your account was not activated yet.'
not_found_in_database: "Je bent nog niet bij ons bekend. Meld je aan om Qwaiter te kunnen gebruiken!" not_found_in_database: "Je bent nog niet bij ons bekend. Meld je aan om Qwaiter te kunnen gebruiken!"
sessions: sessions:
title: Inloggen title: Inloggen voor horeca
button: Inloggen button: Inloggen
signed_in: Succesvol ingelogd signed_in: Succesvol ingelogd
signed_out: Succesvol uitgelogd signed_out: Succesvol uitgelogd
@@ -44,13 +44,14 @@ nl:
send_instructions: 'U ontvangt binnen enkele minuten een e-mail met instructies voor het resetten van uw wachtwoord' send_instructions: 'U ontvangt binnen enkele minuten een e-mail met instructies voor het resetten van uw wachtwoord'
updated: 'Uw wachtwoord is succesvol gewijzigd. U bent nu ingelogd.' updated: 'Uw wachtwoord is succesvol gewijzigd. U bent nu ingelogd.'
forgot_password: Wachtwoord vergeten? forgot_password: Wachtwoord vergeten?
no_token: Geen token gegeven
send_instructions_button: Stuur mij reset instructies send_instructions_button: Stuur mij reset instructies
edit: edit:
title: Verander je wachtwoord title: Verander je wachtwoord
button: Verander wachtwoord button: Verander wachtwoord
registrations: registrations:
title: Aanmelden title: Nieuwe aanmelding als horeca
button: Aanmelden button: Nieuwe aanmelding als horeca
signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.' signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.' signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.' signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'