diff options
| author | Robert | 2017-10-13 18:17:00 +0200 |
|---|---|---|
| committer | Robert | 2017-10-16 07:50:34 +0200 |
| commit | 9dd7b4d050b64b6fcaebb2cd3f635593a0cb34c3 (patch) | |
| tree | d20fb589df06d01e46fa8ef4c5313c8cdc7aff94 /app | |
| parent | c266ee913353d67a3674ed6188c2ff96b44407c1 (diff) | |
| download | chouette-core-9dd7b4d050b64b6fcaebb2cd3f635593a0cb34c3.tar.bz2 | |
Refs: #4720@1.3h;
Validation implemented for min_max_values with correct I18n'd error messages
Applied to: VehicleJourneyControl::Speed & GenericAttributeControl::MinMax
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/stylesheets/components/_referential_suites.sass | 69 | ||||
| -rw-r--r-- | app/models/concerns/min_max_values_validation.rb | 13 | ||||
| -rw-r--r-- | app/models/generic_attribute_control/min_max.rb | 5 | ||||
| -rw-r--r-- | app/models/vehicle_journey_control/speed.rb | 1 |
4 files changed, 84 insertions, 4 deletions
diff --git a/app/assets/stylesheets/components/_referential_suites.sass b/app/assets/stylesheets/components/_referential_suites.sass new file mode 100644 index 000000000..5e564ea8e --- /dev/null +++ b/app/assets/stylesheets/components/_referential_suites.sass @@ -0,0 +1,69 @@ +table.calendar + display: table + width: 100% + table-layout: fixed + margin-bottom: 20px + + th, td + border: 1px solid $darkgrey + text-align: center + padding: 0.35em 0.5em + + th + padding: 0.5em + + thead + tr + > th + border: none + + &:first-child + text-transform: uppercase + + tbody + tr > td + &.weekNumber + border: none + padding: 0.5em 0.5em 0.5em 0 + + &.outsideMonth + color: rgba($darkgrey, 0.35) + + &.weekend + font-weight: bold + + &.selected_period, &.selected_date, &.overlaped_date + > a + display: block + margin: 0 auto + width: 24px + height: 24px + line-height: 24px + color: $darkgrey + background-color: rgba($gold, 0.75) + border-radius: 50% + + &:hover, &:focus + color: $darkgrey + text-decoration: none + +.col-xs-6 + &:nth-child(2n +1) + clear: both + +.col-sm-4 + @media (min-width: 768px) + &:nth-child(2n +1) + clear: none + &:nth-child(3n+1) + clear: both + +// .col-md-4 +// @media (min-width: 992px) + +.col-lg-3 + @media (min-width: 1200px) + &:nth-child(2n +1), &:nth-child(3n+1) + clear: none + &:nth-child(4n+1) + clear: both diff --git a/app/models/concerns/min_max_values_validation.rb b/app/models/concerns/min_max_values_validation.rb new file mode 100644 index 000000000..c177e55ca --- /dev/null +++ b/app/models/concerns/min_max_values_validation.rb @@ -0,0 +1,13 @@ +module MinMaxValuesValidation + extend ActiveSupport::Concern + + included do + validate :min_max_values_validation + end + + def min_max_values_validation + return true unless minimum && maximum + return true unless maximum < minimum + errors.add(:min_max_values, I18n.t('compliance_controls.min_max_values', min: minimum, max: maximum)) + end +end diff --git a/app/models/generic_attribute_control/min_max.rb b/app/models/generic_attribute_control/min_max.rb index c46ba0453..1f75c2edb 100644 --- a/app/models/generic_attribute_control/min_max.rb +++ b/app/models/generic_attribute_control/min_max.rb @@ -5,10 +5,7 @@ module GenericAttributeControl validates :minimum, numericality: true, allow_nil: true validates :maximum, numericality: true, allow_nil: true #validates :target, presence: true - validate :min_max_values - def min_max_values - true - end + include MinMaxValuesValidation class << self def attribute_type; :integer end diff --git a/app/models/vehicle_journey_control/speed.rb b/app/models/vehicle_journey_control/speed.rb index 099a46d1d..be9f838e4 100644 --- a/app/models/vehicle_journey_control/speed.rb +++ b/app/models/vehicle_journey_control/speed.rb @@ -4,6 +4,7 @@ module VehicleJourneyControl validates :minimum, numericality: true, allow_nil: true validates :maximum, numericality: true, allow_nil: true + include MinMaxValuesValidation def self.default_code; "3-VehicleJourney-2" end end |
