@adactive/adsum-wayfindingcontrols-asia
Advanced tools
Comparing version 2.5.3 to 2.5.4
{ | ||
"name": "@adactive/adsum-wayfindingcontrols-asia", | ||
"version": "2.5.3", | ||
"version": "2.5.4", | ||
"description": "Adsum Way Finding Controls Component", | ||
@@ -40,3 +40,3 @@ "main": "index.js", | ||
], | ||
"gitHead": "5a7de0b34b71a7589e5e6e4161d2a82b7b0a3482" | ||
"gitHead": "2121186bd4ef7818108a494d1da8bb7abe7ef99f" | ||
} |
@@ -9,3 +9,3 @@ // @flow | ||
import { MainActions, WayfindingActions, SelectionActions } from '@adactive/arc-map'; | ||
import { WayFindingControlsActions } from '../'; | ||
import { WayFindingControlsActions } from '..'; | ||
@@ -30,6 +30,6 @@ type MappedStatePropsType = {| | ||
resetMapAndWayFinding: ( | ||
reset : ?boolean, | ||
resetMap: ?boolean, | ||
resetMapAnimatedOption: ?boolean, | ||
resetWayfinding: ?boolean) | ||
reset: ?boolean, | ||
resetMap: ?boolean, | ||
resetMapAnimatedOption: ?boolean, | ||
resetWayfinding: ?boolean) | ||
=> void, | ||
@@ -42,6 +42,6 @@ resetMap: (animated: boolean) => void, | ||
type OwnPropsType = {| | ||
//props needed when call this component | ||
// props needed when call this component | ||
awm: *, | ||
kioskPlace: object, | ||
//optional props | ||
// optional props | ||
destinationLabelText: string, | ||
@@ -53,20 +53,23 @@ icLabelText: string, | ||
type PropsType = MappedStatePropsType & MappedDispatchPropsType & OwnPropsType; | ||
type StateType = {||} | ||
class WayFindingControls extends React.Component<PropsType, StateType> { | ||
static defaultProps = { | ||
destinationLabelText: "You reached ", | ||
icLabelText: "Head ", | ||
destinationLabelText: 'You reached ', | ||
icLabelText: 'Head ', | ||
arrivalLabelStyle: { | ||
offset: { | ||
x: 0, | ||
y: 0, | ||
z: 15, | ||
}, | ||
style: { | ||
backgroundColor: '#00437a', | ||
backgroundOpacity: 0.9, | ||
backgroundRadius: 3, | ||
color: '#ffffff', | ||
size: 4, | ||
}, | ||
offset: { | ||
x: 0, | ||
y: 0, | ||
z: 15, | ||
}, | ||
style: { | ||
backgroundColor: '#00437a', | ||
backgroundOpacity: 0.9, | ||
backgroundRadius: 3, | ||
color: '#ffffff', | ||
size: 4, | ||
}, | ||
}, | ||
@@ -86,29 +89,29 @@ interchangeLabelStyle: { | ||
}, | ||
}, | ||
}, | ||
} | ||
componentDidUpdate(prevProps){ | ||
const { kioskPlace, | ||
wayfindingState, | ||
wayFindingControlsState, | ||
getPath, | ||
destination, | ||
placeDestination, | ||
destinationLabelText, | ||
icLabelText, | ||
resetMapAndWayFinding, | ||
resetMap, | ||
resetSelection, | ||
onRemovePath, | ||
} = this.props; | ||
componentDidUpdate(prevProps) { | ||
const { | ||
kioskPlace, | ||
wayfindingState, | ||
wayFindingControlsState, | ||
getPath, | ||
destination, | ||
placeDestination, | ||
destinationLabelText, | ||
icLabelText, | ||
resetMapAndWayFinding, | ||
resetMap, | ||
resetSelection, | ||
onRemovePath, | ||
} = this.props; | ||
// While Drawing | ||
// While Drawing | ||
if(!wayfindingState.drawing | ||
if (!wayfindingState.drawing | ||
&& prevProps.wayfindingState.drawing | ||
&& wayFindingControlsState.takeMeThere | ||
&& wayFindingControlsState.takeMeThere | ||
&& wayFindingControlsState.takeMeThere[0] | ||
&& wayFindingControlsState.takeMeThere[0].id){ | ||
// Define Needed Variable | ||
&& wayFindingControlsState.takeMeThere[0].id) { | ||
// Define Needed Variable | ||
@@ -120,57 +123,52 @@ const path = getPath(wayFindingControlsState.takeMeThere[0].id); | ||
const finalLabelText = destinationLabelText + poiDestination[0].name; | ||
// Store Destination Poi and Destination Place | ||
if(wayFindingControlsState.destination !== poiDestination | ||
&& wayFindingControlsState.placeDestination !== destinationFloor){ | ||
destination(poiDestination); | ||
placeDestination(destinationFloor); | ||
} | ||
// If The Current Index Of Wayfinder is Even (Between Add Interchange(IC) Label or Add Destination Label) | ||
if (wayfindingState.currentSectionIndex % 2 === 0){ | ||
// Store Destination Poi and Destination Place | ||
// If Interchange Label Exist, Delete it | ||
if(wayFindingControlsState.interchangeLabel.length>0){ | ||
if (wayFindingControlsState.destination !== poiDestination | ||
&& wayFindingControlsState.placeDestination !== destinationFloor) { | ||
destination(poiDestination); | ||
placeDestination(destinationFloor); | ||
} | ||
// If The Current Index Of Wayfinder is Even (Between Add Interchange(IC) Label or Add Destination Label) | ||
if (wayfindingState.currentSectionIndex % 2 === 0) { | ||
// If Interchange Label Exist, Delete it | ||
if (wayFindingControlsState.interchangeLabel.length > 0) { | ||
this.deleteInterchangeLabel(); | ||
} | ||
// If It is Destination Label | ||
if(prevProps.wayfindingState.drawing !== wayfindingState.drawing | ||
&& wayfindingState.currentSectionIndex === (pathSection.length-1)){ | ||
// If It is Destination Label | ||
if (prevProps.wayfindingState.drawing !== wayfindingState.drawing | ||
&& wayfindingState.currentSectionIndex === (pathSection.length - 1)) { | ||
this.addArrivalLabel(finalLabelText, pathSection); | ||
} | ||
// If it is Interchange Label(s) | ||
else if(wayfindingState.currentSectionIndex !== (pathSection.length-1)){ | ||
// If it is Interchange Label(s) | ||
} else if (wayfindingState.currentSectionIndex !== (pathSection.length - 1)) { | ||
let icDestinationFloorPosition; | ||
if(pathSection[wayfindingState.currentSectionIndex+1].to.pathNode.ground.id > kioskPlace.id){ | ||
icDestinationFloorPosition = "Up "; | ||
if (pathSection[wayfindingState.currentSectionIndex + 1].to.pathNode.ground.id > kioskPlace.id) { | ||
icDestinationFloorPosition = 'Up '; | ||
} else if (pathSection[wayfindingState.currentSectionIndex + 1].to.pathNode.ground.id < kioskPlace.id) { | ||
icDestinationFloorPosition = 'Down '; | ||
} else { | ||
icDestinationFloorPosition = 'Straight '; | ||
} | ||
else if(pathSection[wayfindingState.currentSectionIndex+1].to.pathNode.ground.id < kioskPlace.id){ | ||
icDestinationFloorPosition = "Down "; | ||
} | ||
else { | ||
icDestinationFloorPosition = "Straight "; | ||
} | ||
const icDestinationFloor = pathSection[wayfindingState.currentSectionIndex+1].to.pathNode.ground.name; | ||
const icDestinationFloor = pathSection[wayfindingState.currentSectionIndex + 1].to.pathNode.ground.name; | ||
const changeFloorLabelText = icLabelText + icDestinationFloorPosition + icDestinationFloor.replace('_', ' '); | ||
this.addInterchangeLabel(changeFloorLabelText, pathSection); | ||
} | ||
} | ||
} | ||
} | ||
// If ResetMap And WayFinding | ||
// If ResetMap And WayFinding | ||
if(wayFindingControlsState.resetMapAndWayFinding.reset){ | ||
if (wayFindingControlsState.resetMapAndWayFinding.reset) { | ||
const { awm } = this.props; | ||
awm.wayfindingManager.reset(); | ||
if(wayFindingControlsState.resetMapAndWayFinding.resetWayfinding){ | ||
if (wayFindingControlsState.resetMapAndWayFinding.resetWayfinding) { | ||
this.resetAllWayFinding(); | ||
} | ||
if (wayFindingControlsState.resetMapAndWayFinding.resetMap){ | ||
resetMap(wayFindingControlsState.resetMapAndWayFinding.resetMapAnimatedOption) | ||
if (wayFindingControlsState.resetMapAndWayFinding.resetMap) { | ||
resetMap(wayFindingControlsState.resetMapAndWayFinding.resetMapAnimatedOption); | ||
} | ||
@@ -183,12 +181,12 @@ resetMapAndWayFinding(false, false, false, false); | ||
deleteInterchangeLabel(){ | ||
deleteInterchangeLabel() { | ||
const { wayFindingControlsState, awm } = this.props; | ||
for(let i = 0; i < wayFindingControlsState.interchangeLabel.length; i++){ | ||
for (let i = 0; i < wayFindingControlsState.interchangeLabel.length; i++) { | ||
const willBeDeletedLabel = Array.from(awm.objectManager.labels).filter( | ||
label => label[1].text === wayFindingControlsState.interchangeLabel[i] | ||
) | ||
); | ||
if (willBeDeletedLabel && willBeDeletedLabel[0]) { | ||
awm.objectManager.removeLabel(willBeDeletedLabel[0][1]); | ||
if (willBeDeletedLabel && willBeDeletedLabel[1]){ | ||
if (willBeDeletedLabel && willBeDeletedLabel[1]) { | ||
awm.objectManager.removeLabel(willBeDeletedLabel[1][1]); | ||
@@ -200,13 +198,13 @@ } | ||
addArrivalLabel(finalLabelText, pathSection){ | ||
const { | ||
wayFindingControlsState, | ||
resetInterchangeLabel, | ||
arrivedLabel, | ||
awm, | ||
arrivalLabelStyle | ||
} = this.props; | ||
addArrivalLabel(finalLabelText, pathSection) { | ||
const { | ||
wayFindingControlsState, | ||
resetInterchangeLabel, | ||
arrivedLabel, | ||
awm, | ||
arrivalLabelStyle | ||
} = this.props; | ||
if(wayFindingControlsState.interchangeLabel.length>0){ | ||
resetInterchangeLabel() | ||
if (wayFindingControlsState.interchangeLabel.length > 0) { | ||
resetInterchangeLabel(); | ||
} | ||
@@ -220,22 +218,20 @@ | ||
if(wayFindingControlsState.arrivedLabel && wayFindingControlsState.arrivedLabel.length>0){ | ||
if (wayFindingControlsState.arrivedLabel && wayFindingControlsState.arrivedLabel.length > 0) { | ||
this.resetAllWayFinding(); | ||
} | ||
const findDuplicateArrivalLabel = wayFindingControlsState.arrivedLabel.find(function(element) { | ||
return element === finalLabelText; | ||
}) | ||
if(!findDuplicateArrivalLabel){ | ||
const findDuplicateArrivalLabel = wayFindingControlsState.arrivedLabel.find(element => element === finalLabelText); | ||
if (!findDuplicateArrivalLabel) { | ||
arrivedLabel(finalLabelText); | ||
} | ||
awm.objectManager.addLabelOnAdsumLocation(arrivedLabelText, pathSection[pathSection.length-1].to); | ||
awm.objectManager.addLabelOnAdsumLocation(arrivedLabelText, pathSection[pathSection.length - 1].to); | ||
} | ||
addInterchangeLabel(changeFloorLabelText, pathSection){ | ||
const { | ||
wayFindingControlsState, | ||
interchangeLabel, | ||
awm, | ||
wayfindingState, | ||
interchangeLabelStyle | ||
} = this.props; | ||
addInterchangeLabel(changeFloorLabelText, pathSection) { | ||
const { | ||
wayFindingControlsState, | ||
interchangeLabel, | ||
awm, | ||
wayfindingState, | ||
interchangeLabelStyle | ||
} = this.props; | ||
@@ -247,6 +243,4 @@ const changeFloorLabel = new LabelTextObject({ | ||
}); | ||
const findDuplicateIcLabel = wayFindingControlsState.interchangeLabel.find(function(element) { | ||
return element === changeFloorLabelText; | ||
}) | ||
if(!findDuplicateIcLabel){ | ||
const findDuplicateIcLabel = wayFindingControlsState.interchangeLabel.find(element => element === changeFloorLabelText); | ||
if (!findDuplicateIcLabel) { | ||
interchangeLabel(changeFloorLabelText); | ||
@@ -257,19 +251,19 @@ } | ||
resetAllWayFinding(){ | ||
const { wayFindingControlsState, | ||
awm, | ||
destination, | ||
placeDestination, | ||
tmtt, | ||
resetArrivalLabel | ||
} = this.props; | ||
resetAllWayFinding() { | ||
const { | ||
wayFindingControlsState, | ||
awm, | ||
destination, | ||
placeDestination, | ||
tmtt, | ||
resetArrivalLabel | ||
} = this.props; | ||
if(wayFindingControlsState.arrivedLabel.length>0){ | ||
for(let k=0; k<wayFindingControlsState.arrivedLabel.length; k++){ | ||
if (wayFindingControlsState.arrivedLabel.length > 0) { | ||
for (let k = 0; k < wayFindingControlsState.arrivedLabel.length; k++) { | ||
const willBeDeletedArrivalLabel = Array.from(awm.objectManager.labels).filter( | ||
label => label[1].text === wayFindingControlsState.arrivedLabel[k] | ||
) | ||
); | ||
if (willBeDeletedArrivalLabel && willBeDeletedArrivalLabel[k]) { | ||
for(let j = 0; j < willBeDeletedArrivalLabel.length; j++){ | ||
for (let j = 0; j < willBeDeletedArrivalLabel.length; j++) { | ||
awm.objectManager.removeLabel(willBeDeletedArrivalLabel[j][1]); | ||
@@ -281,12 +275,12 @@ } | ||
} | ||
if(wayFindingControlsState.interchangeLabel.length>0){ | ||
if (wayFindingControlsState.interchangeLabel.length > 0) { | ||
this.deleteInterchangeLabel(); | ||
} | ||
if(wayFindingControlsState.takeMeThere){ | ||
if (wayFindingControlsState.takeMeThere) { | ||
tmtt([]); | ||
} | ||
if(wayFindingControlsState.destination){ | ||
if (wayFindingControlsState.destination) { | ||
destination(null); | ||
} | ||
if(wayFindingControlsState.placeDestination){ | ||
if (wayFindingControlsState.placeDestination) { | ||
placeDestination(null); | ||
@@ -296,7 +290,7 @@ } | ||
render(){ | ||
return( | ||
render() { | ||
return ( | ||
<React.Fragment> | ||
</React.Fragment> | ||
) | ||
); | ||
} | ||
@@ -337,5 +331,5 @@ } | ||
resetMap, | ||
resetMapAnimatedOption, | ||
resetMapAnimatedOption, | ||
resetWayfinding | ||
)); | ||
)); | ||
}, | ||
@@ -342,0 +336,0 @@ resetMap: (animated: boolean = false): void => dispatch(MainActions.resetAction(false, true, animated)), |
// @flow | ||
import { WayfindingActions, MainActions } from '@adactive/arc-map'; | ||
import store from './../../../../src/store/index'; | ||
import { WayfindingActions } from '@adactive/arc-map'; | ||
// eslint-disable-next-line import/no-unresolved | ||
import store from '../../../../src/store/index'; | ||
export const tmt = 'tmt'; | ||
@@ -84,15 +86,16 @@ export const DESTINATION = 'DESTINATION'; | ||
resetMap, | ||
resetMapAnimatedOption, | ||
resetWayfinding) { | ||
return (dispatch) => { | ||
dispatch({ | ||
type: RESET_MAP_AND_WAY_FINDING, | ||
payload: { | ||
reset: reset ? reset : false, | ||
resetMap: resetMap ? resetMap : false, | ||
resetMapAnimatedOption: resetMapAnimatedOption ? resetMapAnimatedOption : false, | ||
resetWayfinding: resetWayfinding ? resetWayfinding : false | ||
} | ||
}); | ||
}; | ||
resetMapAnimatedOption, | ||
resetWayfinding | ||
) { | ||
return (dispatch) => { | ||
dispatch({ | ||
type: RESET_MAP_AND_WAY_FINDING, | ||
payload: { | ||
reset: reset || false, | ||
resetMap: resetMap || false, | ||
resetMapAnimatedOption: resetMapAnimatedOption || false, | ||
resetWayfinding: resetWayfinding || false | ||
} | ||
}); | ||
}; | ||
} |
// @flow | ||
import { | ||
import { | ||
tmt, | ||
@@ -65,2 +65,2 @@ DESTINATION, | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24756