formwork
formwork copied to clipboard
Add the possibility to delete pages in place from the tree
This pull request improves the user experience and robustness of deleting pages in the panel by introducing a dedicated modal for page deletion and enhancing both backend and frontend handling of delete actions, especially for AJAX (XHR) requests. The changes ensure that errors and success messages are communicated appropriately whether the action is performed via a standard HTTP request or an XHR request, and that the UI updates dynamically after deletion.
Backend enhancements for delete actions:
- The
PagesController@deletemethod now returns JSON error responses for XHR requests when the page is not found, the language is invalid, or the page is not deletable, ensuring AJAX requests receive structured error feedback. [1] [2] - On successful deletion via XHR, a JSON success response is returned, improving frontend integration.
- The
panel.pages.deleteroute now explicitly supports both HTTP and XHR request types, clarifying its usage for AJAX operations.
Frontend and modal improvements:
- A new modal definition
deletePageItem.yamlis added for deleting pages, with clear messaging and command handling. - The pages tree UI now uses the new
deletePageItemModalfor delete actions, and the modal is properly initialized in the TypeScript logic. [1] [2] [3] - The frontend logic (
pages.ts) is updated to handle the new modal's open and command events, sending the delete request via AJAX, updating the UI to remove the deleted page, and showing notifications based on the server response.
These changes collectively make page deletion more user-friendly, reliable, and consistent across different types of requests.