aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2018-04-13 17:35:44 +0200
committerGitHub2018-04-13 17:35:44 +0200
commitc1801cab30268f70547061435e02126155b07916 (patch)
tree19cb01956307e86631083622913248f55110b247
parent3864c37d9d07113baeb05c3d16ca646f8e49abaa (diff)
parent665f90e2b8e87a91700f687ded8e036b12178cc8 (diff)
downloadchouette-core-c1801cab30268f70547061435e02126155b07916.tar.bz2
Merge pull request #439 from af83/6383-stop-point-default-attributes
Refs #6383 Fix Stop point defautlt attributes
-rw-r--r--app/javascript/routes/actions/index.js7
-rw-r--r--app/javascript/routes/components/StopPoint.js4
-rw-r--r--app/javascript/routes/index.js5
-rw-r--r--app/javascript/routes/reducers/stopPoints.js9
4 files changed, 12 insertions, 13 deletions
diff --git a/app/javascript/routes/actions/index.js b/app/javascript/routes/actions/index.js
index 5fbf5bce9..13b2d60b2 100644
--- a/app/javascript/routes/actions/index.js
+++ b/app/javascript/routes/actions/index.js
@@ -56,12 +56,7 @@ 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/StopPoint.js b/app/javascript/routes/components/StopPoint.js
index 768d069c0..908e97263 100644
--- a/app/javascript/routes/components/StopPoint.js
+++ b/app/javascript/routes/components/StopPoint.js
@@ -19,14 +19,14 @@ export default function StopPoint(props, {I18n}) {
</div>
<div>
- <select className='form-control' value={defaultAttribute(props.value.for_boarding, props.value.stoparea_kind)} id="for_boarding" onChange={props.onSelectChange}>
+ <select className='form-control' value={props.value.for_boarding} id="for_boarding" onChange={props.onSelectChange}>
<option value="normal">{I18n.t('routes.edit.stop_point.boarding.normal')}</option>
<option value="forbidden">{I18n.t('routes.edit.stop_point.boarding.forbidden')}</option>
</select>
</div>
<div>
- <select className='form-control' value={defaultAttribute(props.value.for_alighting, props.value.stoparea_kind)} id="for_alighting" onChange={props.onSelectChange}>
+ <select className='form-control' value={props.value.for_alighting} id="for_alighting" onChange={props.onSelectChange}>
<option value="normal">{I18n.t('routes.edit.stop_point.alighting.normal')}</option>
<option value="forbidden">{I18n.t('routes.edit.stop_point.alighting.forbidden')}</option>
</select>
diff --git a/app/javascript/routes/index.js b/app/javascript/routes/index.js
index 3c7322953..fc99a3086 100644
--- a/app/javascript/routes/index.js
+++ b/app/javascript/routes/index.js
@@ -22,6 +22,7 @@ const getInitialState = () => {
let fancyText = v.name.replace("&#39;", "\'")
if(v.zip_code && v.city_name)
fancyText += ", " + v.zip_code + " " + v.city_name.replace("&#39;", "\'")
+ forAlightingAndBoarding = v.stoparea_kind === 'commercial' ? 'normal' : 'forbidden'
state.push({
stoppoint_id: v.stoppoint_id,
@@ -37,8 +38,8 @@ const getInitialState = () => {
name: v.name ? v.name.replace("&#39;", "\'") : '',
registration_number: v.registration_number,
text: fancyText,
- for_boarding: v.for_boarding || '',
- for_alighting: v.for_alighting || '',
+ for_boarding: v.for_boarding || forAlightingAndBoarding,
+ for_alighting: v.for_alighting || forAlightingAndBoarding,
longitude: v.longitude || 0,
latitude: v.latitude || 0,
comment: v.comment ? v.comment.replace("&#39;", "\'") : '',
diff --git a/app/javascript/routes/reducers/stopPoints.js b/app/javascript/routes/reducers/stopPoints.js
index ba183d002..54142338d 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: '',
- for_alighting: '',
+ for_boarding: 'normal',
+ for_alighting: 'normal',
olMap: {
isOpened: false,
json: {}
@@ -61,6 +61,7 @@ const stopPoints = (state = [], action) => {
case 'UPDATE_INPUT_VALUE':
return state.map( (t, i) => {
if (i === action.index) {
+ let forAlightingAndBoarding = action.text.stoparea_kind === 'commercial' ? 'normal' : 'forbidden'
return _.assign(
{},
t,
@@ -77,7 +78,9 @@ const stopPoints = (state = [], action) => {
area_type: action.text.area_type,
city_name: action.text.city_name,
comment: action.text.comment,
- registration_number: action.text.registration_number
+ registration_number: action.text.registration_number,
+ for_alighting: forAlightingAndBoarding,
+ for_boarding: forAlightingAndBoarding
}
)
} else {