diff options
| author | Xinhui | 2017-03-03 17:50:58 +0100 |
|---|---|---|
| committer | Xinhui | 2017-03-03 17:50:58 +0100 |
| commit | bd1458253c7956dd4a07dd3017e6cbb5004c56f1 (patch) | |
| tree | f70e2152f19b8dd418cef3a9cde6bebd06f4d0c0 | |
| parent | dd6c19075007302c1ccf33a3e94a98162c721d62 (diff) | |
| parent | b74d373bc477fd60b083fa9a5b79b346cd9d07de (diff) | |
| download | chouette-core-bd1458253c7956dd4a07dd3017e6cbb5004c56f1.tar.bz2 | |
Merge branch 'master' into staging
74 files changed, 1152 insertions, 495 deletions
diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js b/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js index 30fa872dd..f5a3357eb 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/actions/index.js @@ -169,31 +169,38 @@ const actions = { if(hasError == true) { dispatch(actions.unavailableServer()) } else { - let val - for (val of json){ - for (let stop_point of val.route_short_description.stop_points){ - stop_point.checked = false - val.stop_area_short_descriptions.map((element) => { - if(element.stop_area_short_description.id === stop_point.id){ - stop_point.checked = true - } + if(json.length != 0){ + let val + for (val of json){ + for (let stop_point of val.route_short_description.stop_points){ + stop_point.checked = false + val.stop_area_short_descriptions.map((element) => { + if(element.stop_area_short_description.id === stop_point.id){ + stop_point.checked = true + } + }) + } + journeyPatterns.push({ + name: val.name, + object_id: val.object_id, + published_name: val.published_name, + registration_number: val.registration_number, + stop_points: val.route_short_description.stop_points, + deletable: false }) } - journeyPatterns.push({ - name: val.name, - object_id: val.object_id, - published_name: val.published_name, - registration_number: val.registration_number, - stop_points: val.route_short_description.stop_points, - deletable: false - }) - } - if(journeyPatterns.length != window.journeyPatternsPerPage){ - dispatch(actions.updateTotalCount(journeyPatterns.length - window.journeyPatternsPerPage)) + if(journeyPatterns.length != window.journeyPatternsPerPage){ + dispatch(actions.updateTotalCount(journeyPatterns.length - window.journeyPatternsPerPage)) + } } dispatch(actions.receiveJourneyPatterns(journeyPatterns)) } }) + }, + getChecked : (jp) => { + return jp.filter((obj) => { + return obj.checked + }) } } diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/components/ConfirmModal.js b/app/assets/javascripts/es6_browserified/journey_patterns/components/ConfirmModal.js index d9fbf07f8..5e51f469c 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/components/ConfirmModal.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/ConfirmModal.js @@ -4,28 +4,35 @@ var PropTypes = require('react').PropTypes const ConfirmModal = ({dispatch, modal, onModalAccept, onModalCancel, journeyPatterns}) => ( <div className={ 'modal fade ' + ((modal.type == 'confirm') ? 'in' : '') } id='ConfirmModal'> - <div className='modal-dialog'> - <div className='modal-content'> - <div className='modal-body'> - <p> Voulez-vous enregistrer vos modifications avant de changer de page? </p> - </div> - <div className='modal-footer'> - <button - className='btn btn-default' - data-dismiss='modal' - type='button' - onClick= {() => {onModalCancel(modal.confirmModal.callback)}} - > - Ne pas enregistrer - </button> - <button - className='btn btn-danger' - data-dismiss='modal' - type='button' - onClick = {() => {onModalAccept(modal.confirmModal.callback, journeyPatterns)}} - > - Enregistrer - </button> + <div className='modal-container'> + <div className='modal-dialog'> + <div className='modal-content'> + <div className='modal-header'> + <h4 className='modal-title'>Confirmation</h4> + </div> + <div className='modal-body'> + <div className='mt-md mb-md'> + <p>Vous vous apprêtez à changer de page. Voulez-vous enregistrer vos modifications avant cela ?</p> + </div> + </div> + <div className='modal-footer'> + <button + className='btn btn-link' + data-dismiss='modal' + type='button' + onClick= {() => {onModalCancel(modal.confirmModal.callback)}} + > + Ne pas enregistrer + </button> + <button + className='btn btn-primary' + data-dismiss='modal' + type='button' + onClick = {() => {onModalAccept(modal.confirmModal.callback, journeyPatterns)}} + > + Enregistrer + </button> + </div> </div> </div> </div> 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 0b966d6d9..d9a4df099 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/CreateModal.js @@ -34,71 +34,73 @@ class CreateModal extends Component { </button> <div className={ 'modal fade ' + ((this.props.modal.type == 'create') ? 'in' : '') } id='NewJourneyPatternModal'> - <div className='modal-dialog'> - <div className='modal-content'> - <div className='modal-header clearfix'> - <h4>Ajouter une mission</h4> - </div> + <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'>N° d'enregistrement</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'>N° d'enregistrement</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-default' - data-dismiss='modal' - type='button' - onClick={this.props.onModalClose} - > - Annuler - </button> - <button - className='btn btn-danger' - 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> diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/components/EditModal.js b/app/assets/javascripts/es6_browserified/journey_patterns/components/EditModal.js index 7d7dd40a4..37f2b5547 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/components/EditModal.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/EditModal.js @@ -18,110 +18,86 @@ class EditModal extends Component { render() { return ( <div className={ 'modal fade ' + ((this.props.modal.type == 'edit') ? 'in' : '') } id='JourneyPatternModal'> - <div className='modal-dialog'> - <div className='modal-content'> - <div className='modal-header clearfix'> - <h4 className='pull-left'> - Modifier la mission - {(this.props.modal.type == 'edit') && ( - <em> "{this.props.modal.modalProps.journeyPattern.name}"</em> - )} - </h4> - <div className='btn-group btn-group-sm pull-right'> - <button - type='button' - className='btn btn-primary dropdown-toggle' - data-toggle='dropdown' - > - <span className='fa fa-bars'></span> - <span className='caret'></span> - </button> - - <ul className='dropdown-menu'> - <li><a href='#'>Horaires des courses</a></li> - <li> - <a - href='#' - data-dismiss='modal' - onClick={(e) => { - e.preventDefault() - this.props.onDeleteJourneyPattern(this.props.modal.modalProps.index)} - } - > - Supprimer la mission - </a> - </li> - </ul> + <div className='modal-container'> + <div className='modal-dialog'> + <div className='modal-content'> + <div className='modal-header'> + <h4 className='modal-title'> + Modifier la mission + {(this.props.modal.type == 'edit') && ( + <em> "{this.props.modal.modalProps.journeyPattern.name}"</em> + )} + </h4> </div> - </div> - {(this.props.modal.type == 'edit') && ( - <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' - id={this.props.modal.modalProps.index} - defaultValue={this.props.modal.modalProps.journeyPattern.name} - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} - required - /> - </div> + {(this.props.modal.type == 'edit') && ( + <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' + id={this.props.modal.modalProps.index} + defaultValue={this.props.modal.modalProps.journeyPattern.name} + 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' - id={this.props.modal.modalProps.index} - defaultValue={this.props.modal.modalProps.journeyPattern.published_name} - 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' + id={this.props.modal.modalProps.index} + defaultValue={this.props.modal.modalProps.journeyPattern.published_name} + onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + required + /> + </div> </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'>N° d'enregistrement</label> - <input - type='text' - ref='registration_number' - className='form-control' - id={this.props.modal.modalProps.index} - defaultValue={this.props.modal.modalProps.journeyPattern.registration_number} - onKeyDown={(e) => actions.resetValidation(e.currentTarget)} - required - /> + <div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'> + <div className='form-group'> + <label className='control-label is-required'>N° d'enregistrement</label> + <input + type='text' + ref='registration_number' + className='form-control' + id={this.props.modal.modalProps.index} + defaultValue={this.props.modal.modalProps.journeyPattern.registration_number} + onKeyDown={(e) => actions.resetValidation(e.currentTarget)} + required + /> + </div> </div> </div> </div> - </div> - <div className='modal-footer'> - <button - className='btn btn-default' - data-dismiss='modal' - type='button' - onClick={this.props.onModalClose} - > - Annuler - </button> - <button - className='btn btn-danger' - 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> @@ -133,8 +109,7 @@ EditModal.propTypes = { index: PropTypes.number, modal: PropTypes.object, onModalClose: PropTypes.func.isRequired, - saveModal: PropTypes.func.isRequired, - onDeleteJourneyPattern: PropTypes.func.isRequired + saveModal: PropTypes.func.isRequired } module.exports = EditModal diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPattern.js b/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPattern.js index c0272a476..72ba2061a 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPattern.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPattern.js @@ -1,64 +1,125 @@ var React = require('react') +var Component = require('react').Component var PropTypes = require('react').PropTypes +var actions = require('../actions') -const JourneyPattern = (props) => { - return ( - <div className={'tc-item' + (props.value.deletable ? ' disabled' : '') + (props.value.object_id ? '' : ' to_record')}> - {/* Errors */} - {(props.value.errors) && ( - <ul className='alert alert-danger small' style={{paddingLeft: 30}}> - {Object.keys(props.value.errors).map(function(key, i) { - return ( - <li key={i} style={{listStyleType: 'disc'}}> - <strong>'{key}'</strong> {props.value.errors[key]} - </li> - ) - })} - </ul> - )} +class JourneyPattern extends Component{ + constructor(props){ + super(props) + this.previousCity = undefined + } - <div className='tc-th'> - <span>{props.value.object_id}</span> - <span>{props.value.registration_number}</span> - <span>n</span> + vehicleJourneyURL(oid) { + // oid will be used later, for params in URL... - <div className='clearfix' style={{display: 'inline-block', verticalAlign: 'top', width: '25px'}}> - <button className={(props.value.deletable ? 'disabled' : '') + ' btn btn-xs btn-danger pull-right'} onClick={props.onOpenEditModal} data-toggle='modal' data-target='#JourneyPatternModal'> - <span className='fa fa-pencil'></span> - </button> - </div> + let routeURL = window.location.pathname.split('/', 7).join('/') + let vjURL = routeURL + '/vehicle_journeys' + + return ( + <a href={vjURL}>Horaires des courses</a> + ) + } + + cityNameChecker(sp) { + let bool = false + if(sp.city_name != this.previousCity){ + bool = true + this.previousCity = sp.city_name + } + return ( + <div + className={(bool) ? 'headlined' : ''} + > + <span className='has_radio'> + <input + onChange = {(e) => this.props.onCheckboxChange(e)} + type='checkbox' + id={sp.id} + checked={sp.checked} + disabled={this.props.value.deletable ? 'disabled' : ''} + > + </input> + <span className='radio-label'></span> + </span> </div> - <div className='tc-td'> - <ul className='list-group'> - {props.value.stop_points.map((stopPoint, i) => - <li - key={ i } - className='list-group-item clearfix' - > - <span className='label label-default' style={{marginRight: 5}}>{stopPoint.id}</span> - <span>{stopPoint.name}</span> - <span className='pull-right'> - <input - onChange = {(e) => props.onCheckboxChange(e)} - type='checkbox' - id={stopPoint.id} - checked={stopPoint.checked} - disabled={props.value.deletable ? 'disabled' : ''} - ></input> - </span> - </li> + ) + } + + render() { + this.previousCity = undefined + + return ( + <div className={'t2e-item' + (this.props.value.deletable ? ' disabled' : '') + (this.props.value.object_id ? '' : ' to_record')}> + {/* Errors */} + {(this.props.value.errors) && ( + <ul className='alert alert-danger small' style={{paddingLeft: 30}}> + {Object.keys(this.props.value.errors).map(function(key, i) { + return ( + <li key={i} style={{listStyleType: 'disc'}}> + <strong>'{key}'</strong> {this.props.value.errors[key]} + </li> + ) + })} + </ul> )} - </ul> - </div> - </div> - ) + + <div className='th'> + <div className='strong mb-xs'>{this.props.value.object_id ? this.props.value.object_id : '-'}</div> + <div>{this.props.value.registration_number}</div> + <div>{actions.getChecked(this.props.value.stop_points).length} arrêt(s)</div> + + <div className={this.props.value.deletable ? 'btn-group disabled' : 'btn-group'}> + <div + className={this.props.value.deletable ? 'btn dropdown-toggle disabled' : 'btn dropdown-toggle'} + data-toggle='dropdown' + > + <span className='fa fa-cog'></span> + </div> + <ul className='dropdown-menu'> + <li className={this.props.value.deletable ? 'disabled' : ''}> + <a + href='#' + onClick={this.props.onOpenEditModal} + data-toggle='modal' + data-target='#JourneyPatternModal' + > + Modifier + </a> + </li> + <li>{this.vehicleJourneyURL(this.props.value.object_id)}</li> + <li className='delete-action'> + <a + href='#' + onClick={(e) => { + e.preventDefault() + this.props.onDeleteJourneyPattern(this.props.index)} + } + > + <span className='fa fa-trash'></span>Supprimer + </a> + </li> + </ul> + </div> + </div> + + {this.props.value.stop_points.map((stopPoint, i) =>{ + return ( + <div key={i} className='td'> + {this.cityNameChecker(stopPoint)} + </div> + ) + })} + </div> + ) + } } JourneyPattern.propTypes = { value: PropTypes.object, index: PropTypes.number, onCheckboxChange: PropTypes.func.isRequired, - onOpenEditModal: PropTypes.func.isRequired + onOpenEditModal: PropTypes.func.isRequired, + onDeleteJourneyPattern: PropTypes.func.isRequired } module.exports = JourneyPattern diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPatterns.js b/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPatterns.js index 2d922d745..69d36abe6 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPatterns.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/JourneyPatterns.js @@ -6,12 +6,74 @@ var JourneyPattern = require('./JourneyPattern') class JourneyPatterns extends Component{ constructor(props){ super(props) + this.previousCity = undefined } componentDidMount() { this.props.onLoadFirstPage() } + componentDidUpdate(prevProps, prevState) { + if(this.props.status.isFetching == false){ + $('.table-2entries').each(function() { + var refH = [] + var refCol = [] + + $(this).find('.t2e-head').children('div').each(function() { + var h = $(this).outerHeight(); + refH.push(h) + }); + + var i = 0 + $(this).find('.t2e-item').children('div').each(function() { + var h = $(this).outerHeight(); + if(refCol.length < refH.length){ + refCol.push(h) + } else { + if(h > refCol[i]) { + refCol[i] = h + } + } + if(i == (refH.length - 1)){ + i = 0 + } else { + i++ + } + }); + + for(var n = 0; n < refH.length; n++) { + if(refCol[n] < refH[n]) { + refCol[n] = refH[n] + } + } + + $(this).find('.th').css('height', refCol[0]); + + for(var nth = 1; nth < refH.length; nth++) { + $(this).find('.td:nth-child('+ (nth + 1) +')').css('height', refCol[nth]); + } + }); + } + } + + 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>{sp.name}</span> + </div> + ) + } render() { + this.previousCity = undefined + if(this.props.status.isFetching == true) { return ( <div className="isLoading" style={{marginTop: 80, marginBottom: 80}}> @@ -29,27 +91,34 @@ class JourneyPatterns extends Component{ </div> )} - <div className='table table-cbyc mt-sm mb-sm'> - <div className='tc-wrapper'> - <div className='tc-head'> - <div className='tc-th'> - <span>ID Mission</span> - <span>Code mission</span> - <span>Nb arrêts</span> - </div> - {this.props.stopPointsList.map((sp, i) => - <span key={i} className='tc-td'>{sp}</span> - )} + <div className='table table-2entries mt-sm mb-sm'> + <div className='t2e-head w20'> + <div className='th'> + <div className='strong mb-xs'>ID Mission</div> + <div>Code mission</div> + <div>Nb arrêts</div> </div> + {this.props.stopPointsList.map((sp, i) =>{ + return ( + <div key={i} className='td'> + {this.cityNameChecker(sp)} + </div> + ) + })} + </div> - {this.props.journeyPatterns.map((journeyPattern, index) => - <JourneyPattern - value={ journeyPattern } - key={ index } - onCheckboxChange= {(e) => this.props.onCheckboxChange(e, index)} - onOpenEditModal= {() => this.props.onOpenEditModal(index, journeyPattern)} - /> - )} + <div className='t2e-item-list w80'> + <div> + {this.props.journeyPatterns.map((journeyPattern, index) => + <JourneyPattern + value={ journeyPattern } + key={ index } + onCheckboxChange= {(e) => this.props.onCheckboxChange(e, index)} + onOpenEditModal= {() => this.props.onOpenEditModal(index, journeyPattern)} + onDeleteJourneyPattern={() => this.props.onDeleteJourneyPattern(index)} + /> + )} + </div> </div> </div> </div> diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/components/Navigate.js b/app/assets/javascripts/es6_browserified/journey_patterns/components/Navigate.js index def7d1471..839d8f72e 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/components/Navigate.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/Navigate.js @@ -28,20 +28,24 @@ let Navigate = ({ dispatch, journeyPatterns, pagination, status }) => { e.preventDefault() dispatch(actions.checkConfirmModal(e, actions.goToPreviousPage(dispatch, pagination), pagination.stateChanged, dispatch)) }} - type="submit" + type='button' data-toggle='' data-target='#ConfirmModal' - className={'previous_page' + (pagination.page == firstPage ? ' disabled' : '')}> + className={'previous_page' + (pagination.page == firstPage ? ' disabled' : '')} + disabled={'previous_page' + (pagination.page == firstPage ? ' disabled' : '')} + > </button> <button onClick={e => { e.preventDefault() dispatch(actions.checkConfirmModal(e, actions.goToNextPage(dispatch, pagination), pagination.stateChanged, dispatch)) }} - type="submit" + type='button' data-toggle='' data-target='#ConfirmModal' - className={'next_page' + (pagination.page == lastPage ? ' disabled' : '')}> + className={'next_page' + (pagination.page == lastPage ? ' disabled' : '')} + disabled={'next_page' + (pagination.page == lastPage ? ' disabled' : '')} + > </button> </form> </div> diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/components/SaveJourneyPattern.js b/app/assets/javascripts/es6_browserified/journey_patterns/components/SaveJourneyPattern.js new file mode 100644 index 000000000..b4b278ae4 --- /dev/null +++ b/app/assets/javascripts/es6_browserified/journey_patterns/components/SaveJourneyPattern.js @@ -0,0 +1,52 @@ +var React = require('react') +var Component = require('react').Component +var PropTypes = require('react').PropTypes +var actions = require('../actions') + +class SaveJourneyPattern extends Component{ + constructor(props){ + super(props) + } + + componentDidUpdate(prevProps, prevState) { + if(prevProps.status.isFetching == true){ + submitMover(); + } + } + + render() { + if(this.props.status.isFetching == true) { + return false + } + if(this.props.status.fetchSuccess == true) { + return ( + <div className='row mt-md'> + <div className='col-lg-12 text-right'> + <form className='jp_collection formSubmitr ml-xs' onSubmit={e => {e.preventDefault()}}> + <button + className='btn btn-default' + type='button' + onClick={e => { + e.preventDefault() + actions.submitJourneyPattern(this.props.dispatch, this.props.journeyPatterns) + }} + > + Enregistrer + </button> + </form> + </div> + </div> + ) + } else { + return false + } + } +} + +SaveJourneyPattern.propTypes = { + journeyPatterns: PropTypes.array.isRequired, + status: PropTypes.object.isRequired, + page: PropTypes.number.isRequired +} + +module.exports = SaveJourneyPattern diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/containers/JourneyPatternList.js b/app/assets/javascripts/es6_browserified/journey_patterns/containers/JourneyPatternList.js index bace802e5..bc2aaf95b 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/containers/JourneyPatternList.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/containers/JourneyPatternList.js @@ -21,6 +21,9 @@ const mapDispatchToProps = (dispatch) => { }, onOpenEditModal: (index, journeyPattern) =>{ dispatch(actions.openEditModal(index, journeyPattern)) + }, + onDeleteJourneyPattern: (index) =>{ + dispatch(actions.deleteJourneyPattern(index)) } } } diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/containers/Modal.js b/app/assets/javascripts/es6_browserified/journey_patterns/containers/Modal.js index 4b1809fa1..ef6a4a6b1 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/containers/Modal.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/containers/Modal.js @@ -17,9 +17,6 @@ const mapDispatchToProps = (dispatch) => { }, saveModal: (index, data) =>{ dispatch(actions.saveModal(index, data)) - }, - onDeleteJourneyPattern: (index) =>{ - dispatch(actions.deleteJourneyPattern(index)) } } } diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/containers/SaveJourneyPattern.js b/app/assets/javascripts/es6_browserified/journey_patterns/containers/SaveJourneyPattern.js index 24ccdcd5a..33442c5a0 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/containers/SaveJourneyPattern.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/containers/SaveJourneyPattern.js @@ -1,34 +1,7 @@ var React = require('react') var connect = require('react-redux').connect var actions = require('../actions') - -let SaveJourneyPattern = ({ dispatch, journeyPatterns, page, status }) => { - if(status.isFetching == true) { - return false - } - if(status.fetchSuccess == true) { - return ( - <div className='row mt-md'> - <div className='col-lg-12 text-right'> - <form className='jp_collection_submitr' onSubmit={e => {e.preventDefault()}}> - <button - className='btn btn-danger' - type='submit' - onClick={e => { - e.preventDefault() - actions.submitJourneyPattern(dispatch, journeyPatterns) - }} - > - Enregistrer - </button> - </form> - </div> - </div> - ) - } else { - return false - } -} +var SaveJourneyPatternComponent = require('../components/SaveJourneyPattern') const mapStateToProps = (state) => { return { @@ -38,6 +11,6 @@ const mapStateToProps = (state) => { } } -SaveJourneyPattern = connect(mapStateToProps)(SaveJourneyPattern) +const SaveJourneyPattern = connect(mapStateToProps)(SaveJourneyPatternComponent) module.exports = SaveJourneyPattern diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/index.js b/app/assets/javascripts/es6_browserified/journey_patterns/index.js index 6db78445f..a2e1c2fb6 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/index.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/index.js @@ -17,7 +17,7 @@ var initialState = { isFetching: false }, journeyPatterns: [], - stopPointsList: [], + stopPointsList: window.stopPoints, pagination: { page : 1, totalCount: window.journeyPatternLength, diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/reducers/index.js b/app/assets/javascripts/es6_browserified/journey_patterns/reducers/index.js index 85817616a..aa35adf0e 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/reducers/index.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/reducers/index.js @@ -8,8 +8,8 @@ var stopPointsList = require('./stopPointsList') const journeyPatternsApp = combineReducers({ status, journeyPatterns, - stopPointsList, pagination, + stopPointsList, modal }) diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/reducers/journeyPatterns.js b/app/assets/javascripts/es6_browserified/journey_patterns/reducers/journeyPatterns.js index 13f1100b3..92381f018 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/reducers/journeyPatterns.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/reducers/journeyPatterns.js @@ -3,11 +3,14 @@ var actions = require("../actions") const journeyPattern = (state = {}, action) => { switch (action.type) { case 'ADD_JOURNEYPATTERN': - let stopPoints = JSON.parse(JSON.stringify(state[0].stop_points)) - stopPoints.map((s)=>{ - s.checked = false - return s - }) + let stopPoints = window.stopPoints + + if(stopPoints != undefined) { + stopPoints.map((s)=>{ + s.checked = false + return s + }) + } return { name: action.data.name.value, published_name: action.data.published_name.value, @@ -65,8 +68,8 @@ const journeyPatterns = (state = [], action) => { }) case 'ADD_JOURNEYPATTERN': return [ - ...state, - journeyPattern(state, action) + journeyPattern(state, action), + ...state ] case 'SAVE_MODAL': return state.map((j, i) =>{ diff --git a/app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js b/app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js index 407a8e382..9abacc8c8 100644 --- a/app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js +++ b/app/assets/javascripts/es6_browserified/journey_patterns/reducers/stopPointsList.js @@ -1,12 +1,5 @@ -const stopPointsList = (state = {}, action) => { +const stopPointsList = (state = [], action) => { switch (action.type) { - case 'RECEIVE_JOURNEY_PATTERNS': - let sp = action.json[0].stop_points - let spArray = [] - sp.map((s) => { - spArray.push(s.name) - }) - return [...spArray] default: return state } diff --git a/app/assets/javascripts/forms.coffee b/app/assets/javascripts/forms.coffee index ff35066c5..c8dd69581 100644 --- a/app/assets/javascripts/forms.coffee +++ b/app/assets/javascripts/forms.coffee @@ -18,6 +18,9 @@ labelCont.text(labelCont.data('checkedvalue')) @submitMover = -> + if $('.page-action').children('.formSubmitr').length > 0 + $('.page-action').children('.formSubmitr').remove() + $('.formSubmitr').appendTo('.page-action') # IE fix diff --git a/app/assets/javascripts/selectable_table.coffee b/app/assets/javascripts/selectable_table.coffee index 1b4b95c0b..84475857e 100644 --- a/app/assets/javascripts/selectable_table.coffee +++ b/app/assets/javascripts/selectable_table.coffee @@ -28,11 +28,26 @@ elm = selection.indexOf(e.currentTarget.id) selection.splice(elm, 1) + # console.log(selection) + # Updating toolbox, according to selection if selection.length > 0 toolbox .removeClass 'noselect' .children('.info-msg').children('span').text(selection.length) + + # Injecting selection into action urls + toolbox.find('.st_action').each -> + actionURL = $(this).children('a').attr('data-path') + + newSelection = [] + i = 0 + while i < selection.length + newSelection[i] = 'referentials[]=' + selection[i] + '' + i++ + + $(this).children('a').attr('href', actionURL + '?' + newSelection.join('&')) + else toolbox .addClass 'noselect' diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index 99e5b41bf..c2cee88c9 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -12,3 +12,4 @@ @import 'components/*' @import 'modules/routes_stopoints' +@import 'modules/jp_collection' diff --git a/app/assets/stylesheets/base/_utilities.sass b/app/assets/stylesheets/base/_utilities.sass index bf7fba1d5..65091e904 100644 --- a/app/assets/stylesheets/base/_utilities.sass +++ b/app/assets/stylesheets/base/_utilities.sass @@ -19,3 +19,30 @@ margin-bottom: 20px .mb-lg margin-bottom: 40px + +.ml-xs + margin-left: 10px +.ml-sm + margin-left: 15px +.ml-md + margin-left: 20px +.ml-lg + margin-left: 40px + +.mr-xs + margin-right: 10px +.mr-sm + margin-right: 15px +.mr-md + margin-right: 20px +.mr-lg + margin-right: 40px + +@for $i from 5 through 100 + .w#{$i} + width: $i * 1% + +// Empty zones +=emptyzone($col1, $col2) + background-image: linear-gradient(-45deg, $col1 25%, $col2 25%, $col2 50%, $col1 50%, $col1 75%, $col2 75%, transparent) + background-size: 40px 40px diff --git a/app/assets/stylesheets/components/_buttons.sass b/app/assets/stylesheets/components/_buttons.sass index b2d42584d..00551f7cb 100644 --- a/app/assets/stylesheets/components/_buttons.sass +++ b/app/assets/stylesheets/components/_buttons.sass @@ -63,6 +63,9 @@ table, .table text-align: center padding: 0 + tbody > tr > td.actions, + &.table-2entries .t2e-item > .th + > .btn-group height: 100% width: 100% @@ -79,6 +82,16 @@ table, .table color: #fff transition: 0.2s + &.disabled + cursor: not-allowed + + &, &:hover, &:focus + color: rgba($blue, 0.5) + background-color: rgba($blue, 0) + + > .btn.disabled + opacity: 1 + &.open .dropdown-toggle box-shadow: none @@ -121,3 +134,23 @@ table, .table .fa:first-child margin-right: 0.5em + + &.table-2entries .t2e-item + > .th + position: relative + + > .btn-group + width: auto + height: auto + position: absolute + right: 0 + top: 0 + + .dropdown-menu + left: 0 + right: auto + + &:last-child + > .th > .btn-group .dropdown-menu + left: auto + right: 0 diff --git a/app/assets/stylesheets/components/_dropdown.sass b/app/assets/stylesheets/components/_dropdown.sass new file mode 100644 index 000000000..ee26aaeb5 --- /dev/null +++ b/app/assets/stylesheets/components/_dropdown.sass @@ -0,0 +1,8 @@ +//-------------// +// Dropdowns // +//-------------// + +.dropdown-menu + > .disabled > a + &, &:hover, &:focus + color: rgba($darkgrey, 0.5) diff --git a/app/assets/stylesheets/components/_forms.sass b/app/assets/stylesheets/components/_forms.sass index f4894c46a..307182082 100644 --- a/app/assets/stylesheets/components/_forms.sass +++ b/app/assets/stylesheets/components/_forms.sass @@ -58,11 +58,17 @@ input // Search bar .search_bar position: relative + background-color: rgba($grey, 0.15) + padding: 7px 15px width: 100% + padding-right: 60% > .form-control + vertical-align: top + border-color: rgba($grey, 0.3) border-radius: 4px - padding-right: 31px + height: 31px + padding: 4px 31px 5px 12px &:first-child, &:last-child border-radius: 4px @@ -71,13 +77,13 @@ input position: absolute top: 0 bottom: 0 - right: 0 + right: 60% z-index: 2 width: auto > .btn margin: 0 - padding: 6px 9px + padding: 4px 9px 5px 9px border: none border-radius: 0 background-color: transparent @@ -138,6 +144,46 @@ $cbx-size: 20px &[type='checkbox']:checked + label:before background-color: $blue +// Radio +.has_radio + position: relative + display: block + height: $cbx-size + width: $cbx-size + margin: 0 auto + + > input[type='checkbox'] + &:not(:checked), &:checked + position: absolute + z-index: 5 + margin: 0 + left: 0 + top: 0 + height: $cbx-size + width: $cbx-size + opacity: 0 + cursor: pointer + + + .radio-label + display: inline-block + position: relative + height: $cbx-size + width: $cbx-size + margin: 0 + background-color: #fff + border: 2px solid $blue + border-radius: 50% + // cursor: pointer + + &:checked + .radio-label + background-color: $blue + + &:disabled + cursor: not-allowed + + + .radio-label + opacity: 0.5 + // Switch .has_switch &.form-group @@ -207,10 +253,13 @@ $cbx-size: 20px .form.form-filter display: block position: relative - background-color: lighten($blue, 58%) - padding-right: 167px + background-color: rgba($grey, 0.15) + padding-right: 185px min-height: 42px - border-bottom: 2px solid $darkgrey + border-top: 1px solid #fff + + &:first-child + border-top: none > * display: inline-block @@ -225,7 +274,7 @@ $cbx-size: 20px .control-label font-weight: 700 - color: $blue + color: $darkgrey line-height: 34px margin: 0 padding: 0 10px 0 0 @@ -270,7 +319,6 @@ $cbx-size: 20px &.togglable padding: 7px 44px 7px 15px - // padding-right: 44px cursor: pointer > .control-label @@ -284,7 +332,7 @@ $cbx-size: 20px width: 100% &:hover, &.open - background-color: rgba($blue, 0.4) + background-color: $blue color: #fff > .control-label, &:before diff --git a/app/assets/stylesheets/components/_lists.sass b/app/assets/stylesheets/components/_lists.sass index 53c7df907..d8f83d72b 100644 --- a/app/assets/stylesheets/components/_lists.sass +++ b/app/assets/stylesheets/components/_lists.sass @@ -13,6 +13,7 @@ $dlWidth: 40% text-rendering: optimizespeed font-weight: 300 margin-bottom: 40px + border-bottom: 1px solid rgba($grey, 0.5) .dl-head display: block @@ -27,7 +28,7 @@ $dlWidth: 40% word-spacing: normal text-rendering: auto // overflow: hidden - vertical-align: middle + vertical-align: top padding: 5px 15px 6px 15px // Definition term @@ -36,16 +37,20 @@ $dlWidth: 40% width: $dlWidth font-weight: 700 - &:after + &:before content: '' display: block position: absolute z-index: 1 - bottom: 0 + top: 0 left: 0 width: (100 / ($dlWidth / 1%)) * 100 * 1% border-bottom: 1px solid rgba($grey, 0.5) + &:first-child + &:before + display: none + // Definition .dl-def width: 100% - $dlWidth diff --git a/app/assets/stylesheets/components/_tables.sass b/app/assets/stylesheets/components/_tables.sass index 6b2831035..495e27951 100644 --- a/app/assets/stylesheets/components/_tables.sass +++ b/app/assets/stylesheets/components/_tables.sass @@ -8,6 +8,7 @@ font-size: $h2-size font-weight: 700 border-bottom: 2px solid $darkgrey + vertical-align: middle > a position: relative @@ -65,6 +66,11 @@ > td background-color: whitesmoke + &.has-filter, &.has-search + border-top: 2px solid $darkgrey + margin-top: 15px + + // select_toolbox .select_toolbox padding: 10px @@ -106,11 +112,103 @@ background-color: darken($red, 5%) &.noselect - .st_action > a + > ul > .st_action > a &, &[title='Supprimer'], &:hover, &:focus - background-color: rgba($grey, 0.65) + background-color: rgba($grey, 0.3) cursor: not-allowed > .info-msg font-style: italic font-size: 0.85em + + +//-----------------------------// +// Tables (column by column) // +//-----------------------------// + +.table.table-2entries + display: table + table-layout: fixed + width: 100% + + > * + display: table-cell + vertical-align: top + + .th + padding: 6px 8px + border-bottom: 2px solid rgba($grey, 0.5) + border-top: 1px solid rgba($grey, 0.5) + .td + padding: 6px 8px + border-bottom: 1px solid rgba($grey, 0.5) + word-wrap: break-word + hyphens: auto + + > div + position: relative + height: 100% + + &.headlined:before + content: '' + display: block + border-bottom: 1px solid rgba($grey, 0.5) + margin: -6px -9px 6px -8px + padding: 6px 9px 6px 8px + border-right: 1px solid #fff + height: calc(1.4em + 12px) + overflow: hidden + text-overflow: ellipsis + white-space: nowrap + + .t2e-head + border-right: 1px solid rgba($grey, 0.5) + + .th + text-align: right + border-top-color: transparent + + .td > .headlined + &:before + content: attr(data-headline) + text-transform: uppercase + color: rgba($grey, 0.75) + + .t2e-item-list + +emptyzone(rgba($grey, 0.075), rgba($grey, 0.015)) + + > div + display: inline-block + vertical-align: top + overflow: auto + white-space: nowrap + border-right: 1px solid rgba($grey, 0.5) + max-width: 100% + padding-right: 1px + + .t2e-item + display: inline-block + vertical-align: top + white-space: normal + border-left: 1px solid rgba($grey, 0.5) + background-color: #fff + + &:first-child + border-left: none + + .th + > *:first-child + padding-right: 30px + + .td + > div + > .has_radio + top: 50% + margin-top: -10px + + &.headlined > .has_radio + margin-top: calc((1.4em + 6px) * -1) + + &.disabled + color: rgba($darkgrey, 0.5) + background-color: rgba(#fff, 0.5) diff --git a/app/assets/stylesheets/modules/_jp_collection.sass b/app/assets/stylesheets/modules/_jp_collection.sass new file mode 100644 index 000000000..05485dcf9 --- /dev/null +++ b/app/assets/stylesheets/modules/_jp_collection.sass @@ -0,0 +1,56 @@ +//-----------------// +// JP Collection // +//-----------------// + +#journey_patterns + .table-2entries + .t2e-head + > .td + position: relative + padding-left: 25px + + > .headlined + &:before + margin-left: -25px + padding-left: 25px + + > div > span + position: relative + + &:before + content: '' + display: block + width: 10px + height: 10px + background-color: #fff + border: 2px solid $blue + border-radius: 50% + position: absolute + z-index: 5 + left: -20px + 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: -6px + left: -20px + bottom: -6px + + > .headlined > span + &:after + top: calc((1.4em + 18px) * -1) + + &:last-child > div > span + &:after + bottom: 50% + + &:nth-child(2) > div > span + &:after + top: 50% diff --git a/app/assets/stylesheets/typography/_typography.sass b/app/assets/stylesheets/typography/_typography.sass index b08840781..d0d22e27b 100644 --- a/app/assets/stylesheets/typography/_typography.sass +++ b/app/assets/stylesheets/typography/_typography.sass @@ -25,6 +25,9 @@ p border-color: $blue transition: 0.2s +strong, .strong + font-weight: 700 + // Text coloring .text-danger color: $red diff --git a/app/controllers/journey_patterns_collections_controller.rb b/app/controllers/journey_patterns_collections_controller.rb index 1ee267ffa..d96d7f9c7 100644 --- a/app/controllers/journey_patterns_collections_controller.rb +++ b/app/controllers/journey_patterns_collections_controller.rb @@ -11,8 +11,33 @@ class JourneyPatternsCollectionsController < ChouetteController def show @q = route.journey_patterns.includes(:stop_points) - @ppage = 3 + @ppage = 10 @journey_patterns ||= @q.paginate(page: params[:page], per_page: @ppage).order(:name) + + @stop_points_list = [] + route.stop_points.each do |sp| + @stop_points_list << { + :id => sp.stop_area.id, + :route_id => sp.try(:route_id), + :object_id => sp.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), + :comment => sp.stop_area.try(:comment), + :area_type => sp.stop_area.try(:area_type), + :registration_number => sp.stop_area.try(:registration_number), + :nearest_topic_name => sp.stop_area.try(:nearest_topic_name), + :fare_code => sp.stop_area.try(:fare_code), + :longitude => sp.stop_area.try(:longitude), + :latitude => sp.stop_area.try(:latitude), + :long_lat_type => sp.stop_area.try(:long_lat_type), + :country_code => sp.stop_area.try(:country_code), + :street_name => sp.stop_area.try(:street_name) + } + end end def update diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 1626ae039..3818ea866 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -15,6 +15,14 @@ class WorkbenchesController < BreadcrumbController end end + def delete_referentials + referentials = resource.referentials.where(id: params[:referentials]) + if referentials.destroy_all + flash[:notice] = t('notice.referentials.deleted') + end + redirect_to resource + end + private def sort_column Workbench.find(params[:id]).referentials.include?(params[:sort]) ? params[:sort] : 'name' diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb index 49b717beb..11c794ea3 100644 --- a/app/helpers/newapplication_helper.rb +++ b/app/helpers/newapplication_helper.rb @@ -161,8 +161,7 @@ module NewapplicationHelper def sortable_columns collection, key direction = (key == params[:sort] && params[:direction] == 'desc') ? 'asc' : 'desc' - - link_to({sort: key, direction: direction}) do + link_to(params.merge({direction: direction, sort: key})) do pic1 = content_tag :span, '', class: "fa fa-sort-asc #{(direction == 'desc') ? 'active' : ''}" pic2 = content_tag :span, '', class: "fa fa-sort-desc #{(direction == 'asc') ? 'active' : ''}" @@ -174,12 +173,16 @@ module NewapplicationHelper # Actions on select toolbox (for selectables tables) def select_toolbox(actions) tools = content_tag :ul do - actions.collect do |action| + dPath = nil + dPath = referentials_workbench_path if params[:controller] = 'workbenches' - actitem = link_to '#', title: t("actions.#{action}") do - if action == :edit + actions.collect do |action| + if action == :edit + actitem = link_to('#', title: t("actions.#{action}")) do content_tag :span, '', class: 'fa fa-pencil' - elsif action == :delete + end + elsif action == :delete + actitem = link_to('#', method: :delete, data: { path: dPath, confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' }, title: t("actions.#{action}")) do content_tag :span, '', class: 'fa fa-trash' end end diff --git a/app/models/import.rb b/app/models/import.rb index 8ffac5c5e..c407daa78 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -3,5 +3,12 @@ class Import < ActiveRecord::Base belongs_to :workbench belongs_to :referential + extend Enumerize + enumerize :status, in: %i(new pending successful failed canceled) + validates :file, presence: true + + before_create do + self.token_download = SecureRandom.urlsafe_base64 + end end diff --git a/app/models/import_resource.rb b/app/models/import_resource.rb index f140e1b36..3ddd325fd 100644 --- a/app/models/import_resource.rb +++ b/app/models/import_resource.rb @@ -2,6 +2,11 @@ class ImportResource < ActiveRecord::Base include AASM belongs_to :import + extend Enumerize + enumerize :status, in: %i(new pending successful failed) + + validates_presence_of :name, :type, :reference + aasm column: :status do state :new, :initial => true state :pending diff --git a/app/models/referential_metadata.rb b/app/models/referential_metadata.rb index f3f8e2eff..560bb2371 100644 --- a/app/models/referential_metadata.rb +++ b/app/models/referential_metadata.rb @@ -9,7 +9,7 @@ class ReferentialMetadata < ActiveRecord::Base validates :lines, presence: true validates :periodes, presence: true - scope :include_lines, -> (line_ids) { where('line_ids && ARRAY[?]', line_ids) } + scope :include_lines, -> (line_ids) { where('line_ids && ARRAY[?]::bigint[]', line_ids) } scope :include_dateranges, -> (dateranges) { where('periodes && ARRAY[?]', dateranges) } class Period diff --git a/app/models/workbench.rb b/app/models/workbench.rb index 008f73d46..4023c221b 100644 --- a/app/models/workbench.rb +++ b/app/models/workbench.rb @@ -20,7 +20,7 @@ class Workbench < ActiveRecord::Base if line_ids.empty? Referential.none else - Referential.joins(:metadatas).where(['referential_metadata.line_ids && ARRAY[?]', line_ids]).ready + Referential.joins(:metadatas).where(['referential_metadata.line_ids && ARRAY[?]::bigint[]', line_ids]).ready end end diff --git a/app/views/api/v1/stop_areas/short_description.rabl b/app/views/api/v1/stop_areas/short_description.rabl index fb0213510..7d571b0a2 100644 --- a/app/views/api/v1/stop_areas/short_description.rabl +++ b/app/views/api/v1/stop_areas/short_description.rabl @@ -1,10 +1,9 @@ object @stop_area extends "api/v1/trident_objects/short_description" -[ :id, :name, :area_type, :longitude, :latitude, :long_lat_type].each do |attr| +[:id, :name, :city_name, :zip_code, :area_type, :longitude, :latitude, :long_lat_type].each do |attr| attributes attr, :unless => lambda { |m| m.send( attr).nil?} end node(:parent_object_id) do |stop_area| stop_area.parent.objectid end unless root_object.parent.nil? - diff --git a/app/views/api/v1/stop_areas/show.rabl b/app/views/api/v1/stop_areas/show.rabl index 1a0acecc5..3d4e5ba55 100644 --- a/app/views/api/v1/stop_areas/show.rabl +++ b/app/views/api/v1/stop_areas/show.rabl @@ -1,7 +1,7 @@ object @stop_area extends "api/v1/trident_objects/show" -[ :name, :area_type,:nearest_topic_name, :fare_code, :registration_number, +[:name, :area_type, :nearest_topic_name, :fare_code, :registration_number, :longitude, :latitude, :long_lat_type, :country_code, :street_name, :projection_x, :projection_y, :projection, :comment ].each do |attr| @@ -10,7 +10,7 @@ end node(:routing_stop_area_object_ids) do |stop_area| stop_area.routing_stops.map(&:objectid) -end unless root_object.routing_stops.empty? +end unless root_object.routing_stops.empty? node(:routing_line_object_ids) do |stop_area| stop_area.routing_lines.map(&:objectid) diff --git a/app/views/companies/index.html.slim b/app/views/companies/index.html.slim index 97d70190a..b07696a79 100644 --- a/app/views/companies/index.html.slim +++ b/app/views/companies/index.html.slim @@ -10,7 +10,11 @@ .container-fluid - if params[:q].present? or @companies.any? .row.mb-sm - .col-lg-5.col-md-6.col-sm-6.col-xs-8 + .col-lg-12.text-right + = new_pagination @companies + + .row + .col-lg-12 = search_form_for @q, url: line_referential_companies_path(@line_referential), html: {method: :get} do |f| .input-group.search_bar = f.search_field :name_or_objectid_cont, placeholder: t('.name_or_objectid'), class: 'form-control' @@ -19,9 +23,6 @@ button.btn.btn-default#search-btn type='submit' span.fa.fa-search - .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right - = new_pagination @companies - - if @companies.any? .row .col-lg-12 @@ -29,7 +30,7 @@ { 'Oid' => Proc.new { |n| n.try(:objectid).try(:local_id) }, @companies.human_attribute_name(:name) => 'name' }, [:show, :edit, :delete], [], - 'table' + 'table has-search' = new_pagination @companies, 'pull-right' diff --git a/app/views/journey_patterns_collections/show.html.slim b/app/views/journey_patterns_collections/show.html.slim index 28fdaf1ae..a2058fa64 100644 --- a/app/views/journey_patterns_collections/show.html.slim +++ b/app/views/journey_patterns_collections/show.html.slim @@ -2,7 +2,7 @@ = pageheader 'map-marker', "Missions de #{@route.name}", 'Lorem ipsum dolor sit amet', - t('last_update', time: l(@journey_patterns.last.updated_at, format: :short)) + (@journey_patterns.any? ? t('last_update', time: l(@journey_patterns.last.updated_at, format: :short)) : '') / PageContent .page_content @@ -13,6 +13,7 @@ = javascript_tag do + | window.stopPoints = #{(@stop_points_list.to_json).html_safe}; | window.journeyPatternLength = #{@journey_patterns.total_entries()}; | window.journeyPatternsPerPage = #{@ppage} = javascript_include_tag 'es6_browserified/journey_patterns/index.js' diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim index 6d22e6080..bcda959f7 100644 --- a/app/views/layouts/navigation/_main_nav_left.html.slim +++ b/app/views/layouts/navigation/_main_nav_left.html.slim @@ -74,17 +74,17 @@ #miFive.panel-collapse.collapse .list-group - = link_to '#', target: '_blank', class: 'list-group-item' do + = link_to Rails.application.config.try(:portal_url), target: '_blank', class: 'list-group-item' do span span.fa.fa-2x.fa-circle |Portail (POSTIF) - = link_to '#', target: '_blank', class: 'list-group-item' do + = link_to Rails.application.config.try(:codifligne_url), target: '_blank', class: 'list-group-item' do span span.fa.fa-2x.fa-circle |Codifligne (iLLICO) - = link_to '#', target: '_blank', class: 'list-group-item' do + = link_to Rails.application.config.try(:reflex_url), target: '_blank', class: 'list-group-item' do span span.fa.fa-2x.fa-circle |Reflex (iCAR) diff --git a/app/views/line_footnotes/edit.html.slim b/app/views/line_footnotes/edit.html.slim index 28e41b089..0dda8bf0f 100644 --- a/app/views/line_footnotes/edit.html.slim +++ b/app/views/line_footnotes/edit.html.slim @@ -2,7 +2,7 @@ = pageheader 'map-marker', "Notes sur la ligne #{@line.name}", 'Lorem ipsum dolor sit amet', - t('last_update', time: l(@line.footnotes.last.updated_at, format: :short)) + (@line.footnotes.any? ? t('last_update', time: l(@line.footnotes.last.updated_at, format: :short)) : '') / PageContent .page_content diff --git a/app/views/line_footnotes/show.html.slim b/app/views/line_footnotes/show.html.slim index e32d97292..36eebe288 100644 --- a/app/views/line_footnotes/show.html.slim +++ b/app/views/line_footnotes/show.html.slim @@ -2,7 +2,7 @@ = pageheader 'map-marker', "Notes sur la ligne #{@line.name}", 'Lorem ipsum dolor sit amet', - t('last_update', time: l(@line.footnotes.last.updated_at, format: :short)), + (@line.footnotes.any? ? t('last_update', time: l(@line.footnotes.last.updated_at, format: :short)) : ''), (policy(@line).update_footnote? ? link_to(t('actions.edit'), edit_referential_line_footnotes_path(@referential, @line), class: 'btn btn-primary') : '') / PageContent diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim index 056733a55..8e8a73e1b 100644 --- a/app/views/lines/index.html.slim +++ b/app/views/lines/index.html.slim @@ -10,20 +10,19 @@ .container-fluid - if params[:q].present? or @lines.any? .row.mb-sm - .col-lg-5.col-md-6.col-sm-6.col-xs-8 + .col-lg-12.text-right + = new_pagination @lines + + .row + .col-lg-12 = search_form_for @q, url: line_referential_lines_path(@line_referential), html: {method: :get} do |f| .input-group.search_bar - = f.search_field :name_or_number_or_objectid_cont, placeholder: t('lines.index.name_or_number_or_objectid'), class: 'form-control' + = f.search_field :name_or_objectid_cont, placeholder: t('lines.index.name_or_objectid'), class: 'form-control' span.input-group-btn button.btn.btn-default#search-btn type='submit' span.fa.fa-search - .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right - = new_pagination @lines - - .row - .col-lg-12 = render 'filters' - if @lines.any? @@ -35,9 +34,9 @@ @lines.human_attribute_name(:company) => Proc.new { |n| n.try(:company).try(:name) }, @lines.human_attribute_name(:transport_mode) => Proc.new { |n| n.transport_mode.nil? ? '-' : t("enumerize.line.transport_mode.#{n.try(:transport_mode)}") }, @lines.human_attribute_name(:transport_submode) => Proc.new { |n| n.transport_submode.nil? ? '-' : t("enumerize.line.transport_submode.#{n.try(:transport_submode)}") } }, - [:show], - [:delete], - 'table' + [:show, :delete], + [], + 'table has-filter has-search' = new_pagination @lines, 'pull-right' diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim index 0589b1923..9dbdd2bfe 100644 --- a/app/views/lines/show.html.slim +++ b/app/views/lines/show.html.slim @@ -24,13 +24,19 @@ .container-fluid .row .col-lg-6.col-md-6.col-sm-12.col-xs-12 + p = 'toto' + ul + - @line.secondary_companies.each do |sc| + li = sc.inspect + = definition_list t('metadatas'), - { 'Activé' => (@line.deactivated? ? t('false') : t('true')), + { 'ID Codif' => @line.objectid.local_id, + 'Activé' => (@line.deactivated? ? t('false') : t('true')), @line.human_attribute_name(:network) => (@line.network.nil? ? t('lines.index.unset') : @line.network.name), @line.human_attribute_name(:company) => (@line.company.nil? ? t('lines.index.unset') : @line.company.name), - @line.human_attribute_name(:number) => @line.number, - @line.human_attribute_name(:published_name) => @line.published_name, - @line.human_attribute_name(:registration_number) => @line.registration_number, + # 'Transporteur(s) secondaire(s)' => (@line.secondary_companies.nil? ? t('lines.index.unset') : @line.secondary_companies.pluck(:name)), + 'Nom court' => @line.number, + 'Code public' => (@line.registration_number ? @line.registration_number : '-'), @line.human_attribute_name(:transport_mode) => (@line.transport_mode ? t("enumerize.line.transport_mode.#{@line.transport_mode}") : '-'), @line.human_attribute_name(:transport_submode) => (@line.transport_submode ? t("enumerize.line.transport_submode.#{@line.transport_submode}") : '-'), @line.human_attribute_name(:url) => (@line.url ? @line.url : '-') } diff --git a/app/views/networks/index.html.slim b/app/views/networks/index.html.slim index 2bc934f61..d99f612bc 100644 --- a/app/views/networks/index.html.slim +++ b/app/views/networks/index.html.slim @@ -10,7 +10,11 @@ .container-fluid - if params[:q].present? or @networks.any? .row.mb-sm - .col-lg-5.col-md-6.col-sm-6.col-xs-8 + .col-lg-12.text-right + = new_pagination @networks + + .row + .col-lg-12 = search_form_for @q, url: line_referential_networks_path(@line_referential), html: {method: :get} do |f| .input-group.search_bar = f.search_field :name_or_objectid_cont, placeholder: t('.name_or_objectid'), class: 'form-control' @@ -19,9 +23,6 @@ button.btn.btn-default#search-btn type='submit' span.fa.fa-search - .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right - = new_pagination @networks - - if @networks.any? .row .col-lg-12 @@ -29,7 +30,7 @@ { 'Oid' => Proc.new { |n| n.try(:objectid).try(:local_id) }, @networks.human_attribute_name(:name) => 'name' }, [:show, :edit, :delete], [], - 'table' + 'table has-search' = new_pagination @networks, 'pull-right' diff --git a/app/views/referential_companies/index.html.slim b/app/views/referential_companies/index.html.slim index 4f6040e5d..3b9f3bb06 100644 --- a/app/views/referential_companies/index.html.slim +++ b/app/views/referential_companies/index.html.slim @@ -10,7 +10,11 @@ .container-fluid - if params[:q].present? or @companies.any? .row.mb-sm - .col-lg-5.col-md-6.col-sm-6.col-xs-8 + .col-lg-12.text-right + = new_pagination @companies + + .row + .col-lg-12 = search_form_for @q, url: referential_companies_path(@referential), html: {method: :get} do |f| .input-group.search_bar = f.text_field :name_or_objectid_cont, placeholder: t('.name_or_objectid'), class: 'form-control' @@ -19,9 +23,6 @@ button.btn.btn-default#search-btn type="submit" span.fa.fa-search - .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right - = new_pagination @companies - - if @companies.any? .row .col-lg-12 @@ -30,7 +31,7 @@ @companies.human_attribute_name(:name) => 'name', @companies.human_attribute_name(:phone) => 'phone', @companies.human_attribute_name(:email) => 'email', @companies.human_attribute_name(:url) => 'url' }, [:show, :edit, :delete], [], - 'table' + 'table has-search' = new_pagination @companies, 'pull-right' diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index c0acc6309..5f95463c4 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -32,12 +32,13 @@ .row .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), - { 'Activé' => (@line.deactivated? ? t('false') : t('true')), + { 'ID Codif' => @line.objectid.local_id, + 'Activé' => (@line.deactivated? ? t('false') : t('true')), @line.human_attribute_name(:network) => (@line.network.nil? ? t('lines.index.unset') : @line.network.name), @line.human_attribute_name(:company) => (@line.company.nil? ? t('lines.index.unset') : @line.company.name), - @line.human_attribute_name(:number) => @line.number, - @line.human_attribute_name(:published_name) => @line.published_name, - @line.human_attribute_name(:registration_number) => @line.registration_number, + 'Transporteur(s) secondaire(s)' => (@line.secondary_companies.nil? ? t('lines.index.unset') : @line.secondary_companies.collect(&:name).join(', ')), + 'Nom court' => @line.number, + 'Code public' => (@line.registration_number ? @line.registration_number : '-'), @line.human_attribute_name(:transport_mode) => (@line.transport_mode ? t("enumerize.line.transport_mode.#{@line.transport_mode}") : '-'), @line.human_attribute_name(:transport_submode) => (@line.transport_submode ? t("enumerize.line.transport_submode.#{@line.transport_submode}") : '-'), @line.human_attribute_name(:url) => (@line.url ? @line.url : '-') } @@ -46,7 +47,11 @@ .col-lg-12 - if params[:q].present? or @routes.any? .row.mb-sm - .col-lg-5.col-md-6.col-sm-6.col-xs-8 + .col-lg-12.text-right + = new_pagination @routes + + .row + .col-lg-12 = search_form_for @q, url: referential_line_path(@referential, @line) do |f| .input-group.search_bar = f.search_field :name_cont, class: 'form-control', placeholder: "Indiquez un nom d'itinéraire..." @@ -55,20 +60,21 @@ button.btn.btn-default type='submit' span.fa.fa-search - .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right - = new_pagination @routes - if @routes.any? .row - .col-lg-12 + .col-lg-12 = table_builder @routes, - { @routes.human_attribute_name(:number) => 'number', @routes.human_attribute_name(:name) => 'name', - 'Arrêt de départ' => Proc.new{|r| r.try(:stop_points).first.try(:stop_area).try(:name)}, - "Arrêt d'arrivée" => Proc.new{|r| r.try(:stop_points).last.try(:stop_area).try(:name)}, - 'Nb arrêts' => Proc.new{|r| r.try(:stop_points).count}, 'Nb missions' => Proc.new{|r| r.try(:journey_patterns).count} }, + { 'OiD' => Proc.new { |n| n.objectid.local_id }, + @routes.human_attribute_name(:name) => 'name', + @routes.human_attribute_name(:published_name) => 'published_name', + @routes.human_attribute_name(:wayback) => 'wayback_text', + 'Arrêt de départ' => Proc.new{|r| r.try(:stop_points).first.try(:stop_area).try(:name)}, + "Arrêt d'arrivée" => Proc.new{|r| r.try(:stop_points).last.try(:stop_area).try(:name)}, + 'Nb arrêts' => Proc.new{|r| r.try(:stop_points).count}, 'Nb missions' => Proc.new{|r| r.try(:journey_patterns).count} }, [:show, :edit, :delete], [], - 'table' + 'table has-search' = new_pagination @routes, 'pull-right' diff --git a/app/views/referential_networks/index.html.slim b/app/views/referential_networks/index.html.slim index 9619035c4..ba2c5b2c1 100644 --- a/app/views/referential_networks/index.html.slim +++ b/app/views/referential_networks/index.html.slim @@ -10,7 +10,11 @@ .container-fluid - if params[:q].present? or @networks.any? .row.mb-sm - .col-lg-5.col-md-6.col-sm-6.col-xs-8 + .col-lg-12.text-right + = new_pagination @networks + + .row + .col-lg-12 = search_form_for @q, url: referential_networks_path(@referential), html: {method: :get} do |f| .input-group.search_bar = f.text_field :name_or_objectid_cont, placeholder: t('.name_or_objectid'), class: 'form-control' @@ -19,9 +23,6 @@ button.btn.btn-default#search_btn type="submit" span.fa.fa-search - .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right - = new_pagination @networks - - if @networks.any? .row .col-lg-12 @@ -29,7 +30,7 @@ { 'ID Codif' => Proc.new { |n| n.try(:objectid).try(:local_id) }, @networks.human_attribute_name(:name) => 'name' }, [:show, :edit, :delete], [], - 'table' + 'table has-search' = new_pagination @networks, 'pull-right' diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim index 9affba08e..7932b6c2e 100644 --- a/app/views/referential_stop_areas/show.html.slim +++ b/app/views/referential_stop_areas/show.html.slim @@ -20,10 +20,11 @@ .row .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), - { @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"), + { 'ID Reflex' => @stop_area.try(:user_objectid), + 'Activé' => (@stop_area.deleted_at ? t('false') : t('true')), + @stop_area.human_attribute_name(:comment) => @stop_area.try(:comment), + @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"), @stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number, - 'Code Reflex' => @stop_area.try(:objectid), 'Coordonnées' => geo_data(@stop_area, @stop_area_referential), @stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code, - @stop_area.human_attribute_name(:city_name) => @stop_area.city_name, - 'Etat' => (@stop_area.deleted_at ? 'Supprimé' : 'Actif') } + @stop_area.human_attribute_name(:city_name) => @stop_area.city_name } diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim index ff4d3e64b..fa89b220d 100644 --- a/app/views/referentials/show.html.slim +++ b/app/views/referentials/show.html.slim @@ -35,7 +35,11 @@ - if params[:q].present? or @reflines.any? .row.mb-sm - .col-lg-5.col-md-6.col-sm-6.col-xs-8 + .col-lg-12.text-right + = new_pagination @reflines + + .row + .col-lg-12 = search_form_for @q, url: referential_path(@referential.id) do |f| .input-group.search_bar = f.search_field :name_cont, class: 'form-control', placeholder: 'Indiquez un nom de ligne' @@ -44,11 +48,6 @@ button.btn.btn-default type='submit' span.fa.fa-search - .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right - = new_pagination @reflines - - .row - .col-lg-12 = render 'filters' - if @reflines.any? @@ -56,14 +55,16 @@ .col-lg-12 / ID Codif, nom court, nom de la ligne, réseau, mode, transporteur principal, actions = [show, edit_notes] = table_builder @reflines, - { 'ID Codif' => Proc.new { |n| n.objectid.local_id }, @reflines.human_attribute_name(:registration_number) => 'registration_number', + { 'ID Codif' => Proc.new { |n| n.objectid.local_id }, + 'Nom court' => 'number', @reflines.human_attribute_name(:name) => 'name', + 'Activé' => Proc.new{|n| n.deactivated? ? t('false') : t('true')}, @reflines.human_attribute_name(:transport_mode) => 'transport_mode', @reflines.human_attribute_name(:network) => Proc.new { |n| n.try(:network).try(:name) }, @reflines.human_attribute_name(:company) => Proc.new { |n| n.try(:company).try(:name) } }, [:show], [], - 'table' + 'table has-filter has-search' = new_pagination @reflines, 'pull-right' diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim index 428c82c58..88b93bb06 100644 --- a/app/views/routes/show.html.slim +++ b/app/views/routes/show.html.slim @@ -8,8 +8,8 @@ / Below is secundary actions & optional contents (filters, ...) .row.mb-sm .col-lg-12.text-right + = link_to t('journey_patterns.index.title'), [@referential, @line, @route, :journey_patterns_collection], class: 'btn btn-primary' - if @route.journey_patterns.present? - = link_to t('journey_patterns.index.title'), [@referential, @line, @route, :journey_patterns_collection], class: 'btn btn-primary' = link_to t('vehicle_journeys.actions.index'), [@referential, @line, @route, :vehicle_journeys], class: 'btn btn-primary' = link_to t('vehicle_journey_exports.new.title'), referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, format: :zip), class: 'btn btn-primary' @@ -25,7 +25,8 @@ .row .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), - { @route.human_attribute_name(:direction) => (@route.direction ? @route.direction_text : '-'), + { 'OiD' => @route.try(:objectid).try(:local_id), + 'Direction' => (@route.published_name ? @route.published_name : '-'), @route.human_attribute_name(:wayback) => (@route.wayback ? @route.wayback_text : '-' ), @route.human_attribute_name(:opposite_route) => (@route.opposite_route ? @route.opposite_route.name : '-') } @@ -35,10 +36,11 @@ = table_builder @route_sp, { 'ID Reflex' => Proc.new {|s| s.try(:stop_area).try(:user_objectid)}, Chouette::StopArea.human_attribute_name(:name) => Proc.new {|s| s.try(:stop_area).try(:name)}, + 'Activé' => Proc.new{|s| s.try(:stop_area).deleted_at ? t('false') : t('true')}, Chouette::StopArea.human_attribute_name(:zip_code) => Proc.new {|s| s.try(:stop_area).try(:zip_code)}, Chouette::StopArea.human_attribute_name(:city_name) => Proc.new {|s| s.try(:stop_area).try(:city_name)}, Chouette::StopArea.human_attribute_name(:area_type) => Proc.new {|s| t("area_types.label.#{s.try(:stop_area).try(:area_type)}")}, - Chouette::StopArea.human_attribute_name(:for_boarding) => Proc.new {|s| t("stop_points.stop_point.for_boarding.#{s.for_boarding}")}, Chouette::StopArea.human_attribute_name(:for_alighting) => Proc.new {|s| t("stop_points.stop_point.for_alighting.#{s.for_alighting}")}, 'Position' => 'position' }, + Chouette::StopPoint.human_attribute_name(:for_boarding) => Proc.new {|s| t("stop_points.stop_point.for_boarding.#{s.for_boarding}")}, Chouette::StopPoint.human_attribute_name(:for_alighting) => Proc.new {|s| t("stop_points.stop_point.for_alighting.#{s.for_alighting}")}, 'Position' => 'position' }, [:show], [], 'table' diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim index 8baa81ab0..4ca3007ed 100644 --- a/app/views/stop_areas/index.html.slim +++ b/app/views/stop_areas/index.html.slim @@ -10,7 +10,11 @@ .container-fluid - if params[:q].present? or @stop_areas.any? .row.mb-sm - .col-lg-5.col-md-6.col-sm-6.col-xs-8 + .col-lg-12.text-right + = new_pagination @stop_areas + + .row + .col-lg-12 = search_form_for @q, url: stop_area_referential_stop_areas_path(@stop_area_referential), html: {method: :get} do |f| .input-group.search_bar = f.search_field :name_or_objectid_cont, placeholder: t('.name_or_objectid'), class: 'form-control' @@ -19,11 +23,6 @@ button.btn.btn-default#search-btn type='submit' span.fa.fa-search - .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right - = new_pagination @stop_areas - - .row - .col-lg-12 = render 'filters' - if @stop_areas.any? @@ -34,7 +33,7 @@ @stop_areas.human_attribute_name(:city_name) => 'city_name', @stop_areas.human_attribute_name(:area_type) => Proc.new{|s| (s.area_type.nil? ? '-' : t("enumerize.stop_area.area_type.#{s.try(:area_type)}"))} }, [:show, :edit, :delete], [], - 'table' + 'table has-filter has-search' = new_pagination @stop_areas, 'pull-right' diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index d6b7a5b4e..880b7d20b 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -14,18 +14,18 @@ .container-fluid - if params[:q].present? or @wbench_refs.any? .row.mb-sm - .col-lg-5.col-md-6.col-sm-6.col-xs-8 + .col-lg-12.text-right + = new_pagination @wbench_refs + + .row + .col-lg-12 = search_form_for @q, url: workbench_path(@workbench.id), builder: SimpleForm::FormBuilder do |f| .input-group.search_bar = f.search_field :name_cont, class: 'form-control', placeholder: 'Indiquez un nom de référentiel' span.input-group-btn button.btn.btn-default type='submit' span.fa.fa-search - .col-lg-7.col-md-6.col-sm-6.col-xs-4.text-right - = new_pagination @wbench_refs - .row - .col-lg-12 = render 'filters' - if @wbench_refs.any? @@ -41,7 +41,7 @@ @wbench_refs.human_attribute_name(:published_at) => ''}, [:show, :edit, :archive, :unarchive, :delete], [:delete], - 'table' + 'table has-filter has-search' = new_pagination @wbench_refs, 'pull-right' diff --git a/config/environments/development.rb b/config/environments/development.rb index 95819a5c2..61a0b97e9 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -73,6 +73,11 @@ Rails.application.configure do url: "http://stif-portail-dev.af83.priv" } + # Ext. apps links + config.reflex_url = "https://195.46.215.128" + config.codifligne_url = "https://pprod.codifligne.stif.info" + config.portal_url = "http://stif-boiv-staging.af83.priv" + # file to data for demo config.demo_data = "tmp/demo.zip" diff --git a/config/locales/enumerize.en.yml b/config/locales/enumerize.en.yml index f98672236..8857e593c 100644 --- a/config/locales/enumerize.en.yml +++ b/config/locales/enumerize.en.yml @@ -5,6 +5,19 @@ en: for_boarding: "Undefined" for_alighting: "Undefined" enumerize: + import: + status: + new: New + pending: Pending + successful: Successful + failed: Failed + canceled: Canceled + import_resource: + status: + new: New + pending: Pending + successful: Successful + failed: Failed for_boarding: normal: "Regularly scheduled pickup" forbidden: "No pickup available" diff --git a/config/locales/enumerize.fr.yml b/config/locales/enumerize.fr.yml index 9ff4546da..6ce7fd1cc 100644 --- a/config/locales/enumerize.fr.yml +++ b/config/locales/enumerize.fr.yml @@ -5,6 +5,19 @@ fr: for_boarding: "Non défini" for_alighting: "Non défini" enumerize: + import: + status: + new: Nouveau + pending: En file d'attente + successful: Réussi + failed: Echoué + canceled: Annulé + import_resource: + status: + new: Nouveau + pending: En file d'attente + successful: Réussi + failed: Echoué for_boarding: normal: "Montée autorisée" forbidden: "Montée interdite" diff --git a/config/locales/lines.en.yml b/config/locales/lines.en.yml index c9cec146b..35df30037 100644 --- a/config/locales/lines.en.yml +++ b/config/locales/lines.en.yml @@ -27,7 +27,7 @@ en: deactivated: "Disabled line" title: "Lines" name_or_number: "Search by name or number..." - name_or_number_or_objectid: "Search by name, number or objectid..." + name_or_objectid: "Search by name or objectid..." no_networks: "No networks" no_companies: "No companies" no_group_of_lines: "No group of lines" diff --git a/config/locales/lines.fr.yml b/config/locales/lines.fr.yml index d89020b4b..c12b233cd 100644 --- a/config/locales/lines.fr.yml +++ b/config/locales/lines.fr.yml @@ -27,7 +27,7 @@ fr: deactivated: "Ligne désactivée" title: "Lignes" name_or_number: "Recherche par nom ou indice..." - name_or_number_or_objectid: "Recherche par nom, indice ou objectid..." + name_or_objectid: "Recherche par nom ou objectid..." no_networks: "Aucun réseaux" no_companies: "Aucun transporteurs" no_group_of_lines: "Aucun groupes de ligne" diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml index 183518094..2c28d04a2 100644 --- a/config/locales/referentials.en.yml +++ b/config/locales/referentials.en.yml @@ -107,6 +107,8 @@ en: end: 'Period end' notice: + referentials: + deleted: "Datasets has been successfully destroyed" referential: archived: "The data space has been successfully archived" unarchived: "The data space has been successfully unarchived" diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml index 13e3d3d18..17ea64a56 100644 --- a/config/locales/referentials.fr.yml +++ b/config/locales/referentials.fr.yml @@ -107,6 +107,8 @@ fr: end: 'Fin de période' notice: + referentials: + deleted: "Les jeux de données on été supprimés" referential: archived: "Le jeu de données a été correctement archivé" unarchived: "Le jeu de données a été correctement désarchivé" diff --git a/config/locales/stop_points.en.yml b/config/locales/stop_points.en.yml index c09a9f7fe..4c8eb2c7f 100644 --- a/config/locales/stop_points.en.yml +++ b/config/locales/stop_points.en.yml @@ -41,6 +41,8 @@ en: lines: "lines" created_at: Created at updated_at: Updated at + for_boarding: "For boarding" + for_alighting: "For alighting" simple_form: labels: stop_point: diff --git a/config/locales/stop_points.fr.yml b/config/locales/stop_points.fr.yml index 1c4ed09ed..217bd9825 100644 --- a/config/locales/stop_points.fr.yml +++ b/config/locales/stop_points.fr.yml @@ -41,6 +41,8 @@ fr: lines: "Lignes" created_at: "Créé le" updated_at: "Modifié le" + for_boarding: "Montée" + for_alighting: "Descente" simple_form: labels: stop_point: diff --git a/config/routes.rb b/config/routes.rb index 2a912124d..6e26cbd72 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ require 'sidekiq/web' ChouetteIhm::Application.routes.draw do resources :workbenches, :only => [:show] do + delete :referentials, on: :member, action: :delete_referentials resources :imports end diff --git a/db/migrate/20170228135627_add_dates_and_token_to_import.rb b/db/migrate/20170228135627_add_dates_and_token_to_import.rb new file mode 100644 index 000000000..fa4be85ed --- /dev/null +++ b/db/migrate/20170228135627_add_dates_and_token_to_import.rb @@ -0,0 +1,7 @@ +class AddDatesAndTokenToImport < ActiveRecord::Migration + def change + add_column :imports, :started_at, :date + add_column :imports, :ended_at, :date + add_column :imports, :token_download, :string + end +end diff --git a/db/migrate/20170301145604_change_foreign_keys_to_bigint.rb b/db/migrate/20170301145604_change_foreign_keys_to_bigint.rb new file mode 100644 index 000000000..cc89198c5 --- /dev/null +++ b/db/migrate/20170301145604_change_foreign_keys_to_bigint.rb @@ -0,0 +1,46 @@ +class ChangeForeignKeysToBigint < ActiveRecord::Migration + def change + change_column :stop_area_referential_syncs, :stop_area_referential_id, :bigint + change_column :stop_area_referential_sync_messages, :stop_area_referential_sync_id, :bigint + change_column :stop_area_referential_memberships, :organisation_id, :bigint + change_column :stop_area_referential_memberships, :stop_area_referential_id, :bigint + change_column :line_referential_memberships, :organisation_id, :bigint + change_column :line_referential_memberships, :line_referential_id, :bigint + change_column :line_referential_sync_messages, :line_referential_sync_id, :bigint + change_column :line_referential_syncs, :line_referential_id, :bigint + change_column :referential_metadata, :referential_id, :bigint + change_column :referential_metadata, :line_ids, :bigint, array: true + change_column :referential_metadata, :referential_source_id, :bigint + change_column :workbenches, :organisation_id, :bigint + change_column :workbenches, :line_referential_id, :bigint + change_column :workbenches, :stop_area_referential_id, :bigint + change_column :api_keys, :referential_id, :bigint + change_column :calendars, :organisation_id, :bigint + change_column :clean_up_results, :clean_up_id, :bigint + change_column :clean_ups, :referential_id, :bigint + change_column :companies, :line_referential_id, :bigint + change_column :group_of_lines, :line_referential_id, :bigint + change_column :import_messages, :import_id, :bigint + change_column :import_messages, :resource_id, :bigint + change_column :import_resources, :import_id, :bigint + change_column :imports, :workbench_id, :bigint + change_column :imports, :referential_id, :bigint + change_column :lines, :line_referential_id, :bigint + change_column :lines, :secondary_company_ids, :bigint, array: true + change_column :networks, :line_referential_id, :bigint + change_column :referential_clonings, :source_referential_id, :bigint + change_column :referential_clonings, :target_referential_id, :bigint + change_column :referentials, :line_referential_id, :bigint + change_column :referentials, :stop_area_referential_id, :bigint + change_column :referentials, :workbench_id, :bigint + change_column :referentials, :created_from_id, :bigint + change_column :routing_constraint_zones, :line_id, :bigint + change_column :stop_areas, :stop_area_referential_id, :bigint + change_column :taggings, :tag_id, :bigint + change_column :taggings, :taggable_id, :bigint + change_column :taggings, :tagger_id, :bigint + change_column :time_tables, :calendar_id, :bigint + change_column :users, :organisation_id, :bigint + change_column :users, :invited_by_id, :bigint + end +end diff --git a/db/migrate/20170301165631_add_resource_attributes_to_import_messages.rb b/db/migrate/20170301165631_add_resource_attributes_to_import_messages.rb new file mode 100644 index 000000000..d180bdcb9 --- /dev/null +++ b/db/migrate/20170301165631_add_resource_attributes_to_import_messages.rb @@ -0,0 +1,5 @@ +class AddResourceAttributesToImportMessages < ActiveRecord::Migration + def change + add_column :import_messages, :resource_attributes, :hstore + end +end diff --git a/db/migrate/20170301170956_add_attributes_to_import_resource.rb b/db/migrate/20170301170956_add_attributes_to_import_resource.rb new file mode 100644 index 000000000..b7da38d80 --- /dev/null +++ b/db/migrate/20170301170956_add_attributes_to_import_resource.rb @@ -0,0 +1,8 @@ +class AddAttributesToImportResource < ActiveRecord::Migration + def change + add_column :import_resources, :type, :string + add_column :import_resources, :reference, :string + add_column :import_resources, :name, :string + add_column :import_resources, :metrics, :hstore + end +end diff --git a/db/schema.rb b/db/schema.rb index 0dcd5457c..6ee6bb4ea 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,8 +11,8 @@ # # It's strongly recommended that you check this file into your version control system. +ActiveRecord::Schema.define(version: 20170301170956) do -ActiveRecord::Schema.define(version: 20170215163027) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "postgis" @@ -72,7 +72,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do add_index "access_points", ["objectid"], :name => "access_points_objectid_key", :unique => true create_table "api_keys", force: true do |t| - t.integer "referential_id" + t.integer "referential_id", limit: 8 t.string "token" t.string "name" t.datetime "created_at" @@ -82,10 +82,10 @@ ActiveRecord::Schema.define(version: 20170215163027) do create_table "calendars", force: true do |t| t.string "name" t.string "short_name" - t.daterange "date_ranges", array: true - t.date "dates", array: true + t.daterange "date_ranges", array: true + t.date "dates", array: true t.boolean "shared" - t.integer "organisation_id" + t.integer "organisation_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" end @@ -96,7 +96,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do create_table "clean_up_results", force: true do |t| t.string "message_key" t.hstore "message_attributs" - t.integer "clean_up_id" + t.integer "clean_up_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" end @@ -107,7 +107,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.string "status" t.datetime "started_at" t.datetime "ended_at" - t.integer "referential_id" + t.integer "referential_id", limit: 8 t.datetime "begin_date" t.datetime "created_at" t.datetime "updated_at" @@ -131,7 +131,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.string "registration_number" t.string "url" t.string "time_zone" - t.integer "line_referential_id" + t.integer "line_referential_id", limit: 8 t.text "import_xml" t.datetime "created_at" t.datetime "updated_at" @@ -229,7 +229,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.string "name" t.string "comment" t.string "registration_number" - t.integer "line_referential_id" + t.integer "line_referential_id", limit: 8 t.text "import_xml" t.datetime "created_at" t.datetime "updated_at" @@ -247,20 +247,25 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.integer "criticity" t.string "message_key" t.hstore "message_attributs" - t.integer "import_id" - t.integer "resource_id" + t.integer "import_id", limit: 8 + t.integer "resource_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" + t.hstore "resource_attributes" end add_index "import_messages", ["import_id"], :name => "index_import_messages_on_import_id" add_index "import_messages", ["resource_id"], :name => "index_import_messages_on_resource_id" create_table "import_resources", force: true do |t| - t.integer "import_id" + t.integer "import_id", limit: 8 t.string "status" t.datetime "created_at" t.datetime "updated_at" + t.string "type" + t.string "reference" + t.string "name" + t.hstore "metrics" end add_index "import_resources", ["import_id"], :name => "index_import_resources_on_import_id" @@ -269,12 +274,15 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.string "status" t.string "current_step_id" t.float "current_step_progress" - t.integer "workbench_id" - t.integer "referential_id" + t.integer "workbench_id", limit: 8 + t.integer "referential_id", limit: 8 t.string "name" t.datetime "created_at" t.datetime "updated_at" t.string "file" + t.date "started_at" + t.date "ended_at" + t.string "token_download" end add_index "imports", ["referential_id"], :name => "index_imports_on_referential_id" @@ -332,8 +340,8 @@ ActiveRecord::Schema.define(version: 20170215163027) do add_index "journey_patterns_stop_points", ["journey_pattern_id"], :name => "index_journey_pattern_id_on_journey_patterns_stop_points" create_table "line_referential_memberships", force: true do |t| - t.integer "organisation_id" - t.integer "line_referential_id" + t.integer "organisation_id", limit: 8 + t.integer "line_referential_id", limit: 8 t.boolean "owner" end @@ -341,7 +349,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.integer "criticity" t.string "message_key" t.hstore "message_attributs" - t.integer "line_referential_sync_id" + t.integer "line_referential_sync_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" end @@ -349,7 +357,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do add_index "line_referential_sync_messages", ["line_referential_sync_id"], :name => "line_referential_sync_id" create_table "line_referential_syncs", force: true do |t| - t.integer "line_referential_id" + t.integer "line_referential_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" t.datetime "started_at" @@ -385,11 +393,11 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.string "color", limit: 6 t.string "text_color", limit: 6 t.string "stable_id" - t.integer "line_referential_id" + t.integer "line_referential_id", limit: 8 t.boolean "deactivated", default: false t.text "import_xml" t.string "transport_submode" - t.integer "secondary_company_ids", array: true + t.integer "secondary_company_ids", limit: 8, array: true t.datetime "created_at" t.datetime "updated_at" end @@ -412,7 +420,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.string "source_identifier" t.string "comment" t.text "import_xml" - t.integer "line_referential_id" + t.integer "line_referential_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" end @@ -453,8 +461,8 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.string "status" t.datetime "started_at" t.datetime "ended_at" - t.integer "source_referential_id" - t.integer "target_referential_id" + t.integer "source_referential_id", limit: 8 + t.integer "target_referential_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" end @@ -463,12 +471,12 @@ ActiveRecord::Schema.define(version: 20170215163027) do add_index "referential_clonings", ["target_referential_id"], :name => "index_referential_clonings_on_target_referential_id" create_table "referential_metadata", force: true do |t| - t.integer "referential_id" - t.integer "line_ids", array: true - t.integer "referential_source_id" + t.integer "referential_id", limit: 8 + t.integer "line_ids", limit: 8, array: true + t.integer "referential_source_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" - t.daterange "periodes", array: true + t.daterange "periodes", array: true end add_index "referential_metadata", ["line_ids"], :name => "index_referential_metadata_on_line_ids" @@ -489,11 +497,11 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.integer "user_id", limit: 8 t.string "user_name" t.string "data_format" - t.integer "line_referential_id" - t.integer "stop_area_referential_id" - t.integer "workbench_id" + t.integer "line_referential_id", limit: 8 + t.integer "stop_area_referential_id", limit: 8 + t.integer "workbench_id", limit: 8 t.datetime "archived_at" - t.integer "created_from_id" + t.integer "created_from_id", limit: 8 t.boolean "ready", default: false end @@ -534,7 +542,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do create_table "routing_constraint_zones", force: true do |t| t.string "name" t.integer "stop_area_ids", array: true - t.integer "line_id" + t.integer "line_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" t.string "objectid", null: false @@ -558,8 +566,8 @@ ActiveRecord::Schema.define(version: 20170215163027) do end create_table "stop_area_referential_memberships", force: true do |t| - t.integer "organisation_id" - t.integer "stop_area_referential_id" + t.integer "organisation_id", limit: 8 + t.integer "stop_area_referential_id", limit: 8 t.boolean "owner" end @@ -567,7 +575,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.integer "criticity" t.string "message_key" t.hstore "message_attributs" - t.integer "stop_area_referential_sync_id" + t.integer "stop_area_referential_sync_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" end @@ -575,7 +583,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do add_index "stop_area_referential_sync_messages", ["stop_area_referential_sync_id"], :name => "stop_area_referential_sync_id" create_table "stop_area_referential_syncs", force: true do |t| - t.integer "stop_area_referential_id" + t.integer "stop_area_referential_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" t.datetime "ended_at" @@ -615,7 +623,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.string "city_name" t.string "url" t.string "time_zone" - t.integer "stop_area_referential_id" + t.integer "stop_area_referential_id", limit: 8 t.string "status" t.text "import_xml" t.datetime "deleted_at" @@ -649,10 +657,10 @@ ActiveRecord::Schema.define(version: 20170215163027) do add_index "stop_points", ["objectid"], :name => "stop_points_objectid_key", :unique => true create_table "taggings", force: true do |t| - t.integer "tag_id" - t.integer "taggable_id" + t.integer "tag_id", limit: 8 + t.integer "taggable_id", limit: 8 t.string "taggable_type" - t.integer "tagger_id" + t.integer "tagger_id", limit: 8 t.string "tagger_type" t.string "context", limit: 128 t.datetime "created_at" @@ -695,7 +703,7 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.integer "int_day_types", default: 0 t.date "start_date" t.date "end_date" - t.integer "calendar_id" + t.integer "calendar_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" end @@ -733,25 +741,25 @@ ActiveRecord::Schema.define(version: 20170215163027) do end create_table "users", force: true do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "" + t.string "email", default: "", null: false + t.string "encrypted_password", default: "" t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0 + t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" - t.integer "organisation_id" + t.integer "organisation_id", limit: 8 t.string "name" t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" - t.integer "failed_attempts", default: 0 + t.integer "failed_attempts", default: 0 t.string "unlock_token" t.datetime "locked_at" t.string "authentication_token" @@ -759,12 +767,12 @@ ActiveRecord::Schema.define(version: 20170215163027) do t.datetime "invitation_sent_at" t.datetime "invitation_accepted_at" t.integer "invitation_limit" - t.integer "invited_by_id" + t.integer "invited_by_id", limit: 8 t.string "invited_by_type" t.datetime "invitation_created_at" t.string "username" t.datetime "synced_at" - t.string "permissions", array: true + t.string "permissions", array: true end add_index "users", ["email"], :name => "index_users_on_email", :unique => true @@ -813,11 +821,11 @@ ActiveRecord::Schema.define(version: 20170215163027) do create_table "workbenches", force: true do |t| t.string "name" - t.integer "organisation_id" + t.integer "organisation_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" - t.integer "line_referential_id" - t.integer "stop_area_referential_id" + t.integer "line_referential_id", limit: 8 + t.integer "stop_area_referential_id", limit: 8 end add_index "workbenches", ["line_referential_id"], :name => "index_workbenches_on_line_referential_id" diff --git a/spec/factories/import_messages.rb b/spec/factories/import_messages.rb index 2d26477e6..1101107d2 100644 --- a/spec/factories/import_messages.rb +++ b/spec/factories/import_messages.rb @@ -1,10 +1,11 @@ FactoryGirl.define do factory :import_message do criticity 1 -message_key "MyString" -message_attributs "" -import nil -resource nil + message_key "MyString" + message_attributs "" + import nil + resource nil + resource_attributes {} end end diff --git a/spec/factories/import_resources.rb b/spec/factories/import_resources.rb index 274edab60..6854dc4af 100644 --- a/spec/factories/import_resources.rb +++ b/spec/factories/import_resources.rb @@ -2,5 +2,8 @@ FactoryGirl.define do factory :import_resource do association :import status :new + sequence(:name) { |n| "Import resource #{n}" } + type 'type' + reference 'reference' end end diff --git a/spec/factories/imports.rb b/spec/factories/imports.rb index bb9a97c9c..fc8668606 100644 --- a/spec/factories/imports.rb +++ b/spec/factories/imports.rb @@ -1,11 +1,13 @@ FactoryGirl.define do factory :import do - name "MyString" + sequence(:name) { |n| "Import #{n}" } current_step_id "MyString" current_step_progress 1.5 association :workbench association :referential file {File.open(File.join(Rails.root, 'spec', 'fixtures', 'terminated_job.json'))} - status "MyString" + status :new + started_at nil + ended_at nil end end diff --git a/spec/features/lines_spec.rb b/spec/features/lines_spec.rb index 4ecefab33..f15d33f60 100644 --- a/spec/features/lines_spec.rb +++ b/spec/features/lines_spec.rb @@ -28,21 +28,21 @@ describe "Lines", :type => :feature do context 'filtering' do it 'supports filtering by name' do - fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.name + fill_in 'q[name_or_objectid_cont]', with: lines.first.name click_button 'search-btn' expect(page).to have_content(lines.first.name) expect(page).not_to have_content(lines.last.name) end it 'supports filtering by number' do - fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.number + fill_in 'q[name_or_objectid_cont]', with: lines.first.number click_button 'search-btn' expect(page).to have_content(lines.first.name) expect(page).not_to have_content(lines.last.name) end it 'supports filtering by objectid' do - fill_in 'q[name_or_number_or_objectid_cont]', with: lines.first.objectid + fill_in 'q[name_or_objectid_cont]', with: lines.first.objectid click_button 'search-btn' expect(page).to have_content(lines.first.name) expect(page).not_to have_content(lines.last.name) diff --git a/spec/javascripts/journey_patterns/reducers/journey_patterns_spec.js b/spec/javascripts/journey_patterns/reducers/journey_patterns_spec.js index 422c97fee..df288e530 100644 --- a/spec/javascripts/journey_patterns/reducers/journey_patterns_spec.js +++ b/spec/javascripts/journey_patterns/reducers/journey_patterns_spec.js @@ -6,7 +6,6 @@ let fakeStopPoints = [{ id : 45289, name : "Clichy Levallois", object_id : "FR:92044:LDA:72073:STIF", - object_version : 1, position : 0, },{ area_type : "lda", @@ -14,9 +13,29 @@ let fakeStopPoints = [{ id : 40534, name : "Thomas Lemaître", object_id : "FR:92050:LDA:70915:STIF", - object_version : 1, position : 1, }] +let stopPoints = [{ + area_type : 'zdep', + city_name : 'Plaisir', + for_alighting : 'normal', + for_boarding : 'normal', + id : 14892, + name : 'test1', + object_id : 'test:StopPoint:1', + position : 0, + zip_code : '78490' +},{ + area_type : 'zdep', + city_name : 'Plaisir', + for_alighting : 'normal', + for_boarding : 'normal', + id : 14893, + name : 'test2', + object_id : 'test:StopPoint:2', + position : 1, + zip_code : '78490' +}] describe('journeyPatterns reducer', () => { beforeEach(()=>{ @@ -52,18 +71,19 @@ describe('journeyPatterns reducer', () => { published_name: {value: 'M3'}, registration_number: {value: ''} } + let stopPoints = stopPoints expect( jpReducer(state, { type: 'ADD_JOURNEYPATTERN', data: fakeData }) - ).toEqual([...state, { + ).toEqual([{ name : 'm3', published_name: 'M3', registration_number: '', deletable: false, - stop_points: fakeStopPoints - }]) + stop_points: stopPoints + }, ...state]) }) it('should handle UPDATE_CHECKBOX_VALUE', () => { diff --git a/spec/models/chouette/route_spec.rb b/spec/models/chouette/route_spec.rb index 7bd89703c..e24e16b18 100644 --- a/spec/models/chouette/route_spec.rb +++ b/spec/models/chouette/route_spec.rb @@ -108,7 +108,7 @@ describe Chouette::Route, :type => :model do end it "should have swap stop_points from route's journey pattern" do subject.update_attributes( :stop_points_attributes => swapped_stop_hash) - expect(Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id)).to eq(new_stop_id_list) + expect(Chouette::JourneyPattern.find( journey_pattern.id ).stop_points.map(&:id).sort).to eq(new_stop_id_list.sort) end it "should have swap stop_points from route's vehicle journey at stop" do subject.update_attributes( :stop_points_attributes => swapped_stop_hash) diff --git a/spec/models/import_resource_spec.rb b/spec/models/import_resource_spec.rb index a2177979e..99d260b20 100644 --- a/spec/models/import_resource_spec.rb +++ b/spec/models/import_resource_spec.rb @@ -3,6 +3,12 @@ require 'rails_helper' RSpec.describe ImportResource, :type => :model do it { should belong_to(:import) } + it { should enumerize(:status).in(:new, :pending, :successful, :failed) } + + it { should validate_presence_of(:name) } + it { should validate_presence_of(:type) } + it { should validate_presence_of(:reference) } + describe 'states' do let(:import_resource) { create(:import_resource) } diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 4c44eb99c..e34f368ae 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -4,5 +4,7 @@ RSpec.describe Import, :type => :model do it { should belong_to(:referential) } it { should belong_to(:workbench) } + it { should enumerize(:status).in(:new, :pending, :successful, :failed, :canceled) } + it { should validate_presence_of(:file) } end |
