From 09e69b714d4f53eba0fe5751d70627bc68e77e98 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Wed, 1 May 2024 08:28:32 +0200 Subject: [PATCH 01/19] 1280: Simplified planning form. Added default value --- .env | 1 + CHANGELOG.md | 2 + config/services.yaml | 1 + src/Controller/PlanningController.php | 51 +--- src/Form/PlanningType.php | 1 - templates/planning/index.html.twig | 247 +++++++++++++++++- templates/planning/planning-sprints.html.twig | 199 -------------- templates/planning/planning-weeks.html.twig | 237 +---------------- 8 files changed, 256 insertions(+), 483 deletions(-) delete mode 100644 templates/planning/planning-sprints.html.twig diff --git a/.env b/.env index 4b82ab45..8446720f 100644 --- a/.env +++ b/.env @@ -27,6 +27,7 @@ APP_INVOICE_SUPPLIER_ACCOUNT=APP_INVOICE_SUPPLIER_ACCOUNT APP_INVOICE_RECEIVER_DEFAULT_ACCOUNT=APP_INVOICE_DEFAULT_RECEIVER_ACCOUNT APP_INVOICE_DESCRIPTION_TEMPLATE="Spørgsmål vedrørende fakturaen rettes til %name%, %email%." APP_PROJECT_BILLING_DEFAULT_DESCRIPTION= +APP_DEFAULT_PLANNING_DATA_PROVIDER= ###< Planning ### ###> itk-dev/openid-connect-bundle ### diff --git a/CHANGELOG.md b/CHANGELOG.md index e0484e57..ee9c7a84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* [PR-112](https://github.com/itk-dev/economics/pull/112) + 1280: Simplified planning form. Added default value. * [PR-110](https://github.com/itk-dev/economics/pull/110) 1209: No cost invoices * [PR-111](https://github.com/itk-dev/economics/pull/111) diff --git a/config/services.yaml b/config/services.yaml index e513281c..c393dd81 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -23,6 +23,7 @@ services: $invoiceSupplierAccount: '%env(string:APP_INVOICE_SUPPLIER_ACCOUNT)%' $invoiceDefaultReceiverAccount: '%env(string:APP_INVOICE_RECEIVER_DEFAULT_ACCOUNT)%' $projectBillingDefaultDescription: '%env(string:APP_PROJECT_BILLING_DEFAULT_DESCRIPTION)%' + $planningDefaultDataProvider: '%env(string:APP_DEFAULT_PLANNING_DATA_PROVIDER)%' # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name diff --git a/src/Controller/PlanningController.php b/src/Controller/PlanningController.php index 4f446bd7..140d03e3 100644 --- a/src/Controller/PlanningController.php +++ b/src/Controller/PlanningController.php @@ -24,8 +24,8 @@ class PlanningController extends AbstractController public function __construct( private readonly DataProviderService $dataProviderService, private readonly DataProviderRepository $dataProviderRepository, - private readonly TranslatorInterface $translator, private readonly ViewService $viewService, + private readonly ?int $planningDefaultDataProvider, ) { } @@ -39,6 +39,9 @@ public function index(Request $request): Response $planningFormData = new PlanningFormData(); $form = $this->createForm(PlanningType::class, $planningFormData); + $dataProviders = $this->dataProviderRepository->findAll(); + $defaultProvider = $this->dataProviderRepository->find($this->planningDefaultDataProvider); + $form->add('dataProvider', EntityType::class, [ 'class' => DataProvider::class, 'required' => true, @@ -48,56 +51,24 @@ public function index(Request $request): Response 'class' => 'form-element', ], 'help' => 'planning.data_provider_helptext', - 'choices' => $this->dataProviderRepository->findAll(), - ]); - - $form->add('viewType', ChoiceType::class, [ - 'required' => true, - 'label' => 'planning.view_type', - 'label_attr' => ['class' => 'label'], - 'attr' => [ - 'class' => 'form-element', - ], - 'help' => 'planning.data_provider_helptext', - 'choices' => $this->getTypeChoices(), + 'data' => $this->dataProviderRepository->find($this->planningDefaultDataProvider), + 'choices' => $dataProviders, ]); $form->handleRequest($request); - $planningData = null; - $template = 'planning/index.html.twig'; - if ($form->isSubmitted() && $form->isValid()) { $service = $this->dataProviderService->getService($planningFormData->dataProvider); - $viewType = $form->getData()->viewType; - - switch ($viewType) { - case 'week': - $planningData = $service->getPlanningDataWeeks(); - $template = 'planning/planning-weeks.html.twig'; - break; - case 'sprint': - $planningData = $service->getPlanningDataSprints(); - $template = 'planning/planning-sprints.html.twig'; - break; - default: - $planningData = $service->getPlanningDataSprints(); - break; - } + } else { + $service = $this->dataProviderService->getService($defaultProvider); } - return $this->render($template, $this->viewService->addView([ + $planningData = $service->getPlanningDataWeeks(); + + return $this->render('planning/index.html.twig', $this->viewService->addView([ 'controller_name' => 'PlanningController', 'planningData' => $planningData, 'form' => $form, ])); } - - private function getTypeChoices() - { - return [ - $this->translator->trans('planning.week_view') => 'week', - $this->translator->trans('planning.sprint_view') => 'sprint', - ]; - } } diff --git a/src/Form/PlanningType.php b/src/Form/PlanningType.php index d89b9b90..dbc98bf5 100644 --- a/src/Form/PlanningType.php +++ b/src/Form/PlanningType.php @@ -13,7 +13,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('dataProvider') - ->add('viewType') ; } diff --git a/templates/planning/index.html.twig b/templates/planning/index.html.twig index 87932843..cbdf6174 100644 --- a/templates/planning/index.html.twig +++ b/templates/planning/index.html.twig @@ -5,12 +5,245 @@ {% block content %}

{{ 'planning.title'|trans }}

- {{ form_start(form) }} - {{ form_row(form.dataProvider) }} - {{ form_row(form.viewType) }} -
- -
- {{ form_end(form) }} + {{ form_start(form) }} + {{ form_row(form.dataProvider) }} +
+ +
+ {{ form_end(form) }} + + {% if planningData is not null %} +
+ + + {% set svg_expand %} + + {% endset %} + {% set svg_hide %} + + {% endset %} + + {% set weeks = planningData.weeks %} + {% set assignees = planningData.assignees %} + {% set projects = planningData.projects %} +

{{ 'planning.assignees'|trans }}

