diff options
| author | Robert | 2018-01-08 08:34:34 +0100 | 
|---|---|---|
| committer | Robert | 2018-01-08 08:34:34 +0100 | 
| commit | dcc56c4d02f9f71b13dd38251367306842cd10c7 (patch) | |
| tree | 50f69c0ea454e2ba3d8576bfd5fc0c4d98127bff | |
| parent | 04274ab7d2b02dd43bb117b817657db5a1ccbfd4 (diff) | |
| parent | fa63d6e3d51ccc0b3a38616747fcd91b5fdfbba5 (diff) | |
| download | chouette-core-dcc56c4d02f9f71b13dd38251367306842cd10c7.tar.bz2 | |
Merge branch 'master' of github.com:af83/stif-boiv
25 files changed, 93 insertions, 40 deletions
| diff --git a/INSTALL.md b/INSTALL.md index 28ffdeb4d..5ed8ca9f1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -137,7 +137,7 @@ RAILS_ENV=test bundle exec rake db:create db:migrate  #### Load seed datas  ```sh -bundle exec rake db:seed +bundle exec rake db:seed:stif  ```  #### Synchronise datas with lines and stop areas referentials diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js index 4ff3f77ea..1c2eb68b2 100644 --- a/app/javascript/journey_patterns/actions/index.js +++ b/app/javascript/journey_patterns/actions/index.js @@ -198,6 +198,7 @@ const actions = {                  name: val.name,                  object_id: val.object_id,                  short_id: val.short_id, +                checksum: val.checksum,                  published_name: val.published_name,                  registration_number: val.registration_number,                  stop_points: val.route_short_description.stop_points, @@ -217,4 +218,4 @@ const actions = {    }  } -export default actions
\ No newline at end of file +export default actions diff --git a/app/javascript/journey_patterns/components/EditModal.js b/app/javascript/journey_patterns/components/EditModal.js index e7ce24aa1..7a5d24fba 100644 --- a/app/javascript/journey_patterns/components/EditModal.js +++ b/app/javascript/journey_patterns/components/EditModal.js @@ -36,7 +36,6 @@ export default class EditModal extends Component {                  {this.renderModalTitle()}                  <span type="button" className="close modal-close" data-dismiss="modal">×</span>                </div> -                {(this.props.modal.type == 'edit') && (                  <form>                    <div className='modal-body'> @@ -85,6 +84,16 @@ export default class EditModal extends Component {                          </div>                        </div>                      </div> +                    <div> +                      <label className='control-label'>Signature métier</label> +                        <input +                        type='text' +                        ref='checksum' +                        className='form-control' +                        disabled='disabled' +                        defaultValue={this.props.modal.modalProps.journeyPattern.checksum} +                        /> +                    </div>                    </div>                    {                      this.props.editMode && @@ -121,4 +130,4 @@ EditModal.propTypes = {    modal: PropTypes.object,    onModalClose: PropTypes.func.isRequired,    saveModal: PropTypes.func.isRequired -}
\ No newline at end of file +} diff --git a/app/javascript/packs/routes/show.js b/app/javascript/packs/routes/show.js index 7f14a6f11..4d91ace13 100644 --- a/app/javascript/packs/routes/show.js +++ b/app/javascript/packs/routes/show.js @@ -4,6 +4,7 @@ route = JSON.parse(decodeURIComponent(route))  const geoColPts = []  const geoColLns = [] +const area = []  const geoColEdges = [    new ol.Feature({      geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(route[0].longitude), parseFloat(route[0].latitude)])) @@ -23,8 +24,8 @@ route.forEach(function (stop, i) {    }    geoColPts.push(new ol.Feature({      geometry: new ol.geom.Point(ol.proj.fromLonLat([parseFloat(stop.longitude), parseFloat(stop.latitude)])) -  }) -  ) +  })) +  area.push([parseFloat(stop.longitude), parseFloat(stop.latitude)])  })  var edgeStyles = new ol.style.Style({    image: new ol.style.Circle(({ @@ -100,3 +101,7 @@ var map = new ol.Map({      zoom: 13    })  }); +const boundaries = ol.extent.applyTransform( +  ol.extent.boundingExtent(area), ol.proj.getTransform('EPSG:4326', 'EPSG:3857') +) +map.getView().fit(boundaries, map.getSize()); diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index f8d6add03..cad04ed0e 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -52,32 +52,32 @@ export default class EditVehicleJourney extends Component {                    {(this.props.modal.type == 'edit') && (                      <form>                        <div className='modal-body'> -                        <div className='row'> -                          <div className='col-lg-6 col-md-6 col-sm-6 col-xs-12'> -                            <div className='form-group'> -                              <label className='control-label'>Nom de la course</label> -                              <input -                                type='text' -                                ref='published_journey_name' -                                className='form-control' -                                disabled={!this.props.editMode} -                                defaultValue={this.props.modal.modalProps.vehicleJourney.published_journey_name} -                                onKeyDown={(e) => actions.resetValidation(e.currentTarget)} -                                /> +                          <div className='row'> +                            <div className='col-lg-6 col-md-6 col-sm-6 col-xs-12'> +                              <div className='form-group'> +                                <label className='control-label'>Nom de la course</label> +                                <input +                                  type='text' +                                  ref='published_journey_name' +                                  className='form-control' +                                  disabled={!this.props.editMode} +                                  defaultValue={this.props.modal.modalProps.vehicleJourney.published_journey_name} +                                  onKeyDown={(e) => actions.resetValidation(e.currentTarget)} +                                  /> +                              </div>                              </div> -                          </div> -                          <div className='col-lg-6 col-md-6 col-sm-6 col-xs-12'> -                            <div className='form-group'> -                              <label className='control-label'>Mission</label> -                              <input -                                type='text' -                                className='form-control' -                                value={this.props.modal.modalProps.vehicleJourney.journey_pattern.short_id + ' - ' + (this.props.modal.modalProps.vehicleJourney.journey_pattern.name)} -                                disabled={true} -                              /> +                            <div className='col-lg-6 col-md-6 col-sm-6 col-xs-12'> +                              <div className='form-group'> +                                <label className='control-label'>Mission</label> +                                <input +                                  type='text' +                                  className='form-control' +                                  value={this.props.modal.modalProps.vehicleJourney.journey_pattern.short_id + ' - ' + (this.props.modal.modalProps.vehicleJourney.journey_pattern.name)} +                                  disabled={true} +                                /> +                              </div>                              </div>                            </div> -                        </div>                          <div className='row'>                            <div className='col-lg-6 col-md-6 col-sm-6 col-xs-12'> @@ -131,9 +131,20 @@ export default class EditVehicleJourney extends Component {                              </div>                            </div>                          </div> +                        <div className='form-group'> +                          <label className='control-label'>Signature métier</label> +                            <input +                            type='text' +                            ref='checksum' +                            className='form-control' +                            disabled='disabled' +                            defaultValue={this.props.modal.modalProps.vehicleJourney.checksum} +                            /> +                        </div> +                        </div>                        { -                        this.props.editMode &&  +                        this.props.editMode &&                          <div className='modal-footer'>                            <button                              className='btn btn-link' @@ -151,7 +162,7 @@ export default class EditVehicleJourney extends Component {                              Valider                          </button>                          </div> -                      }      +                      }                      </form>                    )} @@ -171,4 +182,4 @@ EditVehicleJourney.propTypes = {    onOpenEditModal: PropTypes.func.isRequired,    onModalClose: PropTypes.func.isRequired,    disabled: PropTypes.bool.isRequired -}
\ No newline at end of file +} diff --git a/app/models/chouette/area_type.rb b/app/models/chouette/area_type.rb index 43d96b391..4703ea646 100644 --- a/app/models/chouette/area_type.rb +++ b/app/models/chouette/area_type.rb @@ -13,6 +13,8 @@ class Chouette::AreaType    @@instances = {}    def self.find(code) +    return unless code +      code = code.to_sym      @@instances[code] ||= new(code) if ALL.include? code    end diff --git a/app/models/chouette/journey_pattern.rb b/app/models/chouette/journey_pattern.rb index 03967abfa..366fde188 100644 --- a/app/models/chouette/journey_pattern.rb +++ b/app/models/chouette/journey_pattern.rb @@ -40,7 +40,8 @@ module Chouette            # Update attributes and stop_points associations            jp.update_attributes(state_permited_attributes(item)) unless item['new_record']            jp.state_stop_points_update(item) if !jp.errors.any? && jp.persisted? -          item['errors'] = jp.errors if jp.errors.any? +          item['errors']   = jp.errors if jp.errors.any? +          item['checksum'] = jp.checksum          end          if state.any? {|item| item['errors']} diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb index 332ddb7b8..d4dc82a56 100644 --- a/app/models/chouette/vehicle_journey.rb +++ b/app/models/chouette/vehicle_journey.rb @@ -170,7 +170,8 @@ module Chouette            vj.update_attributes(state_permited_attributes(item))            vj.update_has_and_belongs_to_many_from_state(item) -          item['errors'] = vj.errors.full_messages.uniq if vj.errors.any? +          item['errors']   = vj.errors.full_messages.uniq if vj.errors.any? +          item['checksum'] = vj.checksum          end          # Delete ids of new object from state if we had to rollback diff --git a/app/views/api/v1/journey_patterns/show.rabl b/app/views/api/v1/journey_patterns/show.rabl index 3ea1bb6ff..86876f3fb 100644 --- a/app/views/api/v1/journey_patterns/show.rabl +++ b/app/views/api/v1/journey_patterns/show.rabl @@ -1,7 +1,7 @@  object @journey_pattern  extends "api/v1/trident_objects/show" -[:id, :name, :published_name, :registration_number, :comment].each do |attr| +[:id, :name, :published_name, :registration_number, :comment, :checksum].each do |attr|    attributes attr, :unless => lambda { |m| m.send( attr).nil?}  end diff --git a/app/views/line_footnotes/show.html.slim b/app/views/line_footnotes/show.html.slim index e4f2a1d42..29e1f5708 100644 --- a/app/views/line_footnotes/show.html.slim +++ b/app/views/line_footnotes/show.html.slim @@ -16,7 +16,11 @@                .panel-heading = footnote.code                .panel-body                  p = footnote.label +                .panel-footer.text-right +                div +                  p.text-muted.small = Chouette::Footnote.human_attribute_name(:checksum) +                  p.text-muted.small = footnote.checksum                  p.text-muted                    em.small = "Dernière mise à jour le #{l(footnote.updated_at, format: :short)}" diff --git a/app/views/purchase_windows/show.html.slim b/app/views/purchase_windows/show.html.slim index 9f3abb267..4ddde1706 100644 --- a/app/views/purchase_windows/show.html.slim +++ b/app/views/purchase_windows/show.html.slim @@ -17,4 +17,5 @@          = definition_list t('metadatas'),            { Chouette::PurchaseWindow.human_attribute_name(:name) => @purchase_window.try(:name),              'Organisation' => @purchase_window.referential.organisation.name, -            Chouette::PurchaseWindow.human_attribute_name(:date_ranges) => @purchase_window.periods.map{|d| t('validity_range', debut: l(d.begin, format: :short), end: l(d.end, format: :short))}.join('<br>').html_safe } +            Chouette::PurchaseWindow.human_attribute_name(:date_ranges) => @purchase_window.periods.map{|d| t('validity_range', debut: l(d.begin, format: :short), end: l(d.end, format: :short))}.join('<br>').html_safe, +            Chouette::PurchaseWindow.human_attribute_name(:checksum) => @purchase_window.checksum } diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim index 2b4ebf159..644f79022 100644 --- a/app/views/routes/show.html.slim +++ b/app/views/routes/show.html.slim @@ -22,7 +22,8 @@            { t('objectid') => @route.get_objectid.short_id,              t('activerecord.attributes.route.published_name') => (@route.published_name ? @route.published_name : '-'),              @route.human_attribute_name(:wayback) => (@route.wayback ? @route.wayback_text : '-' ), -            @route.human_attribute_name(:opposite_route) => (@route.opposite_route ? @route.opposite_route.name : '-') } +            @route.human_attribute_name(:opposite_route) => (@route.opposite_route ? @route.opposite_route.name : '-'), +            @route.human_attribute_name(:checksum) => @route.checksum }        - if @route_sp.any?          .col-lg-6.col-md-6.col-sm-12.col-xs-12 diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim index 6235ade68..3d1988545 100644 --- a/app/views/routing_constraint_zones/show.html.slim +++ b/app/views/routing_constraint_zones/show.html.slim @@ -17,7 +17,8 @@          = definition_list t('metadatas'),            { @routing_constraint_zone.human_attribute_name(:name) => @routing_constraint_zone.try(:name),              @routing_constraint_zone.human_attribute_name(:route) => link_to(@routing_constraint_zone.try(:route_name), [@referential, @line, @routing_constraint_zone.route]), -            @routing_constraint_zone.human_attribute_name(:line) => link_to(@line.name, [@referential, @line])} +            @routing_constraint_zone.human_attribute_name(:line) => link_to(@line.name, [@referential, @line]), +            @routing_constraint_zone.human_attribute_name(:checksum) => @routing_constraint_zone.checksum}      .row        .col-lg-12 diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim index 036581268..df9789055 100644 --- a/app/views/time_tables/show.html.slim +++ b/app/views/time_tables/show.html.slim @@ -28,7 +28,8 @@              'Couleur associée' => (@time_table.color.nil? ? '-' : content_tag(:span, '', class: 'fa fa-circle', style: "color:#{@time_table.try(:color)}")),              'Etiquettes' => @time_table.tag_list,              'Modèle de calendrier' => (@time_table.calendar ? link_to(@time_table.calendar.name, @time_table.calendar) : '-'), -            "Journées d'application pour les périodes ci-dessous" => %w(monday tuesday wednesday thursday friday saturday sunday).collect{ |d| content_tag(:span, t("calendars.days.#{d}"), class: "label label-default #{@time_table.send(d) ? '' : 'disabled'}") }.join.html_safe } +            "Journées d'application pour les périodes ci-dessous" => %w(monday tuesday wednesday thursday friday saturday sunday).collect{ |d| content_tag(:span, t("calendars.days.#{d}"), class: "label label-default #{@time_table.send(d) ? '' : 'disabled'}") }.join.html_safe, +              Chouette::TimeTable.human_attribute_name(:checksum) => @time_table.checksum}      .row        .col-lg-12.mb-sm diff --git a/app/views/vehicle_journeys/show.rabl b/app/views/vehicle_journeys/show.rabl index 01175a85d..eeed79b34 100644 --- a/app/views/vehicle_journeys/show.rabl +++ b/app/views/vehicle_journeys/show.rabl @@ -1,6 +1,6 @@  object @vehicle_journey -[:objectid, :published_journey_name, :published_journey_identifier, :company_id, :comment].each do |attr| +[:objectid, :published_journey_name, :published_journey_identifier, :company_id, :comment, :checksum].each do |attr|    attributes attr, :unless => lambda { |m| m.send( attr).nil?}  end diff --git a/config/initializers/stif.rb b/config/initializers/stif.rb index eb918131b..60db50083 100644 --- a/config/initializers/stif.rb +++ b/config/initializers/stif.rb @@ -3,6 +3,9 @@ Rails.application.config.to_prepare do      line_referential      = LineReferential.find_by(name: "CodifLigne")      stop_area_referential = StopAreaReferential.find_by(name: "Reflex") +    line_referential.organisations << organisation +    stop_area_referential.organisations << organisation +      organisation.workbenches.find_or_create_by(name: "Gestion de l'offre") do |workbench|        workbench.line_referential      = line_referential        workbench.stop_area_referential = stop_area_referential diff --git a/config/locales/footnotes.en.yml b/config/locales/footnotes.en.yml index dba8edd0b..5b86f0806 100644 --- a/config/locales/footnotes.en.yml +++ b/config/locales/footnotes.en.yml @@ -16,4 +16,5 @@ en:      attributes:        footnote:          code: "number" +        checksum: checksum          label: "line text" diff --git a/config/locales/footnotes.fr.yml b/config/locales/footnotes.fr.yml index f5cd71c21..692098046 100644 --- a/config/locales/footnotes.fr.yml +++ b/config/locales/footnotes.fr.yml @@ -16,4 +16,5 @@ fr:      attributes:        footnote:          code: "numéro" +        checksum: Signature métier          label: "ligne de texte" diff --git a/config/locales/routes.en.yml b/config/locales/routes.en.yml index 7b82e788b..bd8358bdd 100644 --- a/config/locales/routes.en.yml +++ b/config/locales/routes.en.yml @@ -69,6 +69,7 @@ en:          other: "routes"      attributes:        route: +        checksum: Checksum          wayback:            positive: "forward"            negative: "backward" diff --git a/config/locales/routes.fr.yml b/config/locales/routes.fr.yml index 1d151e60b..c08e64cfd 100644 --- a/config/locales/routes.fr.yml +++ b/config/locales/routes.fr.yml @@ -72,6 +72,7 @@ fr:          other: "itinéraires"      attributes:        route: +        checksum: Signature métier          wayback:            positive: "Aller"            negative: "Retour" diff --git a/config/locales/routing_constraint_zones.en.yml b/config/locales/routing_constraint_zones.en.yml index 34a10ac67..5675fd5db 100644 --- a/config/locales/routing_constraint_zones.en.yml +++ b/config/locales/routing_constraint_zones.en.yml @@ -7,6 +7,7 @@ en:          other: routing constraint zones      attributes:        routing_constraint_zone: +        checksum: Checksum          name: Name          stop_areas: Stop areas          line: Line diff --git a/config/locales/routing_constraint_zones.fr.yml b/config/locales/routing_constraint_zones.fr.yml index 80bbad8cf..024dd3288 100644 --- a/config/locales/routing_constraint_zones.fr.yml +++ b/config/locales/routing_constraint_zones.fr.yml @@ -7,6 +7,7 @@ fr:          other: zone de contraintes      attributes:        routing_constraint_zone: +        checksum: Signature métier          name: Nom          stop_areas: Arrêts          line: Ligne associée diff --git a/config/locales/time_tables.en.yml b/config/locales/time_tables.en.yml index ff36a6d7d..ce890942d 100644 --- a/config/locales/time_tables.en.yml +++ b/config/locales/time_tables.en.yml @@ -102,6 +102,7 @@ en:          other: "timetables"      attributes:        time_table: +        checksum: Checksum          comment: "Name"          color: "Associated color"          bounding_dates: 'Global validity period' diff --git a/config/locales/time_tables.fr.yml b/config/locales/time_tables.fr.yml index 631ecca95..8abc0e0af 100644 --- a/config/locales/time_tables.fr.yml +++ b/config/locales/time_tables.fr.yml @@ -102,6 +102,7 @@ fr:          other: "calendriers"      attributes:        time_table: +        checksum: Signature métier          comment: "Nom du calendrier"          color: "Couleur associée"          bounding_dates: 'Période contenue dans le calendrier' diff --git a/spec/models/chouette/area_type_spec.rb b/spec/models/chouette/area_type_spec.rb index 82c3f96bc..67d218df8 100644 --- a/spec/models/chouette/area_type_spec.rb +++ b/spec/models/chouette/area_type_spec.rb @@ -9,6 +9,10 @@ RSpec.describe Chouette::AreaType do    end    describe ".find" do +    it "returns nil if the given code is nil" do +      expect(Chouette::AreaType.find(nil)).to be_nil +    end +      it "returns nil if the given code is unknown" do        expect(Chouette::AreaType.find('dummy')).to be_nil      end | 
