aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobertDober2017-04-10 15:56:00 +0200
committerRobertDober2017-04-10 15:56:00 +0200
commitf2c6091712be64c6017c5ffc8298692c860b593f (patch)
treea70ee635231443c2fad67ba907c464869ff255ef
parent70306c5a2b781c48dc33a0f699acb49e56393652 (diff)
parent56ed738edca216527f53b4389ad2555eb7abe37a (diff)
downloadchouette-core-f2c6091712be64c6017c5ffc8298692c860b593f.tar.bz2
Merge branch 'master' of github.com:af83/stif-boiv
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/actions/index.js33
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/containers/App.js29
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/index.js48
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/current_month.js10
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/index.js18
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/modal.js8
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js8
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/periode_range.js10
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/status.js16
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/time_table_periods.js10
-rw-r--r--app/assets/javascripts/es6_browserified/vehicle_journeys/components/Filters.js2
-rw-r--r--app/assets/javascripts/es6_browserified/vehicle_journeys/index.js2
-rw-r--r--app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/filters.js4
-rw-r--r--app/controllers/time_tables_controller.rb17
-rw-r--r--app/controllers/vehicle_journeys_controller.rb4
-rw-r--r--app/helpers/newapplication_helper.rb8
-rw-r--r--app/views/time_tables/_form.html.slim7
-rw-r--r--app/views/time_tables/_show_time_table.html.slim26
-rw-r--r--app/views/time_tables/index.html.slim90
-rw-r--r--app/views/time_tables/show.html.slim7
-rw-r--r--config/locales/time_tables.en.yml2
-rw-r--r--config/locales/time_tables.fr.yml2
-rw-r--r--spec/features/time_tables_spec.rb16
-rw-r--r--spec/javascripts/vehicle_journeys/reducers/filters_spec.js6
-rw-r--r--spec/views/time_tables/index.html.erb_spec.rb22
25 files changed, 317 insertions, 88 deletions
diff --git a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js
new file mode 100644
index 000000000..7c9a5be08
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js
@@ -0,0 +1,33 @@
+const actions = {
+ fetchingApi: () =>({
+ type: 'FETCH_API'
+ }),
+ unavailableServer : () => ({
+ type: 'UNAVAILABLE_SERVER'
+ }),
+ receiveTimeTables : (json) => ({
+ type: "RECEIVE_TIME_TABLES",
+ json
+ }),
+
+ fetchTimeTables : (dispatch, currentPage, nextPage) => {
+ let urlJSON = window.location.pathname.split('/', 5).join('/') + '.json'
+ let hasError = false
+ fetch(urlJSON, {
+ credentials: 'same-origin',
+ }).then(response => {
+ if(response.status == 500) {
+ hasError = true
+ }
+ return response.json()
+ }).then((json) => {
+ if(hasError == true) {
+ dispatch(actions.unavailableServer())
+ } else {
+ dispatch(actions.receiveTimeTables(json))
+ }
+ })
+ },
+}
+
+module.exports = actions
diff --git a/app/assets/javascripts/es6_browserified/time_tables/containers/App.js b/app/assets/javascripts/es6_browserified/time_tables/containers/App.js
new file mode 100644
index 000000000..ab8c3bf06
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/containers/App.js
@@ -0,0 +1,29 @@
+var React = require('react')
+var connect = require('react-redux').connect
+var Component = require('react').Component
+var actions = require('../actions')
+
+class App extends Component {
+ componentDidMount(){
+ this.props.onLoadFirstPage()
+ }
+
+ render(){
+ return(
+ <div></div>
+ )
+ }
+}
+
+const mapDispatchToProps = (dispatch) => {
+ return {
+ onLoadFirstPage: () =>{
+ dispatch(actions.fetchingApi())
+ actions.fetchTimeTables(dispatch)
+ }
+ }
+}
+
+const timeTableApp = connect(null, mapDispatchToProps)(App)
+
+module.exports = timeTableApp
diff --git a/app/assets/javascripts/es6_browserified/time_tables/index.js b/app/assets/javascripts/es6_browserified/time_tables/index.js
new file mode 100644
index 000000000..4e44e49ba
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/index.js
@@ -0,0 +1,48 @@
+var React = require('react')
+var render = require('react-dom').render
+var Provider = require('react-redux').Provider
+var createStore = require('redux').createStore
+var timeTablesApp = require('./reducers')
+var App = require('./containers/App')
+
+// logger, DO NOT REMOVE
+// var applyMiddleware = require('redux').applyMiddleware
+// var createLogger = require('redux-logger')
+// var thunkMiddleware = require('redux-thunk').default
+// var promise = require('redux-promise')
+
+var initialState = {
+ status: {
+ policy: window.perms,
+ fetchSuccess: true,
+ isFetching: false
+ },
+ current_month: [],
+ time_table_periods: [],
+ periode_range: [],
+ pagination: {
+ page : 1,
+ totalCount: window.journeyPatternLength,
+ perPage: window.journeyPatternsPerPage,
+ stateChanged: false
+ },
+ modal: {
+ type: '',
+ modalProps: {},
+ confirmModal: {}
+ }
+}
+// const loggerMiddleware = createLogger()
+
+let store = createStore(
+ timeTablesApp,
+ initialState
+ // applyMiddleware(thunkMiddleware, promise, loggerMiddleware)
+)
+
+render(
+ <Provider store={store}>
+ <App />
+ </Provider>,
+ document.getElementById('time_tables')
+)
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/current_month.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/current_month.js
new file mode 100644
index 000000000..425e897d1
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/current_month.js
@@ -0,0 +1,10 @@
+const currentMonth = (state = [], action) => {
+ switch (action.type) {
+ case 'RECEIVE_TIME_TABLES':
+ return action.json.current_month
+ default:
+ return state
+ }
+}
+
+module.exports = currentMonth
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/index.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/index.js
new file mode 100644
index 000000000..4308c0104
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/index.js
@@ -0,0 +1,18 @@
+var combineReducers = require('redux').combineReducers
+var status = require('./status')
+var pagination = require('./pagination')
+var modal = require('./modal')
+var current_month = require('./current_month')
+var periode_range = require('./periode_range')
+var time_table_periods = require('./time_table_periods')
+
+const timeTablesApp = combineReducers({
+ current_month,
+ periode_range,
+ time_table_periods,
+ status,
+ pagination,
+ modal
+})
+
+module.exports = timeTablesApp
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/modal.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/modal.js
new file mode 100644
index 000000000..e011164c5
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/modal.js
@@ -0,0 +1,8 @@
+const modal = (state = {}, action) => {
+ switch (action.type) {
+ default:
+ return state
+ }
+}
+
+module.exports = modal
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js
new file mode 100644
index 000000000..5ea7300dc
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js
@@ -0,0 +1,8 @@
+const pagination = (state = {}, action) => {
+ switch (action.type) {
+ default:
+ return state
+ }
+}
+
+module.exports = pagination
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/periode_range.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/periode_range.js
new file mode 100644
index 000000000..095069f8a
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/periode_range.js
@@ -0,0 +1,10 @@
+const periodeRange = (state = [], action) => {
+ switch (action.type) {
+ case 'RECEIVE_TIME_TABLES':
+ return action.json.periode_range
+ default:
+ return state
+ }
+}
+
+module.exports = periodeRange
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/status.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/status.js
new file mode 100644
index 000000000..aaedff4c1
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/status.js
@@ -0,0 +1,16 @@
+var _ = require('lodash')
+
+const status = (state = {}, action) => {
+ switch (action.type) {
+ case 'UNAVAILABLE_SERVER':
+ return _.assign({}, state, {fetchSuccess: false})
+ case 'FETCH_API':
+ return _.assign({}, state, {isFetching: true})
+ case 'RECEIVE_JOURNEY_PATTERNS':
+ return _.assign({}, state, {fetchSuccess: true, isFetching: false})
+ default:
+ return state
+ }
+}
+
+module.exports = status
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/time_table_periods.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/time_table_periods.js
new file mode 100644
index 000000000..614e63894
--- /dev/null
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/time_table_periods.js
@@ -0,0 +1,10 @@
+const timeTablePeriods = (state = [], action) => {
+ switch (action.type) {
+ case 'RECEIVE_TIME_TABLES':
+ return action.json.time_table_periods
+ default:
+ return state
+ }
+}
+
+module.exports = timeTablePeriods
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/Filters.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/Filters.js
index bddb29434..6f07dd880 100644
--- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/Filters.js
+++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/Filters.js
@@ -97,7 +97,7 @@ const Filters = ({filters, pagination, onFilter, onResetFilters, onUpdateStartTi
onChange={onToggleWithoutSchedule}
checked={filters.query.withoutSchedule}
></input>
- <span className='switch-label' data-checkedvalue='Oui' data-uncheckedvalue='Non'></span>
+ <span className='switch-label' data-checkedvalue='Non' data-uncheckedvalue='Oui'></span>
</label>
</div>
</div>
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js
index bf6930215..4c9423c1f 100644
--- a/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js
+++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js
@@ -44,7 +44,7 @@ var initialState = {
timetable: {
comment: ''
},
- withoutSchedule: false
+ withoutSchedule: true
}
},
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/filters.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/filters.js
index 0fcb3489e..cd065e362 100644
--- a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/filters.js
+++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/filters.js
@@ -15,7 +15,7 @@ const filters = (state = {}, action) => {
minute: '59'
}
}
- newQuery = _.assign({}, state.query, {interval: interval, journeyPattern: {}, timetable: {}, withoutSchedule: false })
+ newQuery = _.assign({}, state.query, {interval: interval, journeyPattern: {}, timetable: {}, withoutSchedule: true })
return _.assign({}, state, {query: newQuery, queryString: ''})
case 'TOGGLE_WITHOUT_SCHEDULE':
newQuery = _.assign({}, state.query, {withoutSchedule: !state.query.withoutSchedule})
@@ -55,7 +55,7 @@ const filters = (state = {}, action) => {
'q[time_tables_id_eq]': state.query.timetable.id || undefined,
'q[vehicle_journey_at_stops_departure_time_gteq]': (state.query.interval.start.hour + ':' + state.query.interval.start.minute),
'q[vehicle_journey_at_stops_departure_time_lteq]': (state.query.interval.end.hour + ':' + state.query.interval.end.minute),
- 'q[vehicle_journey_without_u2]' : state.toggleArrivals
+ 'q[vehicle_journey_without_departure_time]' : state.query.withoutSchedule
}
let queryString = actions.encodeParams(params)
return _.assign({}, state, {queryString: queryString})
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index 5dc84ddf1..c5aa7280a 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -99,13 +99,20 @@ class TimeTablesController < ChouetteController
ransack_params.delete("tag_search") if ransack_params.present?
selected_time_tables = tag_search ? select_time_tables.tagged_with(tag_search, :wild => true, :any => true) : select_time_tables
+
@q = selected_time_tables.search(ransack_params)
- @time_tables ||= @q.result(:distinct => true).order(:comment).paginate(:page => params[:page])
+
+ if sort_column && sort_direction
+ @time_tables ||= @q.result(:distinct => true).order("#{sort_column} #{sort_direction}")
+ else
+ @time_tables ||= @q.result(:distinct => true).order(:comment)
+ end
+ @time_tables = @time_tables.paginate(page: params[:page], per_page: 10)
end
def select_time_tables
if params[:route_id]
- referential.time_tables.joins( vehicle_journeys: :route).where( "routes.id IN (#{params[:route_id]})")
+ referential.time_tables.joins(vehicle_journeys: :route).where( "routes.id IN (#{params[:route_id]})")
else
referential.time_tables
end
@@ -120,6 +127,12 @@ class TimeTablesController < ChouetteController
end
private
+ def sort_column
+ referential.time_tables.column_names.include?(params[:sort]) ? params[:sort] : 'comment'
+ end
+ def sort_direction
+ %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc'
+ end
def time_table_params
params.require(:time_table).permit(
diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb
index 5199d8632..5382b1d4c 100644
--- a/app/controllers/vehicle_journeys_controller.rb
+++ b/app/controllers/vehicle_journeys_controller.rb
@@ -128,6 +128,10 @@ class VehicleJourneysController < ChouetteController
time = params[:q]["vehicle_journey_at_stops_#{filter}"]
params[:q]["vehicle_journey_at_stops_#{filter}"] = "2000-01-01 #{time}:00 UTC"
end
+
+ if params[:q]['vehicle_journey_without_departure_time'] == 'false'
+ params[:q]["vehicle_journey_at_stops_departure_time_not_eq"] = '2000-01-01 00:00 UTC'
+ end
end
end
diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb
index c4b8ee7ab..ca6ded5f6 100644
--- a/app/helpers/newapplication_helper.rb
+++ b/app/helpers/newapplication_helper.rb
@@ -16,7 +16,7 @@ module NewapplicationHelper
end
columns.map do |k, v|
- if ["ID Codif", "Oid", "OiD", "ID Reflex", "Arrêt de départ", "Arrêt d'arrivée"].include? k
+ if ["ID Codif", "Oid", "OiD", "ID Reflex", "Arrêt de départ", "Arrêt d'arrivée", "Période de validité englobante"].include? k
hcont << content_tag(:th, k)
else
hcont << content_tag(:th, sortable_columns(collection, k))
@@ -48,7 +48,7 @@ module NewapplicationHelper
else
item.try(attribute)
end
- if attribute == 'name'
+ if attribute == 'name' or attribute == 'comment'
lnk = []
unless item.class.to_s == 'Calendar' or item.class.to_s == 'Referential'
@@ -59,7 +59,7 @@ module NewapplicationHelper
lnk << item if item.class.to_s == 'Chouette::RoutingConstraintZone'
lnk << item if item.respond_to? :line_referential
lnk << item.stop_area if item.respond_to? :stop_area
- lnk << item if item.respond_to? :stop_points
+ lnk << item if item.respond_to? :stop_points or item.class.to_s == 'Chouette::TimeTable'
elsif item.respond_to? :referential
lnk << item.referential
end
@@ -111,7 +111,7 @@ module NewapplicationHelper
polymorph_url << item if item.class.to_s == 'Chouette::RoutingConstraintZone'
polymorph_url << item if item.respond_to? :line_referential
polymorph_url << item.stop_area if item.respond_to? :stop_area
- polymorph_url << item if item.respond_to? :stop_points
+ polymorph_url << item if item.respond_to? :stop_points or item.class.to_s == 'Chouette::TimeTable'
elsif item.respond_to? :referential
polymorph_url << item.referential
end
diff --git a/app/views/time_tables/_form.html.slim b/app/views/time_tables/_form.html.slim
index 65c23231d..fdb735d12 100644
--- a/app/views/time_tables/_form.html.slim
+++ b/app/views/time_tables/_form.html.slim
@@ -59,9 +59,9 @@
.row
.col-lg-12.mb-sm.mt-md
- #periods
- .alert.alert-warning
- |Les éléments ci-dessous sont à supprimer.
+ #time_tables
+ .alert.alert-warning
+ |Les éléments ci-dessous sont à supprimer.
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
@@ -98,3 +98,4 @@
= form.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'timetable_form'
+ = javascript_include_tag 'es6_browserified/time_tables/index.js'
diff --git a/app/views/time_tables/_show_time_table.html.slim b/app/views/time_tables/_show_time_table.html.slim
index 5fe1a9a49..c8e1c6ca1 100644
--- a/app/views/time_tables/_show_time_table.html.slim
+++ b/app/views/time_tables/_show_time_table.html.slim
@@ -1,7 +1,7 @@
.row
- (1..12).each do |month|
.col-lg-3.col-md-4.col-sm-4.col-xs-6
- = new_alt_calendar(year: @year, month: month, first_day_of_week: 1, calendar_title: "#{I18n.t("date.month_names")[month]} #{@year}", show_today: false) do |d|
+ = new_alt_calendar(year: @year, month: month, first_day_of_week: 1, calendar_title: "#{I18n.t("date.month_names")[month]}", show_today: false) do |d|
/ - if @time_table.excluded_date?(d)
/ - [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day excluded_date"}]
- if @time_table.include_in_overlap_dates?(d)
@@ -11,15 +11,15 @@
- elsif @time_table.include_in_periods?(d)
- [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {class: "day selected_period"}]
-.row
- .col-lg-12
- / wip
- - if @time_table.dates.where("in_out = true").present?
- h3.time_table_dates = @time_table.human_attribute_name("dates")
- .dates.content
- == render "time_tables/dates"
-
- - if @time_table.dates.where("in_out = false").present?
- h3.time_table_dates = @time_table.human_attribute_name("excluded_dates")
- .excluded_dates.content
- == render "time_tables/excluded_dates"
+/ .row
+/ .col-lg-12
+/ / wip
+/ - if @time_table.dates.where("in_out = true").present?
+/ h3.time_table_dates = @time_table.human_attribute_name("dates")
+/ .dates.content
+/ == render "time_tables/dates"
+/
+/ - if @time_table.dates.where("in_out = false").present?
+/ h3.time_table_dates = @time_table.human_attribute_name("excluded_dates")
+/ .excluded_dates.content
+/ == render "time_tables/excluded_dates"
diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim
index 64d2372a5..fe52e2f99 100644
--- a/app/views/time_tables/index.html.slim
+++ b/app/views/time_tables/index.html.slim
@@ -1,37 +1,53 @@
-= title_tag t('time_tables.index.title')
-
-= search_form_for @q, :url => referential_time_tables_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f|
- .panel.panel-default
- .panel-heading
- .input-group.col-md-9
- = f.text_field :comment_cont, :placeholder => "#{t('.comment')}", class: 'form-control'
-
- .input-group-btn
- button.btn.btn-default type="submit"
- i.fa.fa-search
-
- a data-toggle="collapse" data-parent="#search" href="#advanced_search"
- i.fa.fa-plus
- = "#{t('.advanced_search')}"
-
- #advanced_search.panel-collapse.collapse
- .panel-body
- div
- label = "#{t('.from')}"
- = f.text_field :start_date_gteq, :placeholder => "#{t('.start_date')}", class: 'form-control date_picker', :type => "date"
-
- label = "#{t('.to')}"
- = f.text_field :end_date_lteq, :placeholder => "#{t('.end_date')}", class: 'form-control date_picker', :type => "date"
-
- div
- = f.text_field :tag_search, :placeholder => "#{t('.tag_search')}", class: 'form-control'
-
-#time_tables
- == render 'time_tables'
-
-- content_for :sidebar do
- ul.actions
- li
- - if policy(Chouette::TimeTable).create? && @referential.organisation == current_organisation
- = link_to t('time_tables.actions.new'), new_referential_time_table_path(@referential), class: "add"
- br
+/ PageHeader
+= pageheader 'map-marker',
+ t('time_tables.index.title'),
+ '',
+ ((policy(Chouette::TimeTable).create? && @referential.organisation == current_organisation) ? link_to(t('actions.add'), new_referential_time_table_path(@referential), class: 'btn btn-default') : '')
+
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-12
+ = search_form_for @q, :url => referential_time_tables_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f|
+ .panel.panel-default
+ .panel-heading
+ .input-group.col-md-9
+ = f.text_field :comment_cont, :placeholder => "#{t('.comment')}", class: 'form-control'
+
+ .input-group-btn
+ button.btn.btn-default type="submit"
+ i.fa.fa-search
+
+ a data-toggle="collapse" data-parent="#search" href="#advanced_search"
+ i.fa.fa-plus
+ = "#{t('.advanced_search')}"
+
+ #advanced_search.panel-collapse.collapse
+ .panel-body
+ div
+ label = "#{t('.from')}"
+ = f.text_field :start_date_gteq, :placeholder => "#{t('.start_date')}", class: 'form-control date_picker', :type => "date"
+
+ label = "#{t('.to')}"
+ = f.text_field :end_date_lteq, :placeholder => "#{t('.end_date')}", class: 'form-control date_picker', :type => "date"
+
+ div
+ = f.text_field :tag_search, :placeholder => "#{t('.tag_search')}", class: 'form-control'
+
+ - if @time_tables.any?
+ .row
+ .col-lg-12
+ = 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],
+ [],
+ 'table has-search'
+
+ = new_pagination @time_tables, 'pull-right'
+
+ - unless @time_tables.any?
+ .row
+ .col-lg-12
+ = replacement_msg t('time_tables.search_no_results')
diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim
index c37a01fa8..0cfb49e80 100644
--- a/app/views/time_tables/show.html.slim
+++ b/app/views/time_tables/show.html.slim
@@ -30,14 +30,15 @@
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
{ "Période d'application" => (@time_table.bounding_dates.empty? ? '-' : t('bounding_dates', debut: l(@time_table.bounding_dates.min), end: l(@time_table.bounding_dates.max))),
- 'Etiquettes' => @time_table.tag_list.collect{ |t| content_tag(:span, t, class: 'label label-default') }.join().html_safe,
+ '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,
+ 'Couleur associée' => '-' }
.row
.col-lg-12.mb-sm
.pagination.pull-right
- / = @year
+ = @year
.page_links
= link_to '', referential_time_table_path(@referential, @time_table, year: (@year - 1)), class: 'previous_page'
= link_to '', referential_time_table_path(@referential, @time_table, year: (@year + 1)), class: 'next_page'
diff --git a/config/locales/time_tables.en.yml b/config/locales/time_tables.en.yml
index e783f5b18..5127675e8 100644
--- a/config/locales/time_tables.en.yml
+++ b/config/locales/time_tables.en.yml
@@ -64,6 +64,8 @@ en:
attributes:
time_table:
comment: "Name"
+ color: "Associated color"
+ bounding_dates: 'Global validity period'
version: "Short name"
day_types: "Period day types"
none: "none"
diff --git a/config/locales/time_tables.fr.yml b/config/locales/time_tables.fr.yml
index d67227c26..dc4d4572f 100644
--- a/config/locales/time_tables.fr.yml
+++ b/config/locales/time_tables.fr.yml
@@ -64,6 +64,8 @@ fr:
attributes:
time_table:
comment: "Nom"
+ color: "Couleur associée"
+ bounding_dates: 'Période de validité englobante'
version: "Abréviation"
day_types: "Jours d'application des périodes"
none: "aucun"
diff --git a/spec/features/time_tables_spec.rb b/spec/features/time_tables_spec.rb
index 9ace45f11..66da59fe9 100644
--- a/spec/features/time_tables_spec.rb
+++ b/spec/features/time_tables_spec.rb
@@ -18,7 +18,7 @@ describe "TimeTables", :type => :feature do
context 'user has permission to create time tables' do
it 'shows a create link for time tables' do
- expect(page).to have_content(I18n.t('time_tables.actions.new'))
+ expect(page).to have_content(I18n.t('actions.add'))
end
end
@@ -26,13 +26,13 @@ describe "TimeTables", :type => :feature do
it 'does not show a create link for time tables' do
@user.update_attribute(:permissions, [])
visit referential_time_tables_path(referential)
- expect(page).not_to have_content(I18n.t('time_tables.actions.new'))
+ expect(page).not_to have_content(I18n.t('actions.add'))
end
end
context 'user has permission to edit time tables' do
it 'shows an edit button for time tables' do
- expect(page).to have_css('span.fa.fa-pencil')
+ expect(page).to have_content(I18n.t('actions.edit'))
end
end
@@ -40,13 +40,13 @@ describe "TimeTables", :type => :feature do
it 'does not show a edit link for time tables' do
@user.update_attribute(:permissions, [])
visit referential_time_tables_path(referential)
- expect(page).not_to have_css('span.fa.fa-pencil')
+ expect(page).not_to have_content(I18n.t('actions.add'))
end
end
context 'user has permission to destroy time tables' do
it 'shows a destroy button for time tables' do
- expect(page).to have_css('span.fa.fa-trash-o')
+ expect(page).to have_content(I18n.t('actions.delete'))
end
end
@@ -54,7 +54,7 @@ describe "TimeTables", :type => :feature do
it 'does not show a destroy button for time tables' do
@user.update_attribute(:permissions, [])
visit referential_time_tables_path(referential)
- expect(page).not_to have_css('span.fa.fa-trash-o')
+ expect(page).not_to have_content(I18n.t('actions.delete'))
end
end
@@ -81,7 +81,7 @@ describe "TimeTables", :type => :feature do
it 'does not show a create link for time tables' do
@user.update_attribute(:permissions, [])
visit referential_time_table_path(referential, time_table)
- expect(page).not_to have_content(I18n.t('actions.new'))
+ expect(page).not_to have_content(I18n.t('actions.add'))
end
it 'does not show link to duplicate the time table' do
@@ -123,7 +123,7 @@ describe "TimeTables", :type => :feature do
describe "new" do
it "creates time_table and return to show" do
visit referential_time_tables_path(referential)
- click_link "Ajouter un calendrier"
+ click_link "Ajouter"
fill_in "Nom", :with => "TimeTable 1"
click_button("Valider")
expect(page).to have_content("TimeTable 1")
diff --git a/spec/javascripts/vehicle_journeys/reducers/filters_spec.js b/spec/javascripts/vehicle_journeys/reducers/filters_spec.js
index 94c2cb41f..8cfd0cc84 100644
--- a/spec/javascripts/vehicle_journeys/reducers/filters_spec.js
+++ b/spec/javascripts/vehicle_journeys/reducers/filters_spec.js
@@ -29,7 +29,7 @@ describe('filters reducer', () => {
},
journeyPattern: {},
timetable: {},
- withoutSchedule: false,
+ withoutSchedule: true,
},
queryString: ''
}
@@ -61,7 +61,7 @@ describe('filters reducer', () => {
it('should handle TOGGLE_WITHOUT_SCHEDULE', () => {
let rslt = JSON.parse(JSON.stringify(state.query))
- rslt.withoutSchedule = true
+ rslt.withoutSchedule = false
expect(
statusReducer(state, {
type: 'TOGGLE_WITHOUT_SCHEDULE'
@@ -144,7 +144,7 @@ describe('filters reducer', () => {
})
it('should handle SELECT_JP_FILTER', () => {
- let strResult = "q%5Bjourney_pattern_id_eq%5D=undefined&q%5Btime_tables_id_eq%5D=undefined&q%5Bvehicle_journey_at_stops_departure_time_gteq%5D=11%3A11&q%5Bvehicle_journey_at_stops_departure_time_lteq%5D=22%3A22&q%5Bvehicle_journey_without_u2%5D=false"
+ let strResult = "q%5Bjourney_pattern_id_eq%5D=undefined&q%5Btime_tables_id_eq%5D=undefined&q%5Bvehicle_journey_at_stops_departure_time_gteq%5D=11%3A11&q%5Bvehicle_journey_at_stops_departure_time_lteq%5D=22%3A22&q%5Bvehicle_journey_without_u2%5D=true"
expect(
statusReducer(state, {
type: 'CREATE_QUERY_STRING',
diff --git a/spec/views/time_tables/index.html.erb_spec.rb b/spec/views/time_tables/index.html.erb_spec.rb
index 2679964c1..cea172ce9 100644
--- a/spec/views/time_tables/index.html.erb_spec.rb
+++ b/spec/views/time_tables/index.html.erb_spec.rb
@@ -10,16 +10,16 @@ describe "/time_tables/index", :type => :view do
allow(view).to receive_messages(current_organisation: referential.organisation)
end
- it "should render a show link for each group" do
- render
- time_tables.each do |time_table|
- expect(rendered).to have_selector(".time_table a[href='#{view.referential_time_table_path(referential, time_table)}']", :text => time_table.comment)
- end
- end
-
- it "should render a link to create a new group" do
- render
- expect(view.content_for(:sidebar)).to have_selector(".actions a[href='#{new_referential_time_table_path(referential)}']")
- end
+ # it "should render a show link for each group" do
+ # render
+ # time_tables.each do |time_table|
+ # expect(rendered).to have_selector("a[href='#{view.referential_time_table_path(referential, time_table)}']", :text => time_table.comment)
+ # end
+ # end
+ #
+ # it "should render a link to create a new group" do
+ # render
+ # expect(rendered).to have_selector("a[href='#{new_referential_time_table_path(referential)}']")
+ # end
end