+
+ + + + + + {% for week in weeks %} + + {% endfor %} + + + {% for assignee in assignees %} + + + + + {% for week in weeks %} + {% set res = null %} + + {% for week_number in week.weekCollection %} + {% if assignee.sprintSums.containsKey(week_number) %} + {% set res = assignee.sprintSums.get(week_number).sumHours %} + {% endif %} + {% endfor %} + + {% endfor %} + + {% for project in assignee.projects %} + + + + {% for week in weeks %} + + {% endfor %} + + {% for issue in project.issues %} + + + + {% for week in weeks %} + + {% endfor %} + + {% endfor %} + {% endfor %} + + {% endfor %} +
{{ week.displayName }}
+ {{ assignee.displayName }} + + + + {{ res }} +
{{ project.displayName }} + + + {% for week_number in week.weekCollection %} + {% if project.sprintSums.containsKey(week_number) %} + {{ project.sprintSums.get(week_number).sumHours }} + {% endif %} + {% endfor %} +
+ #{{ issue.key }}
+ {{ issue.displayName }} +
+ {% for week_number in week.weekCollection %} + {% if issue.sprintId == week_number %} + {{ issue.remainingHours ?? 'UE' }} + {% endif %} + {% endfor %} +
+ +
+ {{ 'planning.hidden-entries'|trans }}: + +
+
+ +

{{ 'planning.projects'|trans }}

+
+ + + + + + {% for week in weeks %} + + {% endfor %} + + + {% for project in projects %} + + + + + {% for week in weeks %} + + {% endfor %} + + {% for assignee in project.assignees %} + + + + {% for week in weeks %} + + {% endfor %} + + {% for issue in assignee.issues %} + + + + {% for week in weeks %} + + {% endfor %} + + {% endfor %} + {% endfor %} + + {% endfor %} +
{{ week.displayName }}
+ {{ project.displayName }} + + + {% set res = null %} + {% for week_number in week.weekCollection %} + {% if project.sprintSums.containsKey(week_number) %} + {% set res = (res + project.sprintSums.get(week_number).sumHours) %} + {% endif %} + {% endfor %} + {{ res }} +
+ {{ assignee.displayName }} + + + {% for week_number in week.weekCollection %} + {% if assignee.sprintSums.containsKey(week_number) %} + {{ assignee.sprintSums.get(week_number).sumHours }} + {% endif %} + {% endfor %} +
+ #{{ issue.key }} +
+ {{ issue.displayName }} +
+ {% for week_number in week.weekCollection %} + {% if issue.sprintId == week_number %} + {{ issue.remainingHours ?? 'UE' }} + {% endif %} + {% endfor %} +
+
+
+ {% endif %} {% endblock %} diff --git a/templates/planning/planning-sprints.html.twig b/templates/planning/planning-sprints.html.twig deleted file mode 100644 index 56c2498e..00000000 --- a/templates/planning/planning-sprints.html.twig +++ /dev/null @@ -1,199 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %} - {{ 'planning.title'|trans }} -{% endblock %} - -{% block content %} -

{{ 'planning.title'|trans }}

- - {% if planningData is not null %} -
- - - {% set svg_expand %} - - {% endset %} - {% set svg_hide %} - - {% endset %} - - {% set sprints = planningData.sprints %} - {% set assignees = planningData.assignees %} - {% set projects = planningData.projects %} - -

{{ 'planning.assignees'|trans }}

-
- - - - - - {% for sprint in sprints %} - - {% endfor %} - - - {% for assignee in assignees %} - - - - - {% for sprint in sprints %} - {% if assignee.sprintSums.containsKey(sprint.sprintId) %} - {% set res = assignee.sprintSums.get(sprint.sprintId).sumHours %} - - {% else %} - - {% endif %} - {% endfor %} - - {% for project in assignee.projects %} - - - - {% for sprint in sprints %} - {% if project.sprintSums.containsKey(sprint.sprintId) %} - - {% else %} - - {% endif %} - {% endfor %} - - {% for issue in project.issues %} - - - - {% for sprint in sprints %} - {% if issue.sprintId == sprint.sprintId %} - - {% else %} - - {% endif %} - {% endfor %} - - {% endfor %} - {% endfor %} - - {% endfor %} -
{{ sprint.displayName }}
- {{ assignee.displayName }} - - - - - - {{ res }} -
{{ project.displayName }} - - - {{ project.sprintSums.get(sprint.sprintId).sumHours }} -
- {{ issue.key }}: - {{ issue.displayName }} - - {{ issue.remainingHours ?? 'UE' }} -
- -
- {{ 'planning.hidden-entries'|trans }}: - -
-
- -

{{ 'planning.projects'|trans }}

-
- - - - - - {% for sprint in sprints %} - - {% endfor %} - - - {% for project in projects %} - - - - - {% for sprint in sprints %} - {% if project.sprintSums.containsKey(sprint.sprintId) %} - {% set res = project.sprintSums.get(sprint.sprintId).sumHours %} - - {% else %} - - {% endif %} - {% endfor %} - - {% for assignee in project.assignees %} - - - - {% for sprint in sprints %} - {% if assignee.sprintSums.containsKey(sprint.sprintId) %} - - {% else %} - - {% endif %} - {% endfor %} - - {% for issue in assignee.issues %} - - - - {% for sprint in sprints %} - {% if issue.sprintId == sprint.sprintId %} - - {% else %} - - {% endif %} - {% endfor %} - - {% endfor %} - {% endfor %} - - {% endfor %} -
{{ sprint.displayName }}
- {{ project.displayName }} - - - {{ res }} -
- {{ assignee.displayName }} - - - {{ assignee.sprintSums.get(sprint.sprintId).sumHours }} -
- {{ issue.key }}: - {{ issue.displayName }} - - {{ issue.remainingHours ?? 'UE' }} -
-
-
- {% endif %} -{% endblock %} diff --git a/templates/planning/planning-weeks.html.twig b/templates/planning/planning-weeks.html.twig index 3ffa1e7a..9ba782dd 100644 --- a/templates/planning/planning-weeks.html.twig +++ b/templates/planning/planning-weeks.html.twig @@ -1,244 +1,9 @@ -{% extends 'base.html.twig' %} +a{% extends 'base.html.twig' %} {% block title %} {{ 'planning.title'|trans }} {% endblock %} {% block content %} -

{{ 'planning.title'|trans }}

- {% if planningData is not null %} -
- - - {% set svg_expand %} - - {% endset %} - {% set svg_hide %} - - {% endset %} - - {% set weeks = planningData.weeks %} - {% set assignees = planningData.assignees %} - {% set projects = planningData.projects %} - -

{{ 'planning.assignees'|trans }}

