diff options
| author | cedricnjanga | 2017-11-27 15:45:37 +0100 | 
|---|---|---|
| committer | cedricnjanga | 2017-11-27 16:15:51 +0100 | 
| commit | d5db245d67ba14351f09c707b566671e1bd04541 (patch) | |
| tree | 96d2ae3bd6b8945d980ffe655246633ba192e334 | |
| parent | d832ccaa091595bbab0ee0e4c5e863905963686c (diff) | |
| download | chouette-core-d5db245d67ba14351f09c707b566671e1bd04541.tar.bz2 | |
Refs #4941 Fix objectid short version Display on views
25 files changed, 31 insertions, 43 deletions
| diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js index 8bea5a990..4ff3f77ea 100644 --- a/app/javascript/journey_patterns/actions/index.js +++ b/app/javascript/journey_patterns/actions/index.js @@ -90,10 +90,6 @@ const actions = {    resetValidation: (target) => {      $(target).parent().removeClass('has-error').children('.help-block').remove()    }, -  humanOID : (oid) => { -    let shortOId = oid.split(':')[2].split("-").pop() -    return shortOId.length > 10 ? `${shortOId.slice(0, 10)}...` : shortOId -  },    validateFields : (fields) => {      const test = [] @@ -201,6 +197,7 @@ const actions = {                journeyPatterns.push({                  name: val.name,                  object_id: val.object_id, +                short_id: val.short_id,                  published_name: val.published_name,                  registration_number: val.registration_number,                  stop_points: val.route_short_description.stop_points, diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 34d102c5d..d4c9816ec 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -68,7 +68,7 @@ export default class JourneyPattern extends Component{          {/* this.props.value.errors ? this.getErrors(this.props.value.errors) : '' */}          <div className='th'> -          <div className='strong mb-xs'>{this.props.value.object_id ? actions.humanOID(this.props.value.object_id) : '-'}</div> +          <div className='strong mb-xs'>{this.props.value.object_id ? this.props.value.short_id : '-'}</div>            <div>{this.props.value.registration_number}</div>            <div>{actions.getChecked(this.props.value.stop_points).length} arrêt(s)</div> diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index 95c739893..ddb54d615 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -269,10 +269,6 @@ const actions = {      type: 'RECEIVE_TOTAL_COUNT',      total    }), -  humanOID: (oid) => { -   let shortOId = oid.split(':')[2].split("-").pop() -   return shortOId.length > 10 ? `${shortOId.slice(0, 10)}...` : shortOId -  },    fetchVehicleJourneys : (dispatch, currentPage, nextPage, queryString) => {      if(currentPage == undefined){        currentPage = 1 @@ -334,6 +330,7 @@ const actions = {                journey_pattern: val.journey_pattern,                published_journey_name: val.published_journey_name,                objectid: val.objectid, +              short_id: val.short_id,                footnotes: val.footnotes,                time_tables: timeTables,                vehicle_journey_at_stops: vjasWithDelta, diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 13f8eced2..8fb4b8a7e 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -49,8 +49,8 @@ export default class VehicleJourney extends Component {      return (        <div className={'t2e-item' + (this.props.value.deletable ? ' disabled' : '') + (this.props.value.errors ? ' has-error': '')}>          <div className='th'> -          <div className='strong mb-xs'>{this.props.value.objectid ? actions.humanOID(this.props.value.objectid) : '-'}</div> -          <div>{actions.humanOID(this.props.value.journey_pattern.objectid)}</div> +          <div className='strong mb-xs'>{this.props.value.objectid ? this.props.value.short_id : '-'}</div> +          <div>{this.props.value.journey_pattern.short_id}</div>            <div>              {time_tables.slice(0,3).map((tt, i)=>                <span key={i} className='vj_tt'>{this.timeTableURL(tt)}</span> diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index 7ad3cf510..7d91896eb 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -72,7 +72,7 @@ export default class EditVehicleJourney extends Component {                                <input                                  type='text'                                  className='form-control' -                                value={actions.humanOID(this.props.modal.modalProps.vehicleJourney.journey_pattern.objectid) + ' - ' + (this.props.modal.modalProps.vehicleJourney.journey_pattern.name)} +                                value={this.props.modal.modalProps.vehicleJourney.journey_pattern.short_id + ' - ' + (this.props.modal.modalProps.vehicleJourney.journey_pattern.name)}                                  disabled={true}                                />                              </div> diff --git a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js index ebfbed9eb..a54e40502 100644 --- a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js @@ -49,7 +49,7 @@ export default class ShiftVehicleJourney extends Component {                    <div className='modal-header'>                      <h4 className='modal-title'>Mettre à jour une course</h4>                      {(this.props.modal.type == 'shift') && ( -                      <em>Mettre à jour les horaires de la course {actions.humanOID(actions.getSelected(this.props.vehicleJourneys)[0].objectid)}</em> +                      <em>Mettre à jour les horaires de la course {actions.getSelected(this.props.vehicleJourneys)[0].short_id}</em>                      )}                      <span type="button" className="close modal-close" data-dismiss="modal">×</span>                    </div> diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js index 6069bf089..5b4ae564c 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js @@ -42,7 +42,7 @@ export default class BSelect4 extends Component {                    item => _.assign(                      {},                      item, -                    { text: "<strong>" + item.published_name + " - " + actions.humanOID(item.object_id) + "</strong><br/><small>" + item.registration_number + "</small>" } +                    { text: "<strong>" + item.published_name + " - " + item.short_id + "</strong><br/><small>" + item.registration_number + "</small>" }                    )                  )                }; diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js index 60c3eab83..a90a9f7b8 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js @@ -44,7 +44,7 @@ export default class BSelect4 extends Component {                    item => _.assign(                      {},                      item, -                    {text: '<strong>' + "<span class='fa fa-circle' style='color:" + (item.color ? item.color : '#4B4B4B') + "'></span> " + item.comment + ' - ' + actions.humanOID(item.objectid) + '</strong><br/><small>' + (item.day_types ? item.day_types.match(/[A-Z]?[a-z]+/g).join(', ') : "") + '</small>'} +                    {text: '<strong>' + "<span class='fa fa-circle' style='color:" + (item.color ? item.color : '#4B4B4B') + "'></span> " + item.comment + ' - ' + item.short_id + '</strong><br/><small>' + (item.day_types ? item.day_types.match(/[A-Z]?[a-z]+/g).join(', ') : "") + '</small>'}                    )                  )                }; diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js index 7cccbbc05..37628fce0 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js @@ -42,7 +42,7 @@ export default class BSelect4b extends Component {                    item => _.assign(                      {},                      item, -                    { id: item.objectid, text: actions.humanOID(item.objectid) } +                    { id: item.objectid, text: item.short_id }                    )                  )                }; diff --git a/app/views/api/v1/journey_patterns/show.rabl b/app/views/api/v1/journey_patterns/show.rabl index 7c3af52fc..3ea1bb6ff 100644 --- a/app/views/api/v1/journey_patterns/show.rabl +++ b/app/views/api/v1/journey_patterns/show.rabl @@ -5,13 +5,6 @@ extends "api/v1/trident_objects/show"    attributes attr, :unless => lambda { |m| m.send( attr).nil?}  end -node do |jp| -  { -    short_id: jp.objectid.parts.try(:third) -  } - -end -  node(:route_short_description) do |journey_pattern|    partial("api/v1/routes/short_description", :object => journey_pattern.route)  end diff --git a/app/views/api/v1/trident_objects/show.rabl b/app/views/api/v1/trident_objects/show.rabl index e53a791ef..e58c0a866 100644 --- a/app/views/api/v1/trident_objects/show.rabl +++ b/app/views/api/v1/trident_objects/show.rabl @@ -3,3 +3,4 @@ attributes :objectid => :object_id    attributes attr, :unless => lambda { |m| m.send( attr).nil?}  end +node { |model| {short_id: model.get_objectid.short_id} }
\ No newline at end of file diff --git a/app/views/autocomplete_time_tables/index.rabl b/app/views/autocomplete_time_tables/index.rabl index 7aafdca16..b17411684 100644 --- a/app/views/autocomplete_time_tables/index.rabl +++ b/app/views/autocomplete_time_tables/index.rabl @@ -10,7 +10,7 @@ node do |time_table|      :tags => time_table.tags.join(','),      :color => time_table.color,      :day_types => time_table.display_day_types, -    :short_id => time_table.objectid.parts.try(:third), -    :text => "<strong><span class='fa fa-circle' style='color:" + (time_table.color ? time_table.color : '#4b4b4b') + "'></span> " + time_table.comment + " - " + time_table.objectid.parts.try(:third) + "</strong><br/><small>" + time_table.display_day_types + "</small>" +    :short_id => time_table.get_objectid.short_id, +    :text => "<strong><span class='fa fa-circle' style='color:" + (time_table.color ? time_table.color : '#4b4b4b') + "'></span> " + time_table.comment + " - " + time_table.get_objectid.short_id + "</strong><br/><small>" + time_table.display_day_types + "</small>"    }  end diff --git a/app/views/companies/index.html.slim b/app/views/companies/index.html.slim index 942924e73..8fcadc370 100644 --- a/app/views/companies/index.html.slim +++ b/app/views/companies/index.html.slim @@ -27,7 +27,7 @@              [ \                TableBuilderHelper::Column.new( \                  name: 'Oid', \ -                attribute: Proc.new { |n| n.try(:get_objectid).try(:local_id) }, \ +                attribute: Proc.new { |n| n.try(:get_objectid).try(:short_id) }, \                  sortable: false \                ), \                TableBuilderHelper::Column.new( \ diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim index 0cb7ab493..c5b2d0f40 100644 --- a/app/views/lines/index.html.slim +++ b/app/views/lines/index.html.slim @@ -21,7 +21,7 @@              [ \                TableBuilderHelper::Column.new( \                  name: 'ID Codifligne', \ -                attribute: Proc.new { |n| n.get_objectid.local_id }, \ +                attribute: Proc.new { |n| n.get_objectid.short_id }, \                  sortable: false \                ), \                TableBuilderHelper::Column.new( \ diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim index 4c6c6fc95..ccf237154 100644 --- a/app/views/lines/show.html.slim +++ b/app/views/lines/show.html.slim @@ -21,7 +21,7 @@      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'), -          {  'ID Codif' => @line.get_objectid.local_id, +          {  'ID Codif' => @line.get_objectid.short_id,               'Activé' => (@line.deactivated? ? t('false') : t('true')),               @line.human_attribute_name(:network) => (@line.network.nil? ? t('lines.index.unset') : @line.network.name),               @line.human_attribute_name(:company) => (@line.company.nil? ? t('lines.index.unset') : @line.company.name), diff --git a/app/views/networks/index.html.slim b/app/views/networks/index.html.slim index e498ea35f..6004f5859 100644 --- a/app/views/networks/index.html.slim +++ b/app/views/networks/index.html.slim @@ -27,7 +27,7 @@              [ \                TableBuilderHelper::Column.new( \                  name: 'Oid', \ -                attribute: Proc.new { |n| n.try(:objectid).try(:local_id) }, \ +                attribute: Proc.new { |n| n.get_objectid.try(:short_id) }, \                  sortable: false \                ),                TableBuilderHelper::Column.new( \ diff --git a/app/views/networks/show.html.slim b/app/views/networks/show.html.slim index 9b2a0dbf8..89aa1e50a 100644 --- a/app/views/networks/show.html.slim +++ b/app/views/networks/show.html.slim @@ -21,4 +21,4 @@      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'), -          { 'ID Codif' => @network.try(:objectid).try(:local_id) } +          { 'ID Codif' => @network.try(:get_objectid).try(:short_id) } diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index 74542d2b6..7607c391b 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -21,7 +21,7 @@      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'), -          {  t('id_codif') => @line.get_objectid.local_id, +          {  t('id_codif') => @line.get_objectid.short_id,               'Activé' => (@line.deactivated? ? t('false') : t('true')),               @line.human_attribute_name(:network) => (@line.network.nil? ? t('lines.index.unset') : link_to(@line.network.name, [@referential, @line.network]) ),               @line.human_attribute_name(:company) => (@line.company.nil? ? t('lines.index.unset') : link_to(@line.company.name, [@referential, @line.company]) ), @@ -47,7 +47,7 @@                = table_builder_2 @routes,                  [ \                    TableBuilderHelper::Column.new( \ -                    name: 'ID', \ +                    name: 'Oid', \                      attribute: Proc.new { |n| n.get_objectid.short_id }, \                      sortable: false \                    ), \ diff --git a/app/views/referential_networks/index.html.slim b/app/views/referential_networks/index.html.slim index 57d3e7f1f..e29658f2b 100644 --- a/app/views/referential_networks/index.html.slim +++ b/app/views/referential_networks/index.html.slim @@ -27,7 +27,7 @@              [ \                TableBuilderHelper::Column.new( \                  name: 'ID Codifligne', \ -                attribute: Proc.new { |n| n.try(:objectid).try(:local_id) }, \ +                attribute: Proc.new { |n| n.get_objectid.try(:short_id) }, \                  sortable: false \                ),                TableBuilderHelper::Column.new( \ diff --git a/app/views/referential_networks/show.html.slim b/app/views/referential_networks/show.html.slim index eab0cd51a..c2cc79e0d 100644 --- a/app/views/referential_networks/show.html.slim +++ b/app/views/referential_networks/show.html.slim @@ -21,4 +21,4 @@      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'), -          { t('id_codif') => @network.try(:objectid).try(:local_id) } +          { t('id_codif') => @network.try(:get_objectid).try(:local_id) } diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim index 33dc07567..0abeb0669 100644 --- a/app/views/referentials/show.html.slim +++ b/app/views/referentials/show.html.slim @@ -43,7 +43,7 @@              [ \                TableBuilderHelper::Column.new( \                  name: t('id_codif'), \ -                attribute: Proc.new { |n| n.get_objectid.local_id }, \ +                attribute: Proc.new { |n| n.get_objectid.short_id }, \                  sortable: false \                ), \                TableBuilderHelper::Column.new( \ diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim index 4e880f7a3..b838859bf 100644 --- a/app/views/stop_areas/index.html.slim +++ b/app/views/stop_areas/index.html.slim @@ -21,7 +21,7 @@              [ \                TableBuilderHelper::Column.new( \                  name: 'ID Reflex', \ -                attribute: Proc.new { |n| n.try(:user_objectid) }, \ +                attribute: Proc.new { |n| n.get_objectid.try(:short_id) }, \                  sortable: false \                ), \                TableBuilderHelper::Column.new( \ diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim index bc9cc2ac0..7f7c2e07f 100644 --- a/app/views/stop_areas/show.html.slim +++ b/app/views/stop_areas/show.html.slim @@ -19,9 +19,9 @@      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'), -          { @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"), +          { t('id_reflex') => @stop_area.get_objectid.short_id, +            @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"),              @stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number, -            t('id_reflex') => @stop_area.user_objectid,              'Coordonnées' => geo_data(@stop_area, @stop_area_referential),              @stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code,              @stop_area.human_attribute_name(:city_name) => @stop_area.city_name, diff --git a/app/views/vehicle_journeys/show.rabl b/app/views/vehicle_journeys/show.rabl index fce16dfb3..830dee8bd 100644 --- a/app/views/vehicle_journeys/show.rabl +++ b/app/views/vehicle_journeys/show.rabl @@ -4,6 +4,8 @@ object @vehicle_journey    attributes attr, :unless => lambda { |m| m.send( attr).nil?}  end +node { |vj| {short_id: vj.get_objectid.short_id} } +  child(:company) do |company|    attributes :id, :objectid, :name  end @@ -16,6 +18,7 @@ end  child(:journey_pattern) do |journey_pattern|    attributes :id, :objectid, :name, :published_name +  node(:short_id) {journey_pattern.get_objectid.short_id}  end  child(:time_tables, :object_root => false) do |time_tables| diff --git a/spec/models/chouette/stop_point_spec.rb b/spec/models/chouette/stop_point_spec.rb index f48173e65..264fd26fc 100644 --- a/spec/models/chouette/stop_point_spec.rb +++ b/spec/models/chouette/stop_point_spec.rb @@ -1,7 +1,4 @@ -# From Chouette import what we need ™ -StopPoint = Chouette::StopPoint - -describe StopPoint, :type => :model do +describe Chouette::StopPoint, :type => :model do    let!(:vehicle_journey) { create(:vehicle_journey)}    subject { Chouette::Route.find( vehicle_journey.route_id).stop_points.first } @@ -44,7 +41,7 @@ describe StopPoint, :type => :model do      let!( :new_route ){ create :route }      it 'creates a new instance' do -      expect{ subject.duplicate(for_route: new_route) }.to change{ StopPoint.count }.by(1) +      expect{ subject.duplicate(for_route: new_route) }.to change{ Chouette::StopPoint.count }.by(1)      end      it 'new instance has a new route' do        expect(subject.duplicate(for_route: new_route).route).to eq(new_route) | 
