Skip to content

Conversation

@giuscris
Copy link
Member

@giuscris giuscris commented Nov 9, 2025

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@delete method 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.delete route now explicitly supports both HTTP and XHR request types, clarifying its usage for AJAX operations.

Frontend and modal improvements:

  • A new modal definition deletePageItem.yaml is added for deleting pages, with clear messaging and command handling.
  • The pages tree UI now uses the new deletePageItemModal for 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.

@giuscris giuscris added this to the 2.2.0 milestone Nov 9, 2025
@giuscris giuscris requested a review from Copilot November 9, 2025 17:54
@giuscris giuscris self-assigned this Nov 9, 2025
@giuscris giuscris added the enhancement New feature or request label Nov 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds AJAX-based page deletion functionality to the pages tree view, enabling in-place deletion without page reloads. The implementation follows the existing pattern used for file deletion.

  • Introduces a new deletePageItem modal with command-based actions for AJAX requests
  • Updates the PagesController::delete method to handle both traditional form submissions and XHR requests with JSON responses
  • Adds TypeScript handling for the delete operation with dynamic UI updates (removing items, updating parent state)

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
panel/views/pages/tree.php Updates modal reference and data attribute for AJAX-based deletion
panel/src/ts/components/views/pages.ts Adds modal handlers for AJAX page deletion with UI state management
panel/modals/deletePageItem.yaml Defines new command-based modal configuration for tree item deletion
panel/config/routes/routes.php Enables XHR support for the delete route
formwork/src/Panel/Controllers/PagesController.php Adds JSON response handling for AJAX delete requests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giuscris giuscris marked this pull request as ready for review November 15, 2025 12:18
@giuscris giuscris merged commit b4033a1 into 2.x Nov 15, 2025
8 checks passed
@giuscris giuscris deleted the feature/delete-page-item branch November 15, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

2 participants