-
- - - - - - {% for week in weeks %} - - {% endfor %} - - - {% for assignee in assignees %} - - - - - {% for week in weeks %} - {% set res = null %} - - {% for week_number in week.weekCollection %} - {% if assignee.sprintSums.containsKey(week_number) %} - {% set res = assignee.sprintSums.get(week_number).sumHours %} - {% endif %} - {% endfor %} - - {% endfor %} - - {% for project in assignee.projects %} - - - - {% for week in weeks %} - - {% endfor %} - - {% for issue in project.issues %} - - - - {% for week in weeks %} - - {% endfor %} - - {% endfor %} - {% endfor %} - - {% endfor %} -
{{ week.displayName }}
- {{ assignee.displayName }} - - - - {{ res }} -
{{ project.displayName }} - - - {% for week_number in week.weekCollection %} - {% if project.sprintSums.containsKey(week_number) %} - {{ project.sprintSums.get(week_number).sumHours }} - {% endif %} - {% endfor %} -
- #{{ issue.key }}
- {{ issue.displayName }} -
- {% for week_number in week.weekCollection %} - {% if issue.sprintId == week_number %} - {{ issue.remainingHours ?? 'UE' }} - {% endif %} - {% endfor %} -
- -
- {{ 'planning.hidden-entries'|trans }}: - -
-
- -

{{ 'planning.projects'|trans }}

-
- - - - - - {% for week in weeks %} - - {% endfor %} - - - {% for project in projects %} - - - - - {% for week in weeks %} - - {% endfor %} - - {% for assignee in project.assignees %} - - - - {% for week in weeks %} - - {% endfor %} - - {% for issue in assignee.issues %} - - - - {% for week in weeks %} - - {% endfor %} - - {% endfor %} - {% endfor %} - - {% endfor %} -
{{ week.displayName }}
- {{ project.displayName }} - - - {% set res = null %} - {% for week_number in week.weekCollection %} - {% if project.sprintSums.containsKey(week_number) %} - {% set res = (res + project.sprintSums.get(week_number).sumHours) %} - {% endif %} - {% endfor %} - {{ res }} -
- {{ assignee.displayName }} - - - {% for week_number in week.weekCollection %} - {% if assignee.sprintSums.containsKey(week_number) %} - {{ assignee.sprintSums.get(week_number).sumHours }} - {% endif %} - {% endfor %} -
- #{{ issue.key }} -
- {{ issue.displayName }} -
- {% for week_number in week.weekCollection %} - {% if issue.sprintId == week_number %} - {{ issue.remainingHours ?? 'UE' }} - {% endif %} - {% endfor %} -
-
-
- {% endif %} {% endblock %} From d62a476c052568298dbb8382a822245297ad6a27 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Wed, 1 May 2024 08:53:52 +0200 Subject: [PATCH 02/19] 1280: Fixed issues with automatic reviews --- src/Controller/PlanningController.php | 8 ++++---- src/DataFixtures/AppFixtures.php | 11 +++++------ templates/planning/planning-weeks.html.twig | 9 --------- 3 files changed, 9 insertions(+), 19 deletions(-) delete mode 100644 templates/planning/planning-weeks.html.twig diff --git a/src/Controller/PlanningController.php b/src/Controller/PlanningController.php index 140d03e3..b049e2a4 100644 --- a/src/Controller/PlanningController.php +++ b/src/Controller/PlanningController.php @@ -12,11 +12,9 @@ use App\Service\ViewService; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; -use Symfony\Contracts\Translation\TranslatorInterface; #[Route('/admin/planning')] class PlanningController extends AbstractController @@ -57,13 +55,15 @@ public function index(Request $request): Response $form->handleRequest($request); + $service = null; + if ($form->isSubmitted() && $form->isValid()) { $service = $this->dataProviderService->getService($planningFormData->dataProvider); - } else { + } elseif (null !== $defaultProvider) { $service = $this->dataProviderService->getService($defaultProvider); } - $planningData = $service->getPlanningDataWeeks(); + $planningData = $service?->getPlanningDataWeeks(); return $this->render('planning/index.html.twig', $this->viewService->addView([ 'controller_name' => 'PlanningController', diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php index acd6a8f8..ba6c898d 100644 --- a/src/DataFixtures/AppFixtures.php +++ b/src/DataFixtures/AppFixtures.php @@ -27,8 +27,6 @@ public function load(ObjectManager $manager): void $dataProvider1->setUrl('http://localhost/'); $dataProvider1->setSecret('Not so secret'); - $manager->persist($dataProvider1); - $dataProviders[] = $dataProvider1; $dataProvider2 = new DataProvider(); @@ -38,11 +36,11 @@ public function load(ObjectManager $manager): void $dataProvider2->setUrl('http://localhost/'); $dataProvider2->setSecret('Not so secret'); - $manager->persist($dataProvider2); - $dataProviders[] = $dataProvider2; foreach ($dataProviders as $key => $dataProvider) { + $manager->persist($dataProvider); + for ($c = 0; $c < 2; ++$c) { $client = new Client(); $client->setName("client $key-$c"); @@ -126,8 +124,9 @@ public function load(ObjectManager $manager): void $manager->flush(); } } - } - $manager->flush(); + $manager->flush(); + $manager->clear(); + } } } diff --git a/templates/planning/planning-weeks.html.twig b/templates/planning/planning-weeks.html.twig deleted file mode 100644 index 9ba782dd..00000000 --- a/templates/planning/planning-weeks.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -a{% extends 'base.html.twig' %} - -{% block title %} - {{ 'planning.title'|trans }} -{% endblock %} - -{% block content %} - -{% endblock %} From 093f643a2b53af92bb1712eb46cb114ffc812735 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Wed, 1 May 2024 09:21:13 +0200 Subject: [PATCH 03/19] 1280: Fixed default provider issue --- src/Controller/PlanningController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Controller/PlanningController.php b/src/Controller/PlanningController.php index b049e2a4..6ce10d42 100644 --- a/src/Controller/PlanningController.php +++ b/src/Controller/PlanningController.php @@ -23,7 +23,7 @@ public function __construct( private readonly DataProviderService $dataProviderService, private readonly DataProviderRepository $dataProviderRepository, private readonly ViewService $viewService, - private readonly ?int $planningDefaultDataProvider, + private readonly ?string $planningDefaultDataProvider, ) { } @@ -40,6 +40,10 @@ public function index(Request $request): Response $dataProviders = $this->dataProviderRepository->findAll(); $defaultProvider = $this->dataProviderRepository->find($this->planningDefaultDataProvider); + if (null === $defaultProvider && count($dataProviders) > 0) { + $defaultProvider = $dataProviders[0]; + } + $form->add('dataProvider', EntityType::class, [ 'class' => DataProvider::class, 'required' => true, From 4d857eacbb934ef034a2334671c07fcf0fd1490a Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Wed, 1 May 2024 09:41:11 +0200 Subject: [PATCH 04/19] 1280: Added error message when data provider does not support supplying planning data --- src/Controller/PlanningController.php | 8 +++++++- templates/planning/index.html.twig | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Controller/PlanningController.php b/src/Controller/PlanningController.php index 6ce10d42..1bf3e4cf 100644 --- a/src/Controller/PlanningController.php +++ b/src/Controller/PlanningController.php @@ -67,11 +67,17 @@ public function index(Request $request): Response $service = $this->dataProviderService->getService($defaultProvider); } - $planningData = $service?->getPlanningDataWeeks(); + try { + $planningData = $service?->getPlanningDataWeeks(); + } catch (\Exception $e) { + $error = $e->getMessage(); + $planningData = null; + } return $this->render('planning/index.html.twig', $this->viewService->addView([ 'controller_name' => 'PlanningController', 'planningData' => $planningData, + 'error' => $error ?? null, 'form' => $form, ])); } diff --git a/templates/planning/index.html.twig b/templates/planning/index.html.twig index cbdf6174..f6469b3c 100644 --- a/templates/planning/index.html.twig +++ b/templates/planning/index.html.twig @@ -12,6 +12,9 @@ {{ form_end(form) }} + {% if error is not null %} + {% include 'components/alert.html.twig' with {level: "danger", text: error} %} + {% endif %} {% if planningData is not null %}
- - {% set svg_expand %} - - {% endset %} - {% set svg_hide %} - - {% endset %} - - {% set weeks = planningData.weeks %} - {% set assignees = planningData.assignees %} - {% set projects = planningData.projects %} - -

