Bulk delete availability slots from the admin list view
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 1m40s
CI / Tests (PHP 8.1) (pull_request) Successful in 46s
CI / Tests (PHP 8.2) (pull_request) Successful in 45s
CI / Tests (PHP 8.3) (pull_request) Successful in 1m34s
CI / PHPStan (pull_request) Successful in 2m52s
CI / Build Plugin Zip (pull_request) Has been skipped
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 1m40s
CI / Tests (PHP 8.1) (pull_request) Successful in 46s
CI / Tests (PHP 8.2) (pull_request) Successful in 45s
CI / Tests (PHP 8.3) (pull_request) Successful in 1m34s
CI / PHPStan (pull_request) Successful in 2m52s
CI / Build Plugin Zip (pull_request) Has been skipped
The list view of Current Slots gets a checkbox per unbooked slot, a select-all header checkbox, and a Delete selected button submitting a new bulk_delete form action. Each id is ownership-checked through the same path as single delete; the repository's is_booked guard refuses booked slots as a second layer. Row checkboxes attach to the bulk form via the HTML form attribute because the table already contains the per-row delete forms and forms cannot nest. Closes #57 Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
@@ -136,9 +136,22 @@ $deleteForm = static function (\Unsupervised\Schedular\Availability\Availability
|
||||
<?php elseif (empty($slots)) : ?>
|
||||
<p><?php esc_html_e('No availability slots configured.', 'unsupervised-schedular'); ?></p>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
// Bulk-delete form. The row checkboxes live inside the table and are
|
||||
// associated via the HTML form attribute, because the table also
|
||||
// contains the per-row delete forms and forms cannot nest.
|
||||
?>
|
||||
<form method="post" id="usc-bulk-delete-form" onsubmit="return confirm('<?php echo esc_js(__('Delete the selected slots?', 'unsupervised-schedular')); ?>');">
|
||||
<?php wp_nonce_field('usc_availability_action'); ?>
|
||||
<input type="hidden" name="usc_action" value="bulk_delete">
|
||||
</form>
|
||||
<table class="wp-list-table widefat fixed striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="manage-column column-cb check-column">
|
||||
<input type="checkbox" id="cb-select-all-1">
|
||||
<label for="cb-select-all-1"><span class="screen-reader-text"><?php esc_html_e('Select all', 'unsupervised-schedular'); ?></span></label>
|
||||
</td>
|
||||
<th><?php esc_html_e('Start', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('End', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('Length', 'unsupervised-schedular'); ?></th>
|
||||
@@ -149,6 +162,11 @@ $deleteForm = static function (\Unsupervised\Schedular\Availability\Availability
|
||||
<tbody>
|
||||
<?php foreach ($slots as $slot) : ?>
|
||||
<tr>
|
||||
<th scope="row" class="check-column">
|
||||
<?php if (! $slot->isBooked) : ?>
|
||||
<input type="checkbox" name="slot_ids[]" form="usc-bulk-delete-form" value="<?php echo esc_attr((string) $slot->id); ?>">
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td><?php echo esc_html((string) mysql2date('M j, Y g:i A', $slot->startDt)); ?></td>
|
||||
<td><?php echo esc_html((string) mysql2date('M j, Y g:i A', $slot->endDt)); ?></td>
|
||||
<td><?php echo esc_html((string) $slot->durationMinutes . ' min'); ?></td>
|
||||
@@ -162,5 +180,10 @@ $deleteForm = static function (\Unsupervised\Schedular\Availability\Availability
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
<button type="submit" class="button" form="usc-bulk-delete-form">
|
||||
<?php esc_html_e('Delete selected', 'unsupervised-schedular'); ?>
|
||||
</button>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user