Added back the delete button
This commit is contained in:
+33
-1
@@ -116,9 +116,16 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-list__item form {
|
.task-list__item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-list__completion-form {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
align-items: center;
|
||||||
gap: .75rem;
|
gap: .75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,6 +184,31 @@ body {
|
|||||||
outline-offset: 3px;
|
outline-offset: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.task-list__remove {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
width: 2rem;
|
||||||
|
height: 2rem;
|
||||||
|
padding: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #ffe0e0;
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
border-radius: .5rem;
|
||||||
|
transition: color .15s ease, background-color .15s ease, transform .15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-list__remove:hover {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #a71d1d;
|
||||||
|
transform: scale(1.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-list__remove:focus-visible {
|
||||||
|
outline: 3px solid #fff;
|
||||||
|
outline-offset: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
.task-list__title {
|
.task-list__title {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,10 @@ final class TaskController extends AbstractController
|
|||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->headers->has('HX-Request')) {
|
||||||
|
return new Response('', Response::HTTP_OK);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->redirectToRoute('app_task_index', [], Response::HTTP_SEE_OTHER);
|
return $this->redirectToRoute('app_task_index', [], Response::HTTP_SEE_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<li class="task-list__item{{ not task.isActive ? ' task-list__item--completed' : '' }}">
|
<li class="task-list__item{{ not task.isActive ? ' task-list__item--completed' : '' }}">
|
||||||
<form>
|
<form class="task-list__completion-form">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token('completion' ~ task.id) }}">
|
<input type="hidden" name="_token" value="{{ csrf_token('completion' ~ task.id) }}">
|
||||||
<input
|
<input
|
||||||
id="task-completion-{{ task.id }}"
|
id="task-completion-{{ task.id }}"
|
||||||
@@ -21,4 +21,16 @@
|
|||||||
</label>
|
</label>
|
||||||
<a class="task-list__title" href="{{ path('app_task_edit', {'id': task.id}) }}">{{ task.title }}</a>
|
<a class="task-list__title" href="{{ path('app_task_edit', {'id': task.id}) }}">{{ task.title }}</a>
|
||||||
</form>
|
</form>
|
||||||
|
<form
|
||||||
|
class="task-list__remove-form"
|
||||||
|
hx-post="{{ path('app_task_delete', {'id': task.id}) }}"
|
||||||
|
hx-target="closest .task-list__item"
|
||||||
|
hx-swap="delete"
|
||||||
|
hx-confirm="Remove {{ task.title }}?"
|
||||||
|
>
|
||||||
|
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ task.id) }}">
|
||||||
|
<button class="task-list__remove" type="submit" aria-label="Remove {{ task.title }}" title="Remove {{ task.title }}">
|
||||||
|
<span class="material-symbols-outlined" aria-hidden="true">delete</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user