ui touch ups
This commit is contained in:
+31
-3
@@ -56,12 +56,13 @@ header {
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.day-picker {
|
.day-picker {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
margin-bottom: 1.5rem;
|
margin-bottom: 0;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
@@ -184,11 +185,12 @@ header {
|
|||||||
|
|
||||||
.weather-forecast {
|
.weather-forecast {
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
margin-bottom: 50px;
|
// margin-bottom: 50px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
> span {
|
|
||||||
|
>span {
|
||||||
line-height: 2;
|
line-height: 2;
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
}
|
}
|
||||||
@@ -199,9 +201,11 @@ header {
|
|||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
&__submit {
|
&__submit {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
form.task-composer__form {
|
form.task-composer__form {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: unset;
|
max-width: unset;
|
||||||
@@ -217,9 +221,22 @@ header {
|
|||||||
&__main {
|
&__main {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
&__heading {
|
||||||
|
padding: 25px;
|
||||||
|
h2 {
|
||||||
|
font-size: 2em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&__row {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
&__details {
|
&__details {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
gap: 25px;
|
gap: 25px;
|
||||||
|
|
||||||
input[type=checkbox] {
|
input[type=checkbox] {
|
||||||
@@ -288,6 +305,13 @@ header {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: .75rem;
|
gap: .75rem;
|
||||||
|
color: #000;
|
||||||
|
a.task-list__title:focus,
|
||||||
|
a.task-list__title:active,
|
||||||
|
a.task-list__title:visited
|
||||||
|
{
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-list__checkbox,
|
.task-list__checkbox,
|
||||||
@@ -513,3 +537,7 @@ header {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.weather-refresh {
|
||||||
|
box-shadow: unset;
|
||||||
|
border: unset;
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
#[Route('/task')]
|
#[Route('/task')]
|
||||||
final class TaskController extends AbstractController
|
final class TaskController extends AbstractController
|
||||||
@@ -116,7 +117,7 @@ final class TaskController extends AbstractController
|
|||||||
#[Route('/{id}/completion', name: 'app_task_toggle_completion', methods: ['POST'])]
|
#[Route('/{id}/completion', name: 'app_task_toggle_completion', methods: ['POST'])]
|
||||||
public function toggleCompletion(Request $request, Task $task, EntityManagerInterface $entityManager, TaskRepository $taskRepository, TaskRecommendationService $taskRecommendationService): Response
|
public function toggleCompletion(Request $request, Task $task, EntityManagerInterface $entityManager, TaskRepository $taskRepository, TaskRecommendationService $taskRecommendationService): Response
|
||||||
{
|
{
|
||||||
if (!$this->isCsrfTokenValid('completion'.$task->getId(), $request->getPayload()->getString('_token'))) {
|
if (!$this->isCsrfTokenValid('completion' . $task->getId(), $request->getPayload()->getString('_token'))) {
|
||||||
throw $this->createAccessDeniedException('Invalid CSRF token.');
|
throw $this->createAccessDeniedException('Invalid CSRF token.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +135,7 @@ final class TaskController extends AbstractController
|
|||||||
#[Route('/{id}', name: 'app_task_delete', methods: ['POST'])]
|
#[Route('/{id}', name: 'app_task_delete', methods: ['POST'])]
|
||||||
public function delete(Request $request, Task $task, EntityManagerInterface $entityManager): Response
|
public function delete(Request $request, Task $task, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
if ($this->isCsrfTokenValid('delete'.$task->getId(), $request->getPayload()->getString('_token'))) {
|
if ($this->isCsrfTokenValid('delete' . $task->getId(), $request->getPayload()->getString('_token'))) {
|
||||||
$entityManager->remove($task);
|
$entityManager->remove($task);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
}
|
}
|
||||||
@@ -183,6 +184,23 @@ final class TaskController extends AbstractController
|
|||||||
|
|
||||||
return $user instanceof User ? $user->getSettings() : null;
|
return $user instanceof User ? $user->getSettings() : null;
|
||||||
}
|
}
|
||||||
|
#[Route('/task/refresh/weather', name: 'weather_refresh', methods: ['POST'])]
|
||||||
|
public function refresh(): Response
|
||||||
|
{
|
||||||
|
$process = new Process([
|
||||||
|
'frankenphp',
|
||||||
|
'php-cli',
|
||||||
|
$this->getParameter('kernel.project_dir') . '/bin/console',
|
||||||
|
'app:weather:refresh',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
if (!$process->isSuccessful()) {
|
||||||
|
throw new \RuntimeException($process->getErrorOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->redirectToRoute('app_task_index');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,16 @@ use App\Entity\WeatherForecast;
|
|||||||
|
|
||||||
final class WeatherEvaluator
|
final class WeatherEvaluator
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Summary of scoreAdjustment
|
||||||
|
* @param Task $task
|
||||||
|
* @param mixed $forecast
|
||||||
|
* @param mixed $previousDay
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function scoreAdjustment(Task $task, ?WeatherForecast $forecast, ?WeatherForecast $previousDay = null): int
|
public function scoreAdjustment(Task $task, ?WeatherForecast $forecast, ?WeatherForecast $previousDay = null): int
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$task->isOutdoor() || null === $forecast) {
|
if (!$task->isOutdoor() || null === $forecast) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -27,7 +35,11 @@ final class WeatherEvaluator
|
|||||||
|
|
||||||
return $this->isWet($forecast) ? -45 : 0;
|
return $this->isWet($forecast) ? -45 : 0;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Summary of isWet
|
||||||
|
* @param mixed $forecast
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function isWet(?WeatherForecast $forecast): bool
|
public function isWet(?WeatherForecast $forecast): bool
|
||||||
{
|
{
|
||||||
return null !== $forecast
|
return null !== $forecast
|
||||||
@@ -35,12 +47,23 @@ final class WeatherEvaluator
|
|||||||
|| ($forecast->getPrecipitationSum() ?? 0) >= 1.0
|
|| ($forecast->getPrecipitationSum() ?? 0) >= 1.0
|
||||||
|| ($forecast->getRainSum() ?? 0) >= 1.0);
|
|| ($forecast->getRainSum() ?? 0) >= 1.0);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Summary of isDryForecast
|
||||||
|
* @param mixed $forecast
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function isDryForecast(?WeatherForecast $forecast): bool
|
public function isDryForecast(?WeatherForecast $forecast): bool
|
||||||
{
|
{
|
||||||
return null !== $forecast && !$this->isWet($forecast);
|
return null !== $forecast && !$this->isWet($forecast);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Summary of shouldCarryForward
|
||||||
|
* @param Task $task
|
||||||
|
* @param \DateTimeImmutable $selectedDay
|
||||||
|
* @param mixed $previousDay
|
||||||
|
* @param mixed $currentDay
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function shouldCarryForward(Task $task, \DateTimeImmutable $selectedDay, ?WeatherForecast $previousDay, ?WeatherForecast $currentDay): bool
|
public function shouldCarryForward(Task $task, \DateTimeImmutable $selectedDay, ?WeatherForecast $previousDay, ?WeatherForecast $currentDay): bool
|
||||||
{
|
{
|
||||||
return $task->isOutdoor()
|
return $task->isOutdoor()
|
||||||
|
|||||||
@@ -20,9 +20,12 @@
|
|||||||
{{ form_errors(form.title) }}
|
{{ form_errors(form.title) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="task-composer__details">
|
<div class="task-composer__details">
|
||||||
|
<div class="task-composer__row">
|
||||||
<div>{{ form_row(form.estimatedDurationMinutes) }}</div>
|
<div>{{ form_row(form.estimatedDurationMinutes) }}</div>
|
||||||
<div>{{ form_row(form.priority) }}</div>
|
<div>{{ form_row(form.priority) }}</div>
|
||||||
<div>{{ form_row(form.category) }}</div>
|
<div>{{ form_row(form.category) }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="task-composer__row">
|
||||||
<div>{{ form_row(form.scheduledFor) }}</div>
|
<div>{{ form_row(form.scheduledFor) }}</div>
|
||||||
<div>{{ form_row(form.isOutdoor) }}</div>
|
<div>{{ form_row(form.isOutdoor) }}</div>
|
||||||
<div>{{ form_row(form.weatherProfile) }}</div>
|
<div>{{ form_row(form.weatherProfile) }}</div>
|
||||||
@@ -36,6 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<details class="task-composer__notes">
|
<details class="task-composer__notes">
|
||||||
<summary>Add a note</summary>
|
<summary>Add a note</summary>
|
||||||
{{ form_row(form.description) }}
|
{{ form_row(form.description) }}
|
||||||
|
|||||||
@@ -1,38 +1,48 @@
|
|||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% block title %}Tasks{% endblock %}
|
{% block title %}Tasks
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="task-list-header">
|
<div class="task-list-header">
|
||||||
<h1>Tasks</h1>
|
<button class="weather-location" type="button" data-weather-location data-location-url="{{ path('app_task_location') }}" data-location-token="{{ csrf_token('weather_location') }}">
|
||||||
|
<span class="material-symbols-outlined" aria-hidden="true">my_location</span>
|
||||||
|
{{ has_saved_location ? 'Update weather location' : 'Use my location for weather' }}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{# <p class="weather-location__status" data-weather-location-status aria-live="polite"></p> #}
|
||||||
|
{% if weather_forecast %}
|
||||||
|
{{ include('task/_weather_forecast.html.twig', {forecast: weather_forecast}) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<nav class="day-picker" aria-label="Choose task day">
|
<nav class="day-picker" aria-label="Choose task day">
|
||||||
<a href="{{ path('app_task_index', {date: selected_date|date_modify('-1 day')|date('Y-m-d')}) }}" aria-label="Previous day"><span class="material-symbols-outlined">
|
<a href="{{ path('app_task_index', {date: selected_date|date_modify('-1 day')|date('Y-m-d')}) }}" aria-label="Previous day">
|
||||||
chevron_backward
|
<span class="material-symbols-outlined">
|
||||||
</span></a>
|
chevron_backward
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
<div>
|
<div>
|
||||||
<strong>{{ selected_date|date('l, j F') }}</strong>
|
<strong>{{ selected_date|date('l, j F') }}</strong>
|
||||||
{% if selected_date|date('Y-m-d') != 'now'|date('Y-m-d') %}
|
{% if selected_date|date('Y-m-d') != 'now'|date('Y-m-d') %}
|
||||||
<a href="{{ path('app_task_index') }}">Today</a>
|
<a href="{{ path('app_task_index') }}">Today</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<a href="{{ path('app_task_index', {date: selected_date|date_modify('+1 day')|date('Y-m-d')}) }}" aria-label="Next day"><span class="material-symbols-outlined">
|
<a href="{{ path('app_task_index', {date: selected_date|date_modify('+1 day')|date('Y-m-d')}) }}" aria-label="Next day">
|
||||||
chevron_forward
|
<span class="material-symbols-outlined">
|
||||||
</span></a>
|
chevron_forward
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
<form method="post" action="{{ path('weather_refresh') }}" class="weather-refresh">
|
||||||
|
<button type="submit" class="btn btn-primary">
|
||||||
|
Update weather
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<button class="weather-location" type="button" data-weather-location data-location-url="{{ path('app_task_location') }}" data-location-token="{{ csrf_token('weather_location') }}">
|
<h1>Tasks</h1>
|
||||||
<span class="material-symbols-outlined" aria-hidden="true">my_location</span>
|
|
||||||
{{ has_saved_location ? 'Update weather location' : 'Use my location for weather' }}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<p class="weather-location__status" data-weather-location-status aria-live="polite"></p>
|
|
||||||
{% if weather_forecast %}
|
|
||||||
{{ include('task/_weather_forecast.html.twig', {forecast: weather_forecast}) }}
|
|
||||||
{% endif %}
|
|
||||||
{{ include('task/_task_composer.html.twig', {form: form}) }}
|
{{ include('task/_task_composer.html.twig', {form: form}) }}
|
||||||
|
|
||||||
{{ include('task/_task_recommendations.html.twig', {
|
{{ include('task/_task_recommendations.html.twig', {
|
||||||
|
|||||||
Reference in New Issue
Block a user