{{ 'planning.assignees'|trans }}

-
- - - - - - {% for week in weeks %} - - {% endfor %} - - - {% for assignee in assignees %} - - - - - {% for week in weeks %} - {% set res = null %} - - {% for week_number in week.weekCollection %} - {% if assignee.sprintSums.containsKey(week_number) %} - {% set res = assignee.sprintSums.get(week_number).sumHours %} - {% endif %} - {% endfor %} - - {% endfor %} - - {% for project in assignee.projects %} - - - - {% for week in weeks %} - - {% endfor %} - - {% for issue in project.issues %} - - - - {% for week in weeks %} - - {% endfor %} - - {% endfor %} - {% endfor %} - - {% endfor %} -
{{ week.displayName }}
- {{ assignee.displayName }} - - - - {{ res }} -
{{ project.displayName }} - - - {% for week_number in week.weekCollection %} - {% if project.sprintSums.containsKey(week_number) %} - {{ project.sprintSums.get(week_number).sumHours }} - {% endif %} - {% endfor %} -
- #{{ issue.key }}
- {{ issue.displayName }} -
- {% for week_number in week.weekCollection %} - {% if issue.sprintId == week_number %} - {{ issue.remainingHours ?? 'UE' }} - {% endif %} - {% endfor %} -
- -
- {{ 'planning.hidden-entries'|trans }}: - -
-
+
+
+ {{ 'planning.description'|trans }} +
-

{{ 'planning.projects'|trans }}

-
- - - - - - {% for week in weeks %} - - {% endfor %} - - - {% for project in projects %} - - - - - {% for week in weeks %} - - {% endfor %} - - {% for assignee in project.assignees %} - - - - {% for week in weeks %} - - {% endfor %} - - {% for issue in assignee.issues %} - - - - {% for week in weeks %} - - {% endfor %} - - {% endfor %} - {% endfor %} - - {% endfor %} -
{{ week.displayName }}
- {{ project.displayName }} - - - {% set res = null %} - {% for week_number in week.weekCollection %} - {% if project.sprintSums.containsKey(week_number) %} - {% set res = (res + project.sprintSums.get(week_number).sumHours) %} - {% endif %} - {% endfor %} - {{ res }} -
- {{ assignee.displayName }} - - - {% for week_number in week.weekCollection %} - {% if assignee.sprintSums.containsKey(week_number) %} - {{ assignee.sprintSums.get(week_number).sumHours }} - {% endif %} - {% endfor %} -
- #{{ issue.key }} -
- {{ issue.displayName }} -
- {% for week_number in week.weekCollection %} - {% if issue.sprintId == week_number %} - {{ issue.remainingHours ?? 'UE' }} - {% endif %} - {% endfor %} -
-
+ - {% endif %} +
{% endblock %} diff --git a/templates/planning/planning.html.twig b/templates/planning/planning.html.twig new file mode 100644 index 00000000..3c1485c7 --- /dev/null +++ b/templates/planning/planning.html.twig @@ -0,0 +1,90 @@ +{% extends 'base.html.twig' %} + +{% block title %}{{ 'planning.title'|trans }}{% endblock %} + +{% block content %} +

{{ 'planning.title'|trans }}

+ + {{ form_start(form) }} + {{ form_row(form.dataProvider) }} +
+ +
+ {{ form_end(form) }} + + {% if error is not null %} + {% include 'components/alert.html.twig' with {level: "danger", text: error} %} + {% endif %} + {% if planningData is not null %} +
+ + + {% set svg_expand %} + + {% endset %} + {% set svg_hide %} + + {% endset %} + + {% set weeks = planningData.weeks %} + {% set assignees = planningData.assignees %} + {% set projects = planningData.projects %} + + {% if mode is defined %} + {% include 'planning/' ~ mode ~ '.html.twig' %} + {% endif %} +
+ {% endif %} +{% endblock %} diff --git a/templates/planning/projects.html.twig b/templates/planning/projects.html.twig new file mode 100644 index 00000000..89b5a09e --- /dev/null +++ b/templates/planning/projects.html.twig @@ -0,0 +1,77 @@ +

{{ 'planning.projects'|trans }}

+
+ + + + + + {% for week in weeks %} + + {% endfor %} + + + {% for project in projects %} + + + + + {% for week in weeks %} + + {% endfor %} + + {% for assignee in project.assignees %} + + + + {% for week in weeks %} + + {% endfor %} + + {% for issue in assignee.issues %} + + + + {% for week in weeks %} + + {% endfor %} + + {% endfor %} + {% endfor %} + + {% endfor %} +
{{ week.displayName }}
+ {{ project.displayName }} + + + {% set res = null %} + {% for week_number in week.weekCollection %} + {% if project.sprintSums.containsKey(week_number) %} + {% set res = (res + project.sprintSums.get(week_number).sumHours) %} + {% endif %} + {% endfor %} + {{ res }} +
+ {{ assignee.displayName }} + + + {% for week_number in week.weekCollection %} + {% if assignee.sprintSums.containsKey(week_number) %} + {{ assignee.sprintSums.get(week_number).sumHours }} + {% endif %} + {% endfor %} +
+ #{{ issue.key }} +
+ {{ issue.displayName }} +
+ {% for week_number in week.weekCollection %} + {% if issue.sprintId == week_number %} + {{ issue.remainingHours ?? 'UE' }} + {% endif %} + {% endfor %} +
+
diff --git a/templates/planning/users.html.twig b/templates/planning/users.html.twig new file mode 100644 index 00000000..3ab1dc7a --- /dev/null +++ b/templates/planning/users.html.twig @@ -0,0 +1,87 @@ +

