fix: allow booking the free part of a partly booked day
This commit is contained in:
1 parent
a88ff7ff24
commit
78839838f0
15 files changed
+541
-60
No files matched your search
@@ -9,6 +9,7 @@ use App\Booking\BoardPresenter;
|
||||
use App\Booking\BookingManager;
|
||||
use App\Booking\DateParam;
|
||||
use App\Booking\ResourceAlreadyBookedException;
|
||||
use App\Booking\Spot;
|
||||
use App\Booking\SeriesResult;
|
||||
use App\Booking\TimeRange;
|
||||
use App\Entity\Booking;
|
||||
@@ -70,9 +71,17 @@ final class BookingController extends AbstractController
|
||||
$selected = DateParam::parseOrToday($date);
|
||||
$boardTime = BoardController::timeOf($request);
|
||||
|
||||
// Prefilled from whatever span the board is showing, so narrowing the board and then
|
||||
// clicking a desk books exactly what was on screen.
|
||||
$data = new BookingRequest($selected, $boardTime);
|
||||
// Prefilled with the longest window still free inside the board's span -- NOT the span
|
||||
// itself. On an all-day board a resource booked 09:00-13:00 would otherwise be offered
|
||||
// as 00:00-24:00, collide with itself on submit, and leave the user exactly as stuck as
|
||||
// before. Falls back to the board's span when nothing is booked at all.
|
||||
$spot = Spot::for(
|
||||
$resource,
|
||||
$this->repository->findOverlapping($resource, $selected, $boardTime),
|
||||
$boardTime,
|
||||
$this->currentUser(),
|
||||
);
|
||||
$data = new BookingRequest($selected, $spot->suggested() ?? $boardTime);
|
||||
|
||||
$form = $this->createForm(BookingType::class, $data, [
|
||||
'action' => $this->generateUrl('app_booking_new', ['id' => $resource->getId(), 'date' => $date] + $this->timeParameters($boardTime)),
|
||||
|
||||
Reference in new issue
Block a user