Skip to content

Commit

Permalink
Merge pull request #147 from crf-devs/allow_near_availabilities_creat…
Browse files Browse the repository at this point in the history
…aion

Allow user near availabiity creation
  • Loading branch information
mRoca authored Mar 26, 2020
2 parents 25f5994 + a0157db commit f9d0686
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ public function __invoke(Request $request): Response

$end = $start->add(new \DateInterval('P7D'));

$blockedSlotsInterval = new \DateInterval('PT48H');
$availabilitiesDomain = AvailabilitiesDomain::generate(
$start,
$end,
$this->userAvailabilityRepository->findBetweenDates($user, $start, $end),
new \DateInterval('PT48H')
$blockedSlotsInterval
);

$form = $this
Expand All @@ -78,6 +79,7 @@ public function __invoke(Request $request): Response

return $this->render('user/availability.html.twig', [
'form' => $form->createView(),
'blockedSlotsInterval' => $blockedSlotsInterval,
]);
}
}
2 changes: 1 addition & 1 deletion src/Domain/AvailabilityDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function isEditable(): bool
$trueNow = new \DateTimeImmutable('now', new \DateTimeZone('Europe/Paris'));
$fakeUTCnow = new \DateTimeImmutable($trueNow->format('Y-m-d H:i:s'));

if (null !== $this->disabledIntervalFromNow) {
if (null !== $this->availability && null !== $this->disabledIntervalFromNow && AvailabilityInterface::STATUS_UNKNOW !== $this->availability->getStatus()) {
return $this->date > $fakeUTCnow->add($this->disabledIntervalFromNow);
}

Expand Down
15 changes: 12 additions & 3 deletions templates/availability/_table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div class="col-12 col-md-8">
<nav class="mt-3">
<ul class="pagination pagination-sm">
<ul class="pagination pagination-sm justify-content-end">
<li class="page-item{% if nowIsCurrent %} disabled{% endif %}">
<a class="page-link" href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({week: 'now'|date('o-\\WW')})) }}">
<span aria-hidden="true">&laquo;</span>
Expand Down Expand Up @@ -59,8 +59,17 @@
</tbody>
</table>
</div>
<div class="float-right">{{ form_widget(form.submit) }}</div>
<div class="clearfix"></div>

<div class="row">
<div class="col-12 col-md-8">
{% if blockedSlotsInterval is defined %}
<p class="font-italic">Vous ne pouvez pas modifier les disponibilités saisies pour les prochaines {{ blockedSlotsInterval.format('%h heures') }}</p>
{% endif %}
</div>
<div class="col-12 col-md-4">
<div class="float-right mt-2">{{ form_widget(form.submit) }}</div>
</div>
</div>

{{ form_end(form) }}

Expand Down

0 comments on commit f9d0686

Please sign in to comment.