{{ 'planning.assignees'|trans }}

+
+ + + + + + {% for week in weeks %} + + {% endfor %} + + + {% for assignee in assignees %} + + + + + {% for week in weeks %} + {% set res = null %} + + {% for week_number in week.weekCollection %} + {% if assignee.sprintSums.containsKey(week_number) %} + {% set res = assignee.sprintSums.get(week_number).sumHours %} + {% endif %} + {% endfor %} + + {% endfor %} + + {% for project in assignee.projects %} + + + + {% for week in weeks %} + + {% endfor %} + + {% for issue in project.issues %} + + + + {% for week in weeks %} + + {% endfor %} + + {% endfor %} + {% endfor %} + + {% endfor %} +
{{ week.displayName }}
+ {{ assignee.displayName }} + + + + {{ res }} +
{{ project.displayName }} + + + {% for week_number in week.weekCollection %} + {% if project.sprintSums.containsKey(week_number) %} + {{ project.sprintSums.get(week_number).sumHours }} + {% endif %} + {% endfor %} +
+ #{{ issue.key }}
+ {{ issue.displayName }} +
+ {% for week_number in week.weekCollection %} + {% if issue.sprintId == week_number %} + {{ issue.remainingHours ?? 'UE' }} + {% endif %} + {% endfor %} +
+ +
+ {{ 'planning.hidden-entries'|trans }}: + +
+
diff --git a/translations/messages.da.yaml b/translations/messages.da.yaml index df3a03fa..39beac91 100644 --- a/translations/messages.da.yaml +++ b/translations/messages.da.yaml @@ -55,6 +55,8 @@ navigation: admin: "Admin" management_report: "Hent ledelsesrapport" team_report: "Hent teamrapport" + planning_users: 'Brugere' + planning_projects: 'Projekter' planning: title: "Planlægning" @@ -67,6 +69,7 @@ planning: view_type: "Vælg visningstype" week_view: "Ugevisning" sprint_view: "Sprintvisning" + description: 'Vælg visning' client: title: "Kunder" From 43a2084ef94bcef07c7dc301213ea0ee2d344911 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Wed, 1 May 2024 10:39:31 +0200 Subject: [PATCH 07/19] 1280: Added redirect from planning index. Removed icons from navigation submenues --- src/Controller/PlanningController.php | 6 +----- templates/components/navigation.html.twig | 14 +++++++------- templates/planning/index.html.twig | 18 ------------------ 3 files changed, 8 insertions(+), 30 deletions(-) delete mode 100644 templates/planning/index.html.twig diff --git a/src/Controller/PlanningController.php b/src/Controller/PlanningController.php index bae9450a..362122d3 100644 --- a/src/Controller/PlanningController.php +++ b/src/Controller/PlanningController.php @@ -27,14 +27,10 @@ public function __construct( ) { } - /** - * @throws UnsupportedDataProviderException - * @throws EconomicsException - */ #[Route('/', name: 'app_planning')] public function index(Request $request): Response { - return $this->render('planning/index.html.twig'); + return $this->redirectToRoute('app_planning_users'); } /** diff --git a/templates/components/navigation.html.twig b/templates/components/navigation.html.twig index 6bd49764..4b9393f4 100644 --- a/templates/components/navigation.html.twig +++ b/templates/components/navigation.html.twig @@ -17,8 +17,8 @@ {{ 'navigation.planning'|trans }} {% endif %} @@ -45,11 +45,11 @@ {{ 'navigation.admin'|trans }} {% elseif is_granted('ROLE_PRODUCT_MANAGER') %} diff --git a/templates/planning/index.html.twig b/templates/planning/index.html.twig deleted file mode 100644 index 443d0936..00000000 --- a/templates/planning/index.html.twig +++ /dev/null @@ -1,18 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}{{ 'planning.title'|trans }}{% endblock %} - -{% block content %} -

{{ 'planning.title'|trans }}

