Skip to content

Commit

Permalink
Added prompt when unsaved changes to extent button. Changed visibilit…
Browse files Browse the repository at this point in the history
…y to only appear on map view.
  • Loading branch information
paulthatjazz committed Jan 2, 2024
1 parent 714ce9e commit a201fbc
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions app/javascript/projects/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,28 @@ export const Toolbar = ({ backButtonPath, projectName, hasUnsavedChanges, curren
<i className="fas fa-save" /> Save
</button>
</div>
<div className="btn-group mr-2">
<a href={`${window.location}/edit`}>
<button className={`btn btn-sm btn-outline-primary`} onMouseEnter={() => setShowExtent(true)} onMouseLeave={() => setShowExtent(false)}>
<i className="fas fa-square" /> Extent
</button>
</a>
<div title={`Zoom level = ${zoomLevel}`} className="p-1 " style={{backgroundColor: zoomLevel > 20 ? "green" : (zoomLevel < 20 ? "orange" : "yellow"), fontSize: ".9em"}}>
{zoomLevel > 20 ? "High" : (zoomLevel < 20 ? "Low" : "Med")}
{
currentTab == Tab.MapView &&
<div className="btn-group mr-2">
<a onClick={()=> {
const editUrl = `${window.location}/edit`
if(hasUnsavedChanges) {
if(confirm("You have unsaved changes. Are you sure you want to leave this page?") == true) window.location.href = editUrl
}else{
window.location.href = editUrl
}
}
}
>
<button className={`btn btn-sm btn-outline-primary`} onMouseEnter={() => setShowExtent(true)} onMouseLeave={() => setShowExtent(false)}>
<i className="fas fa-square" /> Extent
</button>
</a>
<div title={`Zoom level = ${zoomLevel}`} className="p-1 " style={{backgroundColor: zoomLevel > 20 ? "green" : (zoomLevel < 20 ? "orange" : "yellow"), fontSize: ".9em"}}>
{zoomLevel > 20 ? "High" : (zoomLevel < 20 ? "Low" : "Med")}
</div>
</div>
</div>
}
<div className="btn-group mr-2">
<button className={`btn btn-sm ${currentTab == Tab.MapView ? "btn-primary" : "btn-outline-primary"}`} onClick={() => setCurrentTab(Tab.MapView)}>
<i className="fas fa-map-marked-alt" /> Map view
Expand Down

0 comments on commit a201fbc

Please sign in to comment.