From 6b0fbce7ee5dd76aa6275542ac0ff355fa56978f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P=2E?= Date: Thu, 31 Oct 2024 10:24:28 +0100 Subject: [PATCH] Draft record view (bibliography) --- assets/styles/app.css | 9 ++ src/Controller/BibliographyController.php | 25 ++++ src/Controller/VocabFuncContextController.php | 21 ++- src/Entity/Bibliography.php | 134 ++++++++++++++++++ src/RecordStatus.php | 25 ++++ src/Repository/BibliographyRepository.php | 19 +++ templates/bibliography/index.html.twig | 54 +++++++ templates/vocab_func_context/index.html.twig | 2 +- 8 files changed, 287 insertions(+), 2 deletions(-) create mode 100644 src/Controller/BibliographyController.php create mode 100644 src/Entity/Bibliography.php create mode 100644 src/RecordStatus.php create mode 100644 src/Repository/BibliographyRepository.php create mode 100644 templates/bibliography/index.html.twig diff --git a/assets/styles/app.css b/assets/styles/app.css index 2e71726..54149c9 100755 --- a/assets/styles/app.css +++ b/assets/styles/app.css @@ -22,3 +22,12 @@ body { .sf-toolbar-clearer { display: none !important; } + +.table.record td, +.table.record th { + border: none; +} + +.table.record th { + min-width: 220px; +} diff --git a/src/Controller/BibliographyController.php b/src/Controller/BibliographyController.php new file mode 100644 index 0000000..93d5b05 --- /dev/null +++ b/src/Controller/BibliographyController.php @@ -0,0 +1,25 @@ +render('bibliography/index.html.twig', [ + 'controller_name' => 'BibliographyController', + 'record' => $bibliography, + ]); + } +} + diff --git a/src/Controller/VocabFuncContextController.php b/src/Controller/VocabFuncContextController.php index 50c7c22..1091a05 100644 --- a/src/Controller/VocabFuncContextController.php +++ b/src/Controller/VocabFuncContextController.php @@ -10,8 +10,10 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Core\Exception\AccessDeniedException; -use Symfony\Component\Security\Http\Attribute\IsGranted; +/** + * @todo Make edit endpoints JSON? + */ class VocabFuncContextController extends AbstractController { #[Route('/vocabs/functional_context', name: 'app_vocab_func_context')] @@ -57,6 +59,14 @@ class VocabFuncContextController extends AbstractController #[Route('/vocabs/functional_context/update', name: 'app_vocab_func_context_upd')] public function updateTerm(Request $request, EntityManagerInterface $em): Response { + $vocab = new VocabFuncContext; + try { + $this->denyAccessUnlessGranted(VocabVoter::EDIT, $vocab); + } + catch (AccessDeniedException) { + $this->addFlash('warning', 'Only revisors and administrators can edit vocabularies'); + return $this->redirectToRoute('app_home'); + } $id = $request->getPayload()->get('_id'); $newTerm = $request->getPayload()->get('_new_term'); @@ -74,6 +84,15 @@ class VocabFuncContextController extends AbstractController #[Route('/vocabs/functional_context/del', name: 'app_vocab_func_context_del')] public function deleteTerm(Request $request, EntityManagerInterface $em): Response { + $vocab = new VocabFuncContext; + try { + $this->denyAccessUnlessGranted(VocabVoter::EDIT, $vocab); + } + catch (AccessDeniedException) { + $this->addFlash('warning', 'Only revisors and administrators can delete vocabularies'); + return $this->redirectToRoute('app_home'); + } + $id = $request->getPayload()->get('_id'); $repo = $em->getRepository(VocabFuncContext::class); $term = $repo->find($id); diff --git a/src/Entity/Bibliography.php b/src/Entity/Bibliography.php new file mode 100644 index 0000000..f03ec70 --- /dev/null +++ b/src/Entity/Bibliography.php @@ -0,0 +1,134 @@ +id; + } + + public function getStatus(): ?string + { + $status = RecordStatus::tryFrom($this->status); + return $status->toString(); + } + + public function setStatus(int $status): static + { + $this->status = $status; + + return $this; + } + + public function getModifiedAt(): ?DateTimeImmutable + { + return $this->modifiedAt; + } + + public function setModifiedAt(DateTimeImmutable $modifiedAt): static + { + $this->modifiedAt = $modifiedAt; + + return $this; + } + + public function getOwner(): ?string + { + return $this->owner; + } + + public function setOwner(string $owner): static + { + $this->owner = $owner; + + return $this; + } + + public function getEditor(): ?string + { + return $this->editor; + } + + public function setEditor(string $editor): static + { + $this->editor = $editor; + + return $this; + } + + public function getCitation(): ?string + { + return $this->citation; + } + + public function setCitation(string $citation): static + { + $this->citation = $citation; + + return $this; + } + + public function getReference(): ?string + { + return $this->reference; + } + + public function setReference(string $reference): static + { + $this->reference = $reference; + + return $this; + } + + public function getNotes(): ?string + { + return $this->notes; + } + + public function setNotes(string $notes): static + { + $this->notes = $notes; + + return $this; + } +} diff --git a/src/RecordStatus.php b/src/RecordStatus.php new file mode 100644 index 0000000..1ddaca8 --- /dev/null +++ b/src/RecordStatus.php @@ -0,0 +1,25 @@ + 'Draft', + $this::Complete => 'Complete', + $this::Excluded => 'Excluded', + $this::Unindexed => 'Unindexed', + $this::Published => 'Published', + default => 'Draft' + }; + } + +} diff --git a/src/Repository/BibliographyRepository.php b/src/Repository/BibliographyRepository.php new file mode 100644 index 0000000..a00ccda --- /dev/null +++ b/src/Repository/BibliographyRepository.php @@ -0,0 +1,19 @@ + + */ +class BibliographyRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Bibliography::class); + } +} + diff --git a/templates/bibliography/index.html.twig b/templates/bibliography/index.html.twig new file mode 100644 index 0000000..ec16327 --- /dev/null +++ b/templates/bibliography/index.html.twig @@ -0,0 +1,54 @@ +{% extends 'data_entry.html.twig' %} + +{% block title %}Bibliography | ArCOA{% endblock %} + +{% block rightpanel %} +
+

Bibliography

+

{{ record.citation }}

+ +
+
+
+

+ Last modified: {{ record.modifiedAt.format('Y-m-d') }} + at {{ record.modifiedAt.format('H:i:s') }} +

+

Editor: {{ record.editor }}

+
+
+
+ {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_REVISOR') %} +
+ +
+ {% endif %} +
+
    +
  • Record
  • +
  • Relations
  • +
+
+ + + + + + + +
Record ID{{ record.id }}
Status{{ record.getStatus() }}
Editor(s){{ record.editor }}
Citation{{ record.citation }}
Reference{{ record.reference }}
Editorial notes{{ record.notes }}
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/vocab_func_context/index.html.twig b/templates/vocab_func_context/index.html.twig index 7c8cb74..e7e406f 100644 --- a/templates/vocab_func_context/index.html.twig +++ b/templates/vocab_func_context/index.html.twig @@ -57,7 +57,7 @@