From 665f90e2b8e87a91700f687ded8e036b12178cc8 Mon Sep 17 00:00:00 2001
From: cedricnjanga
Date: Tue, 3 Apr 2018 10:44:47 -0700
Subject: Refs #6383 Fix Stop point defautlt attributes
---
 app/javascript/routes/actions/index.js        | 7 +------
 app/javascript/routes/components/StopPoint.js | 4 ++--
 app/javascript/routes/index.js                | 5 +++--
 app/javascript/routes/reducers/stopPoints.js  | 9 ++++++---
 4 files changed, 12 insertions(+), 13 deletions(-)
(limited to 'app')
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 368ec8261..808e739a6 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}) {
         
 
         
-          
 
         
-          
+          
             
             
           
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("'", "\'")
     if(v.zip_code && v.city_name)
       fancyText += ", " + v.zip_code + " " + v.city_name.replace("'", "\'")
+      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("'", "\'") : '',
       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("'", "\'") : '',
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 {
-- 
cgit v1.2.3