ADD: added util function and fix problem with updatin entityOnFocus
This commit is contained in:
@@ -46,7 +46,7 @@ function EntityControl(props)
|
||||
setFormData({name:props.Entity.Name,course:props.Entity.Course,speed:props.Entity.Speed,position:props.Entity.Position})
|
||||
}
|
||||
}else{
|
||||
setFormData({name:"",course:"",speed:"",position:['','']})
|
||||
// setFormData({name:"",course:"",speed:"",position:['','']})
|
||||
|
||||
}
|
||||
// setFormData({speed:props.Entity.Speed})
|
||||
@@ -77,7 +77,8 @@ function EntityControl(props)
|
||||
const handleClick = (e) => {
|
||||
if(e.detail === 2)
|
||||
{
|
||||
setCourseInControl(true);
|
||||
console.log(e)
|
||||
// setCourseInControl(true);
|
||||
e.target.readOnly = false;
|
||||
// e.target.style = "border: 1px solid"
|
||||
}
|
||||
@@ -94,24 +95,48 @@ const handleClick = (e) => {
|
||||
};
|
||||
|
||||
const handleSpeedInput= (e) => {
|
||||
console.log(e.target)
|
||||
// console.log(e.target)
|
||||
if(!isNaN(e.nativeEvent?.data))
|
||||
{
|
||||
setFormData({...formData,speed:e.currentTarget.value});
|
||||
|
||||
}
|
||||
console.log(formData.speed)
|
||||
};
|
||||
|
||||
const handleNameInput = (e) => {
|
||||
setFormData({...formData,name:e.currentTarget.value});
|
||||
|
||||
}
|
||||
const handleInput = (e) => {
|
||||
console.log(e.target.name)
|
||||
switch (e.target.name) {
|
||||
case "Lat":
|
||||
if(!isNaN(e.nativeEvent?.data) )
|
||||
{
|
||||
setFormData({...formData,position:[e.currentTarget.value,formData.position[1],formData.position[2]] });
|
||||
}
|
||||
|
||||
break;
|
||||
case "Lon":
|
||||
setFormData({...formData,position:[formData.position[0],e.currentTarget.value,formData.position[2]] });
|
||||
|
||||
break;
|
||||
case "Height":
|
||||
setFormData({...formData,position:[formData.position[0],formData.position[1],e.currentTarget.value] });
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const emptyForm= (e) =>
|
||||
{
|
||||
|
||||
setFormData({name:'',course:'',speed:'',position:['','']})
|
||||
setEntity(undefined)
|
||||
props.Functions.resetEntityOnFocus();
|
||||
|
||||
}
|
||||
|
||||
@@ -240,14 +265,14 @@ const handleClick = (e) => {
|
||||
<div class="div7">
|
||||
<div class="input-group mb-3 NumberInputsGroup">
|
||||
<span class="input-group-text">Lat</span>
|
||||
<input className="ControlInput NumberInputs" name="Lat" readOnly={true} type="text" onClick={handleClick} value={formData.position[0]} />
|
||||
<input className="ControlInput NumberInputs" name="Lat" readOnly={true} type="text" onClick={handleClick} onChange={handleInput} value={formData.position[0]} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="div8">
|
||||
<div class="input-group mb-3 NumberInputsGroup" >
|
||||
<span class="input-group-text">Lon</span>
|
||||
{/* <input className="ControlInput" name="Lat" readOnly={true} type="text" onClick={handleClick} value={formData.position[0]} /> */}
|
||||
<input className="ControlInput NumberInputs" name="Lon" readOnly={true} type="text" onClick={handleClick} value={formData.position[1]}/>
|
||||
<input className="ControlInput NumberInputs" name="Lon" readOnly={true} type="text" onClick={handleClick} onChange={handleInput} value={formData.position[1]}/>
|
||||
</div>
|
||||
{/* <div className="flex">
|
||||
<div className="ControlHeader">Lon:</div>
|
||||
@@ -257,7 +282,7 @@ const handleClick = (e) => {
|
||||
<div class="input-group mb-3 NumberInputsGroup">
|
||||
<span class="input-group-text">Height</span>
|
||||
{/* <input className="ControlInput" name="Lat" readOnly={true} type="text" onClick={handleClick} value={formData.position[0]} /> */}
|
||||
<input className="ControlInput NumberInputs" name="height" readOnly={true} type="text" onClick={handleClick} value={formData.position[2]}/>
|
||||
<input className="ControlInput NumberInputs" name="Height" readOnly={true} type="text" onClick={handleClick} onChange={handleInput} value={formData.position[2]}/>
|
||||
</div>
|
||||
{/* <div className="ControlHeader">Height:</div>
|
||||
<div className="flex">
|
||||
|
||||
Reference in New Issue
Block a user