Adds feature to discard all the changes on the map
Description
This PR addresses the issue #10033 which concerns the need for a discard button to discard all the changes on the map. Previously this was done by reloading the map and then discarding all the changes but this PR will create a discard button to dump all the changes without having to reload the page, also unlike the reload method this discard action can be undone.
Changes made
Presently this PR has 3 commits
Commit1: creates the discard feature. Commit2: merges changes made into the original repo. Commit3: fixes lint issues in the code.
Here's the rundown of changes made in Commit 1:
- Creates a discard() function in history.js which sets the current state of the map to the original state.
- Created a discard.js file in /tools to render the discard button and write the logic for the same.
- Added UI label in helper.js
- Added the discard button to top_toolbar.js
Proof of concept
Screencast from 12-12-23 10:52:08 PM IST.webm
Final thoughts
I understand that this PR makes some major changes to iD therefore I would request the admins to take a look and this and if there are any changes to be made feel free to let me know as I am more than willing to work further on this issue.
The demo looks amazing! Сan you add improvements?
- the "discard" button has replaced the save button location, this may confuse users - you need to move the "discard" button near the "undo" button
- add a confirmation window
- check will the translation mechanism work for other languages?
@dypa Sure Ill work on it
@dypa Is this better? Screencast from 08-01-24 10:42:25 AM IST.webm
PS: If changes can be undone, there is really no need to add a confirmation dialog. I'd remove it.
PSS: the dist directory should never be manually changed, as it is recreated automatically by the build scripts. New translatable strings should be added to the data/core.yaml file (read more).
@tyrasd Hey I liked the long press functionality for the undo button and here's the implementation
Screencast from 21-01-24 03:38:15 PM IST.webm
Like you suggested, long pressing the undo button will discard all the changes and set the state of the map to the way it was initially also the user can redo the changes one by one if they wish.
If this is alright then I will commit the changes.