aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/main_menu.coffee45
-rw-r--r--app/assets/javascripts/select2.coffee17
-rw-r--r--app/assets/stylesheets/components/_referentials.sass4
-rw-r--r--app/assets/stylesheets/modules/import_messages.sass40
-rw-r--r--app/controllers/referentials_controller.rb17
-rw-r--r--app/controllers/stop_areas_controller.rb10
-rw-r--r--app/helpers/common_helper.rb8
-rw-r--r--app/javascript/vehicle_journeys/actions/index.js78
-rw-r--r--app/javascript/vehicle_journeys/components/VehicleJourney.js3
-rw-r--r--app/javascript/vehicle_journeys/components/VehicleJourneys.js1
-rw-r--r--app/javascript/vehicle_journeys/components/tools/CreateModal.js4
-rw-r--r--app/javascript/vehicle_journeys/reducers/modal.js8
-rw-r--r--app/models/chouette/area_type.rb5
-rw-r--r--app/models/chouette/stop_area.rb12
-rw-r--r--app/models/compliance_control.rb2
-rw-r--r--app/models/import.rb1
-rw-r--r--app/models/referential.rb1
-rw-r--r--app/models/vehicle_journey_control/waiting_time.rb2
-rw-r--r--app/uploaders/import_uploader.rb6
-rw-r--r--app/views/autocomplete_stop_areas/index.rabl3
-rw-r--r--app/views/imports/_import_messages.html.slim19
-rw-r--r--app/views/imports/show.html.slim95
-rw-r--r--app/views/referentials/_form.html.slim2
-rw-r--r--app/views/stop_areas/_form.html.slim5
-rw-r--r--app/views/stop_areas/autocomplete.rabl24
-rw-r--r--app/views/stop_areas/show.html.slim2
-rw-r--r--app/views/vehicle_journeys/index.html.slim2
-rw-r--r--app/views/vehicle_journeys/show.rabl2
28 files changed, 257 insertions, 161 deletions
diff --git a/app/assets/javascripts/main_menu.coffee b/app/assets/javascripts/main_menu.coffee
index 1c39be736..e943f448a 100644
--- a/app/assets/javascripts/main_menu.coffee
+++ b/app/assets/javascripts/main_menu.coffee
@@ -1,12 +1,11 @@
$ ->
- link = []
+ stickyActions = []
ptitleCont = ""
$(document).on 'page:before-change', ->
- link = []
+ stickyActions = []
ptitleCont = ""
-
$el = $('#main_nav')
# Opening/closing left-side menu
$el.find('.openMenu').on 'click', (e) ->
@@ -24,35 +23,45 @@ $ ->
limit = 51
if $(window).scrollTop() >= limit
- data = ""
- if ($('.page-action .small').length > 0)
- data = $('.page-action .small')[0].innerHTML
+ if stickyActions.length == 0
+ if ($('.page-action .small').length > 0)
+ stickyActions.push
+ content: [
+ $('.page-action .small'),
+ $('.page-action .small').first().next()
+ ]
+ originalParent: $('.page-action .small').parent()
+
+ for action in $(".sticky-action, .sticky-actions")
+ stickyActions.push
+ class: "small",
+ content: [$(action)]
+ originalParent: $(action).parent()
- if ($(".page-title").length > 0)
+ if $(".page-title").length > 0
ptitleCont = $(".page-title").html()
- stickyContent = '<div class="sticky-content">'
- stickyContent += '<div class="sticky-ptitle">' + ptitleCont + '</div>'
- stickyContent += '<div class="sticky-paction"><div class="small">' + data + '</div></div>'
- stickyContent += '</div>'
+ stickyContent = $('<div class="sticky-content"></div>')
+ stickyContent.append $("<div class='sticky-ptitle'>#{ptitleCont}</div>")
+ stickyContent.append $('<div class="sticky-paction"></div>')
$('#main_nav').addClass 'sticky'
if $('#menu_top').find('.sticky-content').length == 0
if ptitleCont.length > 0
$('#menu_top').children('.menu-content').after(stickyContent)
- if link.length == 0
- link = $('.page-action .small').next()
-
- $('.sticky-paction .small').after(link)
+ for item in stickyActions
+ for child in item.content
+ child.appendTo $('.sticky-paction')
else
$('#main_nav').removeClass 'sticky'
if $('#menu_top').find('.sticky-content').length > 0
- if !$('.page-action').find('.formSubmitr').length
- $('.page-action .small').after(link)
+ for item in stickyActions
+ for child in item.content
+ child.appendTo item.originalParent
$('.sticky-content').remove()
- sticker();
+ sticker()
# Sticky behavior
$(document).on 'scroll', sticker
diff --git a/app/assets/javascripts/select2.coffee b/app/assets/javascripts/select2.coffee
index 2e3884d7f..4cf5f42d0 100644
--- a/app/assets/javascripts/select2.coffee
+++ b/app/assets/javascripts/select2.coffee
@@ -9,24 +9,27 @@ bind_select2 = (el, cfg = {}) ->
target.select2 $.extend({}, default_cfg, cfg)
bind_select2_ajax = (el, cfg = {}) ->
- target = $(el)
+ _this = $(el)
cfg =
ajax:
data: (params) ->
- q:
- "#{target.data('term')}": params.term
- url: target.data('url'),
+ if _this.data('term')
+ { q: "#{_this.data('term')}": params.term }
+ else
+ { q: params.term }
+ url: _this.data('url'),
dataType: 'json',
delay: 125,
processResults: (data, params) -> results: data
- minimumInputLength: 1
- placeholder: target.data('select2ed-placeholder')
templateResult: (item) ->
item.text
templateSelection: (item) ->
item.text
escapeMarkup: (markup) ->
markup
+ initSelection : (item, callback) ->
+ if _this.data('initvalue')
+ callback(_this.data('initvalue'))
bind_select2(el, cfg)
@@ -40,7 +43,5 @@ bind_select2_ajax = (el, cfg = {}) ->
$('select.form-control.tags').each ->
bind_select2(this, {tags: true})
-
-
$ ->
select_2()
diff --git a/app/assets/stylesheets/components/_referentials.sass b/app/assets/stylesheets/components/_referentials.sass
new file mode 100644
index 000000000..0bbb18f2b
--- /dev/null
+++ b/app/assets/stylesheets/components/_referentials.sass
@@ -0,0 +1,4 @@
+#referential_form
+ .metadatas-errors
+ margin-top: -20px
+ margin-bottom: 20px
diff --git a/app/assets/stylesheets/modules/import_messages.sass b/app/assets/stylesheets/modules/import_messages.sass
index e5666cbcd..6a088dc06 100644
--- a/app/assets/stylesheets/modules/import_messages.sass
+++ b/app/assets/stylesheets/modules/import_messages.sass
@@ -2,4 +2,42 @@
.status_icon
padding-right: 20px
h1
- padding-bottom: 20px
+ padding-bottom: 20px
+
+
+.import_message-list
+ padding-bottom: 20px
+
+ .import_messages-head
+ display: block
+ font-size: 1.8rem
+ font-weight: 700
+ border-bottom: 2px solid #4b4b4b
+ padding: 5px 15px 6px 15px
+
+ dl
+ dd, dt
+ display: inline-block
+ letter-spacing: normal
+ word-spacing: normal
+ text-rendering: auto
+ vertical-align: top
+ padding: 5px 15px 6px 15px
+
+ dt
+ position: relative
+ width: 7%
+ font-weight: 700
+
+ &:before
+ content: ""
+ display: block
+ position: absolute
+ z-index: 1
+ top: 0
+ left: 0
+ width: 250%
+ border-bottom: 1px solid rgba(164, 164, 164, 0.5)
+
+ dd
+ width: 93% \ No newline at end of file
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index 40e8264ce..f63abf685 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -13,13 +13,16 @@ class ReferentialsController < ChouetteController
end
def create
- create! do |format|
- build_referenial
-
- if !!@referential.created_from_id
- flash[:notice] = t('notice.referentials.duplicate')
-
- format.html { redirect_to workbench_path(@referential.workbench) }
+ create! do |success, failure|
+ success.html do
+ if @referential.created_from_id.present?
+ flash[:notice] = t('notice.referentials.duplicate')
+ redirect_to workbench_path(@referential.workbench)
+ end
+ end
+ failure.html do
+ Rails.logger.info "Can't create Referential : #{@referential.errors.inspect}"
+ render :new
end
end
end
diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb
index b24e90ba5..5243ce56c 100644
--- a/app/controllers/stop_areas_controller.rb
+++ b/app/controllers/stop_areas_controller.rb
@@ -14,10 +14,12 @@ class StopAreasController < ChouetteController
respond_to :html, :kml, :xml, :json
respond_to :js, :only => :index
- # def complete
- # @stop_areas = line.stop_areas
- # render :layout => false
- # end
+ def autocomplete
+ scope = stop_area_referential.stop_areas.where(deleted_at: nil)
+ args = [].tap{|arg| 4.times{arg << "%#{params[:q]}%"}}
+ @stop_areas = scope.where("unaccent(name) ILIKE unaccent(?) OR unaccent(city_name) ILIKE unaccent(?) OR registration_number ILIKE ? OR objectid ILIKE ?", *args).limit(50)
+ @stop_areas
+ end
def select_parent
@stop_area = stop_area
diff --git a/app/helpers/common_helper.rb b/app/helpers/common_helper.rb
deleted file mode 100644
index b515f681b..000000000
--- a/app/helpers/common_helper.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-
-module CommonHelper
- def string_keys_to_symbols enumerable_pairs
- enumerable_pairs.inject({}){ | hashy, (k, v) |
- hashy.merge k.to_sym => v
- }
- end
-end
diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js
index 202c09440..40c8006f1 100644
--- a/app/javascript/vehicle_journeys/actions/index.js
+++ b/app/javascript/vehicle_journeys/actions/index.js
@@ -188,26 +188,18 @@ const actions = {
resetValidation: (target) => {
$(target).parent().removeClass('has-error').children('.help-block').remove()
},
- validateFields : (...fields) => {
- const test = []
-
- Object.keys(fields).map(function(key) {
- test.push(fields[key].validity.valid)
+ validateFields : (fields) => {
+ let valid = true
+ Object.keys(fields).forEach((key) => {
+ let field = fields[key]
+ if(field.validity && !field.validity.valid){
+ valid = false
+ $(field).parent().addClass('has-error').children('.help-block').remove()
+ $(field).parent().append("<span class='small help-block'>" + field.validationMessage + "</span>")
+ }
})
- if(test.indexOf(false) >= 0) {
- // Form is invalid
- test.map(function(item, i) {
- if(item == false) {
- const k = Object.keys(fields)[i]
- $(fields[k]).parent().addClass('has-error').children('.help-block').remove()
- $(fields[k]).parent().append("<span class='small help-block'>" + fields[k].validationMessage + "</span>")
- }
- })
- return false
- } else {
- // Form is valid
- return true
- }
+
+ return valid
},
toggleArrivals : () => ({
type: 'TOGGLE_ARRIVALS',
@@ -349,35 +341,35 @@ const actions = {
color: tt.color
})
}
- for (tt of val.purchase_windows){
- purchaseWindows.push({
- objectid: tt.objectid,
- name: tt.name,
- id: tt.id,
- color: tt.color
- })
+ if(val.purchase_windows){
+ for (tt of val.purchase_windows){
+ purchaseWindows.push({
+ objectid: tt.objectid,
+ name: tt.name,
+ id: tt.id,
+ color: tt.color
+ })
+ }
}
let vjasWithDelta = val.vehicle_journey_at_stops.map((vjas, i) => {
actions.fillEmptyFields(vjas)
return actions.getDelta(vjas)
})
- vehicleJourneys.push({
- 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,
- purchase_windows: purchaseWindows,
- vehicle_journey_at_stops: vjasWithDelta,
- deletable: false,
- selected: false,
- published_journey_name: val.published_journey_name || 'non renseigné',
- published_journey_identifier: val.published_journey_identifier || 'non renseigné',
- company: val.company || 'non renseigné',
- transport_mode: val.route.line.transport_mode || 'undefined',
- transport_submode: val.route.line.transport_submode || 'undefined'
- })
+
+ vehicleJourneys.push(
+ _.assign({}, val, {
+ time_tables: timeTables,
+ purchase_windows: purchaseWindows,
+ vehicle_journey_at_stops: vjasWithDelta,
+ deletable: false,
+ selected: false,
+ published_journey_name: val.published_journey_name || 'non renseigné',
+ published_journey_identifier: val.published_journey_identifier || 'non renseigné',
+ company: val.company || {name: 'non renseigné'},
+ transport_mode: val.route.line.transport_mode || 'undefined',
+ transport_submode: val.route.line.transport_submode || 'undefined'
+ })
+ )
}
window.currentItemsLength = vehicleJourneys.length
dispatch(actions.receiveVehicleJourneys(vehicleJourneys))
diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js
index 1e62444ef..5f6281487 100644
--- a/app/javascript/vehicle_journeys/components/VehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js
@@ -64,10 +64,11 @@ export default class VehicleJourney extends Component {
<div
className='th'
onClick={(e) =>
- ($(e.target).parents("a").length == 0) && this.props.editMode && this.props.onSelectVehicleJourney(this.props.index)
+ ($(e.target).parents("a").length == 0) && this.props.onSelectVehicleJourney(this.props.index)
}
>
<div className='strong mb-xs'>{this.props.value.short_id || '-'}</div>
+ <div>{this.props.value.published_journey_name && this.props.value.published_journey_name != "non renseigné" ? this.props.value.published_journey_name : '-'}</div>
<div>{this.props.value.journey_pattern.short_id || '-'}</div>
<div>
{time_tables.slice(0,3).map((tt, i)=>
diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js
index e16d03f90..dc480d6b4 100644
--- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js
+++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js
@@ -115,6 +115,7 @@ export default class VehicleJourneys extends Component {
<div className='t2e-head w20'>
<div className='th'>
<div className='strong mb-xs'>ID course</div>
+ <div>Nom course</div>
<div>ID mission</div>
<div>Calendriers</div>
{ this.hasFeature('purchase_windows') && <div>Calendriers Commerciaux</div> }
diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js
index 33873219c..cd593cdff 100644
--- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js
+++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js
@@ -61,7 +61,7 @@ export default class CreateModal extends Component {
<div className='form-group'>
<label className='control-label'>Nom du transporteur</label>
<CompanySelect2
- company = {undefined}
+ company = {this.props.modal.modalProps.vehicleJourney && this.props.modal.modalProps.vehicleJourney.company || undefined}
onSelect2Company = {(e) => this.props.onSelect2Company(e)}
/>
</div>
@@ -130,4 +130,4 @@ CreateModal.propTypes = {
onAddVehicleJourney: PropTypes.func.isRequired,
onSelect2JourneyPattern: PropTypes.func.isRequired,
disabled: PropTypes.bool.isRequired
-} \ No newline at end of file
+}
diff --git a/app/javascript/vehicle_journeys/reducers/modal.js b/app/javascript/vehicle_journeys/reducers/modal.js
index 862e27e1b..eae3314e8 100644
--- a/app/javascript/vehicle_journeys/reducers/modal.js
+++ b/app/javascript/vehicle_journeys/reducers/modal.js
@@ -1,6 +1,6 @@
import _ from 'lodash'
-let vehicleJourneysModal, newModalProps
+let vehicleJourneysModal, newModalProps, vehicleJourney
export default function modal(state = {}, action) {
switch (action.type) {
@@ -74,10 +74,12 @@ export default function modal(state = {}, action) {
confirmModal: {}
}
case 'SELECT_CP_EDIT_MODAL':
- newModalProps = _.assign({}, state.modalProps, {selectedCompany : action.selectedItem})
+ vehicleJourney = _.assign({}, state.modalProps.vehicleJourney, {company: action.selectedItem})
+ newModalProps = _.assign({}, state.modalProps, {vehicleJourney})
return _.assign({}, state, {modalProps: newModalProps})
case 'UNSELECT_CP_EDIT_MODAL':
- newModalProps = _.assign({}, state.modalProps, {selectedCompany : undefined})
+ vehicleJourney = _.assign({}, state.modalProps.vehicleJourney, {company: undefined})
+ newModalProps = _.assign({}, state.modalProps, {vehicleJourney})
return _.assign({}, state, {modalProps: newModalProps})
case 'SELECT_TT_CALENDAR_MODAL':
newModalProps = _.assign({}, state.modalProps, {selectedTimetable : action.selectedItem})
diff --git a/app/models/chouette/area_type.rb b/app/models/chouette/area_type.rb
index 33cbfbb48..43d96b391 100644
--- a/app/models/chouette/area_type.rb
+++ b/app/models/chouette/area_type.rb
@@ -1,4 +1,5 @@
class Chouette::AreaType
+ include Comparable
ALL = %i(zdep zder zdlp zdlr lda gdl).freeze
@@ -30,6 +31,10 @@ class Chouette::AreaType
@code = code
end
+ def <=>(other)
+ all.index(code) <=> all.index(other.code)
+ end
+
def label
I18n.translate code, scope: 'area_types.label'
end
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb
index 2f8d7c096..4f1359ff8 100644
--- a/app/models/chouette/stop_area.rb
+++ b/app/models/chouette/stop_area.rb
@@ -40,12 +40,20 @@ module Chouette
validates_format_of :url, :with => %r{\Ahttps?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?\Z}, :allow_nil => true, :allow_blank => true
validates_numericality_of :waiting_time, greater_than_or_equal_to: 0, only_integer: true, if: :waiting_time
+ validate :parent_area_type_must_be_greater
def self.nullable_attributes
[:registration_number, :street_name, :country_code, :fare_code,
:nearest_topic_name, :comment, :long_lat_type, :zip_code, :city_name, :url, :time_zone]
end
+ def parent_area_type_must_be_greater
+ return unless self.parent
+ if Chouette::AreaType.find(self.area_type) >= Chouette::AreaType.find(self.parent.area_type)
+ errors.add(:parent_id, I18n.t('stop_areas.errors.parent_area_type', area_type: self.parent.area_type))
+ end
+ end
+
after_update :clean_invalid_access_links
before_save :coordinates_to_lat_lng
@@ -74,6 +82,10 @@ module Chouette
end
end
+ def full_name
+ "#{name} #{zip_code} #{city_name} - #{user_objectid}"
+ end
+
def user_objectid
if objectid =~ /^.*:([0-9A-Za-z_-]+):STIF$/
$1
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index 3fcf26f5d..2bde5b95a 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -6,7 +6,7 @@ class ComplianceControl < ActiveRecord::Base
def prerequisite; I18n.t('compliance_controls.metas.no_prerequisite'); end
def predicate; I18n.t("compliance_controls.#{self.name.underscore}.description") end
def dynamic_attributes
- stored_attributes[:control_attributes]
+ stored_attributes[:control_attributes] || []
end
def policy_class
diff --git a/app/models/import.rb b/app/models/import.rb
index 19e835986..049a65f40 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -19,7 +19,6 @@ class Import < ActiveRecord::Base
validates :name, presence: true
validates :file, presence: true
validates_presence_of :workbench, :creator
- validates_format_of :file, with: %r{\.zip\z}i, message: I18n.t('activerecord.errors.models.import.attributes.file.wrong_file_extension')
before_create :initialize_fields
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 122af65a1..8db009ebd 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -282,6 +282,7 @@ class Referential < ActiveRecord::Base
def detect_overlapped_referentials
self.class.where(id: overlapped_referential_ids).each do |referential|
+ Rails.logger.info "Referential #{referential.id} #{referential.metadatas.inspect} overlaps #{metadatas.inspect}"
errors.add :metadatas, I18n.t("referentials.errors.overlapped_referential", :referential => referential.name)
end
end
diff --git a/app/models/vehicle_journey_control/waiting_time.rb b/app/models/vehicle_journey_control/waiting_time.rb
index 252135f04..f2666cb72 100644
--- a/app/models/vehicle_journey_control/waiting_time.rb
+++ b/app/models/vehicle_journey_control/waiting_time.rb
@@ -2,7 +2,7 @@ module VehicleJourneyControl
class WaitingTime < ComplianceControl
store_accessor :control_attributes, :maximum
- validates :maximum, numericality: true, allow_nil: true
+ validates_numericality_of :maximum, allow_nil: true, greater_than_or_equal_to: 0
def self.default_code; "3-VehicleJourney-1" end
end
diff --git a/app/uploaders/import_uploader.rb b/app/uploaders/import_uploader.rb
index 2740393ca..60e17ca0f 100644
--- a/app/uploaders/import_uploader.rb
+++ b/app/uploaders/import_uploader.rb
@@ -36,9 +36,9 @@ class ImportUploader < CarrierWave::Uploader::Base
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
- # def extension_whitelist
- # %w(jpg jpeg gif png)
- # end
+ def extension_whitelist
+ %w(zip)
+ end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
diff --git a/app/views/autocomplete_stop_areas/index.rabl b/app/views/autocomplete_stop_areas/index.rabl
index 5a9f76a47..d20051ad5 100644
--- a/app/views/autocomplete_stop_areas/index.rabl
+++ b/app/views/autocomplete_stop_areas/index.rabl
@@ -14,7 +14,8 @@ node do |stop_area|
:longitude => stop_area.longitude,
:latitude => stop_area.latitude,
:area_type => stop_area.area_type,
- :comment => stop_area.comment
+ :comment => stop_area.comment,
+ :text => stop_area.full_name
}
end
diff --git a/app/views/imports/_import_messages.html.slim b/app/views/imports/_import_messages.html.slim
index 9ab9226f7..a10dce065 100644
--- a/app/views/imports/_import_messages.html.slim
+++ b/app/views/imports/_import_messages.html.slim
@@ -1,10 +1,11 @@
-
- if import_messages.any?
- dl#import_messages
- - import_messages.each do | import_message |
- dt.import_message
- = import_message.criticity
- dd.import_message
- = t( ['import_messages',
- 'compliance_check_messages',
- import_message.message_key].join('.'), string_keys_to_symbols(import_message.message_attributes))
+ .import_message-list
+ .import_messages-head Messages
+ dl
+ - import_messages.each do | import_message |
+ dt.criticity
+ = import_message.criticity
+ dd
+ = t( ['import_messages',
+ 'compliance_check_messages',
+ import_message.message_key].join('.'), import_message.message_attributes.symbolize_keys)
diff --git a/app/views/imports/show.html.slim b/app/views/imports/show.html.slim
index 90c638d78..cf137867b 100644
--- a/app/views/imports/show.html.slim
+++ b/app/views/imports/show.html.slim
@@ -11,9 +11,6 @@
- page_header_content_for @import
-.error_messages
- = render 'import_messages', import_messages: @import.messages
-
.page_content
.container-fluid
.row
@@ -22,46 +19,52 @@
.row
.col-lg-12
- = table_builder_2 @import.children,
- [ \
- TableBuilderHelper::Column.new( \
- name: 'Nom du jeu de données', \
- attribute: 'name', \
- sortable: false, \
- link_to: lambda do |import| \
- referential_path(import.referential) if import.referential.present? \
- end \
- ), \
- TableBuilderHelper::Column.new( \
- key: :status, \
- attribute: Proc.new { |n| import_status(n.status) }, \
- sortable: false, \
- link_to: lambda do |import| \
- workbench_import_import_resources_path(import.workbench_id, import) \
- end \
- ), \
- TableBuilderHelper::Column.new( \
- name: 'Contrôle STIF', \
- attribute: '', \
- sortable: false, \
- ), \
- TableBuilderHelper::Column.new( \
- name: 'Contrôle organisation', \
- attribute: '', \
- sortable: false, \
- ) \
- ],
- links: [],
- cls: 'table',
- overhead: [ \
- {}, \
- { \
- title: "#{@import.children_succeedeed} jeu de données validé sur #{@import.children.count} présent(s) dans l'archive", \
- width: 1, \
- cls: "#{@import.import_status_css_class} full-border" \
- }, { \
- title: 'Bilan des jeux de contrôles d\'import <span title="Lorem ipsum..." class="fa fa-lg fa-info-circle text-info"></span>', \
- width: 2, \
- cls: 'overheaded-default colspan="2"' \
- } \
- ]
+ .error_messages
+ = render 'import_messages', import_messages: @import.messages
+
+ - if @import.children.any?
+ .row
+ .col-lg-12
+ = table_builder_2 @import.children,
+ [ \
+ TableBuilderHelper::Column.new( \
+ name: 'Nom du jeu de données', \
+ attribute: 'name', \
+ sortable: false, \
+ link_to: lambda do |import| \
+ referential_path(import.referential) if import.referential.present? \
+ end \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :status, \
+ attribute: Proc.new { |n| import_status(n.status) }, \
+ sortable: false, \
+ link_to: lambda do |import| \
+ workbench_import_import_resources_path(import.workbench_id, import) \
+ end \
+ ), \
+ TableBuilderHelper::Column.new( \
+ name: 'Contrôle STIF', \
+ attribute: '', \
+ sortable: false, \
+ ), \
+ TableBuilderHelper::Column.new( \
+ name: 'Contrôle organisation', \
+ attribute: '', \
+ sortable: false, \
+ ) \
+ ],
+ links: [],
+ cls: 'table',
+ overhead: [ \
+ {}, \
+ { \
+ title: "#{@import.children_succeedeed} jeu de données validé sur #{@import.children.count} présent(s) dans l'archive", \
+ width: 1, \
+ cls: "#{@import.import_status_css_class} full-border" \
+ }, { \
+ title: 'Bilan des jeux de contrôles d\'import <span title="Lorem ipsum..." class="fa fa-lg fa-info-circle text-info"></span>', \
+ width: 2, \
+ cls: 'overheaded-default colspan="2"' \
+ } \
+ ]
diff --git a/app/views/referentials/_form.html.slim b/app/views/referentials/_form.html.slim
index 6f7da84c7..1611ee6dd 100644
--- a/app/views/referentials/_form.html.slim
+++ b/app/views/referentials/_form.html.slim
@@ -17,7 +17,7 @@
.row
.col-lg-12
- if @referential.errors.has_key? :metadatas
- .row
+ .row.metadatas-errors
.col-lg-12
.alert.alert-danger
- @referential.errors[:metadatas].each do |msg|
diff --git a/app/views/stop_areas/_form.html.slim b/app/views/stop_areas/_form.html.slim
index e44680499..af8b9d889 100644
--- a/app/views/stop_areas/_form.html.slim
+++ b/app/views/stop_areas/_form.html.slim
@@ -6,6 +6,9 @@
/= @map.to_html
= f.input :id, as: :hidden
= f.input :name, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.name")}
+
+ = f.input :parent_id, as: :select, :collection => [f.object.parent_id], input_html: { data: { select2_ajax: 'true', url: autocomplete_stop_area_referential_stop_areas_path(@stop_area_referential), initvalue: {id: f.object.parent_id, text: f.object.parent.try(:full_name)}}}
+
= f.input :area_type, as: :select, :input_html => {:disabled => !@stop_area.new_record?}, :collection => Chouette::AreaType.options, :include_blank => false
.location_info
@@ -19,9 +22,9 @@
= f.input :coordinates, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.coordinates")}, required: true
= f.input :street_name
- /= f.input :country_code, required: format_restriction_for_locales(@referential) == '.hub'
= f.input :zip_code, :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.zip_code")}
= f.input :city_name, required: format_restriction_for_locales(@referential) == '.hub', :input_html => {:title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.stop_area.city_name")}
+ = f.input :country_code, as: :country, priority: ['FR', 'GB', 'DE', 'ES'], :include_blank => true
.stop_areas.stop_area.general_info
h3 = t("stop_areas.stop_area.general")
diff --git a/app/views/stop_areas/autocomplete.rabl b/app/views/stop_areas/autocomplete.rabl
new file mode 100644
index 000000000..3208289b5
--- /dev/null
+++ b/app/views/stop_areas/autocomplete.rabl
@@ -0,0 +1,24 @@
+collection @stop_areas
+
+node do |stop_area|
+ {
+ :id => stop_area.id,
+ :registration_number => stop_area.registration_number || "",
+ :short_registration_number => truncate(stop_area.registration_number, :length => 10) || "",
+ :name => stop_area.name || "",
+ :short_name => truncate(stop_area.name, :length => 30) || "",
+ :zip_code => stop_area.zip_code || "",
+ :city_name => stop_area.city_name || "",
+ :short_city_name => truncate(stop_area.city_name, :length => 15) || "",
+ :user_objectid => stop_area.user_objectid,
+ :longitude => stop_area.longitude,
+ :latitude => stop_area.latitude,
+ :area_type => stop_area.area_type,
+ :comment => stop_area.comment,
+ :text => stop_area.full_name
+ }
+end
+
+node(:stop_area_path) { |stop_area|
+ stop_area_picture_url(stop_area) || ""
+}
diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim
index 0c23710b6..f9de34a98 100644
--- a/app/views/stop_areas/show.html.slim
+++ b/app/views/stop_areas/show.html.slim
@@ -16,6 +16,7 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
- attributes = { t('id_reflex') => @stop_area.get_objectid.short_id,
+ @stop_area.human_attribute_name(:parent) => @stop_area.parent ? link_to(@stop_area.parent.name, stop_area_referential_stop_area_path(@stop_area_referential, @stop_area.parent)) : "-",
@stop_area.human_attribute_name(:stop_area_type) => Chouette::AreaType.find(@stop_area.area_type).try(:label),
@stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number,
}
@@ -23,6 +24,7 @@
- attributes.merge!({ "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,
+ @stop_area.human_attribute_name(:country_code) => @stop_area.country_code.presence || '-',
'Etat' => (@stop_area.deleted_at ? 'Supprimé' : 'Actif'),
@stop_area.human_attribute_name(:comment) => @stop_area.try(:comment),
})
diff --git a/app/views/vehicle_journeys/index.html.slim b/app/views/vehicle_journeys/index.html.slim
index 595646808..ebcac8197 100644
--- a/app/views/vehicle_journeys/index.html.slim
+++ b/app/views/vehicle_journeys/index.html.slim
@@ -4,7 +4,7 @@
- content_for :page_header_content do
.row.mb-sm
.col-lg-12.text-right
- = link_to(t('routes.actions.opposite_route_timetable'), [@referential, @route.line, @route.opposite_route, :vehicle_journeys], class: 'btn btn-primary')
+ = link_to(t('routes.actions.opposite_route_timetable'), [@referential, @route.line, @route.opposite_route, :vehicle_journeys], class: 'btn btn-primary sticky-action')
.page_content
diff --git a/app/views/vehicle_journeys/show.rabl b/app/views/vehicle_journeys/show.rabl
index a07f09309..01175a85d 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].each do |attr|
+[:objectid, :published_journey_name, :published_journey_identifier, :company_id, :comment].each do |attr|
attributes attr, :unless => lambda { |m| m.send( attr).nil?}
end