Draft record view (bibliography)
This commit is contained in:
parent
a5b7069679
commit
6b0fbce7ee
@ -22,3 +22,12 @@ body {
|
|||||||
.sf-toolbar-clearer {
|
.sf-toolbar-clearer {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table.record td,
|
||||||
|
.table.record th {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table.record th {
|
||||||
|
min-width: 220px;
|
||||||
|
}
|
||||||
|
25
src/Controller/BibliographyController.php
Normal file
25
src/Controller/BibliographyController.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\Bibliography;
|
||||||
|
//use App\Security\Voter\VocabVoter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
//use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
|
|
||||||
|
class BibliographyController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/bibliography/{id}', name: 'app_bibliography')]
|
||||||
|
public function index(Bibliography $bibliography, EntityManagerInterface $em): Response
|
||||||
|
{
|
||||||
|
return $this->render('bibliography/index.html.twig', [
|
||||||
|
'controller_name' => 'BibliographyController',
|
||||||
|
'record' => $bibliography,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,8 +10,10 @@ 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\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo Make edit endpoints JSON?
|
||||||
|
*/
|
||||||
class VocabFuncContextController extends AbstractController
|
class VocabFuncContextController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/vocabs/functional_context', name: 'app_vocab_func_context')]
|
#[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')]
|
#[Route('/vocabs/functional_context/update', name: 'app_vocab_func_context_upd')]
|
||||||
public function updateTerm(Request $request, EntityManagerInterface $em): Response
|
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');
|
$id = $request->getPayload()->get('_id');
|
||||||
$newTerm = $request->getPayload()->get('_new_term');
|
$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')]
|
#[Route('/vocabs/functional_context/del', name: 'app_vocab_func_context_del')]
|
||||||
public function deleteTerm(Request $request, EntityManagerInterface $em): Response
|
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');
|
$id = $request->getPayload()->get('_id');
|
||||||
$repo = $em->getRepository(VocabFuncContext::class);
|
$repo = $em->getRepository(VocabFuncContext::class);
|
||||||
$term = $repo->find($id);
|
$term = $repo->find($id);
|
||||||
|
134
src/Entity/Bibliography.php
Normal file
134
src/Entity/Bibliography.php
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
//use App\Repository\UserRepository;
|
||||||
|
|
||||||
|
use DateTimeImmutable;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use App\RecordStatus;
|
||||||
|
|
||||||
|
#[ORM\Entity()]
|
||||||
|
#[ORM\Table(name: 'bibliography')]
|
||||||
|
class Bibliography
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column(name: 'id')]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(name: 'stato')]
|
||||||
|
private ?int $status = null;
|
||||||
|
|
||||||
|
#[ORM\Column(name: 'modif')]
|
||||||
|
private ?DateTimeImmutable $modifiedAt = null;
|
||||||
|
|
||||||
|
#[ORM\Column(name: 'cit_bib', type: Types::TEXT)]
|
||||||
|
private ?string $citation = null;
|
||||||
|
|
||||||
|
#[ORM\Column(name: 'rif_bib', type: Types::TEXT)]
|
||||||
|
private ?string $reference = null;
|
||||||
|
|
||||||
|
#[ORM\Column(name: 'resp', length: 100)]
|
||||||
|
private ?string $owner = null;
|
||||||
|
|
||||||
|
#[ORM\Column(name: 'note_bib', type: Types::TEXT)]
|
||||||
|
private ?string $notes = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 100)]
|
||||||
|
private ?string $editor = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 100)]
|
||||||
|
private ?string $creator = null;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->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;
|
||||||
|
}
|
||||||
|
}
|
25
src/RecordStatus.php
Normal file
25
src/RecordStatus.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
enum RecordStatus: int
|
||||||
|
{
|
||||||
|
case Draft = 1;
|
||||||
|
case Complete = 2;
|
||||||
|
case Excluded = 3;
|
||||||
|
case Unindexed = 4;
|
||||||
|
case Published = 5;
|
||||||
|
|
||||||
|
public function toString(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
$this::Draft => 'Draft',
|
||||||
|
$this::Complete => 'Complete',
|
||||||
|
$this::Excluded => 'Excluded',
|
||||||
|
$this::Unindexed => 'Unindexed',
|
||||||
|
$this::Published => 'Published',
|
||||||
|
default => 'Draft'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
src/Repository/BibliographyRepository.php
Normal file
19
src/Repository/BibliographyRepository.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Bibliography;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Bibliography>
|
||||||
|
*/
|
||||||
|
class BibliographyRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Bibliography::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
54
templates/bibliography/index.html.twig
Normal file
54
templates/bibliography/index.html.twig
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
{% extends 'data_entry.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Bibliography | ArCOA{% endblock %}
|
||||||
|
|
||||||
|
{% block rightpanel %}
|
||||||
|
<div class="container" style="max-width: 60vw">
|
||||||
|
<h1 class="is-size-1 mt-0 has-text-centered">Bibliography</h1>
|
||||||
|
<h2 class="is-size-3 mt-3 has-text-centered">{{ record.citation }}</h2>
|
||||||
|
|
||||||
|
<div class="container mt-6">
|
||||||
|
<article class="message">
|
||||||
|
<div class="message-body">
|
||||||
|
<p>
|
||||||
|
<strong>Last modified:</strong> {{ record.modifiedAt.format('Y-m-d') }}
|
||||||
|
at {{ record.modifiedAt.format('H:i:s') }}
|
||||||
|
</p>
|
||||||
|
<p><strong>Editor:</strong> {{ record.editor }}</p>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<div class="card p-5">
|
||||||
|
{% if is_granted('ROLE_ADMIN') or is_granted('ROLE_REVISOR') %}
|
||||||
|
<div class="buttons">
|
||||||
|
<button class="button is-link">
|
||||||
|
Edit
|
||||||
|
<span class="icon ml-2">
|
||||||
|
<i class="fa fa-edit"></i>
|
||||||
|
</span>
|
||||||
|
<button class="button is-danger">
|
||||||
|
Delete
|
||||||
|
<span class="icon ml-2">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="tabs is-boxed is-fullwidth">
|
||||||
|
<ul>
|
||||||
|
<li class="is-active">Record</li>
|
||||||
|
<li>Relations</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<table class="table is-fullwidth pt-4 record">
|
||||||
|
<tr><th>Record ID</th><td>{{ record.id }}</td></tr>
|
||||||
|
<tr><th>Status</th><td>{{ record.getStatus() }}</td></tr>
|
||||||
|
<tr><th>Editor(s)</th><td>{{ record.editor }}</td></tr>
|
||||||
|
<tr><th>Citation</th><td>{{ record.citation }}</td></tr>
|
||||||
|
<tr><th>Reference</th><td>{{ record.reference }}</td></tr>
|
||||||
|
<tr><th>Editorial notes</th><td>{{ record.notes }}</td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript" defer></script>
|
||||||
|
{% endblock %}
|
@ -57,7 +57,7 @@
|
|||||||
<button class="button is-link" data-id-edit="{{ term.id }}">
|
<button class="button is-link" data-id-edit="{{ term.id }}">
|
||||||
Edit
|
Edit
|
||||||
<span class="icon ml-2">
|
<span class="icon ml-2">
|
||||||
<i class="fa fa-pencil"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="button is-danger" data-id-delete="{{ term.id }}">
|
<button class="button is-danger" data-id-delete="{{ term.id }}">
|
||||||
|
Loading…
Reference in New Issue
Block a user