aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobertDober2017-04-11 08:47:46 +0200
committerRobertDober2017-04-11 08:47:46 +0200
commit9e716807c6bbf1bb9e1c749369df1706353a77d0 (patch)
treee6ef05adba5711f8197eefd8745300ee6b2b231d
parentf2c6091712be64c6017c5ffc8298692c860b593f (diff)
parentb23f6dca2395d87e2a3c0f8d8ca15303b240aef7 (diff)
downloadchouette-core-9e716807c6bbf1bb9e1c749369df1706353a77d0.tar.bz2
Merge branch 'master' of github.com:af83/stif-boiv
-rw-r--r--app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js4
-rw-r--r--app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/EditVehicleJourney.js47
-rw-r--r--app/assets/javascripts/forms.coffee12
-rw-r--r--app/assets/javascripts/main_menu.coffee3
-rw-r--r--app/assets/stylesheets/components/_buttons.sass2
-rw-r--r--app/assets/stylesheets/components/_forms.sass33
-rw-r--r--app/controllers/time_tables_controller.rb2
-rw-r--r--app/models/chouette/time_table.rb1
-rw-r--r--app/views/time_tables/_form.html.slim15
-rw-r--r--app/views/time_tables/index.html.slim2
-rw-r--r--app/views/time_tables/show.html.slim2
-rw-r--r--app/views/vehicle_journeys/show.rabl6
-rw-r--r--config/locales/actions.en.yml1
-rw-r--r--config/locales/actions.fr.yml1
-rw-r--r--db/migrate/20170410134931_add_color_to_timetables.rb5
-rw-r--r--db/schema.rb3
16 files changed, 119 insertions, 20 deletions
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js
index d39943913..81bbcdbb0 100644
--- a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js
+++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js
@@ -315,7 +315,9 @@ const actions = {
selected: false,
published_journey_name: val.published_journey_name || 'non renseigné',
published_journey_identifier: val.published_journey_name || 'non renseigné',
- company_id: val.published_journey_name || 'non renseigné'
+ company_id: val.published_journey_name || 'non renseigné',
+ transport_mode: val.route.line.transport_mode || 'non renseigné',
+ transport_mode: val.route.line.transport_submode || 'non renseigné'
})
}
window.currentItemsLength = vehicleJourneys.length
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/EditVehicleJourney.js
index 12814bad1..9a4790051 100644
--- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/EditVehicleJourney.js
+++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/tools/EditVehicleJourney.js
@@ -74,22 +74,51 @@ class EditVehicleJourney extends Component {
<div className='row'>
<div className='col-lg-6 col-md-6 col-sm-6 col-xs-12'>
- <label className='control-label is-required'>Numéro de train</label>
- <input
- type='text'
- ref='published_journey_identifier'
- className='form-control'
- defaultValue={this.props.modal.modalProps.vehicleJourney.published_journey_identifier}
- onKeyDown={(e) => actions.resetValidation(e.currentTarget)}
- required
+ <div className='form-group'>
+ <label className='control-label is-required'>Numéro de train</label>
+ <input
+ type='text'
+ ref='published_journey_identifier'
+ className='form-control'
+ defaultValue={this.props.modal.modalProps.vehicleJourney.published_journey_identifier}
+ onKeyDown={(e) => actions.resetValidation(e.currentTarget)}
+ required
/>
+ </div>
</div>
<div className='col-lg-6 col-md-6 col-sm-6 col-xs-12'>
- <label className='control-label'>Transporteur</label>
+ <div className='form-group'>
+ <label className='control-label'>Transporteur</label>
<CompanySelect2
company = {this.props.modal.modalProps.vehicleJourney.company}
onSelect2Company = {(e) => this.props.onSelect2Company(e)}
/>
+ </div>
+ </div>
+ </div>
+
+ <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'>Mode de transport</label>
+ <input
+ type='text'
+ className='form-control'
+ value={(this.props.modal.modalProps.vehicleJourney.transport_mode || 'non renseigné')}
+ disabled={true}
+ />
+ </div>
+ </div>
+ <div className='col-lg-6 col-md-6 col-sm-6 col-xs-12'>
+ <div className='form-group'>
+ <label className='control-label'>Sous mode de transport</label>
+ <input
+ type='text'
+ className='form-control'
+ value={(this.props.modal.modalProps.vehicleJourney.transport_submode || 'non renseigné')}
+ disabled={true}
+ />
+ </div>
</div>
</div>
</div>
diff --git a/app/assets/javascripts/forms.coffee b/app/assets/javascripts/forms.coffee
index 9d884edcd..679f92a54 100644
--- a/app/assets/javascripts/forms.coffee
+++ b/app/assets/javascripts/forms.coffee
@@ -30,9 +30,21 @@ isEdge = !isIE && !!window.StyleMedia
if isIE || isEdge
$('.formSubmitr').off()
+@colorSelector = ->
+ $('.form-group .dropdown.color_selector').each ->
+ selectedStatus = $(this).children('.dropdown-toggle').children('.fa-circle')
+
+ $(this).on 'click', "input[type='radio']", (e) ->
+ selectedValue = e.currentTarget.value
+ if selectedValue == ''
+ $(selectedStatus).css('color', 'transparent')
+ else
+ $(selectedStatus).css('color', selectedValue)
+
$(document).on 'ready page:load', togglableFilter
$(document).on 'ready page:load', submitMover
$(document).on 'ready page:load', switchInput
+$(document).on 'ready page:load', colorSelector
if isIE || isEdge
$(document).on 'click', '.formSubmitr', (e)->
diff --git a/app/assets/javascripts/main_menu.coffee b/app/assets/javascripts/main_menu.coffee
index 9357cff34..67e2f437e 100644
--- a/app/assets/javascripts/main_menu.coffee
+++ b/app/assets/javascripts/main_menu.coffee
@@ -49,5 +49,6 @@ $(document).on 'ready page:load', ->
$('#main_nav').removeClass 'sticky'
if $('#menu_top').find('.sticky-content').length > 0
- $('.page-action .small').after(link)
+ if !$('.page-action').find('.formSubmitr').length
+ $('.page-action .small').after(link)
$('.sticky-content').remove()
diff --git a/app/assets/stylesheets/components/_buttons.sass b/app/assets/stylesheets/components/_buttons.sass
index f128512f5..07758d56c 100644
--- a/app/assets/stylesheets/components/_buttons.sass
+++ b/app/assets/stylesheets/components/_buttons.sass
@@ -5,7 +5,7 @@
.btn
font-weight: 700
- .fa + span
+ .fa + span:not(.caret)
padding-left: 0.5em
span + .fa
padding-left: 0.5em
diff --git a/app/assets/stylesheets/components/_forms.sass b/app/assets/stylesheets/components/_forms.sass
index f2c76c9c1..6d841d5d4 100644
--- a/app/assets/stylesheets/components/_forms.sass
+++ b/app/assets/stylesheets/components/_forms.sass
@@ -95,6 +95,39 @@ input
+ [class*='col-sm-']
float: right
+// Colors dropdown
+.dropdown.color_selector
+ .btn.btn-default
+ &, &:hover, &:focus
+ border: 1px solid #cccccc
+ background-color: #fff
+ font-weight: normal
+ color: $darkgrey
+
+ .dropdown-menu
+ position: absolute
+ margin: 2px 0 0 0
+ min-width: 56px
+
+ > .radio
+ position: relative
+ padding: 3px 20px
+ // cursor: pointer
+
+ &:hover, &:focus
+ background-color: #f5f5f5
+
+ > label
+ padding: 0
+
+ input.color_selector, input[type='radio']
+ position: absolute
+ cursor: pointer
+ z-index: 1
+ width: 100%
+ margin: 0
+ opacity: 0
+
// Search bar
.search_bar
position: relative
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index c5aa7280a..2e03485f2 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -140,7 +140,7 @@ class TimeTablesController < ChouetteController
:object_version,
:creator_id,
:calendar_id,
- :version, :comment,
+ :version, :comment, :color,
:int_day_types,
:monday,
:tuesday,
diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb
index f018382fe..cc866c4dc 100644
--- a/app/models/chouette/time_table.rb
+++ b/app/models/chouette/time_table.rb
@@ -466,4 +466,3 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord
tt
end
end
-
diff --git a/app/views/time_tables/_form.html.slim b/app/views/time_tables/_form.html.slim
index fdb735d12..91fb6e09c 100644
--- a/app/views/time_tables/_form.html.slim
+++ b/app/views/time_tables/_form.html.slim
@@ -3,10 +3,19 @@
.row
.col-lg-12
= form.input :comment, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.time_table.comment")}
- = form.input :tag_list, as: :tags
+
+ .form-group
+ = form.label @time_table.human_attribute_name(:color), required: false, class: 'control-label col-sm-4'
+
+ .col-sm-8
+ .dropdown.color_selector
+ button.btn.btn-default.dropdown-toggle type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"
+ span.fa.fa-circle.mr-xs style="color:#{@time_table.color.nil? ? 'transparent' : @time_table.color}"
+ span.caret
- / = form.input :version
- / = form.input :objectid, :required => !@time_table.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.time_table.objectid")}
+ = form.input :color, as: :radio_buttons, label: false, collection: ["", "#9B9B9B", "#FFA070", "#C67300", "#7F551B", "#41CCE3", "#09B09C", "#3655D7", "#6321A0", "#E796C6", "#DD2DAA"], input_html: {class: 'color_selector'}, label_method: lambda{|c| ("<span class='fa fa-circle' style='color:" + (c.empty? ? 'transparent' : c) + "'></span>").html_safe}, wrapper_html: { class: 'dropdown-menu', 'aria-labelledby': "dropdownMenu1"}, include_blank: true
+
+ = form.input :tag_list, as: :tags
.form-group
label.control-label.col-sm-4
diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim
index fe52e2f99..6653d6015 100644
--- a/app/views/time_tables/index.html.slim
+++ b/app/views/time_tables/index.html.slim
@@ -41,7 +41,7 @@
= table_builder @time_tables,
{ :comment => 'comment', :color => '',
"Période de validité englobante" => Proc.new{ |tt| tt.bounding_dates.empty? ? '-' : t('bounding_dates', debut: l(tt.bounding_dates.min), end: l(tt.bounding_dates.max)) }, :calendar => Proc.new{ |tt| tt.calendar ? tt.calendar.try(:name) : '-' }, :updated_at => Proc.new {|tt| l(tt.updated_at, format: :short)} },
- [:show, :edit, :delete],
+ [:show, :edit, :duplicate, :delete],
[],
'table has-search'
diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim
index 0cfb49e80..d0a145f36 100644
--- a/app/views/time_tables/show.html.slim
+++ b/app/views/time_tables/show.html.slim
@@ -33,7 +33,7 @@
'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,
- 'Couleur associée' => '-' }
+ 'Couleur associée' => content_tag(:span, '', class: 'fa fa-circle', style: "color:#{@time_table.try(:color)}") }
.row
.col-lg-12.mb-sm
diff --git a/app/views/vehicle_journeys/show.rabl b/app/views/vehicle_journeys/show.rabl
index 86edfafa8..3e0477259 100644
--- a/app/views/vehicle_journeys/show.rabl
+++ b/app/views/vehicle_journeys/show.rabl
@@ -8,6 +8,12 @@ child(:company) do |company|
attributes :id, :objectid, :name
end
+child(:route) do |route|
+ child(:line) do |line|
+ attributes :transport_mode, :transport_submode
+ end
+end
+
child(:journey_pattern) do |journey_pattern|
attributes :id, :objectid, :name, :published_name
end
diff --git a/config/locales/actions.en.yml b/config/locales/actions.en.yml
index a5fbbeb64..5bfd9d9fb 100644
--- a/config/locales/actions.en.yml
+++ b/config/locales/actions.en.yml
@@ -9,6 +9,7 @@ en:
archive: "Archive"
unarchive: "Unarchive"
clone: 'Clone'
+ duplicate: 'Clone'
clean_up: 'Clean up'
sync: 'Synchronize'
combine: 'Combine'
diff --git a/config/locales/actions.fr.yml b/config/locales/actions.fr.yml
index f6e4d74e2..94afc1393 100644
--- a/config/locales/actions.fr.yml
+++ b/config/locales/actions.fr.yml
@@ -10,6 +10,7 @@ fr:
archive: 'Conserver'
unarchive: 'Déconserver'
clone: 'Dupliquer'
+ duplicate: 'Dupliquer'
clean_up: 'Purger'
sync: 'Synchroniser'
combine: 'Combiner'
diff --git a/db/migrate/20170410134931_add_color_to_timetables.rb b/db/migrate/20170410134931_add_color_to_timetables.rb
new file mode 100644
index 000000000..c297bc537
--- /dev/null
+++ b/db/migrate/20170410134931_add_color_to_timetables.rb
@@ -0,0 +1,5 @@
+class AddColorToTimetables < ActiveRecord::Migration
+ def change
+ add_column :time_tables, :color, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index c49f52067..69e9de3bf 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170404122930) do
+ActiveRecord::Schema.define(version: 20170410134931) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -706,6 +706,7 @@ ActiveRecord::Schema.define(version: 20170404122930) do
t.integer "calendar_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "color"
end
add_index "time_tables", ["calendar_id"], :name => "index_time_tables_on_calendar_id"