From b0c1dd17d8e301ed2c3c22d84cf3620763b9fdf7 Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Wed, 25 Oct 2017 16:38:09 +0200 Subject: Refs #4016 disable validate button for duplication of VJ on conditions --- .../components/tools/DuplicateVehicleJourney.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js index 0c1c81114..6cce3eaad 100644 --- a/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/DuplicateVehicleJourney.js @@ -8,6 +8,7 @@ export default class DuplicateVehicleJourney extends Component { this.state = {} this.onFormChange = this.onFormChange.bind(this) this.handleSubmit = this.handleSubmit.bind(this) + this.disableValidateButton = this.disableValidateButton.bind(this) } componentWillReceiveProps() { @@ -58,6 +59,16 @@ export default class DuplicateVehicleJourney extends Component { return vjas.departure_time[type] } + disableValidateButton() { + /* We disable the button in two cases : + - if the additional_time_hh or additional_time_mm are above their input max value + - if if their is no change in the other inputs to avoid making a coping of the selected VJ + */ + let incorrectDT = isNaN(this.state.duplicate_time_hh) || isNaN(this.state.duplicate_time_mm) || this.state.duplicate_time_hh > 23 || this.state.duplicate_time_mm > 59 + let noInputChanges = this.state.additional_time == 0 && this.state.originalDT.hour == this.state.duplicate_time_hh && this.state.originalDT.minute == this.state.duplicate_time_mm + return incorrectDT || noInputChanges + } + render() { if(this.props.status.isFetching == true) { return false @@ -171,6 +182,7 @@ export default class DuplicateVehicleJourney extends Component { className={'btn btn-primary ' + (this.state.additional_time == 0 && this.state.originalDT.hour == this.state.duplicate_time_hh && this.state.originalDT.minute == this.state.duplicate_time_mm ? 'disabled' : '')} type='button' onClick={this.handleSubmit} + disabled={this.disableValidateButton()} > Valider -- cgit v1.2.3 From 438f7c293f14e0db6a132128bf36e3fb2e9829db Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Wed, 25 Oct 2017 18:04:54 +0200 Subject: Refs #4781 Add readonly attribute to VJAS when editMode == true --- .../vehicle_journeys/components/VehicleJourney.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index cb5407f81..7a49182ae 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -77,13 +77,14 @@ export default class VehicleJourney extends Component {
{this.props.filters.toggleArrivals &&
- + {this.props.onUpdateTime(e, i, this.props.index, 'hour', false, false)}} value={vj.arrival_time['hour']} /> @@ -93,7 +94,8 @@ export default class VehicleJourney extends Component { min='00' max='59' className='form-control' - disabled={((this.isDisabled(this.props.value.deletable), vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false || this.props.editMode == false)} + disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} + readOnly={!this.props.editMode && !vj.dummy} onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, 'minute', false, false)}} value={vj.arrival_time['minute']} /> @@ -106,13 +108,14 @@ export default class VehicleJourney extends Component { }
- + {this.props.onUpdateTime(e, i, this.props.index, 'hour', true, this.props.filters.toggleArrivals)}} value={vj.departure_time['hour']} /> @@ -122,7 +125,8 @@ export default class VehicleJourney extends Component { min='00' max='59' className='form-control' - disabled={(this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false || this.props.editMode == false)} + disabled={this.isDisabled(this.props.value.deletable, vj.dummy) || this.props.filters.policy['vehicle_journeys.update'] == false} + readOnly={!this.props.editMode && !vj.dummy} onChange={(e) => {this.props.onUpdateTime(e, i, this.props.index, "minute", true, this.props.filters.toggleArrivals)}} value={vj.departure_time['minute']} /> -- cgit v1.2.3 From f185f0d86460af1b200358e2adac63543f76a151 Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Thu, 26 Oct 2017 12:48:32 +0200 Subject: Refs #4586 Escape wildcard character on ILIKE search in the different select2s When the reasearch was '%' or '_' the query interpreted those characters as wildcars. Need to escape them to run properly the ransack query --- app/javascript/vehicle_journeys/actions/index.js | 4 ++++ .../vehicle_journeys/components/tools/select2s/CompanySelect2.js | 3 ++- .../vehicle_journeys/components/tools/select2s/MissionSelect2.js | 2 +- .../vehicle_journeys/components/tools/select2s/TimetableSelect2.js | 5 +---- .../vehicle_journeys/components/tools/select2s/VJSelect2.js | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index 4272c7915..8d7c4d7a0 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -458,6 +458,10 @@ const actions = { } } }, + escapeWildcardCharacters(search) { + let newSearch = search.replace(/^_/, "\\_") + return newSearch.replace(/^%/, "\\%") + } } export default actions diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js index 9c259630d..07f87d891 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js @@ -1,6 +1,7 @@ import _ from 'lodash' import React, { PropTypes, Component } from 'react' import Select2 from 'react-select2' +import actions from '../../../actions' // get JSON full path let origin = window.location.origin @@ -34,7 +35,7 @@ export default class BSelect4 extends Component { delay: '500', data: function(params) { return { - q: {name_cont: params.term}, + q: { name_cont: actions.escapeWildcardCharacters(params.term)}, }; }, processResults: function(data, params) { diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js index e4abdd651..6069bf089 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js @@ -33,7 +33,7 @@ export default class BSelect4 extends Component { delay: '500', data: function(params) { return { - q: {published_name_or_objectid_or_registration_number_cont: params.term}, + q: { published_name_or_objectid_or_registration_number_cont: actions.escapeWildcardCharacters(params.term)}, }; }, processResults: function(data, params) { diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js index 606bf8511..60c3eab83 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js @@ -32,12 +32,9 @@ export default class BSelect4 extends Component { dataType: 'json', delay: '500', data: function(params) { - let newParmas = params.term.split(" ") return { q: { - objectid_cont_any: newParmas, - comment_cont_any: newParmas, - m: 'or' + comment_or_objectid_cont_any: actions.escapeWildcardCharacters(params.term) } }; }, diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js index e1af8816d..7cccbbc05 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js @@ -33,7 +33,7 @@ export default class BSelect4b extends Component { delay: '500', data: function(params) { return { - q: {objectid_cont: params.term}, + q: { objectid_cont: actions.escapeWildcardCharacters(params.term)}, }; }, processResults: function(data, params) { -- cgit v1.2.3 From df12d7b9bc62cab376106ec2673a19d913d3f43b Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Fri, 27 Oct 2017 14:47:19 +0200 Subject: Refs #4794 Added some UX changes on VehicleJourney collection route - truncate the id of the VJ and the JP to 10 characters - only show the 3 first timetable in the metas of the VJ - add a link to the time_table#show in the EditTimeTable modal --- app/javascript/vehicle_journeys/actions/index.js | 5 ++++- app/javascript/vehicle_journeys/components/VehicleJourney.js | 4 +++- .../components/tools/TimetablesEditVehicleJourney.js | 11 +++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index 8d7c4d7a0..95c739893 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -269,7 +269,10 @@ const actions = { type: 'RECEIVE_TOTAL_COUNT', total }), - humanOID: (oid) => oid.split(':')[2].split("-").pop(), + humanOID: (oid) => { + let shortOId = oid.split(':')[2].split("-").pop() + return shortOId.length > 10 ? `${shortOId.slice(0, 10)}...` : shortOId + }, fetchVehicleJourneys : (dispatch, currentPage, nextPage, queryString) => { if(currentPage == undefined){ currentPage = 1 diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 7a49182ae..91f8a8eee 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -44,6 +44,7 @@ export default class VehicleJourney extends Component { render() { this.previousCity = undefined + let {time_tables} = this.props.value return (
@@ -51,9 +52,10 @@ export default class VehicleJourney extends Component {
{this.props.value.objectid ? actions.humanOID(this.props.value.objectid) : '-'}
{actions.humanOID(this.props.value.journey_pattern.objectid)}
- {this.props.value.time_tables.map((tt, i)=> + {time_tables.slice(0,3).map((tt, i)=> {this.timeTableURL(tt)} )} + {time_tables.length > 3 && + {time_tables.length - 3}}
{(this.props.filters.policy['vehicle_journeys.update'] == true && this.props.editMode) && diff --git a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js index fd2304901..1b93222f6 100644 --- a/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/TimetablesEditVehicleJourney.js @@ -5,6 +5,8 @@ import TimetableSelect2 from './select2s/TimetableSelect2' export default class TimetablesEditVehicleJourney extends Component { constructor(props) { super(props) + this.handleSubmit = this.handleSubmit.bind(this) + this.timeTableURL = this.timeTableURL.bind(this) } handleSubmit() { @@ -13,6 +15,11 @@ export default class TimetablesEditVehicleJourney extends Component { $('#CalendarsEditVehicleJourneyModal').modal('hide') } + timeTableURL(tt) { + let refURL = window.location.pathname.split('/', 3).join('/') + return refURL + '/time_tables/' + tt.id + } + render() { if(this.props.status.isFetching == true) { return false @@ -57,7 +64,7 @@ export default class TimetablesEditVehicleJourney extends Component { {this.props.modal.modalProps.timetables.map((tt, i) =>
-
{tt.comment}
+
Valider -- cgit v1.2.3 From 0079238842263768b88b0fa0fd977824b49eabd5 Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Sun, 29 Oct 2017 00:45:10 +0200 Subject: Refs #4795 Show the tools buttons even if editMode = false The only buttons activated (if a vj is selected) are info, timetable and notes We then change the behaviour of the modals depending ont the context (editMode or note) --- .../vehicle_journeys/components/Tools.js | 53 ++++--- .../vehicle_journeys/components/VehicleJourney.js | 28 ++-- .../components/tools/CreateModal.js | 6 +- .../components/tools/DeleteVehicleJourneys.js | 6 +- .../components/tools/DuplicateVehicleJourney.js | 7 +- .../components/tools/EditVehicleJourney.js | 38 ++--- .../components/tools/NotesEditVehicleJourney.js | 154 +++++++++++---------- .../components/tools/ShiftVehicleJourney.js | 5 +- .../tools/TimetablesEditVehicleJourney.js | 85 +++++++----- .../components/tools/select2s/CompanySelect2.js | 3 +- .../containers/tools/AddVehicleJourney.js | 4 +- .../containers/tools/DeleteVehicleJourneys.js | 6 +- .../containers/tools/DuplicateVehicleJourney.js | 3 +- .../containers/tools/EditVehicleJourney.js | 7 +- .../containers/tools/NotesEditVehicleJourney.js | 7 +- .../containers/tools/ShiftVehicleJourney.js | 4 +- .../tools/TimetablesEditVehicleJourney.js | 5 +- 17 files changed, 232 insertions(+), 189 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/vehicle_journeys/components/Tools.js b/app/javascript/vehicle_journeys/components/Tools.js index a717408b9..7621dfc10 100644 --- a/app/javascript/vehicle_journeys/components/Tools.js +++ b/app/javascript/vehicle_journeys/components/Tools.js @@ -1,4 +1,4 @@ -import React, { PropTypes } from 'react' +import React, { PropTypes, Component } from 'react' import actions from '../actions' import AddVehicleJourney from '../containers/tools/AddVehicleJourney' import DeleteVehicleJourneys from '../containers/tools/DeleteVehicleJourneys' @@ -8,28 +8,37 @@ import EditVehicleJourney from '../containers/tools/EditVehicleJourney' import NotesEditVehicleJourney from '../containers/tools/NotesEditVehicleJourney' import TimetablesEditVehicleJourney from '../containers/tools/TimetablesEditVehicleJourney' -export default function Tools({vehicleJourneys, onCancelSelection, filters: {policy}, editMode}) { - return ( -
- { - (policy['vehicle_journeys.create'] && policy['vehicle_journeys.update'] && policy['vehicle_journeys.destroy'] && editMode) && -
-
    - - - - - - - -
- {actions.getSelected(vehicleJourneys).length} course(s) sélectionnée(s) - -
- } -
- ) +export default class Tools extends Component { + constructor(props) { + super(props) + this.hasPolicy = this.hasPolicy.bind(this) + } + + hasPolicy(key) { + // Check if the user has the policy to disable or not the action + return this.props.filters.policy[`vehicle_journeys.${key}`] + } + + render() { + let { vehicleJourneys, onCancelSelection, editMode } = this.props + return ( +
+
    + + + + + + + +
+ + {actions.getSelected(vehicleJourneys).length} course(s) sélectionnée(s) + +
+ ) + } } Tools.propTypes = { diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index 91f8a8eee..13f8eced2 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -57,22 +57,18 @@ export default class VehicleJourney extends Component { )} {time_tables.length > 3 && + {time_tables.length - 3}}
- - {(this.props.filters.policy['vehicle_journeys.update'] == true && this.props.editMode) && -
- this.props.onSelectVehicleJourney(this.props.index)} - type='checkbox' - disabled={this.props.value.deletable} - checked={this.props.value.selected} - > - -
- } - +
+ this.props.onSelectVehicleJourney(this.props.index)} + type='checkbox' + disabled={this.props.value.deletable} + checked={this.props.value.selected} + > + +
{this.props.value.vehicle_journey_at_stops.map((vj, i) =>
diff --git a/app/javascript/vehicle_journeys/components/tools/CreateModal.js b/app/javascript/vehicle_journeys/components/tools/CreateModal.js index 5b5e2f849..2bffebdf6 100644 --- a/app/javascript/vehicle_journeys/components/tools/CreateModal.js +++ b/app/javascript/vehicle_journeys/components/tools/CreateModal.js @@ -25,7 +25,7 @@ export default class CreateModal extends Component {
  • {(this.props.modal.type == 'duplicate') && ( @@ -204,5 +205,5 @@ export default class DuplicateVehicleJourney extends Component { DuplicateVehicleJourney.propTypes = { onOpenDuplicateModal: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired, - filters: PropTypes.object.isRequired + disabled: PropTypes.bool.isRequired } \ No newline at end of file diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js index 3a4a57024..7ad3cf510 100644 --- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js @@ -32,7 +32,7 @@ export default class EditVehicleJourney extends Component {
  • - -
    - - -
    +
    + } )} @@ -163,5 +169,5 @@ export default class EditVehicleJourney extends Component { EditVehicleJourney.propTypes = { onOpenEditModal: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired, - filters: PropTypes.object.isRequired + disabled: PropTypes.bool.isRequired } \ No newline at end of file diff --git a/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js index 1958faf5f..de97bc403 100644 --- a/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/NotesEditVehicleJourney.js @@ -13,21 +13,25 @@ export default class NotesEditVehicleJourney extends Component { $('#NotesEditVehicleJourneyModal').modal('hide') } - renderFootnoteButton(lf, vjArray){ - let footnote_id = undefined - vjArray.forEach((f) => { - if(f.id == lf.id){ - footnote_id = f.id - } - }) + footnotes() { + let { footnotes } = this.props.modal.modalProps.vehicleJourney + let fnIds = footnotes.map(fn => fn.id) + return { + associated: footnotes, + to_associate: window.line_footnotes.filter(fn => !fnIds.includes(fn.id)) + } + } + + renderFootnoteButton(lf) { + if (!this.props.editMode) return false - if(footnote_id){ + if (this.footnotes().associated.includes(lf)) { return - }else{ + } else { return - -
    +
    + } )} @@ -146,5 +160,5 @@ NotesEditVehicleJourney.propTypes = { onModalClose: PropTypes.func.isRequired, onToggleFootnoteModal: PropTypes.func.isRequired, onNotesEditVehicleJourney: PropTypes.func.isRequired, - filters: PropTypes.object.isRequired + disabled: PropTypes.bool.isRequired } \ No newline at end of file diff --git a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js index c1e2de779..175106ac5 100644 --- a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js @@ -34,7 +34,7 @@ export default class ShiftVehicleJourney extends Component {
  • - - + Valider + + + } )} @@ -134,5 +143,5 @@ TimetablesEditVehicleJourney.propTypes = { onTimetablesEditVehicleJourney: PropTypes.func.isRequired, onDeleteCalendarModal: PropTypes.func.isRequired, onSelect2Timetable: PropTypes.func.isRequired, - filters: PropTypes.object.isRequired + disabled: PropTypes.bool.isRequired } \ No newline at end of file diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js index 07f87d891..0697e9141 100644 --- a/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js +++ b/app/javascript/vehicle_journeys/components/tools/select2s/CompanySelect2.js @@ -21,10 +21,11 @@ export default class BSelect4 extends Component { value={(this.props.company) ? this.props.company.name : undefined} onSelect={(e) => this.props.onSelect2Company(e) } onUnselect={() => this.props.onUnselect2Company()} + disabled={!this.props.editMode} multiple={false} ref='company_id' options={{ - allowClear: true, + allowClear: this.props.editMode, theme: 'bootstrap', width: '100%', placeholder: 'Filtrer par transporteur...', diff --git a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js index b3f777448..5da0bd3e9 100644 --- a/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/AddVehicleJourney.js @@ -2,13 +2,13 @@ import actions from '../../actions' import { connect } from 'react-redux' import CreateModal from '../../components/tools/CreateModal' -const mapStateToProps = (state) => { +const mapStateToProps = (state, ownProps) => { return { + disabled: ownProps.disabled, modal: state.modal, vehicleJourneys: state.vehicleJourneys, status: state.status, stopPointsList: state.stopPointsList, - filters: state.filters } } diff --git a/app/javascript/vehicle_journeys/containers/tools/DeleteVehicleJourneys.js b/app/javascript/vehicle_journeys/containers/tools/DeleteVehicleJourneys.js index d7d315da4..95f2eb506 100644 --- a/app/javascript/vehicle_journeys/containers/tools/DeleteVehicleJourneys.js +++ b/app/javascript/vehicle_journeys/containers/tools/DeleteVehicleJourneys.js @@ -2,10 +2,10 @@ import actions from '../../actions' import { connect } from 'react-redux' import DeleteVJComponent from '../../components/tools/DeleteVehicleJourneys' -const mapStateToProps = (state) => { +const mapStateToProps = (state, ownProps) => { return { - vehicleJourneys: state.vehicleJourneys, - filters: state.filters + disabled: ownProps.disabled, + vehicleJourneys: state.vehicleJourneys } } diff --git a/app/javascript/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js index e9ca88040..7b23a06dc 100644 --- a/app/javascript/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/DuplicateVehicleJourney.js @@ -2,8 +2,9 @@ import actions from '../../actions' import { connect } from 'react-redux' import DuplicateVJComponent from '../../components/tools/DuplicateVehicleJourney' -const mapStateToProps = (state) => { +const mapStateToProps = (state, ownProps) => { return { + disabled: ownProps.disabled, modal: state.modal, vehicleJourneys: state.vehicleJourneys, status: state.status, diff --git a/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js index 2d480aa0c..c2eabcc10 100644 --- a/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/EditVehicleJourney.js @@ -2,12 +2,13 @@ import actions from '../../actions' import { connect } from 'react-redux' import EditComponent from '../../components/tools/EditVehicleJourney' -const mapStateToProps = (state) => { +const mapStateToProps = (state, ownProps) => { return { + editMode: state.editMode, + disabled: ownProps.disabled, modal: state.modal, vehicleJourneys: state.vehicleJourneys, - status: state.status, - filters: state.filters + status: state.status } } diff --git a/app/javascript/vehicle_journeys/containers/tools/NotesEditVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/NotesEditVehicleJourney.js index 5a96ff273..6290ae3bf 100644 --- a/app/javascript/vehicle_journeys/containers/tools/NotesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/NotesEditVehicleJourney.js @@ -2,12 +2,13 @@ import actions from '../../actions' import { connect } from 'react-redux' import NotesEditComponent from '../../components/tools/NotesEditVehicleJourney' -const mapStateToProps = (state) => { +const mapStateToProps = (state, ownProps) => { return { + editMode: state.editMode, + disabled: ownProps.disabled, modal: state.modal, vehicleJourneys: state.vehicleJourneys, - status: state.status, - filters: state.filters + status: state.status } } diff --git a/app/javascript/vehicle_journeys/containers/tools/ShiftVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/ShiftVehicleJourney.js index a4b4fbe39..abd7dd145 100644 --- a/app/javascript/vehicle_journeys/containers/tools/ShiftVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/ShiftVehicleJourney.js @@ -2,12 +2,12 @@ import actions from '../../actions' import { connect } from 'react-redux' import ShiftVJComponent from '../../components/tools/ShiftVehicleJourney' -const mapStateToProps = (state) => { +const mapStateToProps = (state, ownProps) => { return { modal: state.modal, vehicleJourneys: state.vehicleJourneys, status: state.status, - filters: state.filters + disabled: ownProps.disabled } } diff --git a/app/javascript/vehicle_journeys/containers/tools/TimetablesEditVehicleJourney.js b/app/javascript/vehicle_journeys/containers/tools/TimetablesEditVehicleJourney.js index 62150a06e..b4ba9d068 100644 --- a/app/javascript/vehicle_journeys/containers/tools/TimetablesEditVehicleJourney.js +++ b/app/javascript/vehicle_journeys/containers/tools/TimetablesEditVehicleJourney.js @@ -2,12 +2,13 @@ import actions from '../../actions' import { connect } from 'react-redux' import TimetablesEditComponent from '../../components/tools/TimetablesEditVehicleJourney' -const mapStateToProps = (state) => { +const mapStateToProps = (state, ownProps) => { return { + editMode: state.editMode, modal: state.modal, vehicleJourneys: state.vehicleJourneys, status: state.status, - filters: state.filters + disabled: ownProps.disabled } } -- cgit v1.2.3 From 76d1787b32e28e4dbb3664e2bad99366781fdcd2 Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Mon, 30 Oct 2017 11:23:56 +0100 Subject: Refs #4792 UX changes on JourneyPattern view - add the possibility to view JP infos in show mode --- app/javascript/journey_patterns/actions/index.js | 5 +- .../journey_patterns/components/EditModal.js | 58 ++++++++++++++-------- .../journey_patterns/components/JourneyPattern.js | 9 ++-- .../journey_patterns/containers/Modal.js | 1 + 4 files changed, 46 insertions(+), 27 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js index 0c1cb5f5c..8bea5a990 100644 --- a/app/javascript/journey_patterns/actions/index.js +++ b/app/javascript/journey_patterns/actions/index.js @@ -90,7 +90,10 @@ const actions = { resetValidation: (target) => { $(target).parent().removeClass('has-error').children('.help-block').remove() }, - humanOID : (oid) => oid.split(':')[2].split("-").pop(), + humanOID : (oid) => { + let shortOId = oid.split(':')[2].split("-").pop() + return shortOId.length > 10 ? `${shortOId.slice(0, 10)}...` : shortOId + }, validateFields : (fields) => { const test = [] diff --git a/app/javascript/journey_patterns/components/EditModal.js b/app/javascript/journey_patterns/components/EditModal.js index 699f89b85..e7ce24aa1 100644 --- a/app/javascript/journey_patterns/components/EditModal.js +++ b/app/javascript/journey_patterns/components/EditModal.js @@ -13,6 +13,19 @@ export default class EditModal extends Component { } } + renderModalTitle() { + if (this.props.editMode) { + return ( +

    + Editer la mission + {this.props.modal.type == 'edit' && "{this.props.modal.modalProps.journeyPattern.name}"} +

    + ) + } else { + return

    Informations

    + } + } + render() { return (
    @@ -20,12 +33,8 @@ export default class EditModal extends Component {
    -

    - Editer la mission - {(this.props.modal.type == 'edit') && ( - "{this.props.modal.modalProps.journeyPattern.name}" - )} -

    + {this.renderModalTitle()} + ×
    {(this.props.modal.type == 'edit') && ( @@ -37,6 +46,7 @@ export default class EditModal extends Component { type='text' ref='name' className='form-control' + disabled={!this.props.editMode} id={this.props.modal.modalProps.index} defaultValue={this.props.modal.modalProps.journeyPattern.name} onKeyDown={(e) => actions.resetValidation(e.currentTarget)} @@ -52,6 +62,7 @@ export default class EditModal extends Component { type='text' ref='published_name' className='form-control' + disabled={!this.props.editMode} id={this.props.modal.modalProps.index} defaultValue={this.props.modal.modalProps.journeyPattern.published_name} onKeyDown={(e) => actions.resetValidation(e.currentTarget)} @@ -66,6 +77,7 @@ export default class EditModal extends Component { type='text' ref='registration_number' className='form-control' + disabled={!this.props.editMode} id={this.props.modal.modalProps.index} defaultValue={this.props.modal.modalProps.journeyPattern.registration_number} onKeyDown={(e) => actions.resetValidation(e.currentTarget)} @@ -74,24 +86,26 @@ export default class EditModal extends Component {
    - -
    - - -
    + Valider + + + } )} diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js index dde73a957..34d102c5d 100644 --- a/app/javascript/journey_patterns/components/JourneyPattern.js +++ b/app/javascript/journey_patterns/components/JourneyPattern.js @@ -56,7 +56,7 @@ export default class JourneyPattern extends Component{ } isDisabled(action) { - return !this.props.status.policy[`journey_patterns.${action}`] && !this.props.editMode + return !this.props.status.policy[`journey_patterns.${action}`] } render() { @@ -88,16 +88,17 @@ export default class JourneyPattern extends Component{ data-toggle='modal' data-target='#JourneyPatternModal' > - Editer + {this.props.editMode ? 'Editer' : 'Consulter'}
  • {this.vehicleJourneyURL(this.props.value.object_id)}
  • -
  • +