diff options
23 files changed, 494 insertions, 157 deletions
@@ -32,7 +32,7 @@ gem 'language_engine', '0.0.5' gem 'gravatar_image_tag' gem 'calendar_helper', "0.2.5" gem 'cocoon', "1.1.2" -gem 'formtastic' +gem 'formtastic', "2.3.1" gem 'RedCloth' # some views use coffee script @@ -50,10 +50,10 @@ gem 'morrisjs-rails' gem 'raphael-rails' # Use twitter bootstrap resources -gem 'rails-assets-bootstrap-sass-official', '~> 3.1.1' +gem 'rails-assets-bootstrap-sass-official', '~> 3.3.0' gem 'font-awesome-sass', '~> 4.2.0' gem 'will_paginate-bootstrap' -gem 'simple_form' +gem 'simple_form', "2.1.1" gem 'rails-assets-tagmanager', '~> 3.0.1.0' gem 'rails-assets-typeahead.js', '~> 0.10.5' gem "breadcrumbs_on_rails" diff --git a/Gemfile.lock b/Gemfile.lock index f768b3d6a..47272cc14 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -138,7 +138,7 @@ GEM sass (~> 3.2) foreigner (1.6.0) activerecord (>= 3.0.0) - formtastic (2.2.1) + formtastic (2.3.1) actionpack (>= 3.0) geokit (1.6.7) multi_json (>= 1.3.2) @@ -240,7 +240,8 @@ GEM railties (= 3.2.18) rails-assets-bootstrap (3.1.1) rails-assets-jquery (>= 1.9.0) - rails-assets-bootstrap-sass-official (3.1.1.2) + rails-assets-bootstrap-sass-official (3.3.0) + rails-assets-jquery (>= 1.9.0) rails-assets-eonasdan-bootstrap-datetimepicker (3.1.3) rails-assets-bootstrap (>= 3.0) rails-assets-jquery (>= 1.8.3) @@ -333,7 +334,7 @@ GEM activemodel (~> 3.0) spreadsheet (0.9.7) ruby-ole (>= 1.0) - sprockets (2.2.2) + sprockets (2.2.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) @@ -399,7 +400,7 @@ DEPENDENCIES dr-apartment factory_girl_rails (= 1.7) font-awesome-sass (~> 4.2.0) - formtastic + formtastic (= 2.3.1) georuby-ext (= 0.0.5) google-analytics-rails gravatar_image_tag @@ -420,7 +421,7 @@ DEPENDENCIES pg (~> 0.11.0) rabl rails (= 3.2.18) - rails-assets-bootstrap-sass-official (~> 3.1.1) + rails-assets-bootstrap-sass-official (~> 3.3.0) rails-assets-eonasdan-bootstrap-datetimepicker (~> 3.1.3) rails-assets-respond rails-assets-tagmanager (~> 3.0.1.0) @@ -438,7 +439,7 @@ DEPENDENCIES rubyzip (~> 1.1.6) sass-rails (~> 3.2.3) shoulda-matchers - simple_form + simple_form (= 2.1.1) sqlite3 squeel therubyracer (~> 0.10.2) diff --git a/app/assets/stylesheets/application.css.scss.erb b/app/assets/stylesheets/application.css.scss.erb index 3ea2b36ed..b510fc524 100644 --- a/app/assets/stylesheets/application.css.scss.erb +++ b/app/assets/stylesheets/application.css.scss.erb @@ -12,6 +12,7 @@ $body-bg: #eee; @import "modules/search"; @import "modules/index_item"; @import "modules/icons"; +@import "modules/devise"; // Partials @import "partials/header"; @@ -36,6 +37,7 @@ $body-bg: #eee; @import "vendor/token-input"; @import "vendor/typeahead"; @import "vendor/bootstrap_changes"; +@import "vendor/simple_form"; // Main css @import "main/*"; diff --git a/app/assets/stylesheets/main/layout.css.scss b/app/assets/stylesheets/main/layout.css.scss index 90da0cc6d..0a9ade3a8 100644 --- a/app/assets/stylesheets/main/layout.css.scss +++ b/app/assets/stylesheets/main/layout.css.scss @@ -1,5 +1,5 @@ body { - padding-top: 55px; + padding-top: 50px; } h1{ color: white;} @@ -17,75 +17,6 @@ ol.breadcrumb{ margin-top: 10px; } -#header { - - .navbar-brand{ - padding-top: 5px; - padding-bottom: 5px; - line-height: 40px; - - img { - height: 40px; - } - - .brand_name{ - margin-left: 3px; - margin-right: 3px; - font-size: 20px; - font-family: monospace; - font-weight: bold; - } - - .version - { - vertical-align: text-top; - color: white; - font-size: 12px; - } - } - - background: $brand_primary url(image-path('header.png')) no-repeat; - - .gravatar { - margin-right: 5px; - img{ - width: 25px; - height: 25px; - } - } - - .dropdown.languages{ - .dropdown-menu{ - min-width: 56px; - } - } - - .dropdown.datas{ - .dropdown-menu{ - - .badge{ - background-color: #DADADA - } - } - } -} - -#footer{ - padding: 20px; - background-color: $gray-darker; - color: $gray-light; - font-size: 12px; - min-height: 200px; - - a { color: $gray-light; } - - h4 { color: $gray-lighter; } - - .logo > img { - margin-left: 20px; - } -} - #middle{ min-height: 500px; -webkit-box-shadow: 0 0 5px 2px rgba(0, 0, 0, .2); diff --git a/app/assets/stylesheets/modules/devise.css.scss b/app/assets/stylesheets/modules/devise.css.scss new file mode 100644 index 000000000..83b2b3fec --- /dev/null +++ b/app/assets/stylesheets/modules/devise.css.scss @@ -0,0 +1,75 @@ +#devise{ + background-color: $gray-light; + + .front_bg{ + //background: url(image-path('intro.jpg')) no-repeat center center; + //background-size: cover; + + #devise_middle{ + min-height: 620px; + padding: 30px 20px 0px 20px; + + #registrations_new{ + + .form-group{ + margin-bottom: 5px; + } + + } + + #sessions_new{ + + .btn{ + font-weight: bold; + } + + .product_summary{ + padding: 30px 60px 0 60px; + + color: white; + text-shadow: 0 0 1px rgba(0,0,0,.6); + + p{ + font-size: 21px; + } + + ul > li{ font-size: 21px; } + } + + .login{ + padding-top: 30px; + + .form-group{ + margin-bottom: 5px; + } + + .options{ + .new_password{ + padding-top: 7px; + } + + .checkbox{ + font-weight: normal; + + input[type="checkbox"]{ + margin-left: 0px !important; + position: relative; + margin: 0px 4px 0px 0px; + } + } + + .form-group{ + margin-bottom: 0px; + } + + font-size: 12px; + } + } + } + } + + #footer{ + background-color: rgba(0, 0, 0, 0.8); + } + } +}
\ No newline at end of file diff --git a/app/assets/stylesheets/partials/header.css.scss b/app/assets/stylesheets/partials/header.css.scss index cc0e4a711..6f7b777f1 100644 --- a/app/assets/stylesheets/partials/header.css.scss +++ b/app/assets/stylesheets/partials/header.css.scss @@ -7,14 +7,25 @@ img { height: 40px; - } + } + } + .navbar-text{ + margin-top: 10px; + margin-bottom: 10px; + margin-left: 0px; + + .brand_name{ + color: white; + font-weight: bold; + font-size: 20px; + } + .version { - margin-left: 3px; - vertical-align: text-top; + margin-left: 5px; color: white; - font-size: 13px; + font-size: 12px; } } @@ -34,12 +45,4 @@ } } - .dropdown.datas{ - .dropdown-menu{ - - .badge{ - background-color: #333 - } - } - } }
\ No newline at end of file diff --git a/app/assets/stylesheets/vendor/simple_form.css.scss b/app/assets/stylesheets/vendor/simple_form.css.scss new file mode 100644 index 000000000..ea5e4d528 --- /dev/null +++ b/app/assets/stylesheets/vendor/simple_form.css.scss @@ -0,0 +1,6 @@ +.simple_form{ + + .help-inline{ + color:#cc0000; + } +}
\ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 64a706557..04dd281d5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -21,6 +21,6 @@ class ApplicationController < ActionController::Base # Overwriting the sign_out redirect path method def after_sign_out_path_for(resource_or_scope) new_user_session_path - end + end end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index f0ac420ce..b02d3217a 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -5,7 +5,6 @@ private def accept_user_creation - puts "J'y passe" if !Rails.application.config.accept_user_creation redirect_to root_path return false diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 17cf9a8f2..f4b2e35f8 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -3,6 +3,5 @@ class Organisation < ActiveRecord::Base has_many :users, :dependent => :destroy has_many :referentials, :dependent => :destroy - validates_presence_of :name - validates_uniqueness_of :name + validates :name, :presence => true, :uniqueness => true end diff --git a/app/models/user.rb b/app/models/user.rb index 1889a3bf0..6c14b93fb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -11,11 +11,11 @@ class User < ActiveRecord::Base belongs_to :organisation accepts_nested_attributes_for :organisation - - validates_presence_of :email - validates_presence_of :name - validates_presence_of :password - validates_presence_of :password_confirmation + + validates :organisation, :presence => true + validates :email, :presence => true, :uniqueness => true + validates :name, :presence => true + validates :password, :presence => true, :confirmation => true before_validation(:on => :create) do self.password ||= Devise.friendly_token.first(6) diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb index f285a0f6d..68fd8c22a 100644 --- a/app/views/devise/passwords/new.html.erb +++ b/app/views/devise/passwords/new.html.erb @@ -1,13 +1,13 @@ -<%= title_tag t('.title') %> +<div class="panel panel-default"> + <div class="panel-heading"><%= t('.title') %></div> + <div class="panel-body"> + <%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |form| %> + <%= form.input :email %> -<%= semantic_form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |form| %> - <%= form.inputs :email %> - - <%= form.actions do %> - <%= form.action :submit, :as => :button, :label => t('.commit') %> - <%= form.action :cancel, :as => :link %> - <% end %> + <%= link_to t("cancel"), root_path, :class => "btn btn-default" %> + <%= form.button :submit, :value => t("devise.passwords.new.commit") %> + <% end %> + </div> +</div> -<% end %> -<%= render "links" %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 79edcb53b..9c780cba3 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,22 +1,26 @@ -<%= title_tag t('.title') %> +<div id="registrations_new" class="col-lg-offset-4 col-lg-4"> -<%= semantic_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |form| %> - <%= form.inputs do %> - <%= form.semantic_fields_for :organisation, Organisation.new do |organisation| %> - <%= organisation.input :name, :label => t("helpers.label.user.organisation_name") %> + <% if Rails.application.config.accept_user_creation %> + <div class="panel panel-default"> + <div class="panel-heading"><%= t("devise.registrations.new.title") %></div> + <div class="panel-body"> + <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :wrapper => "form_without_label" ) do |form| %> + <%= form.simple_fields_for :organisation, Organisation.new do |organisation| %> + <%= organisation.input :name, :label => false, :placeholder => t("helpers.label.user.organisation_name"), input_html: { :class => "form-control" } %> + <% end %> + <% if resource.respond_to?( :name) %> + <%= form.input :name, :label => false, :placeholder => t("helpers.label.user.name"), input_html: { :class => "form-control" } %> + <% end %> + <%= form.input :email, :label => false, :placeholder => t("helpers.label.user.email"), input_html: { :class => "form-control" } %> + <%= form.input :password, :as => :password, :label => false, :placeholder => t("helpers.label.user.password"), input_html: { :class => "form-control" } %> + <%= form.input :password_confirmation, :as => :password, :label => false, :placeholder => t("helpers.label.user.password_confirmation"), input_html: { :class => "form-control" } %> + + <%= form.button :submit, :class => "btn-primary" %> + <% end %> + </div> + </div> <% end %> - <% if resource.respond_to?( :name) %> - <%= form.input :name %> - <% end %> - <%= form.input :email %> - <%= form.input :password, :as => :password %> - <%= form.input :password_confirmation, :as => :password %> - <% end %> + +</div> - <%= form.actions do %> - <%= form.action :submit, :as => :button, :label => t('.commit') %> - <%= form.action :cancel, :as => :link %> - <% end %> -<% end %> -<%= render "links" %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index a6c13df5d..768efdd9f 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,19 +1,65 @@ -<%= title_tag t('.title') %> +<div id="sessions_new" class="row"> + <div class="col-md-8 product_summary"> + <h2>Bienvenue sur Chouette</h2> + <p> + Chouette est un logiciel Open Source de saisie, de visualisation et d'échange d'offre de transport public planifiée. + </p> + <p> + Ce logiciel est déployé en mode Saas et se veut ouvert : + </p> + <ul> + <li>- choix de plusieurs fonds cartographiques</li> + <li>- échange de données en différents normes (Neptune, ...) et standard (GTFS, ...)</li> + </ul> + </div> + <div class="col-md-4 login"> + <div class="panel panel-default"> + <div class="panel-body"> + <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :wrapper => "form_without_label" ) do |form| %> + <%= form.input :email, :label => false, :placeholder => t("helpers.label.user.email"), input_html: { :class => "form-control" } %> + <div class="row"> + <div class="col-md-6"> + <%= form.input :password, :as => :password, :label => false, :placeholder => t("helpers.label.user.password"), input_html: { :class => "form-control" } %> + </div> + <div class="col-md-6"> + <%= form.button :submit, t("devise.sessions.new.commit"), :class => "btn-primary" %> + </div> + </div> + <div class="row options"> + <div class="col-md-6"> + <% if devise_mapping.rememberable? %> + <%= form.input :remember_me, :as => :boolean, :label => false, :inline_label => t("helpers.label.user.remember_me") if devise_mapping.rememberable? %> + <% end %> + </div> + <div class="col-md-6 new_password"> + <%= link_to t("devise.links.new_password"), new_password_path(resource_name) %> + </div> + </div> + <% end %> + </div> + </div> -<%= semantic_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |form| %> - <%= form.inputs do %> - <%= form.input :email %> - <%= form.input :password, :as => :password %> - - <% if devise_mapping.rememberable? -%> - <%= form.input :remember_me, :as => :boolean %> + <% if Rails.application.config.accept_user_creation %> + <div class="panel panel-default"> + <div class="panel-heading"><%= t("devise.registrations.new.title") %></div> + <div class="panel-body"> + <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :wrapper => "form_without_label" ) do |form| %> + <%= form.simple_fields_for :organisation, Organisation.new do |organisation| %> + <%= organisation.input :name, :label => false, :placeholder => t("helpers.label.user.organisation_name"), input_html: { :class => "form-control" } %> + <% end %> + <% if resource.respond_to?( :name) %> + <%= form.input :name, :label => false, :placeholder => t("helpers.label.user.name"), input_html: { :class => "form-control" } %> + <% end %> + <%= form.input :email, :label => false, :placeholder => t("helpers.label.user.email"), input_html: { :class => "form-control" } %> + <%= form.input :password, :as => :password, :label => false, :placeholder => t("helpers.label.user.password"), input_html: { :class => "form-control" } %> + <%= form.input :password_confirmation, :as => :password, :label => false, :placeholder => t("helpers.label.user.password_confirmation"), input_html: { :class => "form-control" } %> + + <%= form.button :submit, :class => "btn-default" %> + <% end %> + </div> + </div> <% end %> - <% end %> - - - <%= form.actions do %> - <%= form.action :submit, :as => :button, :label => t('.commit') %> - <% end %> -<% end %> + + </div> +</div> -<%= render "links" %> diff --git a/app/views/layouts/without_sidebar.html.erb b/app/views/layouts/devise.html.erb index c61dc6b25..60c531780 100644 --- a/app/views/layouts/without_sidebar.html.erb +++ b/app/views/layouts/devise.html.erb @@ -16,23 +16,25 @@ <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> </head> - <body> + <body id="devise"> <div id="header"> <%= render partial: "shared/header" %> </div> - <div id="middle" class="container"> - <div class="row"> - <div class="col-md-12"> + <div class="front_bg"> + <div id="devise_middle" class="container"> + <div class="row"> + <div class="<%= content_for?(:sidebar) ? 'col-md-9' : 'col-md-12' %>"> <div id="workspace" class="<%= controller_name %> <%= action_name %>"> <%= render partial: "shared/flash_messages", flash: flash %> <%= render partial: "shared/breadcrumb" %> <%= yield %> </div> </div> + </div> </div> - </div> - <div id="footer"> - <%= render partial: "shared/footer" %> - </div> + <div id="footer"> + <%= render partial: "shared/footer" %> + </div> + </div> </body> </html> diff --git a/app/views/shared/_header.erb b/app/views/shared/_header.erb index 3b7c90926..380f5b520 100644 --- a/app/views/shared/_header.erb +++ b/app/views/shared/_header.erb @@ -10,10 +10,10 @@ <span class="icon-bar version"><%= APP_VERSION %></span> </button> <%= link_to referentials_path, :class =>"navbar-brand" do %> - <%= image_tag("logo_chouette.png") %><span class="brand_name">CHOUETTE</span></i><span class="version"><%= APP_VERSION %></span> + <%= image_tag("logo_chouette.png") %> <% end %> + <p class="navbar-text"><span class="brand_name">CHOUETTE</span></i><span class="version"><%= APP_VERSION %></span></p> </div> - <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 4aa6ef80d..8434a26c8 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,6 +1,7 @@ # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| + # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. @@ -242,3 +243,11 @@ Devise.setup do |config| # manager.default_strategies(:scope => :user).unshift :some_external_strategy # end end + +Rails.application.config.to_prepare do + Devise::SessionsController.layout "devise" + Devise::RegistrationsController.layout proc{ |controller| ( action_name == "edit") ? "application" : "devise" } + Devise::ConfirmationsController.layout "devise" + Devise::UnlocksController.layout "devise" + Devise::PasswordsController.layout "devise" +end diff --git a/config/initializers/remove_simple_form_bootstrap3_inputs.rb b/config/initializers/remove_simple_form_bootstrap3_inputs.rb new file mode 100644 index 000000000..448487308 --- /dev/null +++ b/config/initializers/remove_simple_form_bootstrap3_inputs.rb @@ -0,0 +1,32 @@ +inputs = %w[ + CollectionSelectInput + DateTimeInput + FileInput + GroupedCollectionSelectInput + NumericInput + PasswordInput + RangeInput + StringInput + TextInput +] + +# Instead of creating top-level custom input classes like TextInput, we wrap it into a module and override +# mapping in SimpleForm::FormBuilder directly +# +SimpleFormBootstrapInputs = Module.new +inputs.each do |input_type| + superclass = "SimpleForm::Inputs::#{input_type}".constantize + + new_class = SimpleFormBootstrapInputs.const_set(input_type, Class.new(superclass) do + def input_html_classes + super.push('form-control') + end + end) + + # Now override existing usages of superclass with new_class + SimpleForm::FormBuilder.mappings.each do |(type, target_class)| + if target_class == superclass + SimpleForm::FormBuilder.map_type(type, to: new_class) + end + end +end diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb new file mode 100644 index 000000000..e2ad34eee --- /dev/null +++ b/config/initializers/simple_form.rb @@ -0,0 +1,142 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + # Wrappers are used by the form builder to generate a + # complete input. You can remove any component from the + # wrapper, change the order or even add your own to the + # stack. The options given below are used to wrap the + # whole input. + config.wrappers :default, :class => :input, + :hint_class => :field_with_hint, :error_class => :field_with_errors do |b| + ## Extensions enabled by default + # Any of these extensions can be disabled for a + # given input by passing: `f.input EXTENSION_NAME => false`. + # You can make any of these extensions optional by + # renaming `b.use` to `b.optional`. + + # Determines whether to use HTML5 (:email, :url, ...) + # and required attributes + b.use :html5 + + # Calculates placeholders automatically from I18n + # You can also pass a string as f.input :placeholder => "Placeholder" + b.use :placeholder + + ## Optional extensions + # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup` + # to the input. If so, they will retrieve the values from the model + # if any exists. If you want to enable the lookup for any of those + # extensions by default, you can change `b.optional` to `b.use`. + + # Calculates maxlength from length validations for string inputs + b.optional :maxlength + + # Calculates pattern from format validations for string inputs + b.optional :pattern + + # Calculates min and max from length validations for numeric inputs + b.optional :min_max + + # Calculates readonly automatically from readonly attributes + b.optional :readonly + + ## Inputs + b.use :label_input + b.use :hint, :wrap_with => { :tag => :span, :class => :hint } + b.use :error, :wrap_with => { :tag => :span, :class => :error } + end + + # The default wrapper to be used by the FormBuilder. + config.default_wrapper = :default + + # Define the way to render check boxes / radio buttons with labels. + # Defaults to :nested for bootstrap config. + # :inline => input + label + # :nested => label > input + config.boolean_style = :nested + + # Default class for buttons + config.button_class = 'btn' + + # Method used to tidy up errors. Specify any Rails Array method. + # :first lists the first message for each field. + # Use :to_sentence to list all errors for each field. + # config.error_method = :first + + # Default tag used for error notification helper. + config.error_notification_tag = :div + + # CSS class to add for error notification helper. + config.error_notification_class = 'alert alert-error' + + # ID to add for error notification helper. + # config.error_notification_id = nil + + # Series of attempts to detect a default label method for collection. + # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] + + # Series of attempts to detect a default value method for collection. + # config.collection_value_methods = [ :id, :to_s ] + + # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. + # config.collection_wrapper_tag = nil + + # You can define the class to use on all collection wrappers. Defaulting to none. + # config.collection_wrapper_class = nil + + # You can wrap each item in a collection of radio/check boxes with a tag, + # defaulting to :span. Please note that when using :boolean_style = :nested, + # SimpleForm will force this option to be a label. + # config.item_wrapper_tag = :span + + # You can define a class to use in all item wrappers. Defaulting to none. + # config.item_wrapper_class = nil + + # How the label text should be generated altogether with the required text. + # config.label_text = lambda { |label, required| "#{required} #{label}" } + + # You can define the class to use on all labels. Default is nil. + config.label_class = 'col-lg-2 control-label' + + # You can define the class to use on all forms. Default is simple_form. + config.form_class = "simple_form form-horizontal" + + # You can define which elements should obtain additional classes + # config.generate_additional_classes_for = [:wrapper, :label, :input] + + # Whether attributes are required by default (or not). Default is true. + # config.required_by_default = true + + # Tell browsers whether to use default HTML5 validations (novalidate option). + # Default is enabled. + config.browser_validations = false + + # Collection of methods to detect if a file type was given. + # config.file_methods = [ :mounted_as, :file?, :public_filename ] + + # Custom mappings for input types. This should be a hash containing a regexp + # to match as key, and the input type that will be used when the field name + # matches the regexp as value. + # config.input_mappings = { /count/ => :integer } + + # Custom wrappers for input types. This should be a hash containing an input + # type as key and the wrapper that will be used for all inputs with specified type. + # config.wrapper_mappings = { :string => :prepend } + + # Default priority for time_zone inputs. + # config.time_zone_priority = nil + + # Default priority for country inputs. + # config.country_priority = nil + + # Default size for text inputs. + # config.default_input_size = 50 + + # When false, do not use translations for labels. + # config.translate_labels = true + + # Automatically discover new inputs in Rails' autoload path. + # config.inputs_discovery = false + + # Cache SimpleForm inputs discovery + # config.cache_discovery = !Rails.env.development? +end diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb new file mode 100644 index 000000000..c3dd5e348 --- /dev/null +++ b/config/initializers/simple_form_bootstrap.rb @@ -0,0 +1,58 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + config.wrappers :bootstrap, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b| + b.use :html5 + b.use :placeholder + b.use :label + b.wrapper :tag => 'div', :class => 'col-lg-10' do |ba| + ba.use :input + ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } + ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' } + end + end + + config.wrappers :form_without_label, :tag => 'div', :class => 'form-group', :error_class => 'error' do |b| + b.use :html5 + b.use :placeholder + b.use :label + b.wrapper :tag => 'div', :class => 'col-lg-12' do |ba| + ba.use :input + ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } + ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' } + end + end + + config.wrappers :prepend, :tag => 'div', :class => "form-group", :error_class => 'error' do |b| + b.use :html5 + b.use :placeholder + b.use :label + b.wrapper :tag => 'div', :class => 'col-lg-10' do |input| + input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend| + prepend.use :input + end + input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' } + input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } + end + end + + config.wrappers :append, :tag => 'div', :class => "form-group", :error_class => 'error' do |b| + b.use :html5 + b.use :placeholder + b.use :label + b.wrapper :tag => 'div', :class => 'col-lg-10' do |input| + input.wrapper :tag => 'div', :class => 'input-append' do |append| + append.use :input + end + input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' } + input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } + end + end + + # Wrappers for forms and inputs using the Twitter Bootstrap toolkit. + # Check the Bootstrap docs (http://twitter.github.com/bootstrap) + # to learn about the different styles for forms and inputs, + # buttons and other elements. + config.default_wrapper = :bootstrap + config.button_class = 'btn' + config.label_class = 'col-lg-2 control-label' +end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 0a42a021d..933eca4a3 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -11,7 +11,7 @@ en: title: Resend confirmation instructions registrations: new: - title: Sign up + title: "Sign up" commit: Sign up edit: title: "Your profile" @@ -36,6 +36,7 @@ en: helpers: label: user: + email: "Email" organisation_name: "Organisation name" name: Full name password: Password diff --git a/config/locales/devise.fr.yml b/config/locales/devise.fr.yml index d3a60d9a0..391ec343a 100644 --- a/config/locales/devise.fr.yml +++ b/config/locales/devise.fr.yml @@ -15,7 +15,7 @@ fr: title: Renvoyer le mail de confirmation registrations: new: - title: "S'inscrire" + title: "Inscrivez vous" commit: Créer un compte edit: title: "Votre Profil" @@ -35,11 +35,12 @@ fr: links: sign_in: "Se connecter" sign_up: "S'inscrire" - new_password: Mot de passe oublié + new_password: "Mot de passe oublié?" new_confirmation: "Vous n'avez pas reçu les instructions de confirmation ?" helpers: label: user: + email: "Email" organisation_name: "Nom de l'organisation" name: Nom complet password: Mot de passe diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml new file mode 100644 index 000000000..0df11fe0f --- /dev/null +++ b/config/locales/simple_form.en.yml @@ -0,0 +1,26 @@ +en: + simple_form: + "yes": 'Yes' + "no": 'No' + required: + text: 'required' + mark: '*' + # You can uncomment the line below if you need to overwrite the whole required html. + # When using html, text and mark won't be used. + # html: '<abbr title="required">*</abbr>' + error_notification: + default_message: "Please review the problems below:" + # Labels and hints examples + # labels: + # defaults: + # password: 'Password' + # user: + # new: + # email: 'E-mail to sign in.' + # edit: + # email: 'E-mail.' + # hints: + # defaults: + # username: 'User name to sign in.' + # password: 'No special characters, please.' + |
