From 1019debe93d776f0d38ae69099e6492a7dd4a87c Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Thu, 15 Mar 2018 12:41:29 -0700 Subject: Refs #6075 Change default attributes for stop areas --- app/javascript/packs/routes/edit.js | 1 + app/javascript/routes/actions/index.js | 7 ++++++- app/javascript/routes/components/BSelect2.js | 1 + app/javascript/routes/components/StopPoint.js | 6 ++++-- app/javascript/routes/index.js | 5 +++-- app/javascript/routes/reducers/stopPoints.js | 5 +++-- 6 files changed, 18 insertions(+), 7 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/packs/routes/edit.js b/app/javascript/packs/routes/edit.js index 81745ad23..fc7aa203d 100644 --- a/app/javascript/packs/routes/edit.js +++ b/app/javascript/packs/routes/edit.js @@ -29,6 +29,7 @@ const getInitialState = () => { state.push({ stoppoint_id: v.stoppoint_id, stoparea_id: v.stoparea_id, + stoparea_kind: v.stoparea_kind, user_objectid: v.user_objectid, short_name: v.short_name ? v.short_name.replace("'", "\'") : '', area_type: v.area_type, diff --git a/app/javascript/routes/actions/index.js b/app/javascript/routes/actions/index.js index 13b2d60b2..5fbf5bce9 100644 --- a/app/javascript/routes/actions/index.js +++ b/app/javascript/routes/actions/index.js @@ -56,7 +56,12 @@ const actions = { unselectMarker: (index) => ({ type: 'UNSELECT_MARKER', index - }) + }), + defaultAttribute: (attribute, stopAreaKind) => { + if (attribute !== '') return attribute + if (stopAreaKind === undefined) return '' + return stopAreaKind === "commercial" ? "normal" : "forbidden" + } } module.exports = actions diff --git a/app/javascript/routes/components/BSelect2.js b/app/javascript/routes/components/BSelect2.js index 035bce155..89e1b6cfa 100644 --- a/app/javascript/routes/components/BSelect2.js +++ b/app/javascript/routes/components/BSelect2.js @@ -17,6 +17,7 @@ export default class BSelect3 extends Component { this.props.onChange(this.props.index, { text: e.currentTarget.textContent, stoparea_id: e.currentTarget.value, + stoparea_kind: e.params.data.kind, user_objectid: e.params.data.user_objectid, longitude: e.params.data.longitude, latitude: e.params.data.latitude, diff --git a/app/javascript/routes/components/StopPoint.js b/app/javascript/routes/components/StopPoint.js index af51a6bb4..368ec8261 100644 --- a/app/javascript/routes/components/StopPoint.js +++ b/app/javascript/routes/components/StopPoint.js @@ -4,6 +4,8 @@ import PropTypes from 'prop-types' import BSelect2 from './BSelect2' import OlMap from './OlMap' +import { defaultAttribute } from '../actions' + export default function StopPoint(props, {I18n}) { return (
@@ -17,14 +19,14 @@ export default function StopPoint(props, {I18n}) {
-
- diff --git a/app/javascript/routes/index.js b/app/javascript/routes/index.js index febae7d54..3c7322953 100644 --- a/app/javascript/routes/index.js +++ b/app/javascript/routes/index.js @@ -26,6 +26,7 @@ const getInitialState = () => { state.push({ stoppoint_id: v.stoppoint_id, stoparea_id: v.stoparea_id, + stoparea_kind: v.stoparea_kind, user_objectid: v.user_objectid, short_name: v.short_name ? v.short_name.replace("'", "\'") : '', area_type: v.area_type, @@ -36,8 +37,8 @@ const getInitialState = () => { name: v.name ? v.name.replace("'", "\'") : '', registration_number: v.registration_number, text: fancyText, - for_boarding: v.for_boarding || "normal", - for_alighting: v.for_alighting || "normal", + for_boarding: v.for_boarding || '', + for_alighting: v.for_alighting || '', longitude: v.longitude || 0, latitude: v.latitude || 0, comment: v.comment ? v.comment.replace("'", "\'") : '', diff --git a/app/javascript/routes/reducers/stopPoints.js b/app/javascript/routes/reducers/stopPoints.js index 0b42b504f..ba183d002 100644 --- a/app/javascript/routes/reducers/stopPoints.js +++ b/app/javascript/routes/reducers/stopPoints.js @@ -8,8 +8,8 @@ const stopPoint = (state = {}, action, length) => { text: '', index: length, edit: true, - for_boarding: 'normal', - for_alighting: 'normal', + for_boarding: '', + for_alighting: '', olMap: { isOpened: false, json: {} @@ -68,6 +68,7 @@ const stopPoints = (state = [], action) => { stoppoint_id: t.stoppoint_id, text: action.text.text, stoparea_id: action.text.stoparea_id, + stoparea_kind: action.text.stoparea_kind, user_objectid: action.text.user_objectid, latitude: action.text.latitude, longitude: action.text.longitude, -- cgit v1.2.3