Skip to content

Commit

Permalink
mejor manejo y visualización de errores
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciopasquier committed Jul 31, 2012
1 parent 606c39b commit f689790
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/assets/stylesheets/comunes/_constantes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $tierra_claro: lighten($tierra, 15%);
float: left;
margin-right: $margen;
* { float: left; }
input { width: 97px !important; }
label { width: 25px;
.input-tag { width: 97px !important; }
.label-tag { width: 25px;
margin: 6px 6px 6px 0; }
}
28 changes: 18 additions & 10 deletions app/assets/stylesheets/comunes/formularios.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,29 @@ form {
::-webkit-input-placeholder { color: $gris_claro; }
input:focus::-webkit-input-placeholder { color: transparent; }

}
// estilo para los campos y etiquetas con error en los formularios

// estilo para los campos y etiquetas con error en los formularios
.field_with_errors {
.field_with_errors {

width: inherit !important;
input {
color: black;
background: lighten($rojo_inta, 50%);
border-color: $rojo_inta;
}

label {
color: $rojo_inta;
text-decoration: underline;
}

label, input {
@include mensaje($rojo_inta);
color: black;
border-width: 1px;
margin-bottom: 0;
}
}

.error_field {
// sobreescribe el default size=30
width: inherit !important;
}

}
// div con mensajes de error
#errorExplanation {
@include mensaje($rojo_inta);
Expand Down
3 changes: 1 addition & 2 deletions app/models/calicata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Calicata < ActiveRecord::Base
validates_numericality_of :cobertura_vegetal,
greater_than_or_equal_to: 0, less_than: 101,
allow_nil: true
validates_associated :ubicacion, :horizontes, :fase, :grupo

has_many :horizontes, dependent: :destroy, inverse_of: :calicata
has_many :adjuntos, dependent: :destroy, inverse_of: :calicata
Expand Down Expand Up @@ -51,7 +50,7 @@ class Calicata < ActiveRecord::Base
belongs_to :grupo, inverse_of: :calicatas

accepts_nested_attributes_for :capacidad, :paisaje, :ubicacion, :pedregosidad,
:humedad,
:humedad, :erosion,
limit: 1, allow_destroy: true
accepts_nested_attributes_for :grupo, :fase, limit: 1, reject_if: :all_blank
accepts_nested_attributes_for :horizontes, :analisis, allow_destroy: true
Expand Down
12 changes: 8 additions & 4 deletions app/views/calicatas/_descripcion_del_sitio.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@
.prepend-2.span-9.campo
.span-2= label_tag nil, 'Coordenadas'
.coordenada-y
= f_u.label :y, 'lat/y'
= f_u.text_field :y, disabled: bloqueado
.label-tag
= f_u.label :y, 'lat/y'
.input-tag
= f_u.text_field :y, disabled: bloqueado
= ayuda_para('ubicacion.y')
.coordenada-x
= f_u.label :x, 'lon/x'
= f_u.text_field :x, disabled: bloqueado
.label-tag
= f_u.label :x, 'lon/x'
.input-tag
= f_u.text_field :x, disabled: bloqueado
= ayuda_para('ubicacion.x')
.span-11.last.campo
.span-2= f_u.label :srid, 'Formato'
Expand Down
7 changes: 7 additions & 0 deletions config/initializers/fields_with_errors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Reemplazo el proc que marca los campos con error para especificar si encierra
# un label o al campo de entrada.
# El archivo es actionpack/lib/action_view/base.rb
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
clase = (html_tag =~ /label/) ? 'error_label' : 'error_field'
"<div class=\"field_with_errors #{clase}\">#{html_tag}</div>".html_safe
end

0 comments on commit f689790

Please sign in to comment.