diff options
Diffstat (limited to 'app')
88 files changed, 376 insertions, 190 deletions
diff --git a/app/assets/stylesheets/components/_forms.sass b/app/assets/stylesheets/components/_forms.sass index 5143d2ba4..b7f720963 100644 --- a/app/assets/stylesheets/components/_forms.sass +++ b/app/assets/stylesheets/components/_forms.sass @@ -462,6 +462,20 @@ table, .table > .form-group.select2ed width: 300px + &.name-filter + .checkbox_list + .form-group + padding: 10px + width: 100px + &.to + width: 20px + color: $grey + text-align: center + input + width: 100% + & + .form-group + padding-left: 0px + > .actions position: absolute right: 15px diff --git a/app/controllers/journey_patterns_collections_controller.rb b/app/controllers/journey_patterns_collections_controller.rb index 4c698bb89..b37ac6cd0 100644 --- a/app/controllers/journey_patterns_collections_controller.rb +++ b/app/controllers/journey_patterns_collections_controller.rb @@ -36,12 +36,14 @@ class JourneyPatternsCollectionsController < ChouetteController :id => sp.stop_area.id, :route_id => sp.try(:route_id), :object_id => sp.try(:objectid), + :stop_area_object_id => sp.stop_area.try(:objectid), :position => sp.try(:position), :for_boarding => sp.try(:for_boarding), :for_alighting => sp.try(:for_alighting), :name => sp.stop_area.try(:name), :zip_code => sp.stop_area.try(:zip_code), :city_name => sp.stop_area.try(:city_name), + :country_name => sp.stop_area.try(:country_name), :comment => sp.stop_area.try(:comment), :area_type => sp.stop_area.try(:area_type), :registration_number => sp.stop_area.try(:registration_number), diff --git a/app/controllers/merges_controller.rb b/app/controllers/merges_controller.rb index 26e2c2e3c..a95768139 100644 --- a/app/controllers/merges_controller.rb +++ b/app/controllers/merges_controller.rb @@ -15,6 +15,12 @@ class MergesController < ChouetteController Rails.logger.debug "Mergeables: #{@mergeable_referentials.inspect}" end + def build_resource + super.tap do |merge| + merge.creator = current_user.name + end + end + # def build_resource # @import ||= WorkbenchImport.new(*resource_params) do |import| # import.workbench = parent diff --git a/app/controllers/referential_vehicle_journeys_controller.rb b/app/controllers/referential_vehicle_journeys_controller.rb index 8445fc423..217fb9629 100644 --- a/app/controllers/referential_vehicle_journeys_controller.rb +++ b/app/controllers/referential_vehicle_journeys_controller.rb @@ -11,7 +11,7 @@ class ReferentialVehicleJourneysController < ChouetteController def collection @q ||= end_of_association_chain.ransack(params[:q]) - @vehicle_journeys ||= @q.result.includes(:vehicle_journey_at_stops).paginate page: params[:page], per_page: 10 + @vehicle_journeys ||= @q.result.order(:published_journey_name).includes(:vehicle_journey_at_stops).paginate page: params[:page], per_page: 10 @all_companies = Chouette::Company.where("id IN (#{@referential.vehicle_journeys.select(:company_id).to_sql})").distinct end diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb index 431d15f57..8a0c41cc2 100644 --- a/app/controllers/vehicle_journeys_controller.rb +++ b/app/controllers/vehicle_journeys_controller.rb @@ -70,6 +70,7 @@ class VehicleJourneysController < ChouetteController :latitude => sp.stop_area.try(:latitude), :long_lat_type => sp.stop_area.try(:long_lat_type), :country_code => sp.stop_area.try(:country_code), + :country_name => sp.stop_area.try(:country_name), :street_name => sp.stop_area.try(:street_name) } end diff --git a/app/decorators/import_decorator.rb b/app/decorators/import_decorator.rb index e748f830d..8b00234d2 100644 --- a/app/decorators/import_decorator.rb +++ b/app/decorators/import_decorator.rb @@ -16,14 +16,6 @@ class ImportDecorator < Draper::Decorator links = [] links << Link.new( - content: h.t('imports.actions.show'), - href: h.workbench_import_path( - context[:workbench], - object - ) - ) - - links << Link.new( content: h.t('imports.actions.download'), href: object.file.url ) diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb index df19113db..6600a03f7 100644 --- a/app/helpers/newapplication_helper.rb +++ b/app/helpers/newapplication_helper.rb @@ -1,3 +1,4 @@ +# coding: utf-8 module NewapplicationHelper # Table Builder @@ -147,7 +148,7 @@ module NewapplicationHelper content_tag :li, link_to(t("actions.#{action}"), polymorph_url) end elsif action == :archive - unless item.archived? + unless item.referential_read_only? content_tag :li, link_to(t("actions.#{action}"), polymorph_url, method: :put) end elsif action == :unarchive diff --git a/app/javascript/helpers/stop_area_header_manager.js b/app/javascript/helpers/stop_area_header_manager.js new file mode 100644 index 000000000..54d957be9 --- /dev/null +++ b/app/javascript/helpers/stop_area_header_manager.js @@ -0,0 +1,42 @@ +import React, { Component } from 'react' + +export default class StopAreaHeaderManager { + constructor(ids_list, stopPointsList, features) { + this.ids_list = ids_list + this.stopPointsList = stopPointsList + this.features = features + } + + hasFeature(key) { + return this.features[key] + } + + stopPointHeader(object_id) { + let index = this.ids_list.indexOf(object_id) + let sp = this.stopPointsList[index] + let showHeadline = this.showHeader(object_id) + return ( + <div + className={(showHeadline) ? 'headlined' : ''} + data-headline={showHeadline} + title={sp.city_name + ' (' + sp.zip_code +')'} + > + <span><span>{sp.name}</span></span> + </div> + ) + } + + showHeader(object_id) { + let showHeadline = false + let headline = "" + let attribute_to_check = this.hasFeature('long_distance_routes') ? "country_code" : "city_name" + let index = this.ids_list.indexOf(object_id) + let sp = this.stopPointsList[index] + let previousBreakpoint = this.stopPointsList[index - 1] + if(index == 0 || (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){ + showHeadline = true + headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name + } + return showHeadline ? headline : "" + } +} diff --git a/app/javascript/journey_patterns/components/ConfirmModal.js b/app/javascript/journey_patterns/components/ConfirmModal.js index 2cc1bef44..ccd0a9384 100644 --- a/app/javascript/journey_patterns/components/ConfirmModal.js +++ b/app/javascript/journey_patterns/components/ConfirmModal.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, journeyPatterns}) { return ( diff --git a/app/javascript/journey_patterns/components/CreateModal.js b/app/javascript/journey_patterns/components/CreateModal.js index d0eff6e57..a6c1b608a 100644 --- a/app/javascript/journey_patterns/components/CreateModal.js +++ b/app/javascript/journey_patterns/components/CreateModal.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class CreateModal extends Component { diff --git a/app/javascript/journey_patterns/components/EditModal.js b/app/javascript/journey_patterns/components/EditModal.js index 7a5d24fba..c960cb41c 100644 --- a/app/javascript/journey_patterns/components/EditModal.js +++ b/app/javascript/journey_patterns/components/EditModal.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class EditModal extends Component { diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index 69eff978e..2ae9f5552 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class JourneyPattern extends Component{ @@ -31,14 +32,8 @@ export default class JourneyPattern extends Component{ return this.props.status.features[key] } - cityNameChecker(sp) { - let bool = false - - if(sp.city_name != this.previousCity){ - bool = true - this.previousCity = sp.city_name - } - return bool + cityNameChecker(sp, i) { + return this.props.journeyPatterns.showHeader(sp.object_id + "-" + i) } spNode(sp, headlined){ @@ -154,7 +149,7 @@ export default class JourneyPattern extends Component{ if(stopPoint.checked){ this.previousSpId = stopPoint.id } - let headlined = this.cityNameChecker(stopPoint) + let headlined = this.cityNameChecker(stopPoint, i) return ( <div key={i} className={(stopPoint.checked ? 'activated' : 'deactivated') + (this.props.editMode ? ' edit-mode' : '')}> <div className={'td' + (headlined ? ' with-headline' : '')}> @@ -189,5 +184,6 @@ JourneyPattern.propTypes = { index: PropTypes.number, onCheckboxChange: PropTypes.func.isRequired, onOpenEditModal: PropTypes.func.isRequired, - onDeleteJourneyPattern: PropTypes.func.isRequired + onDeleteJourneyPattern: PropTypes.func.isRequired, + journeyPatterns: PropTypes.object.isRequired } diff --git a/app/javascript/journey_patterns/components/JourneyPatterns.js b/app/javascript/journey_patterns/components/JourneyPatterns.js index 1e391b0c2..31727fefc 100644 --- a/app/javascript/journey_patterns/components/JourneyPatterns.js +++ b/app/javascript/journey_patterns/components/JourneyPatterns.js @@ -1,16 +1,23 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import _ from 'lodash' import JourneyPattern from './JourneyPattern' - +import StopAreaHeaderManager from '../../helpers/stop_area_header_manager' export default class JourneyPatterns extends Component { constructor(props){ super(props) - this.previousCity = undefined + this.headerManager = new StopAreaHeaderManager( + _.map(this.props.stopPointsList, (sp, i)=>{return sp.stop_area_object_id + "-" + i}), + this.props.stopPointsList, + this.props.status.features + ) } + componentDidMount() { this.props.onLoadFirstPage() } + componentDidUpdate(prevProps, prevState) { if(this.props.status.isFetching == false){ $('.table-2entries').each(function() { @@ -54,25 +61,12 @@ export default class JourneyPatterns extends Component { } } - hasFeature(key) { - return this.props.status.features[key] + showHeader(object_id) { + return this.headerManager.showHeader(object_id) } - cityNameChecker(sp) { - let bool = false - if(sp.city_name != this.previousCity){ - bool = true - this.previousCity = sp.city_name - } - return ( - <div - className={(bool) ? 'headlined' : ''} - data-headline={(bool) ? sp.city_name : ''} - title={sp.city_name + ' (' + sp.zip_code +')'} - > - <span><span>{sp.name}</span></span> - </div> - ) + hasFeature(key) { + return this.props.status.features[key] } render() { @@ -120,7 +114,7 @@ export default class JourneyPatterns extends Component { {this.props.stopPointsList.map((sp, i) =>{ return ( <div key={i} className={'td' + (this.hasFeature('costs_in_journey_patterns') ? ' with-costs' : '')}> - {this.cityNameChecker(sp)} + {this.headerManager.stopPointHeader(sp.stop_area_object_id + "-" + i)} </div> ) })} @@ -138,6 +132,7 @@ export default class JourneyPatterns extends Component { onUpdateJourneyPatternCosts={(costs) => this.props.onUpdateJourneyPatternCosts(index, costs)} status= {this.props.status} editMode= {this.props.editMode} + journeyPatterns= {this} /> )} </div> diff --git a/app/javascript/journey_patterns/components/Navigate.js b/app/javascript/journey_patterns/components/Navigate.js index f2fdd668f..78f324a7d 100644 --- a/app/javascript/journey_patterns/components/Navigate.js +++ b/app/javascript/journey_patterns/components/Navigate.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default function Navigate({ dispatch, journeyPatterns, pagination, status }) { diff --git a/app/javascript/journey_patterns/components/SaveJourneyPattern.js b/app/javascript/journey_patterns/components/SaveJourneyPattern.js index d071fa542..7e4492e0e 100644 --- a/app/javascript/journey_patterns/components/SaveJourneyPattern.js +++ b/app/javascript/journey_patterns/components/SaveJourneyPattern.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class SaveJourneyPattern extends Component { diff --git a/app/javascript/packs/routes/edit.js b/app/javascript/packs/routes/edit.js index d6ceed60f..b787bec97 100644 --- a/app/javascript/packs/routes/edit.js +++ b/app/javascript/packs/routes/edit.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import { render } from 'react-dom' import { Provider } from 'react-redux' import { createStore } from 'redux' @@ -12,7 +14,7 @@ datas = JSON.parse(decodeURIComponent(datas)) // logger, DO NOT REMOVE var applyMiddleware = require('redux').applyMiddleware -var createLogger = require('redux-logger') +import {createLogger} from 'redux-logger'; var thunkMiddleware = require('redux-thunk').default var promise = require('redux-promise') diff --git a/app/javascript/routes/components/App.js b/app/javascript/routes/components/App.js index 0f5786407..26e69bf53 100644 --- a/app/javascript/routes/components/App.js +++ b/app/javascript/routes/components/App.js @@ -1,4 +1,5 @@ -import React, { Component, PropTypes } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import AddStopPoint from '../containers/AddStopPoint' import VisibleStopPoints from'../containers/VisibleStopPoints' import clone from '../../helpers/clone' @@ -16,8 +17,8 @@ export default class App extends Component { <VisibleStopPoints /> <AddStopPoint /> </div> - ) - } + ) + } } App.childContextTypes = { diff --git a/app/javascript/routes/components/BSelect2.js b/app/javascript/routes/components/BSelect2.js index 0d8d7787f..158deaa17 100644 --- a/app/javascript/routes/components/BSelect2.js +++ b/app/javascript/routes/components/BSelect2.js @@ -1,6 +1,7 @@ import _ from'lodash' -import React, { Component, PropTypes } from 'react' -import Select2 from 'react-select2' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Select2 from 'react-select2-wrapper' // get JSON full path diff --git a/app/javascript/routes/components/OlMap.js b/app/javascript/routes/components/OlMap.js index 2c01dfa7f..056bddbcb 100644 --- a/app/javascript/routes/components/OlMap.js +++ b/app/javascript/routes/components/OlMap.js @@ -1,5 +1,6 @@ import _ from 'lodash' -import React, { Component, PropTypes } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' export default class OlMap extends Component{ constructor(props, context){ diff --git a/app/javascript/routes/components/StopPoint.js b/app/javascript/routes/components/StopPoint.js index 606121f99..2d47e802b 100644 --- a/app/javascript/routes/components/StopPoint.js +++ b/app/javascript/routes/components/StopPoint.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import BSelect2 from './BSelect2' import OlMap from './OlMap' diff --git a/app/javascript/routes/components/StopPointList.js b/app/javascript/routes/components/StopPointList.js index 68af16f57..43a027084 100644 --- a/app/javascript/routes/components/StopPointList.js +++ b/app/javascript/routes/components/StopPointList.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import StopPoint from './StopPoint' export default function StopPointList({ stopPoints, onDeleteClick, onMoveUpClick, onMoveDownClick, onChange, onSelectChange, onToggleMap, onToggleEdit, onSelectMarker, onUnselectMarker, onUpdateViaOlMap }, {I18n}) { diff --git a/app/javascript/time_tables/components/ConfirmModal.js b/app/javascript/time_tables/components/ConfirmModal.js index d89170ee7..845e7ed1b 100644 --- a/app/javascript/time_tables/components/ConfirmModal.js +++ b/app/javascript/time_tables/components/ConfirmModal.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}, {I18n}) { return ( diff --git a/app/javascript/time_tables/components/ErrorModal.js b/app/javascript/time_tables/components/ErrorModal.js index e810f49ab..543177e54 100644 --- a/app/javascript/time_tables/components/ErrorModal.js +++ b/app/javascript/time_tables/components/ErrorModal.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import actions from '../actions' export default function ErrorModal({dispatch, modal, onModalClose}, {I18n}) { diff --git a/app/javascript/time_tables/components/ExceptionsInDay.js b/app/javascript/time_tables/components/ExceptionsInDay.js index 3335ee89d..f5ed625be 100644 --- a/app/javascript/time_tables/components/ExceptionsInDay.js +++ b/app/javascript/time_tables/components/ExceptionsInDay.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class ExceptionsInDay extends Component { diff --git a/app/javascript/time_tables/components/Metas.js b/app/javascript/time_tables/components/Metas.js index 7098d2b82..4170ba493 100644 --- a/app/javascript/time_tables/components/Metas.js +++ b/app/javascript/time_tables/components/Metas.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import actions from '../actions' import TagsSelect2 from './TagsSelect2' diff --git a/app/javascript/time_tables/components/Navigate.js b/app/javascript/time_tables/components/Navigate.js index 7307d819b..64f05cb41 100644 --- a/app/javascript/time_tables/components/Navigate.js +++ b/app/javascript/time_tables/components/Navigate.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import map from 'lodash/map' import actions from '../actions' diff --git a/app/javascript/time_tables/components/PeriodForm.js b/app/javascript/time_tables/components/PeriodForm.js index d9f1d3437..085654a88 100644 --- a/app/javascript/time_tables/components/PeriodForm.js +++ b/app/javascript/time_tables/components/PeriodForm.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import filter from 'lodash/filter' let monthsArray = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'] diff --git a/app/javascript/time_tables/components/PeriodManager.js b/app/javascript/time_tables/components/PeriodManager.js index 9922ce2c4..6b817fe73 100644 --- a/app/javascript/time_tables/components/PeriodManager.js +++ b/app/javascript/time_tables/components/PeriodManager.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class PeriodManager extends Component { diff --git a/app/javascript/time_tables/components/PeriodsInDay.js b/app/javascript/time_tables/components/PeriodsInDay.js index 888537579..1aed5c969 100644 --- a/app/javascript/time_tables/components/PeriodsInDay.js +++ b/app/javascript/time_tables/components/PeriodsInDay.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import PeriodManager from './PeriodManager' export default class PeriodsInDay extends Component { diff --git a/app/javascript/time_tables/components/SaveTimetable.js b/app/javascript/time_tables/components/SaveTimetable.js index d5a57bd1c..704590abd 100644 --- a/app/javascript/time_tables/components/SaveTimetable.js +++ b/app/javascript/time_tables/components/SaveTimetable.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class SaveTimetable extends Component{ diff --git a/app/javascript/time_tables/components/TagsSelect2.js b/app/javascript/time_tables/components/TagsSelect2.js index 70a748a04..dc3739d58 100644 --- a/app/javascript/time_tables/components/TagsSelect2.js +++ b/app/javascript/time_tables/components/TagsSelect2.js @@ -1,9 +1,10 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import mapKeys from 'lodash/mapKeys' import map from 'lodash/map' import filter from 'lodash/filter' import assign from 'lodash/assign' -import Select2 from 'react-select2' +import Select2 from 'react-select2-wrapper' // get JSON full path let origin = window.location.origin diff --git a/app/javascript/time_tables/components/TimeTableDay.js b/app/javascript/time_tables/components/TimeTableDay.js index 165c7b848..498e7d0cd 100644 --- a/app/javascript/time_tables/components/TimeTableDay.js +++ b/app/javascript/time_tables/components/TimeTableDay.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' export default class TimeTableDay extends Component { constructor(props) { diff --git a/app/javascript/time_tables/components/Timetable.js b/app/javascript/time_tables/components/Timetable.js index df6e6016b..c44f2a134 100644 --- a/app/javascript/time_tables/components/Timetable.js +++ b/app/javascript/time_tables/components/Timetable.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' import TimeTableDay from './TimeTableDay' import PeriodsInDay from './PeriodsInDay' diff --git a/app/javascript/time_tables/containers/App.js b/app/javascript/time_tables/containers/App.js index 235dccb50..5963f8f1d 100644 --- a/app/javascript/time_tables/containers/App.js +++ b/app/javascript/time_tables/containers/App.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import { connect } from'react-redux' import actions from '../actions' import Metas from './Metas' diff --git a/app/javascript/vehicle_journeys/components/App.js b/app/javascript/vehicle_journeys/components/App.js index 8e5f7aa9d..44559c7c6 100644 --- a/app/javascript/vehicle_journeys/components/App.js +++ b/app/javascript/vehicle_journeys/components/App.js @@ -35,4 +35,4 @@ export default function App() { <ConfirmModal /> </div> ) -}
\ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/components/ConfirmModal.js b/app/javascript/vehicle_journeys/components/ConfirmModal.js index df3c96c48..3bfc852fb 100644 --- a/app/javascript/vehicle_journeys/components/ConfirmModal.js +++ b/app/javascript/vehicle_journeys/components/ConfirmModal.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, vehicleJourneys}) { return ( diff --git a/app/javascript/vehicle_journeys/components/Filters.js b/app/javascript/vehicle_journeys/components/Filters.js index 125c27311..2bd912e3e 100644 --- a/app/javascript/vehicle_journeys/components/Filters.js +++ b/app/javascript/vehicle_journeys/components/Filters.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import MissionSelect2 from'./tools/select2s/MissionSelect2' import VJSelect2 from'./tools/select2s/VJSelect2' import TimetableSelect2 from'./tools/select2s/TimetableSelect2' diff --git a/app/javascript/vehicle_journeys/components/Navigate.js b/app/javascript/vehicle_journeys/components/Navigate.js index 7493b705b..0158b8392 100644 --- a/app/javascript/vehicle_journeys/components/Navigate.js +++ b/app/javascript/vehicle_journeys/components/Navigate.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from'../actions' export default function Navigate({ dispatch, vehicleJourneys, pagination, status, filters}) { diff --git a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js index 6dba5618c..c5161b917 100644 --- a/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/SaveVehicleJourneys.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class SaveVehicleJourneys extends Component{ diff --git a/app/javascript/vehicle_journeys/components/ToggleArrivals.js b/app/javascript/vehicle_journeys/components/ToggleArrivals.js index e26ceec3a..9e7089be5 100644 --- a/app/javascript/vehicle_journeys/components/ToggleArrivals.js +++ b/app/javascript/vehicle_journeys/components/ToggleArrivals.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + export default function ToggleArrivals({filters, onToggleArrivals}) { return ( @@ -24,4 +26,4 @@ export default function ToggleArrivals({filters, onToggleArrivals}) { ToggleArrivals.propTypes = { filters : PropTypes.object.isRequired, onToggleArrivals: PropTypes.func.isRequired -}
\ No newline at end of file +} diff --git a/app/javascript/vehicle_journeys/components/Tools.js b/app/javascript/vehicle_journeys/components/Tools.js index d6e04f00e..ee02e5a68 100644 --- a/app/javascript/vehicle_journeys/components/Tools.js +++ b/app/javascript/vehicle_journeys/components/Tools.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' import AddVehicleJourney from '../containers/tools/AddVehicleJourney' import DeleteVehicleJourneys from '../containers/tools/DeleteVehicleJourneys' diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 8344a951a..d240757a3 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../actions' export default class VehicleJourney extends Component { @@ -8,13 +9,7 @@ export default class VehicleJourney extends Component { } cityNameChecker(sp) { - let bool = false - if(sp.stop_area_cityname != this.previousCity){ - bool = true - this.previousCity = sp.stop_area_cityname - } - - return bool + return this.props.vehicleJourneys.showHeader(sp.stop_point_objectid) } hasFeature(key) { @@ -171,5 +166,6 @@ VehicleJourney.propTypes = { filters: PropTypes.object.isRequired, index: PropTypes.number.isRequired, onUpdateTime: PropTypes.func.isRequired, - onSelectVehicleJourney: PropTypes.func.isRequired + onSelectVehicleJourney: PropTypes.func.isRequired, + vehicleJourneys: PropTypes.object.isRequired, } diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index 0cac0344c..b188962c2 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -1,13 +1,19 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import _ from 'lodash' import VehicleJourney from './VehicleJourney' - +import StopAreaHeaderManager from '../../helpers/stop_area_header_manager' export default class VehicleJourneys extends Component { constructor(props){ super(props) - this.previousCity = undefined + this.headerManager = new StopAreaHeaderManager( + _.map(this.props.stopPointsList, (sp)=>{return sp.object_id}), + this.props.stopPointsList, + this.props.filters.features + ) } + componentDidMount() { this.props.onLoadFirstPage(this.props.filters) } @@ -16,6 +22,10 @@ export default class VehicleJourneys extends Component { return this.props.filters.features[key] } + showHeader(object_id) { + return this.headerManager.showHeader(object_id) + } + componentDidUpdate(prevProps, prevState) { if(this.props.status.isFetching == false){ $('.table-2entries').each(function() { @@ -59,25 +69,8 @@ export default class VehicleJourneys extends Component { } } - cityNameChecker(sp) { - let bool = false - if(sp.city_name != this.previousCity){ - bool = true - this.previousCity = sp.city_name - } - return ( - <div - className={(bool) ? 'headlined' : ''} - data-headline={(bool) ? sp.city_name : ''} - title={sp.city_name + ' (' + sp.zip_code +')'} - > - <span><span>{sp.name}</span></span> - </div> - ) - } - render() { - this.previousCity = undefined + this.previousBreakpoint = undefined if(this.props.status.isFetching == true) { return ( @@ -124,7 +117,7 @@ export default class VehicleJourneys extends Component { {this.props.stopPointsList.map((sp, i) =>{ return ( <div key={i} className='td'> - {this.cityNameChecker(sp)} + {this.headerManager.stopPointHeader(sp.object_id)} </div> ) })} @@ -142,6 +135,7 @@ export default class VehicleJourneys extends Component { features={this.props.features} onUpdateTime={this.props.onUpdateTime} onSelectVehicleJourney={this.props.onSelectVehicleJourney} + vehicleJourneys={this} /> )} </div> diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js index c402dcd84..4601d1690 100644 --- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js +++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import MissionSelect2 from './select2s/MissionSelect2' import CompanySelect2 from './select2s/CompanySelect2' diff --git a/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js b/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js index fc13ae964..4815003d3 100644 --- a/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/tools/DeleteVehicleJourneys.js @@ -1,4 +1,6 @@ -import React, { PropTypes } from 'react' +import React from 'react' +import PropTypes from 'prop-types' + import actions from '../../actions' export default function DeleteVehicleJourneys({onDeleteVehicleJourneys, vehicleJourneys, disabled}) { diff --git a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js index 8083defb9..102a87d85 100644 --- a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import _ from 'lodash' diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index dc10b641a..08d74baba 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import CompanySelect2 from './select2s/CompanySelect2' diff --git a/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js index de97bc403..880542216 100644 --- a/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import _ from 'lodash' diff --git a/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js index d61c7a34b..ce9a4cde9 100644 --- a/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/PurchaseWindowsEditVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import TimetableSelect2 from './select2s/TimetableSelect2' diff --git a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js index a54e40502..6574bfa2d 100644 --- a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' export default class ShiftVehicleJourney extends Component { diff --git a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js index fdaa5aeed..e2fcd27d5 100644 --- a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react' +import React, { Component } from 'react' +import PropTypes from 'prop-types' import actions from '../../actions' import TimetableSelect2 from './select2s/TimetableSelect2' diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js index 79ba8f094..28a092945 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js @@ -1,6 +1,7 @@ import _ from 'lodash' -import React, { PropTypes, Component } from 'react' -import Select2 from 'react-select2' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Select2 from 'react-select2-wrapper' import actions from '../../../actions' // get JSON full path diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js index 8ad60daa3..7ab85a1ea 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js @@ -1,6 +1,7 @@ import _ from 'lodash' -import React, { PropTypes, Component } from 'react' -import Select2 from 'react-select2' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Select2 from 'react-select2-wrapper' import actions from '../../../actions' // get JSON full path diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js index eb8651be2..0339455ca 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js @@ -1,6 +1,7 @@ import _ from 'lodash' -import React, { PropTypes, Component } from 'react' -import Select2 from 'react-select2' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Select2 from 'react-select2-wrapper' import actions from '../../../actions' // get JSON full path diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js index b063abeca..ccb4c9595 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js @@ -1,6 +1,7 @@ import _ from 'lodash' -import React, { PropTypes, Component } from 'react' -import Select2 from 'react-select2' +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Select2 from 'react-select2-wrapper' import actions from '../../../actions' // get JSON full path diff --git a/app/jobs/mailer_job.rb b/app/jobs/mailer_job.rb index 3918745b8..eb3250a27 100644 --- a/app/jobs/mailer_job.rb +++ b/app/jobs/mailer_job.rb @@ -1,6 +1,9 @@ class MailerJob < ActiveJob::Base # No need to specify queue it's already used mailers queue + # This job will be retried, unlike Sidekiq jobs which are configured + # to not retry + def perform klass, action, params klass.constantize.public_send(action, *params).deliver_later end diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index 4f1359ff8..52602be9f 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -49,8 +49,10 @@ module Chouette 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)) + + parent_area_type = Chouette::AreaType.find(self.parent.area_type) + if Chouette::AreaType.find(self.area_type) >= parent_area_type + errors.add(:parent_id, I18n.t('stop_areas.errors.parent_area_type', area_type: parent_area_type.label)) end end @@ -355,5 +357,12 @@ module Chouette def deactivate! update_attribute :deleted_at, Time.now end + + def country_name + return unless country_code + + country = ISO3166::Country[country_code] + country.translations[I18n.locale.to_s] || country.name + end end end diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb index d4dc82a56..11da77948 100644 --- a/app/models/chouette/vehicle_journey.rb +++ b/app/models/chouette/vehicle_journey.rb @@ -243,6 +243,14 @@ module Chouette end end + def custom_fields + CustomField.where(resource_type: self.class.name.split("::").last) + end + + def custom_field_value key + (custom_field_values || {})[key.to_s] + end + def self.matrix(vehicle_journeys) Hash[*VehicleJourneyAtStop.where(vehicle_journey_id: vehicle_journeys.pluck(:id)).map do |vjas| [ "#{vjas.vehicle_journey_id}-#{vjas.stop_point_id}", vjas] diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb new file mode 100644 index 000000000..e8e76c6b5 --- /dev/null +++ b/app/models/custom_field.rb @@ -0,0 +1,7 @@ +class CustomField < ActiveRecord::Base + + extend Enumerize + enumerize :field_type, in: %i{list} + + validates :name, uniqueness: {scope: :resource_type} +end diff --git a/app/models/merge.rb b/app/models/merge.rb index 4cbbd18ab..8051eed4d 100644 --- a/app/models/merge.rb +++ b/app/models/merge.rb @@ -17,7 +17,7 @@ class Merge < ActiveRecord::Base end def name - "Dummy" # FIXME + referentials.first(3).map { |r| r.name.truncate(10) }.join(',') end attr_reader :new diff --git a/app/models/referential.rb b/app/models/referential.rb index 4cddd502e..3eb5d3283 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -252,6 +252,14 @@ class Referential < ActiveRecord::Base before_destroy :destroy_schema before_destroy :destroy_jobs + def referential_read_only? + in_referential_suite? || archived? + end + + def in_referential_suite? + referential_suite_id.present? + end + def in_workbench? workbench_id.present? end @@ -334,9 +342,6 @@ class Referential < ActiveRecord::Base end end - def in_referential_suite? - referential_suite_id.present? - end attr_accessor :inline_clone def clone_schema @@ -355,11 +360,15 @@ class Referential < ActiveRecord::Base Apartment::Tenant.create slug end - Rails.logger.info("Schema create benchmark: '#{slug}'\t#{report}") - Rails.logger.info("Schema migrations count for Referential #{slug}: #{migration_count || '-'}") + check_migration_count(report) end end + def check_migration_count(report) + Rails.logger.info("Schema create benchmark: '#{slug}'\t#{report}") + Rails.logger.info("Schema migrations count for Referential #{slug}: #{migration_count || '-'}") + end + def migration_count if self.class.connection.table_exists?("#{slug}.schema_migrations") self.class.connection.select_value("select count(*) from #{slug}.schema_migrations;") @@ -452,7 +461,7 @@ class Referential < ActiveRecord::Base # No explicit unlock is needed as it will be released at the end of the # transaction. ActiveRecord::Base.connection.execute( - 'LOCK referentials IN ACCESS EXCLUSIVE MODE' + 'LOCK public.referentials IN ACCESS EXCLUSIVE MODE' ) end end diff --git a/app/models/referential_cloning.rb b/app/models/referential_cloning.rb index a2b23e819..d4b74bd52 100644 --- a/app/models/referential_cloning.rb +++ b/app/models/referential_cloning.rb @@ -19,9 +19,12 @@ class ReferentialCloning < ActiveRecord::Base end def clone! - AF83::SchemaCloner - .new(source_referential.slug, target_referential.slug) - .clone_schema + report = Benchmark.measure do + AF83::SchemaCloner + .new(source_referential.slug, target_referential.slug) + .clone_schema + end + target_referential.check_migration_count(report) end private diff --git a/app/models/workbench.rb b/app/models/workbench.rb index 3190246ae..f49f4e7cf 100644 --- a/app/models/workbench.rb +++ b/app/models/workbench.rb @@ -4,6 +4,7 @@ class Workbench < ActiveRecord::Base belongs_to :line_referential belongs_to :stop_area_referential belongs_to :output, class_name: 'ReferentialSuite' + belongs_to :workgroup has_many :lines, -> (workbench) { Stif::MyWorkbenchScopes.new(workbench).line_scope(self) }, through: :line_referential has_many :networks, through: :line_referential diff --git a/app/models/workgroup.rb b/app/models/workgroup.rb new file mode 100644 index 000000000..995917fac --- /dev/null +++ b/app/models/workgroup.rb @@ -0,0 +1,14 @@ +class Workgroup < ActiveRecord::Base + belongs_to :line_referential + belongs_to :stop_area_referential + + has_many :workbenches + has_many :organisations, through: :workbenches + + validates_uniqueness_of :name + + validates_presence_of :line_referential_id + validates_presence_of :stop_area_referential_id + + has_many :custom_fields +end diff --git a/app/policies/access_link_policy.rb b/app/policies/access_link_policy.rb index 1f1147f60..f2ea7027f 100644 --- a/app/policies/access_link_policy.rb +++ b/app/policies/access_link_policy.rb @@ -6,14 +6,14 @@ class AccessLinkPolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('access_links.create') + !referential_read_only? && organisation_match? && user.has_permission?('access_links.create') end def update? - !archived? && organisation_match? && user.has_permission?('access_links.update') + !referential_read_only? && organisation_match? && user.has_permission?('access_links.update') end def destroy? - !archived? && organisation_match? && user.has_permission?('access_links.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('access_links.destroy') end end diff --git a/app/policies/access_point_policy.rb b/app/policies/access_point_policy.rb index 41436e77c..4fa887b9e 100644 --- a/app/policies/access_point_policy.rb +++ b/app/policies/access_point_policy.rb @@ -6,14 +6,14 @@ class AccessPointPolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('access_points.create') + !referential_read_only? && organisation_match? && user.has_permission?('access_points.create') end def update? - !archived? && organisation_match? && user.has_permission?('access_points.update') + !referential_read_only? && organisation_match? && user.has_permission?('access_points.update') end def destroy? - !archived? && organisation_match? && user.has_permission?('access_points.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('access_points.destroy') end end diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index dbe4542e7..c44937c9e 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -81,6 +81,11 @@ class ApplicationPolicy @is_archived = is_archived end + def referential_read_only? + return @is_referential_read_only if instance_variable_defined?(:@is_referential_read_only) + @is_referential_read_only = is_referential_read_only + end + def organisation_match? user.organisation_id == organisation_id end @@ -124,4 +129,13 @@ class ApplicationPolicy current_referential.try(:archived_at) end end + + def is_referential_read_only + !!case referential + when Referential + referential.referential_read_only? + else + current_referential.try(:referential_read_only?) + end + end end diff --git a/app/policies/connection_link_policy.rb b/app/policies/connection_link_policy.rb index 240c2a804..9bab5e4db 100644 --- a/app/policies/connection_link_policy.rb +++ b/app/policies/connection_link_policy.rb @@ -6,14 +6,14 @@ class ConnectionLinkPolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('connection_links.create') + !referential_read_only? && organisation_match? && user.has_permission?('connection_links.create') end def destroy? - !archived? && organisation_match? && user.has_permission?('connection_links.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('connection_links.destroy') end def update? - !archived? && organisation_match? && user.has_permission?('connection_links.update') + !referential_read_only? && organisation_match? && user.has_permission?('connection_links.update') end end diff --git a/app/policies/journey_pattern_policy.rb b/app/policies/journey_pattern_policy.rb index 12bcced17..beb18d151 100644 --- a/app/policies/journey_pattern_policy.rb +++ b/app/policies/journey_pattern_policy.rb @@ -7,14 +7,14 @@ class JourneyPatternPolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('journey_patterns.create') + !referential_read_only? && organisation_match? && user.has_permission?('journey_patterns.create') end def destroy? - !archived? && organisation_match? && user.has_permission?('journey_patterns.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('journey_patterns.destroy') end def update? - !archived? && organisation_match? && user.has_permission?('journey_patterns.update') + !referential_read_only? && organisation_match? && user.has_permission?('journey_patterns.update') end end diff --git a/app/policies/line_policy.rb b/app/policies/line_policy.rb index e7263cc3b..f7b03b0b5 100644 --- a/app/policies/line_policy.rb +++ b/app/policies/line_policy.rb @@ -26,15 +26,15 @@ class LinePolicy < ApplicationPolicy end def create_footnote? - !archived? && organisation_match? && user.has_permission?('footnotes.create') + !referential_read_only? && organisation_match? && user.has_permission?('footnotes.create') end def edit_footnote? - !archived? && organisation_match? && user.has_permission?('footnotes.update') + !referential_read_only? && organisation_match? && user.has_permission?('footnotes.update') end def destroy_footnote? - !archived? && organisation_match? && user.has_permission?('footnotes.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('footnotes.destroy') end def update_footnote? ; edit_footnote? end diff --git a/app/policies/purchase_window_policy.rb b/app/policies/purchase_window_policy.rb index 75143a8bd..eb3b04bf7 100644 --- a/app/policies/purchase_window_policy.rb +++ b/app/policies/purchase_window_policy.rb @@ -6,15 +6,15 @@ class PurchaseWindowPolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('purchase_windows.create') + !referential_read_only? && organisation_match? && user.has_permission?('purchase_windows.create') end def update? - !archived? && organisation_match? && user.has_permission?('purchase_windows.update') + !referential_read_only? && organisation_match? && user.has_permission?('purchase_windows.update') end def destroy? - !archived? && organisation_match? && user.has_permission?('purchase_windows.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('purchase_windows.destroy') end -end
\ No newline at end of file +end diff --git a/app/policies/referential_policy.rb b/app/policies/referential_policy.rb index 253917509..af5c14880 100644 --- a/app/policies/referential_policy.rb +++ b/app/policies/referential_policy.rb @@ -10,23 +10,23 @@ class ReferentialPolicy < ApplicationPolicy end def destroy? - !archived? && organisation_match? && user.has_permission?('referentials.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('referentials.destroy') end def update? - !archived? && organisation_match? && user.has_permission?('referentials.update') + !referential_read_only? && organisation_match? && user.has_permission?('referentials.update') end def clone? - !archived? && create? + !referential_read_only? && create? end def validate? - !archived? && create? && organisation_match? + !referential_read_only? && create? && organisation_match? end def archive? - record.archived_at.nil? && organisation_match? && user.has_permission?('referentials.update') + !referential_read_only? && record.archived_at.nil? && organisation_match? && user.has_permission?('referentials.update') end def unarchive? diff --git a/app/policies/route_policy.rb b/app/policies/route_policy.rb index 7e9fe251a..0337a5300 100644 --- a/app/policies/route_policy.rb +++ b/app/policies/route_policy.rb @@ -6,15 +6,15 @@ class RoutePolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('routes.create') + !referential_read_only? && organisation_match? && user.has_permission?('routes.create') end def destroy? - !archived? && organisation_match? && user.has_permission?('routes.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('routes.destroy') end def update? - !archived? && organisation_match? && user.has_permission?('routes.update') + !referential_read_only? && organisation_match? && user.has_permission?('routes.update') end def duplicate? diff --git a/app/policies/routing_constraint_zone_policy.rb b/app/policies/routing_constraint_zone_policy.rb index 3cfcf46ff..fd8081bef 100644 --- a/app/policies/routing_constraint_zone_policy.rb +++ b/app/policies/routing_constraint_zone_policy.rb @@ -6,14 +6,14 @@ class RoutingConstraintZonePolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.create') + !referential_read_only? && organisation_match? && user.has_permission?('routing_constraint_zones.create') end def destroy? - !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('routing_constraint_zones.destroy') end def update? - !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.update') + !referential_read_only? && organisation_match? && user.has_permission?('routing_constraint_zones.update') end end diff --git a/app/policies/time_table_combination_policy.rb b/app/policies/time_table_combination_policy.rb index daa6808e4..bba458c18 100644 --- a/app/policies/time_table_combination_policy.rb +++ b/app/policies/time_table_combination_policy.rb @@ -7,6 +7,6 @@ class TimeTableCombinationPolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('time_tables.update') + !referential_read_only? && organisation_match? && user.has_permission?('time_tables.update') end end diff --git a/app/policies/time_table_policy.rb b/app/policies/time_table_policy.rb index 92d3aef3e..390c170c7 100644 --- a/app/policies/time_table_policy.rb +++ b/app/policies/time_table_policy.rb @@ -7,23 +7,23 @@ class TimeTablePolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('time_tables.create') + !referential_read_only? && organisation_match? && user.has_permission?('time_tables.create') end def destroy? - !archived? && organisation_match? && user.has_permission?('time_tables.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('time_tables.destroy') end def update? - !archived? && organisation_match? && user.has_permission?('time_tables.update') + !referential_read_only? && organisation_match? && user.has_permission?('time_tables.update') end def actualize? - !archived? && organisation_match? && edit? + !referential_read_only? && organisation_match? && edit? end def duplicate? - !archived? && organisation_match? && create? + !referential_read_only? && organisation_match? && create? end def month? diff --git a/app/policies/vehicle_journey_policy.rb b/app/policies/vehicle_journey_policy.rb index 24040455f..adbc5fd89 100644 --- a/app/policies/vehicle_journey_policy.rb +++ b/app/policies/vehicle_journey_policy.rb @@ -6,14 +6,14 @@ class VehicleJourneyPolicy < ApplicationPolicy end def create? - !archived? && organisation_match? && user.has_permission?('vehicle_journeys.create') + !referential_read_only? && organisation_match? && user.has_permission?('vehicle_journeys.create') end def destroy? - !archived? && organisation_match? && user.has_permission?('vehicle_journeys.destroy') + !referential_read_only? && organisation_match? && user.has_permission?('vehicle_journeys.destroy') end def update? - !archived? && organisation_match? && user.has_permission?('vehicle_journeys.update') + !referential_read_only? && organisation_match? && user.has_permission?('vehicle_journeys.update') end end diff --git a/app/views/imports/index.html.slim b/app/views/imports/index.html.slim index 79452bbfc..856b715e0 100644 --- a/app/views/imports/index.html.slim +++ b/app/views/imports/index.html.slim @@ -34,7 +34,7 @@ attribute: 'creator' \ ) \ ], - links: [], + links: [:show], cls: 'table has-search' = new_pagination @imports, 'pull-right' diff --git a/app/views/merges/_form.html.slim b/app/views/merges/_form.html.slim index ff85ad76b..b97a4b03e 100644 --- a/app/views/merges/_form.html.slim +++ b/app/views/merges/_form.html.slim @@ -4,4 +4,9 @@ .col-lg-12 = form.input :referentials, :collection => @mergeable_referentials, include_blank: false, input_html: { multiple: true, 'data-select2ed': true } + + .row + .col-lg-12 + = form.input :creator, input_html: { disabled: true } + = form.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'wb_merge_form' diff --git a/app/views/merges/show.html.slim b/app/views/merges/show.html.slim index 579995ebf..47e5aa029 100644 --- a/app/views/merges/show.html.slim +++ b/app/views/merges/show.html.slim @@ -7,7 +7,8 @@ .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), { @merge.class.human_attribute_name(:referentials) => @merge.referentials.map(&:name).join(', '), + @merge.class.human_attribute_name(:operator) => @merge.creator, @merge.class.human_attribute_name(:status) => @merge.status, - @merge.class.human_attribute_name(:created_at) => @merge.created_at, - @merge.class.human_attribute_name(:started_at) => @merge.started_at, - @merge.class.human_attribute_name(:ended_at) => @merge.ended_at } + @merge.class.human_attribute_name(:created_at) => @merge.created_at ? l(@merge.created_at) : '-', + @merge.class.human_attribute_name(:started_at) => @merge.started_at ? l(@merge.started_at) : '-', + @merge.class.human_attribute_name(:ended_at) => @merge.ended_at ? l(@merge.ended_at) : '-' } diff --git a/app/views/referential_vehicle_journeys/_filters.html.slim b/app/views/referential_vehicle_journeys/_filters.html.slim index 6d22e1378..4506251c3 100644 --- a/app/views/referential_vehicle_journeys/_filters.html.slim +++ b/app/views/referential_vehicle_journeys/_filters.html.slim @@ -7,8 +7,14 @@ span.fa.fa-search .ffg-row .form-group.togglable - = f.label Chouette::VehicleJourney.human_attribute_name(:company_id), required: false, class: 'control-label' + = f.label Chouette::VehicleJourney.human_attribute_name(:company), required: false, class: 'control-label' = f.input :company_id_eq_any, collection: @all_companies.select(:id, :name).order(name: :asc), as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + l.name + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'} + .form-group.togglable.name-filter + = f.label Chouette::VehicleJourney.human_attribute_name(:published_journey_name), required: false, class: 'control-label' + .inputs.form-inline.checkbox_list + = f.input :published_journey_name_gteq, label: false, wrapper_html: { class: 'w45'} + .form-group.w10.to= I18n.t('vehicle_journeys.form.to') + = f.input :published_journey_name_lteq, label: false, wrapper_html: { class: 'w45'} .actions = link_to 'Effacer', referential_vehicle_journeys_path(@referential), class: 'btn btn-link' diff --git a/app/views/referentials/_form.html.slim b/app/views/referentials/_form.html.slim index 1611ee6dd..9927f05bd 100644 --- a/app/views/referentials/_form.html.slim +++ b/app/views/referentials/_form.html.slim @@ -51,4 +51,8 @@ .hidden = form.input :workbench_id, as: :hidden - = form.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'referential_form' + = form.button :submit, + t('actions.submit'), + class: 'btn btn-default formSubmitr', + data: { disable_with: t('actions.processing') }, + form: 'referential_form' diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim index 96755359c..51041198c 100644 --- a/app/views/referentials/show.html.slim +++ b/app/views/referentials/show.html.slim @@ -1,7 +1,7 @@ - breadcrumb @referential - page_header_content_for @referential - content_for :page_header_actions do - - unless (@referential.archived? || !policy(@referential).edit?) + - unless (@referential.referential_read_only? || !policy(@referential).edit?) = link_to(t('actions.edit'), edit_referential_path(@referential), class: 'btn btn-default') - content_for :page_header_content do @@ -22,7 +22,7 @@ .row .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), - { t('activerecord.attributes.referential.status') => @referential.archived? ? "<div class='td-block'><span class='fa fa-archive'></span><span>#{t('activerecord.attributes.referential.archived_at')}</span></div>".html_safe : "<div class='td-block'><span class='sb sb-lg sb-preparing'></span><span>#{t('activerecord.attributes.referential.archived_at_null')}</span></div>".html_safe, + { t('activerecord.attributes.referential.status') => @referential.referential_read_only? ? "<div class='td-block'><span class='fa fa-archive'></span><span>#{t('activerecord.attributes.referential.archived_at')}</span></div>".html_safe : "<div class='td-block'><span class='sb sb-lg sb-preparing'></span><span>#{t('activerecord.attributes.referential.archived_at_null')}</span></div>".html_safe, @referential.human_attribute_name(:validity_period) => (@referential.validity_period.present? ? t('validity_range', debut: l(@referential.try(:validity_period).try(:begin), format: :short), end: l(@referential.try(:validity_period).try(:end), format: :short)) : '-'), @referential.human_attribute_name(:organisation) => @referential.organisation.name, @referential.human_attribute_name(:published_at) => '-' } @@ -102,5 +102,5 @@ .modal-footer button.btn.btn-link type='button' data-dismiss='modal' #{t('cancel')} - - unless policy(@referential).archived? + - unless policy(@referential).referential_read_only? = f.button :submit, t('actions.clean_up') , class: 'btn btn-primary' diff --git a/app/views/workbench_outputs/show.html.slim b/app/views/workbench_outputs/show.html.slim index 67dc6e8d4..dc0a54204 100644 --- a/app/views/workbench_outputs/show.html.slim +++ b/app/views/workbench_outputs/show.html.slim @@ -19,10 +19,21 @@ attribute: Proc.new { |n| import_status(n.status) }, \ ), \ TableBuilderHelper::Column.new( \ + key: :name, \ + attribute: 'name', \ + link_to: lambda do |merge| \ + workbench_merge_path merge.workbench, merge \ + end \ + ), \ + TableBuilderHelper::Column.new( \ key: :started_at, \ attribute: Proc.new { |n| l(n.started_at, format: :long) if n.started_at }, \ ), \ TableBuilderHelper::Column.new( \ + key: :ended_at, \ + attribute: Proc.new { |n| l(n.ended_at, format: :long) if n.ended_at }, \ + ), \ + TableBuilderHelper::Column.new( \ key: :creator, \ attribute: 'creator' \ ) \ diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index fe0b05330..17ad75051 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -30,7 +30,7 @@ ), \ TableBuilderHelper::Column.new( \ key: :status, \ - attribute: Proc.new {|w| w.archived? ? ("<div class='td-block'><span class='fa fa-archive'></span><span>#{t('activerecord.attributes.referential.archived_at')}</span></div>").html_safe : ("<div class='td-block'><span class='sb sb-lg sb-preparing'></span><span>#{t('activerecord.attributes.referential.archived_at_null')}</span></div>").html_safe} \ + attribute: Proc.new {|w| w.referential_read_only? ? ("<div class='td-block'><span class='fa fa-archive'></span><span>#{t('activerecord.attributes.referential.archived_at')}</span></div>").html_safe : ("<div class='td-block'><span class='sb sb-lg sb-preparing'></span><span>#{t('activerecord.attributes.referential.archived_at_null')}</span></div>").html_safe} \ ), \ TableBuilderHelper::Column.new( \ key: :organisation, \ diff --git a/app/workers/clean_up_worker.rb b/app/workers/clean_up_worker.rb index 2d76b3a68..9a7c3aa5a 100644 --- a/app/workers/clean_up_worker.rb +++ b/app/workers/clean_up_worker.rb @@ -1,6 +1,5 @@ class CleanUpWorker include Sidekiq::Worker - sidekiq_options :retry => false def perform(id) cleaner = CleanUp.find id diff --git a/app/workers/line_referential_sync_worker.rb b/app/workers/line_referential_sync_worker.rb index 253b8a53c..1303a63fd 100644 --- a/app/workers/line_referential_sync_worker.rb +++ b/app/workers/line_referential_sync_worker.rb @@ -1,6 +1,6 @@ class LineReferentialSyncWorker include Sidekiq::Worker - sidekiq_options :retry => false + sidekiq_options retry: true def process_time Process.clock_gettime(Process::CLOCK_MONOTONIC, :second) diff --git a/app/workers/stop_area_referential_sync_worker.rb b/app/workers/stop_area_referential_sync_worker.rb index 08bcf4f5f..3de351a91 100644 --- a/app/workers/stop_area_referential_sync_worker.rb +++ b/app/workers/stop_area_referential_sync_worker.rb @@ -1,6 +1,6 @@ class StopAreaReferentialSyncWorker include Sidekiq::Worker - sidekiq_options :retry => false + sidekiq_options retry: true def process_time Process.clock_gettime(Process::CLOCK_MONOTONIC, :second) |