- -
-
- {{ 'planning.description'|trans }} -
- - -
-{% endblock %} From cbb450113a7ccac8dfab3927fd110a6fb57ff217 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Wed, 1 May 2024 11:06:51 +0200 Subject: [PATCH 08/19] 1280: Added active class for current sprint --- src/Model/Planning/Weeks.php | 1 + src/Service/LeantimeApiService.php | 13 ++++++++++++- templates/planning/planning.html.twig | 3 +++ templates/planning/projects.html.twig | 2 +- templates/planning/users.html.twig | 8 ++++---- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Model/Planning/Weeks.php b/src/Model/Planning/Weeks.php index d850a712..6ef1c1a5 100644 --- a/src/Model/Planning/Weeks.php +++ b/src/Model/Planning/Weeks.php @@ -13,6 +13,7 @@ class Weeks public float $weekGoalHigh; public string $displayName; public string $dateSpan; + public ?bool $activeSprint; public function __construct() { diff --git a/src/Service/LeantimeApiService.php b/src/Service/LeantimeApiService.php index 03a5ad36..17993518 100644 --- a/src/Service/LeantimeApiService.php +++ b/src/Service/LeantimeApiService.php @@ -17,7 +17,6 @@ use App\Model\Planning\Issue; use App\Model\Planning\PlanningData; use App\Model\Planning\Project; -use App\Model\Planning\Sprint; use App\Model\Planning\SprintSum; use App\Model\Planning\Weeks; use App\Model\SprintReport\SprintReportData; @@ -378,6 +377,7 @@ public function getPlanningDataWeeks(): PlanningData $weeks = $planning->weeks; $currentYear = (int) (new \DateTime())->format('Y'); + $currentWeek = (int) (new \DateTime())->format('W'); for ($weekNumber = 1; $weekNumber <= 52; ++$weekNumber) { $date = (new \DateTime())->setISODate($currentYear, $weekNumber); @@ -394,12 +394,19 @@ public function getPlanningDataWeeks(): PlanningData $supportWeek->weekGoalHigh = $this->weekGoalHigh; $supportWeek->displayName = (string) $week; $supportWeek->dateSpan = $weekFirstDay.' - '.$weekLastDay; + if ($week == $currentWeek) { + $supportWeek->activeSprint = true; + } $weeks->add($supportWeek); } else { if (isset($regularWeek)) { $regularWeek->weekCollection->add($week); ++$regularWeek->weeks; $regularWeek->displayName .= '-'.$week; + if ($week == $currentWeek) { + $regularWeek->activeSprint = true; + } + if (3 === count($regularWeek->weekCollection)) { $regularWeek->dateSpan .= ' - '.$weekLastDay; $weeks->add($regularWeek); @@ -413,6 +420,9 @@ public function getPlanningDataWeeks(): PlanningData $regularWeek->weekGoalHigh = $this->weekGoalHigh * 3; $regularWeek->displayName = (string) $week; $regularWeek->dateSpan = $weekFirstDay; + if ($week == $currentWeek) { + $regularWeek->activeSprint = true; + } } } } @@ -433,6 +443,7 @@ public function getPlanningDataWeeks(): PlanningData $weekIssues['unscheduled'][] = $issue; } } + foreach ($weekIssues as $week => $issues) { foreach ($issues as $issueData) { if ('0' !== $issueData->status) { // excludes done issues. diff --git a/templates/planning/planning.html.twig b/templates/planning/planning.html.twig index 3c1485c7..9a429f65 100644 --- a/templates/planning/planning.html.twig +++ b/templates/planning/planning.html.twig @@ -18,6 +18,9 @@ {% if planningData is not null %}
{% set svg_expand %}

{{ 'planning.assignees'|trans }}

+

{{ 'planning.assignees'|trans }}

+
- +
- - - - {% for week in weeks %} - - {% endfor %} - + + + {% for week in weeks %} + + {% endfor %} + {% for assignee in assignees %} - - + - {% for week in weeks %} {% set res = null %} @@ -31,24 +34,35 @@ {% set res = assignee.sprintSums.get(week_number).sumHours %} {% endif %} {% endfor %} - {% endfor %} {% for project in assignee.projects %} - - - + {% for week in weeks %} - {% for issue in project.issues %} - - {% for week in weeks %} -
{{ week.displayName }}
{{ 'User'|trans }}{{ week.displayName }}
- {{ assignee.displayName }} - - +
+
+ + {{ assignee.displayName }} + + + +
+ {{ res }}
{{ project.displayName }} - +
+
+ + {{ project.displayName }} + + +
+ {% for week_number in week.weekCollection %} {% if project.sprintSums.containsKey(week_number) %} {{ project.sprintSums.get(week_number).sumHours }} @@ -59,13 +73,11 @@
- #{{ issue.key }}
- {{ issue.displayName }} +
+ {{ issue.displayName }} #{{ issue.key }} + {% for week_number in week.weekCollection %} {% if issue.sprintId == week_number %} {{ issue.remainingHours ?? 'UE' }} @@ -80,7 +92,7 @@ {% endfor %}
-
+
{{ 'planning.hidden-entries'|trans }}:
From e8a72049bb55d3026970928dc4e3d6c815cdfc82 Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Thu, 2 May 2024 10:41:28 +0200 Subject: [PATCH 10/19] Change colors --- templates/planning/users.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/planning/users.html.twig b/templates/planning/users.html.twig index 646c7055..35048f3a 100644 --- a/templates/planning/users.html.twig +++ b/templates/planning/users.html.twig @@ -6,7 +6,7 @@ {{ 'User'|trans }} {% for week in weeks %} - {{ week.displayName }} + {{ week.displayName }} {% endfor %} @@ -35,7 +35,7 @@ {% endif %} {% endfor %} From 41fd03729c45642473f7b44a773693f951a6a0db Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Thu, 2 May 2024 11:32:08 +0200 Subject: [PATCH 11/19] 1258: Setup font awesome icon loader --- assets/app.js | 7 ++++-- .../fontawesome-icons_controller.js | 23 ------------------- assets/fontawesome.js | 10 ++++++++ 3 files changed, 15 insertions(+), 25 deletions(-) delete mode 100644 assets/controllers/fontawesome-icons_controller.js create mode 100644 assets/fontawesome.js diff --git a/assets/app.js b/assets/app.js index 6f23110f..07a4dd09 100644 --- a/assets/app.js +++ b/assets/app.js @@ -5,8 +5,11 @@ * (and its CSS file) in your base layout (base.html.twig). */ -// any CSS you import will output into a single css file (app.css in this case) +// Any CSS you import will output into a single css file (app.css in this case) import "./styles/app.css"; -// start the Stimulus application +// Start the Stimulus application import "./bootstrap"; + +// Start the Font Awesome icon to svg replacements +import "./fontawesome"; diff --git a/assets/controllers/fontawesome-icons_controller.js b/assets/controllers/fontawesome-icons_controller.js deleted file mode 100644 index c863040d..00000000 --- a/assets/controllers/fontawesome-icons_controller.js +++ /dev/null @@ -1,23 +0,0 @@ -/* -// Add fontawesome icons -*/ -// Import the stimulus controller -import { Controller } from "@hotwired/stimulus"; - -// Import the svg core library -import { library } from '@fortawesome/fontawesome-svg-core' - -// To keep the package size as small as possible we only import icons we use -// Import the icons from the free solid package. -import { - faMaximize, -} from '@fortawesome/free-solid-svg-icons' - -export default class extends Controller { - // Add the icons to the library for replacing with the intended svg. - connect() { - library.add([ - faMaximize, - ]) - } -} diff --git a/assets/fontawesome.js b/assets/fontawesome.js new file mode 100644 index 00000000..02b2744d --- /dev/null +++ b/assets/fontawesome.js @@ -0,0 +1,10 @@ +// Import the svg core library +import { library, dom } from '@fortawesome/fontawesome-svg-core' + +// Import the icons from the free solid package. +import { + faMaximize, +} from '@fortawesome/free-solid-svg-icons' + +library.add(faMaximize); +dom.i2svg() From d3edd2de58505a032ce16c588e9e3e833f42e702 Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Thu, 2 May 2024 11:34:44 +0200 Subject: [PATCH 12/19] Styling --- templates/planning/users.html.twig | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/templates/planning/users.html.twig b/templates/planning/users.html.twig index 35048f3a..213257fc 100644 --- a/templates/planning/users.html.twig +++ b/templates/planning/users.html.twig @@ -1,31 +1,29 @@ -

{{ 'planning.assignees'|trans }}

- -
- +
+
- + {% for week in weeks %} - + {% endfor %} {% for assignee in assignees %} - {% for week in weeks %} {% set res = null %} @@ -35,6 +33,9 @@ {% endif %} {% endfor %}
{{ 'User'|trans }}{{ 'planning.assignees'|trans }}{{ week.displayName }}{{ week.displayName }}
+
{{ assignee.displayName }} - -
- +
el.dataset.active); + + if (!activeColumn) { + return; + } + + const activeIndex = activeColumn.dataset.index; + const scrollToIndex = Math.max(0, activeIndex - 1); + const scrollToColumn = this.columnTargets.find((el) => el.dataset.index == scrollToIndex ); + const firstColumn = this.columnTargets.find((el) => el.dataset.index == 1 ); + + if (!scrollToColumn || !firstColumn) { + return; + } + + const { x } = scrollToColumn.getBoundingClientRect() + const { x: firstColumnX } = firstColumn.getBoundingClientRect() + + scrollContainer.scrollTo(x - firstColumnX, 0); + } +} diff --git a/templates/planning/users.html.twig b/templates/planning/users.html.twig index 213257fc..7a7d3461 100644 --- a/templates/planning/users.html.twig +++ b/templates/planning/users.html.twig @@ -1,10 +1,21 @@ -
- +
+
{% for week in weeks %} - + {% endfor %} @@ -46,13 +57,13 @@ {% for project in assignee.projects %} - {% for week in weeks %} - {% for issue in project.issues %} - + {% for week in weeks %} -
{{ 'planning.assignees'|trans }}{{ week.displayName }} + {{ week.displayName }} +
+
- + {{ project.displayName }}
- +
+ {% for week_number in week.weekCollection %} {% if project.sprintSums.containsKey(week_number) %} {{ project.sprintSums.get(week_number).sumHours }} @@ -74,11 +85,16 @@
- {{ issue.displayName }} #{{ issue.key }} - +
+ + {{ issue.displayName }} + + #{{ issue.key }} +
+
+ {% for week_number in week.weekCollection %} {% if issue.sprintId == week_number %} {{ issue.remainingHours ?? 'UE' }} @@ -93,7 +109,7 @@ {% endfor %}
-
+
{{ 'planning.hidden-entries'|trans }}:
From ebf3af1547d9908ea3e5e91c8a728224627f4485 Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Fri, 3 May 2024 11:38:47 +0200 Subject: [PATCH 14/19] Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee9c7a84..955d7f7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* [PR-114](https://github.com/itk-dev/economics/pull/114) + 1258: Clean up planning view ui and add scrol to active sprint. * [PR-112](https://github.com/itk-dev/economics/pull/112) 1280: Simplified planning form. Added default value. * [PR-110](https://github.com/itk-dev/economics/pull/110) From e96cc87f686a045240bd9f99968f4e3ba2fe1e55 Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Fri, 3 May 2024 12:49:14 +0200 Subject: [PATCH 15/19] Updates after review --- CHANGELOG.md | 2 +- assets/fontawesome.js | 8 +++++++- templates/planning/planning.html.twig | 11 ----------- templates/planning/users.html.twig | 10 +++++----- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 955d7f7f..1b7bf28c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] * [PR-114](https://github.com/itk-dev/economics/pull/114) - 1258: Clean up planning view ui and add scrol to active sprint. + 1258: Clean up planning view ui and add scroll to active sprint. * [PR-112](https://github.com/itk-dev/economics/pull/112) 1280: Simplified planning form. Added default value. * [PR-110](https://github.com/itk-dev/economics/pull/110) diff --git a/assets/fontawesome.js b/assets/fontawesome.js index 02b2744d..4d579cc4 100644 --- a/assets/fontawesome.js +++ b/assets/fontawesome.js @@ -4,7 +4,13 @@ import { library, dom } from '@fortawesome/fontawesome-svg-core' // Import the icons from the free solid package. import { faMaximize, + faEyeSlash, + faMinimize, } from '@fortawesome/free-solid-svg-icons' -library.add(faMaximize); +library.add( + faMaximize, + faEyeSlash, + faMinimize, +); dom.i2svg() diff --git a/templates/planning/planning.html.twig b/templates/planning/planning.html.twig index 11b12f40..50461a70 100644 --- a/templates/planning/planning.html.twig +++ b/templates/planning/planning.html.twig @@ -18,17 +18,6 @@ {% if planningData is not null %}
- {% set svg_expand %} - - {% endset %} - {% set svg_hide %} - - {% endset %} - {% set weeks = planningData.weeks %} {% set assignees = planningData.assignees %} {% set projects = planningData.projects %} diff --git a/templates/planning/users.html.twig b/templates/planning/users.html.twig index 7a7d3461..aca07ac3 100644 --- a/templates/planning/users.html.twig +++ b/templates/planning/users.html.twig @@ -28,10 +28,11 @@ {{ assignee.displayName }}
@@ -44,9 +45,7 @@ {% endif %} {% endfor %}
+ From fc290770261645b0ea933cdc5aed5eff6e0df3c8 Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Fri, 3 May 2024 12:58:27 +0200 Subject: [PATCH 16/19] Reuse users style on projects --- templates/planning/projects.html.twig | 116 ++++++++++++++++---------- templates/planning/users.html.twig | 1 - 2 files changed, 74 insertions(+), 43 deletions(-) diff --git a/templates/planning/projects.html.twig b/templates/planning/projects.html.twig index 0d851583..416f7deb 100644 --- a/templates/planning/projects.html.twig +++ b/templates/planning/projects.html.twig @@ -1,48 +1,78 @@ -

{{ 'planning.projects'|trans }}

-
- +
+
- - - - {% for week in weeks %} - - {% endfor %} - + + + {% for week in weeks %} + + {% endfor %} + {% for project in projects %} - - - - + + + {% for week in weeks %} - {% endfor %} {% for assignee in project.assignees %} - - - + + {% for week in weeks %} - {% for issue in assignee.issues %} - - + {% for week in weeks %} -
{{ week.displayName }}
{{ 'planning.projects'|trans }} + {{ week.displayName }} +
- {{ project.displayName }} - -
+
+ + {{ project.displayName }} + + + +
+
- {% set res = null %} - {% for week_number in week.weekCollection %} - {% if project.sprintSums.containsKey(week_number) %} - {% set res = (res + project.sprintSums.get(week_number).sumHours) %} - {% endif %} - {% endfor %} + {% set res = null %} + {% for week_number in week.weekCollection %} + {% if project.sprintSums.containsKey(week_number) %} + {% set res = (res + project.sprintSums.get(week_number).sumHours) %} + {% endif %} + {% endfor %} + {{ res }}
- {{ assignee.displayName }} - -
+
+ + {{ assignee.displayName }} + + +
+
+ {% for week_number in week.weekCollection %} {% if assignee.sprintSums.containsKey(week_number) %} {{ assignee.sprintSums.get(week_number).sumHours }} @@ -53,14 +83,16 @@
- #{{ issue.key }} -
- {{ issue.displayName }} -
+
+ + {{ issue.displayName }} + + #{{ issue.key }} +
+
+ {% for week_number in week.weekCollection %} {% if issue.sprintId == week_number %} {{ issue.remainingHours ?? 'UE' }} diff --git a/templates/planning/users.html.twig b/templates/planning/users.html.twig index aca07ac3..e8c6193f 100644 --- a/templates/planning/users.html.twig +++ b/templates/planning/users.html.twig @@ -12,7 +12,6 @@ data-index="{{ loop.index }}" {{ week.activeSprint is defined and week.activeSprint ? 'data-active="true"' : '' }} {{ stimulus_target('planning-scroll', 'column') }} - > {{ week.displayName }} From 3c081bc533aeed580ff00ab7b4671954e1b851e9 Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Fri, 3 May 2024 13:02:01 +0200 Subject: [PATCH 17/19] Apply coding standars --- assets/controllers/planning-scroll_controller.js | 16 +++++++++------- assets/fontawesome.js | 12 ++++-------- templates/planning/projects.html.twig | 2 +- templates/planning/users.html.twig | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/assets/controllers/planning-scroll_controller.js b/assets/controllers/planning-scroll_controller.js index d12f5dc0..d9843fac 100644 --- a/assets/controllers/planning-scroll_controller.js +++ b/assets/controllers/planning-scroll_controller.js @@ -1,8 +1,6 @@ import { Controller } from "@hotwired/stimulus"; -/** - * Scroll to active sprint in planning view - */ +/** Scroll to active sprint in planning view */ export default class extends Controller { static targets = ["column"]; @@ -15,15 +13,19 @@ export default class extends Controller { const activeIndex = activeColumn.dataset.index; const scrollToIndex = Math.max(0, activeIndex - 1); - const scrollToColumn = this.columnTargets.find((el) => el.dataset.index == scrollToIndex ); - const firstColumn = this.columnTargets.find((el) => el.dataset.index == 1 ); + const scrollToColumn = this.columnTargets.find( + (el) => el.dataset.index == scrollToIndex, + ); + const firstColumn = this.columnTargets.find( + (el) => el.dataset.index == 1, + ); if (!scrollToColumn || !firstColumn) { return; } - const { x } = scrollToColumn.getBoundingClientRect() - const { x: firstColumnX } = firstColumn.getBoundingClientRect() + const { x } = scrollToColumn.getBoundingClientRect(); + const { x: firstColumnX } = firstColumn.getBoundingClientRect(); scrollContainer.scrollTo(x - firstColumnX, 0); } diff --git a/assets/fontawesome.js b/assets/fontawesome.js index 4d579cc4..bf9d683b 100644 --- a/assets/fontawesome.js +++ b/assets/fontawesome.js @@ -1,16 +1,12 @@ // Import the svg core library -import { library, dom } from '@fortawesome/fontawesome-svg-core' +import { library, dom } from "@fortawesome/fontawesome-svg-core"; // Import the icons from the free solid package. import { faMaximize, faEyeSlash, faMinimize, -} from '@fortawesome/free-solid-svg-icons' +} from "@fortawesome/free-solid-svg-icons"; -library.add( - faMaximize, - faEyeSlash, - faMinimize, -); -dom.i2svg() +library.add(faMaximize, faEyeSlash, faMinimize); +dom.i2svg(); diff --git a/templates/planning/projects.html.twig b/templates/planning/projects.html.twig index 416f7deb..e31f134c 100644 --- a/templates/planning/projects.html.twig +++ b/templates/planning/projects.html.twig @@ -8,7 +8,7 @@ class="text-center px-3 py-3 border border-slate-600 {{ week.activeSprint is defined and week.activeSprint ? 'bg-slate-300 dark:bg-slate-800' : 'bg-slate-100 dark:bg-slate-700' }}" data-span="{{ week.dateSpan }}" {{ week.activeSprint is defined and week.activeSprint ? 'id="activeSprint"' : '' }} - {{ loop.index == 1 ? 'id="firstSprint"' : ''}} + {{ loop.index == 1 ? 'id="firstSprint"' : '' }} data-index="{{ loop.index }}" {{ week.activeSprint is defined and week.activeSprint ? 'data-active="true"' : '' }} {{ stimulus_target('planning-scroll', 'column') }} diff --git a/templates/planning/users.html.twig b/templates/planning/users.html.twig index e8c6193f..08415fc2 100644 --- a/templates/planning/users.html.twig +++ b/templates/planning/users.html.twig @@ -8,7 +8,7 @@ class="text-center px-3 py-3 border border-slate-600 {{ week.activeSprint is defined and week.activeSprint ? 'bg-slate-300 dark:bg-slate-800' : 'bg-slate-100 dark:bg-slate-700' }}" data-span="{{ week.dateSpan }}" {{ week.activeSprint is defined and week.activeSprint ? 'id="activeSprint"' : '' }} - {{ loop.index == 1 ? 'id="firstSprint"' : ''}} + {{ loop.index == 1 ? 'id="firstSprint"' : '' }} data-index="{{ loop.index }}" {{ week.activeSprint is defined and week.activeSprint ? 'data-active="true"' : '' }} {{ stimulus_target('planning-scroll', 'column') }} From 1a87f2d5c8d3a7faaff6868458509e23ff8b83bd Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Fri, 3 May 2024 13:30:29 +0200 Subject: [PATCH 18/19] Use understandable const names for target and first column --- assets/controllers/planning-scroll_controller.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/controllers/planning-scroll_controller.js b/assets/controllers/planning-scroll_controller.js index d9843fac..6f485553 100644 --- a/assets/controllers/planning-scroll_controller.js +++ b/assets/controllers/planning-scroll_controller.js @@ -24,9 +24,9 @@ export default class extends Controller { return; } - const { x } = scrollToColumn.getBoundingClientRect(); - const { x: firstColumnX } = firstColumn.getBoundingClientRect(); + const targetColumnX = scrollToColumn.getBoundingClientRect().x; + const firstColumnX = firstColumn.getBoundingClientRect().x; - scrollContainer.scrollTo(x - firstColumnX, 0); + scrollContainer.scrollTo(targetColumnX - firstColumnX, 0); } } From 3df3ebe0809b6bd9be5d2ea6e0ebb18455f7155b Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Fri, 3 May 2024 13:39:41 +0200 Subject: [PATCH 19/19] Add todo --- src/Service/LeantimeApiService.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Service/LeantimeApiService.php b/src/Service/LeantimeApiService.php index 17993518..1965498e 100644 --- a/src/Service/LeantimeApiService.php +++ b/src/Service/LeantimeApiService.php @@ -379,6 +379,8 @@ public function getPlanningDataWeeks(): PlanningData $currentYear = (int) (new \DateTime())->format('Y'); $currentWeek = (int) (new \DateTime())->format('W'); + // TODO: How to handle 53 weeks + // A year can actually have 53 weeks (cf. https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year), and the year 2026 (in the near future is one of them), so this should be rewritten to iterate over all weeks in the year (or use https://stackoverflow.com/a/21480444). for ($weekNumber = 1; $weekNumber <= 52; ++$weekNumber) { $date = (new \DateTime())->setISODate($currentYear, $weekNumber); $week = (int) $date->format('W'); // Cast as int to remove leading zero.