diff options
| author | Robert | 2017-06-09 17:25:52 +0200 |
|---|---|---|
| committer | Robert | 2017-06-09 17:25:52 +0200 |
| commit | 5d16bcae1f2174c07177227b84e2563930e1ec90 (patch) | |
| tree | 01a17a211612bf0ebeb3f4c77a9bd86fdd52064a /app | |
| parent | 29fbffa1928fc08b5e2392afdd98cc1e2094f023 (diff) | |
| parent | 680b4a76a959b7c362a03c98b2c68733bcb601e5 (diff) | |
| download | chouette-core-5d16bcae1f2174c07177227b84e2563930e1ec90.tar.bz2 | |
conflict resolved
Diffstat (limited to 'app')
23 files changed, 406 insertions, 164 deletions
diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js b/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js index aa2d208df..0ed8660d5 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js @@ -22,90 +22,91 @@ class CreateModal extends Component { } if(this.props.status.fetchSuccess == true) { return ( - <div className='row mt-md'> - <div className='col-lg-12 text-right'> - <button - type='button' - className='btn btn-outline-primary' - data-toggle='modal' - data-target='#NewJourneyPatternModal' - onClick={this.props.onOpenCreateModal} - > - Ajouter une mission - </button> + <div className="select_toolbox"> + <ul> + <li className='st_action'> + <button + type='button' + data-toggle='modal' + data-target='#NewJourneyPatternModal' + onClick={this.props.onOpenCreateModal} + > + <span className="fa fa-plus"></span> + </button> - <div className={ 'modal fade ' + ((this.props.modal.type == 'create') ? 'in' : '') } id='NewJourneyPatternModal'> - <div className='modal-container'> - <div className='modal-dialog'> - <div className='modal-content'> - <div className='modal-header'> - <h4 className='modal-title'>Ajouter une mission</h4> - </div> + <div className={ 'modal fade ' + ((this.props.modal.type == 'create') ? 'in' : '') } id='NewJourneyPatternModal'> + <div className='modal-container'> + <div className='modal-dialog'> + <div className='modal-content'> + <div className='modal-header'> + <h4 className='modal-title'>Ajouter une mission</h4> + </div> - {(this.props.modal.type == 'create') && ( - <form> - <div className='modal-body'> - <div className='form-group'> - <label className='control-label is-required'>Nom</label> - <input - type='text' - ref='name' - className='form-control' - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} - required - /> - </div> - <div className='row'> - <div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'> - <div className='form-group'> - <label className='control-label is-required'>Nom public</label> - <input - type='text' - ref='published_name' - className='form-control' - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} - required - /> - </div> + {(this.props.modal.type == 'create') && ( + <form> + <div className='modal-body'> + <div className='form-group'> + <label className='control-label is-required'>Nom</label> + <input + type='text' + ref='name' + className='form-control' + onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + required + /> </div> - <div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'> - <div className='form-group'> - <label className='control-label is-required'>Code mission</label> - <input - type='text' - ref='registration_number' - className='form-control' - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} - required - /> + <div className='row'> + <div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'> + <div className='form-group'> + <label className='control-label is-required'>Nom public</label> + <input + type='text' + ref='published_name' + className='form-control' + onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + required + /> + </div> + </div> + <div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'> + <div className='form-group'> + <label className='control-label is-required'>Code mission</label> + <input + type='text' + ref='registration_number' + className='form-control' + onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + required + /> + </div> </div> </div> </div> - </div> - <div className='modal-footer'> - <button - className='btn btn-link' - data-dismiss='modal' - type='button' - onClick={this.props.onModalClose} - > - Annuler - </button> - <button - className='btn btn-primary' - type='button' - onClick={this.handleSubmit.bind(this)} - > - Valider - </button> - </div> - </form> - )} + <div className='modal-footer'> + <button + className='btn btn-link' + data-dismiss='modal' + type='button' + onClick={this.props.onModalClose} + > + Annuler + </button> + <button + className='btn btn-primary' + type='button' + onClick={this.handleSubmit.bind(this)} + > + Valider + </button> + </div> + </form> + )} + </div> </div> </div> </div> - </div> - </div> + </li> + </ul> </div> ) } else { diff --git a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js index 41d247b21..0a6e7e1dc 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js +++ b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js @@ -201,8 +201,8 @@ const actions = { start = new Date(start) end = new Date(end) _.each(periods, (period, i) => { - if(index != i && !period.deleted){ - if((new Date(period.period_start) <= start && new Date(period.period_end) >= start) || (new Date(period.period_start) <= end && new Date(period.period_end) >= end)) + if(index !== i && !period.deleted){ + if((new Date(period.period_start) <= start && new Date(period.period_end) >= start) || (new Date(period.period_start) <= end && new Date(period.period_end) >= end) || (start >= new Date(period.period_start) && end <= new Date(period.period_end)) || (start <= new Date(period.period_start) && end >= new Date(period.period_end))) error = 'Les périodes ne peuvent pas se chevaucher' } }) diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js b/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js index c2229d991..40ae0eccf 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js +++ b/app/assets/javascripts/es6_browserified/time_tables/components/ConfirmModal.js @@ -2,7 +2,7 @@ var React = require('react') var Component = require('react').Component var PropTypes = require('react').PropTypes -const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, journeyPatterns}) => ( +const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}) => ( <div className={ 'modal fade ' + ((modal.type == 'confirm') ? 'in' : '') } id='ConfirmModal'> <div className='modal-container'> <div className='modal-dialog'> @@ -28,7 +28,7 @@ const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, journeyPat className='btn btn-primary' data-dismiss='modal' type='button' - onClick = {() => {onModalAccept(modal.confirmModal.callback, journeyPatterns)}} + onClick = {() => {onModalAccept(modal.confirmModal.callback, timetable, metas)}} > Valider </button> diff --git a/app/assets/javascripts/es6_browserified/time_tables/containers/ConfirmModal.js b/app/assets/javascripts/es6_browserified/time_tables/containers/ConfirmModal.js index 8095e1e7c..6282c1d1d 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/containers/ConfirmModal.js +++ b/app/assets/javascripts/es6_browserified/time_tables/containers/ConfirmModal.js @@ -5,13 +5,14 @@ var ConfirmModal = require('../components/ConfirmModal') const mapStateToProps = (state) => { return { modal: state.modal, - journeyPatterns: state.journeyPatterns + timetable: state.timetable, + metas: state.metas } } const mapDispatchToProps = (dispatch) => { return { - onModalAccept: (next, timetable, metas, state) =>{ + onModalAccept: (next, timetable, metas) =>{ dispatch(actions.fetchingApi()) actions.submitTimetable(dispatch, timetable, metas, next) }, diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js index 4f1e7a528..2ce084efd 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js +++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/metas.js @@ -12,6 +12,9 @@ const metas = (state = {}, action) => { color: action.json.color, calendar: action.json.calendar ? action.json.calendar : null }) + case 'RECEIVE_MONTH': + let dt = (typeof state.day_types === 'string') ? actions.strToArrayDayTypes(state.day_types) : state.day_types + return _.assign({}, state, {day_types: dt}) case 'INCLUDE_DATE_IN_PERIOD': case 'EXCLUDE_DATE_FROM_PERIOD': case 'DELETE_PERIOD': diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js index 660484c58..3d96fb7b7 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js +++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/pagination.js @@ -5,8 +5,12 @@ const pagination = (state = {}, action) => { case 'RECEIVE_TIME_TABLES': return _.assign({}, state, { currentPage: action.json.current_periode_range, - periode_range: action.json.periode_range + periode_range: action.json.periode_range, + stateChanged: false }) + case 'RECEIVE_MONTH': + case 'RECEIVE_ERRORS': + return _.assign({}, state, {stateChanged: false}) case 'GO_TO_PREVIOUS_PAGE': case 'GO_TO_NEXT_PAGE': let nextPage = action.nextPage ? 1 : -1 @@ -22,7 +26,6 @@ const pagination = (state = {}, action) => { case 'VALIDATE_PERIOD_FORM': case 'UPDATE_COMMENT': case 'UPDATE_COLOR': - case 'UPDATE_DAY_TYPES': toggleOnConfirmModal('modal') return _.assign({}, state, {stateChanged: true}) default: diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js index ba27ca72c..97aa60526 100644 --- a/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js +++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js @@ -8,10 +8,10 @@ var actions = require("./actions") var enableBatching = require('./batch').enableBatching // 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 applyMiddleware = require('redux').applyMiddleware +// var createLogger = require('redux-logger') +// var thunkMiddleware = require('redux-thunk').default +// var promise = require('redux-promise') var selectedJP = [] @@ -85,12 +85,12 @@ if (window.jpOrigin){ initialState.filters.queryString = actions.encodeParams(params) } -const loggerMiddleware = createLogger() +// const loggerMiddleware = createLogger() let store = createStore( enableBatching(vehicleJourneysApp), - initialState, - applyMiddleware(thunkMiddleware, promise, loggerMiddleware) + initialState + // applyMiddleware(thunkMiddleware, promise, loggerMiddleware) ) render( diff --git a/app/assets/stylesheets/components/_tables.sass b/app/assets/stylesheets/components/_tables.sass index 0cd91a1a8..e3a33e131 100644 --- a/app/assets/stylesheets/components/_tables.sass +++ b/app/assets/stylesheets/components/_tables.sass @@ -82,6 +82,66 @@ border-top: 2px solid $darkgrey margin-top: 15px + // Specific for tables displaying stop points + &.has-stoppoints + tbody + > tr > td:first-child + position: relative + padding-left: 25px + + &:before + content: '' + display: block + width: 10px + height: 10px + background-color: #fff + border: 2px solid $blue + border-radius: 50% + position: absolute + z-index: 5 + left: 5px + top: 50% + margin-top: -5px + + &:after + content: '' + display: block + width: 4px + margin: 0 3px + background-color: rgba($grey, 0.5) + position: absolute + z-index: 3 + top: 0 + left: 5px + bottom: 0 + + > tr:first-child > td:first-child + &:after + content: '' + top: 50% + + > tr:last-child > td:first-child + &:after + content: '' + bottom: 50% + + > tr:first-child > td:first-child, > tr:last-child > td:first-child + &:before + content: '•' + color: $blue + text-align: center + font-size: 28px + letter-spacing: 0 + text-indent: -0.01em + line-height: 12px + width: 15px + height: 15px + left: 2px + top: 50% + margin-top: -8px + + + // select_toolbox .select_toolbox padding: 10px diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb index f2f74e801..b5072f401 100644 --- a/app/controllers/routing_constraint_zones_controller.rb +++ b/app/controllers/routing_constraint_zones_controller.rb @@ -1,6 +1,7 @@ class RoutingConstraintZonesController < ChouetteController - defaults resource_class: Chouette::RoutingConstraintZone + include PolicyChecker + defaults resource_class: Chouette::RoutingConstraintZone respond_to :html, :xml, :json before_action :remove_empty_stop_point, only: [:create, :update] @@ -9,11 +10,50 @@ class RoutingConstraintZonesController < ChouetteController belongs_to :line, parent_class: Chouette::Line end - include PolicyChecker + def index + @routing_constraint_zones = collection + end + + def show + @routing_constraint_zone = collection.find(params[:id]) + end + + protected + + def collection + @q = resource.routing_constraint_zones.search(params[:q]) + + if sort_column && sort_direction + @routing_constraint_zones ||= @q.result(distinct: true).order(sort_column + ' ' + sort_direction) + else + @routing_constraint_zones ||= @q.result(distinct: true).order(:name) + end + @routing_constraint_zones = @routing_constraint_zones.paginate(page: params[:page], per_page: 10) + end private + def sort_column + (Chouette::RoutingConstraintZone.column_names).include?(params[:sort]) ? params[:sort] : 'name' + end + def sort_direction + %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' + end + + def resource + @referential = Referential.find params[:referential_id] + @line = @referential.lines.find params[:line_id] + end + def routing_constraint_zone_params - params.require(:routing_constraint_zone).permit(:name, { stop_point_ids: [] }, :line_id, :route_id, :objectid, :object_version, :creator_id) + params.require(:routing_constraint_zone).permit( + :name, + { stop_point_ids: [] }, + :line_id, + :route_id, + :objectid, + :object_version, + :creator_id + ) end def remove_empty_stop_point diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb index f03228d73..3d43e9fc7 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", "Période de validité englobante", "Période englobante", "Nombre de courses associées", "Journées d'application"].include? k + if ["ID Codif", "Oid", "OiD", "ID Reflex", "Arrêt de départ", "Arrêt d'arrivée", "Période de validité englobante", "Période englobante", "Nombre de courses associées", "Journées d'application", "Arrêts de l'itinéraire", "Arrêts inclus dans l'ITL"].include? k hcont << content_tag(:th, k) else hcont << content_tag(:th, sortable_columns(collection, k)) diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb index 2d329bcc6..151570f20 100644 --- a/app/models/chouette/time_table.rb +++ b/app/models/chouette/time_table.rb @@ -135,6 +135,10 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord [Chouette::TimeTable.maximum(:end_date)].compact.max end + def add_exclude_date(in_out, date) + self.dates.create!({in_out: in_out, date: date}) + end + def actualize self.dates.clear self.periods.clear diff --git a/app/models/chouette/time_table_date.rb b/app/models/chouette/time_table_date.rb index 4624ae88e..b881c9a5d 100644 --- a/app/models/chouette/time_table_date.rb +++ b/app/models/chouette/time_table_date.rb @@ -6,6 +6,8 @@ class Chouette::TimeTableDate < Chouette::ActiveRecord validates_presence_of :date validates_uniqueness_of :date, :scope => :time_table_id + scope :in_dates, -> { where(in_out: true) } + def self.model_name ActiveModel::Name.new Chouette::TimeTableDate, Chouette, "TimeTableDate" end diff --git a/app/models/clean_up.rb b/app/models/clean_up.rb index 457e90b65..a2b150ecc 100644 --- a/app/models/clean_up.rb +++ b/app/models/clean_up.rb @@ -15,25 +15,96 @@ class CleanUp < ActiveRecord::Base end def clean - result = {} - result['time_table_count'] = self.clean_time_tables - result['vehicle_journey_count'] = self.clean_vehicle_journeys - result['journey_pattern_count'] = self.clean_journey_patterns - result + {}.tap do |result| + result['time_table'] = send("destroy_time_tables_#{self.date_type}").try(:count) + result['time_table_date'] = send("destroy_time_tables_dates_#{self.date_type}").try(:count) + result['time_table_period'] = send("destroy_time_tables_periods_#{self.date_type}").try(:count) + self.overlapping_periods.each do |period| + exclude_dates_in_overlapping_period(period) + end + end + end + + def destroy_time_tables_between + time_tables = Chouette::TimeTable.where('end_date <= ? AND start_date >= ?', self.end_date, self.begin_date) + self.destroy_time_tables(time_tables) + end + + def destroy_time_tables_before + time_tables = Chouette::TimeTable.where('end_date <= ?', self.begin_date) + self.destroy_time_tables(time_tables) + end + + def destroy_time_tables_after + time_tables = Chouette::TimeTable.where('start_date >= ?', self.begin_date) + self.destroy_time_tables(time_tables) + end + + def destroy_time_table_dates_before + Chouette::TimeTableDate.in_dates.where('date <= ?', self.begin_date).destroy_all + end + + def destroy_time_tables_dates_after + Chouette::TimeTableDate.in_dates.where('date >= ?', self.begin_date).destroy_all + end + + def destroy_time_tables_dates_between + Chouette::TimeTableDate.in_dates.where('date >= ? AND date <= ?', self.begin_date, self.end_date).destroy_all end - def clean_time_tables - Chouette::TimeTable.validity_out_between?(begin_date, end_date).delete_all + def destroy_time_tables_periods_before + Chouette::TimeTablePeriod.where('period_end <= ?', self.begin_date).destroy_all end - def clean_vehicle_journeys - ids = Chouette::VehicleJourney.includes(:time_tables).where(:time_tables => {id: nil}).pluck(:id) - Chouette::VehicleJourney.where(id: ids).delete_all + def destroy_time_tables_periods_after + Chouette::TimeTablePeriod.where('period_start >= ?', self.begin_date).destroy_all end - def clean_journey_patterns - ids = Chouette::JourneyPattern.includes(:vehicle_journeys).where(:vehicle_journeys => {id: nil}).pluck(:id) - Chouette::JourneyPattern.where(id: ids).delete_all + def destroy_time_tables_periods_between + Chouette::TimeTablePeriod.where('period_start >= ? AND period_end <= ?', self.begin_date, self.end_date).destroy_all + end + + def overlapping_periods + self.end_date = self.begin_date if self.date_type != 'between' + Chouette::TimeTablePeriod.where('(period_start, period_end) OVERLAPS (?, ?)', self.begin_date, self.end_date) + end + + def exclude_dates_in_overlapping_period(period) + days_in_period = period.period_start..period.period_end + day_out = period.time_table.dates.where(in_out: false).map(&:date) + # check if day is greater or less then cleanup date + if date_type != 'between' + operator = date_type == 'after' ? '>' : '<' + to_exclude_days = days_in_period.map do |day| + day if day.public_send(operator, self.begin_date) + end + else + days_in_cleanup_periode = (self.begin_date..self.end_date) + to_exclude_days = days_in_period & days_in_cleanup_periode + end + + to_exclude_days.to_a.compact.each do |day| + # we ensure day is not already an exclude date + if !day_out.include?(day) + self.add_exclude_date(period.time_table, day) + end + end + end + + def add_exclude_date(time_table, day) + day_in = time_table.dates.where(in_out: true).map(&:date) + unless day_in.include?(day) + time_table.add_exclude_date(false, day) + else + time_table.dates.where(date: day).take.update_attribute(:in_out, false) + end + end + + def destroy_time_tables(time_tables) + time_tables.each do |time_table| + time_table.vehicle_journeys.map(&:destroy) + end + time_tables.destroy_all end aasm column: :status do @@ -61,11 +132,11 @@ class CleanUp < ActiveRecord::Base def log_successful message_attributs update_attribute(:ended_at, Time.now) - CleanUpResult.create(clean_up: self, message_key: :successfull, message_attributs: message_attributs) + CleanUpResult.create(destroy_up: self, message_key: :successfull, message_attributs: message_attributs) end def log_failed message_attributs update_attribute(:ended_at, Time.now) - CleanUpResult.create(clean_up: self, message_key: :failed, message_attributs: message_attributs) + CleanUpResult.create(destroy_up: self, message_key: :failed, message_attributs: message_attributs) end end diff --git a/app/views/referential_lines/index.js.slim b/app/views/referential_lines/index.js.slim deleted file mode 100644 index 0165fb077..000000000 --- a/app/views/referential_lines/index.js.slim +++ /dev/null @@ -1 +0,0 @@ -| $('#lines').html("#{escape_javascript(render('lines'))}");
\ No newline at end of file diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index 1e24f0f15..db99381d3 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -1,26 +1,23 @@ / PageHeader = pageheader 'map-marker', @line.name, - 'Lorem ipsum dolor sit amet', + '', t('last_update', time: l(@line.updated_at, format: :short)) do / Below is secundary actions & optional contents .row .col-lg-12.text-right.mb-sm - / = link_to t('lines.actions.show_network'), [@referential, @line.network], class: 'btn btn-primary' - / = link_to t('lines.actions.show_company'), [@referential, @line.company], class: 'btn btn-primary' - = link_to @line.human_attribute_name(:footnotes), referential_line_footnotes_path(@referential, @line), class: 'btn btn-primary' - = link_to Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr), referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-primary disabled' + = link_to t('routing_constraint_zones.index.title'), referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-primary' - if policy(Chouette::Line).create? && @referential.organisation == current_organisation - = link_to t('lines.actions.new'), new_referential_line_path(@referential), class: 'btn btn-primary' + = link_to t('actions.new'), new_referential_line_path(@referential), class: 'btn btn-primary' - if policy(@line).update? - = link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), class: 'btn btn-primary' + = link_to t('actions.edit'), edit_referential_line_path(@referential, @line), class: 'btn btn-primary' - if policy(@line).destroy? = link_to referential_line_path(@referential, @line), method: :delete, data: {confirm: t('lines.actions.destroy_confirm')}, class: 'btn btn-primary' do span.fa.fa-trash - span = t('lines.actions.destroy') + span = t('actions.destroy') - if !@line.hub_restricted? || (@line.hub_restricted? && @line.routes.size < 2) - if policy(Chouette::Route).create? && @referential.organisation == current_organisation diff --git a/app/views/routing_constraint_zones/_filters.html.slim b/app/views/routing_constraint_zones/_filters.html.slim new file mode 100644 index 000000000..18ef40d61 --- /dev/null +++ b/app/views/routing_constraint_zones/_filters.html.slim @@ -0,0 +1,16 @@ += search_form_for @q, url: referential_line_routing_constraint_zones_path(@referential, @line), class: 'form form-filter' do |f| + .ffg-row + .input-group.search_bar + = f.search_field :name_or_objectid_cont, class: 'form-control', placeholder: "Indiquez un nom d'ITL ou un OiD..." + span.input-group-btn + button.btn.btn-default#search-btn type='submit' + span.fa.fa-search + + .ffg-row + .form-group + = f.label 'Itinéraire associé', required: false, class: 'control-label' + = f.input :route_id, as: :select, collection: @line.routing_constraint_zones.pluck(:route_id), label: false, label_method: lambda {|r| @line.routing_constraint_zones.find_by(route_id: r).route_name}, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Indiquez un itinéraire...' }, wrapper_html: { class: 'select2ed'} + + .actions + = link_to 'Effacer', referential_line_routing_constraint_zones_path(@referential, @line), class: 'btn btn-link' + = f.submit 'Filtrer', class: 'btn btn-default' diff --git a/app/views/routing_constraint_zones/_form.html.slim b/app/views/routing_constraint_zones/_form.html.slim index b1c77a44b..082e8f7f8 100644 --- a/app/views/routing_constraint_zones/_form.html.slim +++ b/app/views/routing_constraint_zones/_form.html.slim @@ -1,19 +1,14 @@ -= simple_form_for [@referential, @line, @routing_constraint_zone] do |f| - .row - .col-lg-6.col-sm-12 - = f.input :name - .row - .col-lg-6.col-sm-12 - = f.input :route_id, collection: @line.routes.select { |route| route.stop_points.count > 2 }, include_blank: false - .row - .col-lg-6.col-sm-12 - - stop_points_collection = @routing_constraint_zone.persisted? ? @routing_constraint_zone.route.stop_points : [] - = f.input :stop_point_ids, as: :select, collection: stop_points_collection, selected: @routing_constraint_zone.stop_point_ids, label: Chouette::StopPoint.model_name.human.pluralize.capitalize, label_method: :name, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Sélection des arrêts sur séquence d\'arrêts', 'multiple': 'multiple', style: 'width: 100%' } += simple_form_for [@referential, @line, @routing_constraint_zone], html: {class: 'form-horizontal', id: 'itl_form'}, wrapper: :horizontal_form do |form| .row - .col-lg-12.text-right - = link_to 'Annuler', :back, class: 'btn btn-link' - = f.button :submit, class: 'btn btn-danger' + .col-lg-12 + = form.input :name + + = form.input :route_id, collection: @line.routes.select { |route| route.stop_points.count > 2 }, include_blank: false + + - stop_points_collection = @routing_constraint_zone.persisted? ? @routing_constraint_zone.route.stop_points : [] + = form.input :stop_point_ids, as: :select, collection: stop_points_collection, selected: @routing_constraint_zone.stop_point_ids, label: Chouette::StopPoint.model_name.human.pluralize.capitalize, label_method: :name, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'Sélection des arrêts sur séquence d\'arrêts', 'multiple': 'multiple', style: 'width: 100%' } + = form.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'itl_form' -= hidden_field_tag 'stop_point_ids', @routing_constraint_zone.stop_point_ids.to_s, id: 'stop_point_ids' + = hidden_field_tag 'stop_point_ids', @routing_constraint_zone.stop_point_ids.to_s, id: 'stop_point_ids' diff --git a/app/views/routing_constraint_zones/edit.html.slim b/app/views/routing_constraint_zones/edit.html.slim index fcb0d08a8..d81a347e0 100644 --- a/app/views/routing_constraint_zones/edit.html.slim +++ b/app/views/routing_constraint_zones/edit.html.slim @@ -1,5 +1,12 @@ -= title_tag t('.title', routing_constraint_zone: @routing_constraint_zone.name) +/ PageHeader += pageheader 'map-marker', + t('.title'), + '', + t('last_update', time: l(@routing_constraint_zone.updated_at, format: :short)) -.row - .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2 - == render 'form' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + == render 'form' diff --git a/app/views/routing_constraint_zones/index.html.slim b/app/views/routing_constraint_zones/index.html.slim index 620b0f7db..248efedb4 100644 --- a/app/views/routing_constraint_zones/index.html.slim +++ b/app/views/routing_constraint_zones/index.html.slim @@ -1,11 +1,30 @@ -= title_tag Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr) +/ PageHeader += pageheader 'map-marker', + t('routing_constraint_zones.index.title'), + '', + '', + ((policy(Chouette::RoutingConstraintZone).create? && @referential.organisation == current_organisation) ? link_to(t('actions.new'), new_referential_line_routing_constraint_zone_path(@referential, @line), class: 'btn btn-primary') : '') -- if policy(Chouette::RoutingConstraintZone).create? && @referential.organisation == current_organisation - = link_to t('routing_constraint_zones.actions.new'), new_referential_line_routing_constraint_zone_path(@referential, @line) +/ PageContent +.page_content + .container-fluid + - if params[:q].present? or @routing_constraint_zones.any? + .row + .col-lg-12 + = render 'filters' -- if @routing_constraint_zones.any? - = table_builder @routing_constraint_zones, - { objectid: 'objectid', name: 'name', route: 'route_name', stop_points_count: 'stop_points_count' }, - [:show, :edit, :delete], - [], - 'table table-bordered' + - if @routing_constraint_zones.any? + .row + .col-lg-12 + = table_builder @routing_constraint_zones, + { 'Oid' => Proc.new { |n| n.try(:objectid).try(:local_id) }, + :name => 'name', :stop_points_count => 'stop_points_count', + :route => 'route_name' }, + [:show, :edit, :delete], + [], + 'table has-filter has-search' + + - unless @routing_constraint_zones.any? + .row.mt-xs + .col-lg-12 + = replacement_msg t('routing_constraint_zones.search_no_results') diff --git a/app/views/routing_constraint_zones/new.html.slim b/app/views/routing_constraint_zones/new.html.slim index fcb0d08a8..f6ae62825 100644 --- a/app/views/routing_constraint_zones/new.html.slim +++ b/app/views/routing_constraint_zones/new.html.slim @@ -1,5 +1,10 @@ -= title_tag t('.title', routing_constraint_zone: @routing_constraint_zone.name) +/ PageHeader += pageheader 'map-marker', + t('.title') -.row - .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2 - == render 'form' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 + == render 'form' diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim index 351784ecc..f0c244387 100644 --- a/app/views/routing_constraint_zones/show.html.slim +++ b/app/views/routing_constraint_zones/show.html.slim @@ -1,17 +1,35 @@ -= title_tag @routing_constraint_zone.name +/ PageHeader += pageheader 'map-marker', + @routing_constraint_zone.name, + '', + t('last_update', time: l(@routing_constraint_zone.updated_at, format: :short)) do -p - label => "#{@routing_constraint_zone.human_attribute_name(:name)} : " - = @routing_constraint_zone.name + / Below is secundary actions & optional contents + .row + .col-lg-12.text-right.mb-sm + - if policy(@routing_constraint_zone).update? + = link_to t('actions.edit'), edit_referential_line_routing_constraint_zone_path(@referential, @line, @routing_constraint_zone), class: 'btn btn-primary' -p - label => "#{Chouette::Route.model_name.human.capitalize} : " - = link_to @routing_constraint_zone.route.name, referential_line_route_path(@referential, @line, @routing_constraint_zone.route) + - if policy(@routing_constraint_zone).destroy? + = link_to referential_line_routing_constraint_zone_path(@referential, @line, @routing_constraint_zone), method: :delete, data: {confirm: t('routing_constraint_zones.actions.destroy_confirm')}, class: 'btn btn-primary' do + span.fa.fa-trash + span = t('actions.destroy') -p - label => "#{Chouette::StopPoint.model_name.human.pluralize.capitalize} : " - br - - @routing_constraint_zone.stop_points.each do |stop_point| - = link_to stop_point.name, referential_stop_area_path(@referential, stop_point.stop_area) - br +/ PageContent +.page_content + .container-fluid + .row + .col-lg-6.col-md-6.col-sm-12.col-xs-12 + = definition_list t('metadatas'), + { @routing_constraint_zone.human_attribute_name(:name) => @routing_constraint_zone.try(:name), + @routing_constraint_zone.human_attribute_name(:route) => link_to(@routing_constraint_zone.try(:route_name), [@referential, @line, @routing_constraint_zone.route]), + @routing_constraint_zone.human_attribute_name(:line) => link_to(@line.name, [@referential, @line])} + .row + .col-lg-12 + = table_builder @routing_constraint_zone.route.stop_points, + { "Arrêts de l'itinéraire" => 'name', + "Arrêts inclus dans l'ITL" => Proc.new{ |rsp| (@routing_constraint_zone.stop_points.collect{|c| c.name}.include? rsp.name) ? 'Oui' : 'Non' } }, + [], + [], + 'table has-stoppoints' diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim index c17f96c85..402b09b98 100644 --- a/app/views/time_tables/index.html.slim +++ b/app/views/time_tables/index.html.slim @@ -20,7 +20,7 @@ "Nombre de courses associées" => Proc.new{ |tt| tt.vehicle_journeys.count }, "Journées d'application" => Proc.new{ |tt| (%w(monday tuesday wednesday thursday friday saturday sunday).collect{|d| tt.send(d) ? t("calendars.days.#{d}") : '' }).reject{|a| a.empty?}.join(', ').html_safe }, :calendar => Proc.new{ |tt| tt.calendar ? tt.calendar.try(:name) : '-' }, :updated_at => Proc.new {|tt| l(tt.updated_at, format: :short)} }, - [:show, :edit, :duplicate, :delete], + [:show, :edit, :duplicate, :actualize, :delete], [], 'table has-search' diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim index 1c5984a7d..2e71ebb9e 100644 --- a/app/views/time_tables/show.html.slim +++ b/app/views/time_tables/show.html.slim @@ -4,6 +4,7 @@ = pageheader 'map-marker', @time_table.comment, '', + t('last_update', time: l(@time_table.updated_at, format: :short)), (policy(@time_table).edit? ? link_to(t('actions.edit'), edit_referential_time_table_path(@referential, @time_table), class: 'btn btn-default') : '') / Below is secundary actions & optional contents (filters, ...) |
