diff --git a/src/Command/RedmineCommand.php b/src/Command/RedmineCommand.php new file mode 100644 index 0000000..9ed4b3d --- /dev/null +++ b/src/Command/RedmineCommand.php @@ -0,0 +1,52 @@ +em = $em; + $this->params = $params; + $this->redmineService = $redmineService; + + parent::__construct(); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + $io->title('APP:REDMINE'); + $io->text('Refresh Redmine Project'); + $io->text(''); + + $projects = $this->em->getRepository(Project::class)->findAll(); + foreach ($projects as $project) { + $io->text('> Project = '.$project->getTitle()); + $redmine = $this->redmineService->getProject($project->getId(), $this->params->get('redmineApikey')); + $project->setRedmine($redmine); + $this->em->flush(); + $this->redmineService->majProjectIssues($project, $this->params->get('redmineApikey'), true); + } + + return Command::SUCCESS; + } +} diff --git a/src/Controller/IssueController.php b/src/Controller/IssueController.php index ff39ed1..57455b9 100644 --- a/src/Controller/IssueController.php +++ b/src/Controller/IssueController.php @@ -116,9 +116,9 @@ class IssueController extends AbstractController $issue = $issueRepository->find($rissue); if ($issue) { $issue->setRowissue($key); - $em->flush(); } } + $em->flush(); } return new JsonResponse([ diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php index 3055a66..bb50c07 100644 --- a/src/Controller/ProjectController.php +++ b/src/Controller/ProjectController.php @@ -5,6 +5,7 @@ namespace App\Controller; use App\Entity\Project; use App\Entity\User; use App\Form\ProjectType; +use App\Repository\IssueRepository; use App\Repository\ProjectRepository; use App\Service\RedmineService; use Doctrine\ORM\EntityManagerInterface; @@ -25,7 +26,7 @@ class ProjectController extends AbstractController } #[Route('/user/project/{id}', name: 'app_project_view')] - public function viewProject(int $id, ProjectRepository $projectRepository): Response + public function viewProject(int $id, ProjectRepository $projectRepository, IssueRepository $issueRepository): Response { $project = $projectRepository->find($id); if (!$project) { @@ -63,6 +64,7 @@ class ProjectController extends AbstractController 'usemenu' => true, 'usesidebar' => false, 'project' => $project, + 'issues' => $issueRepository->findIssues($project), ]); } diff --git a/src/Entity/Issue.php b/src/Entity/Issue.php index d9c29e5..5ee516c 100644 --- a/src/Entity/Issue.php +++ b/src/Entity/Issue.php @@ -33,6 +33,9 @@ class Issue #[ORM\Column(nullable: true)] private ?string $color = null; + #[ORM\Column(nullable: false)] + private bool $isClosed = false; + #[ORM\ManyToOne(targetEntity: Project::class, inversedBy: 'issues')] #[ORM\JoinColumn(nullable: false)] private Project $project; @@ -130,9 +133,13 @@ class Issue public function getColor(): ?string { - if($this->color) return $this->color; - elseif($this->parent) return $this->parent->getColor(); - else return null; + if ($this->color) { + return $this->color; + } elseif ($this->parent) { + return $this->parent->getColor(); + } else { + return null; + } } public function setColor(?string $color): static @@ -142,6 +149,18 @@ class Issue return $this; } + public function isClosed(): bool + { + return $this->isClosed(); + } + + public function setIsClosed(bool $isClosed): static + { + $this->isClosed = $isClosed; + + return $this; + } + public function getProject(): Project { return $this->project; diff --git a/src/Repository/IssueRepository.php b/src/Repository/IssueRepository.php index 78f9fd5..9ffb5b9 100644 --- a/src/Repository/IssueRepository.php +++ b/src/Repository/IssueRepository.php @@ -3,6 +3,7 @@ namespace App\Repository; use App\Entity\Issue; +use App\Entity\Project; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; @@ -16,28 +17,19 @@ class IssueRepository extends ServiceEntityRepository parent::__construct($registry, Issue::class); } - // /** - // * @return Issue[] Returns an array of Issue objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('c') - // ->andWhere('c.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('c.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } + public function findIssues(Project $project, bool $closed = false): array + { + $criteria = ['project' => $project]; + if (!$closed) { + $criteria['isClosed'] = false; + } - // public function findOneBySomeField($value): ?Issue - // { - // return $this->createQueryBuilder('c') - // ->andWhere('c.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } + return $this->findBy($criteria, [ + 'rowstatus' => 'ASC', + 'rowsprint' => 'DESC', + 'rowversion' => 'DESC', + 'rowissue' => 'ASC', + 'id' => 'DESC', + ]); + } } diff --git a/src/Service/RedmineService.php b/src/Service/RedmineService.php index 606334b..1a9cb80 100644 --- a/src/Service/RedmineService.php +++ b/src/Service/RedmineService.php @@ -186,6 +186,7 @@ class RedmineService } $issue->setRedmine($rissue); $issue->setProject($project); + $issue->setIsClosed($rissue['status']['is_closed']); // Calcul de la position du status $issueStatusId = $rissue['status']['id']; diff --git a/templates/project/view.html.twig b/templates/project/view.html.twig index cee1248..72ce0ce 100644 --- a/templates/project/view.html.twig +++ b/templates/project/view.html.twig @@ -316,7 +316,7 @@ {% endif %} {% endfor %} - {% for issue in project.issues %} + {% for issue in issues %}
#{{issue.id}}
@@ -413,7 +413,7 @@ $column.append($(this)); } else { - console.log ('no ='+id); + console.log ('no ='+$(this).data('id')); $(this).remove(); } }); @@ -511,7 +511,6 @@ url='{{path('app_issue_view',{id:'xxx'})}}'; url=url.replace('xxx',issueId); - console.log(url); $.ajax({ url: url,