Cleanup labelling flow

This commit is contained in:
Igor 2019-12-10 18:18:37 -03:00
parent ef611e4849
commit 68fcaef19a

View File

@ -44,13 +44,9 @@ const LabellingFlow = ({
const newMeasurementData = cloneDeep(measurementData); const newMeasurementData = cloneDeep(measurementData);
treatMeasurementData(newMeasurementData); treatMeasurementData(newMeasurementData);
let newEditLocation = editLocation;
if (!editDescription && !editLocation) {
newEditLocation = true;
}
setState(state => ({ setState(state => ({
...state, ...state,
editLocation: newEditLocation, editLocation: !editDescription && !editLocation,
measurementData: newMeasurementData, measurementData: newMeasurementData,
})); }));
}, [editDescription, editLocation, measurementData]); }, [editDescription, editLocation, measurementData]);
@ -75,8 +71,8 @@ const LabellingFlow = ({
setState(state => ({ ...state, editDescription: false })); setState(state => ({ ...state, editDescription: false }));
}; };
const handleKeyPress = e => { const handleKeyPress = event => {
if (e.key === 'Enter') { if (event.key === 'Enter') {
descriptionSave(); descriptionSave();
} }
}; };
@ -120,19 +116,16 @@ const LabellingFlow = ({
* Waits for 1 sec to dismiss the labelling component. * Waits for 1 sec to dismiss the labelling component.
* *
*/ */
const fadeOutAndLeave = () => { const fadeOutAndLeave = () =>
setFadeOutTimer(setTimeout(() => setShowComponent(false), 1000)); setFadeOutTimer(setTimeout(fadeOutAndLeaveFast, 1000));
};
const fadeOutAndLeaveFast = () => setShowComponent(false); const fadeOutAndLeaveFast = () => setShowComponent(false);
const clearFadeOutTimer = () => { const clearFadeOutTimer = () => {
if (!fadeOutTimer) { if (fadeOutTimer) {
return; clearTimeout(fadeOutTimer);
setFadeOutTimer(null);
} }
clearTimeout(fadeOutTimer);
setFadeOutTimer(null);
}; };
const descriptionDialogUpdate = description => { const descriptionDialogUpdate = description => {
@ -146,15 +139,13 @@ const LabellingFlow = ({
if (!skipAddLabelButton) { if (!skipAddLabelButton) {
return ( return (
<> <button
<button type="button"
type="button" className="addLabelButton"
className="addLabelButton" onClick={showLabelling}
onClick={showLabelling} >
> {location ? 'Edit' : 'Add'} Label
{location ? 'Edit' : 'Add'} Label </button>
</button>
</>
); );
} else { } else {
if (editLocation) { if (editLocation) {