feat: treat all uploads of type 'document' as global
This commit is contained in:
@@ -39,10 +39,6 @@ class EditController extends AbstractController
|
||||
'placeholder' => $upload->getOriginalFilename(),
|
||||
],
|
||||
])
|
||||
->add('global', CheckboxType::class, [
|
||||
'label' => 'globales Dokument',
|
||||
'required' => false,
|
||||
])
|
||||
->getForm()
|
||||
;
|
||||
$form->handleRequest($request);
|
||||
@@ -61,7 +57,7 @@ class EditController extends AbstractController
|
||||
$response->setCloseAndRedirect($this->generateUrl('app_admin_system_document_index'));
|
||||
} else {
|
||||
$response->setContent($this->renderView('admin/system/document/edit.html.twig', [
|
||||
'form' => $form,
|
||||
'form' => $form->createView(),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class IndexController extends AbstractController
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$query = $this->uploadRepository->getDocumentListQuery();
|
||||
$query = $this->uploadRepository->getGlobalListQuery();
|
||||
|
||||
$pagination = $this->paginator->paginate(
|
||||
$query,
|
||||
|
||||
@@ -60,7 +60,7 @@ class ReplaceController extends AbstractController
|
||||
$response->setCloseAndRedirect($this->generateUrl('app_admin_system_document_index'));
|
||||
} else {
|
||||
$response->setContent($this->renderView('admin/system/document/replace.html.twig', [
|
||||
'form' => $form,
|
||||
'form' => $form->createView(),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ use App\Service\Upload\UploadHandler;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
@@ -33,10 +32,6 @@ class UploadController extends AbstractController
|
||||
|
||||
$form = $this
|
||||
->createFormBuilder(null, ['action' => $formAction, 'ajax_submit' => true])
|
||||
->add('global', CheckboxType::class, [
|
||||
'label' => 'globale(s) Dokument(e)',
|
||||
'required' => false,
|
||||
])
|
||||
->getForm()
|
||||
;
|
||||
$form->handleRequest($request);
|
||||
@@ -49,7 +44,6 @@ class UploadController extends AbstractController
|
||||
$user = $this->getUser();
|
||||
foreach ($uploadSession->getUploads() as $upload) {
|
||||
$document = Upload::fromUploadDto($upload, $user, Upload::TYPE_DOCUMENT);
|
||||
$document->setGlobal($form->get('global')->getData());
|
||||
$uploadedDocuments[] = $document;
|
||||
$this->entityManager->persist($document);
|
||||
}
|
||||
@@ -72,7 +66,7 @@ class UploadController extends AbstractController
|
||||
$response->setCloseAndRedirect($this->generateUrl('app_admin_system_document_index'));
|
||||
} else {
|
||||
$response->setContent($this->renderView('admin/system/document/upload.html.twig', [
|
||||
'form' => $form,
|
||||
'form' => $form->createView(),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
@@ -81,9 +81,6 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
#[ORM\ManyToMany(targetEntity: Teamer::class, mappedBy: 'bookmarks')]
|
||||
private Collection $teamers;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Upload::class)]
|
||||
private Collection $documents;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?User $owner = null;
|
||||
|
||||
@@ -99,7 +96,6 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
$this->dispositions = new ArrayCollection();
|
||||
$this->teamers = new ArrayCollection();
|
||||
$this->benefits = "Anreise im E&P Reisebus\nUnterkunft\nVerpflegung\nSkipass\n";
|
||||
$this->documents = new ArrayCollection();
|
||||
}
|
||||
|
||||
public static function duplicate(Assignment $assignment): static
|
||||
@@ -432,30 +428,6 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Upload>
|
||||
*/
|
||||
public function getDocuments(): Collection
|
||||
{
|
||||
return $this->documents;
|
||||
}
|
||||
|
||||
public function addDocument(Upload $document): static
|
||||
{
|
||||
if (!$this->documents->contains($document)) {
|
||||
$this->documents->add($document);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeDocument(Upload $document): static
|
||||
{
|
||||
$this->documents->removeElement($document);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOwner(): ?User
|
||||
{
|
||||
return $this->owner;
|
||||
|
||||
@@ -63,9 +63,6 @@ class Upload implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
#[ORM\ManyToOne(inversedBy: 'documents')]
|
||||
private ?Disposition $disposition = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private bool $global = false;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $comment = null;
|
||||
|
||||
@@ -222,18 +219,6 @@ class Upload implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isGlobal(): bool
|
||||
{
|
||||
return $this->global;
|
||||
}
|
||||
|
||||
public function setGlobal(bool $global): static
|
||||
{
|
||||
$this->global = $global;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->comment;
|
||||
|
||||
@@ -108,29 +108,6 @@ class AssignmentType extends AbstractType
|
||||
;
|
||||
},
|
||||
])
|
||||
->add('documents', CollectionType::class, [
|
||||
'label' => 'Dokumente',
|
||||
'entry_type' => EntityType::class,
|
||||
'entry_options' => [
|
||||
'class' => Upload::class,
|
||||
'choice_label' => function (Upload $document) {
|
||||
return $document->getDisplayName() ?? $document->getOriginalFilename();
|
||||
},
|
||||
'placeholder' => 'Dokument...',
|
||||
'query_builder' => function (EntityRepository $repository) {
|
||||
return $repository
|
||||
->createQueryBuilder('upload')
|
||||
->where('upload.type = :type')
|
||||
->setParameter('type', Upload::TYPE_DOCUMENT)
|
||||
->orderBy('upload.displayName')
|
||||
->addOrderBy('upload.originalFilename')
|
||||
;
|
||||
},
|
||||
],
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
])
|
||||
->add('remarks', TextareaType::class, [
|
||||
'label' => 'Anmerkungen',
|
||||
'required' => false,
|
||||
|
||||
@@ -25,7 +25,7 @@ class UploadRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Upload::class);
|
||||
}
|
||||
|
||||
public function getDocumentListQuery(): Query
|
||||
public function getGlobalListQuery(): Query
|
||||
{
|
||||
$qb = $this->createQueryBuilder('upload');
|
||||
|
||||
@@ -36,6 +36,15 @@ class UploadRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
public function getGlobal(): array
|
||||
{
|
||||
return $this
|
||||
->getGlobalListQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
public function getAutocompletionData(string $search): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('upload');
|
||||
@@ -123,17 +132,4 @@ class UploadRepository extends ServiceEntityRepository
|
||||
->getSingleScalarResult()
|
||||
;
|
||||
}
|
||||
|
||||
public function getGlobal(): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('upload');
|
||||
|
||||
return $qb
|
||||
->where($qb->expr()->eq('upload.global', ':global'))
|
||||
->setParameter('global', true)
|
||||
->orderBy('upload.createdAt', 'DESC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
{{ form_widget(form.showAvailableDispositions) }}
|
||||
</div>
|
||||
</div>
|
||||
{# <div class="grid lg:grid-cols-2 gap-x-8 gap-y-4">#}
|
||||
{# {{ form_row(form.dateFrom) }}#}
|
||||
{# {{ form_row(form.dateTo) }}#}
|
||||
{# </div>#}
|
||||
<div class="grid lg:grid-cols-2 gap-x-8 gap-y-4">
|
||||
{{ form_row(form.jobProfile) }}
|
||||
{{ form_row(form.contact) }}
|
||||
@@ -44,25 +40,7 @@
|
||||
<div class="grid lg:grid-cols-2 gap-x-8 gap-y-4">
|
||||
{{ form_row(form.benefits) }}
|
||||
{{ form_row(form.fees) }}
|
||||
</div>
|
||||
<div class="grid lg:grid-cols-2 gap-x-8 gap-y-4">
|
||||
{{ form_row(form.remarks) }}
|
||||
<div {{ stimulus_controller('form-collection', { 'prototype': _self.collectionRow(form.documents.vars.prototype)|json_encode }) }}>
|
||||
<h4 class="font-bold pb-2">
|
||||
Dokumente
|
||||
</h4>
|
||||
<div {{ stimulus_target('form-collection', 'fields')}} class="flex flex-col space-y-4 mb-4">
|
||||
{% do form.documents.setRendered %}
|
||||
{%- for document in form.documents -%}{{- _self.collectionRow(document) -}}{%- endfor -%}
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="button"
|
||||
{{ stimulus_action('form-collection', 'addItem') }}
|
||||
title="Dokument hinzufügen">
|
||||
{{ icon('plus', 'w-4 h-4 pointer-events-none') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
<div class="pb-4">
|
||||
{{ form_row(form.displayName) }}
|
||||
</div>
|
||||
<div class="pb-4">
|
||||
{{ form_row(form.global) }}
|
||||
</div>
|
||||
<button type="submit" class="btn">
|
||||
aktualisieren
|
||||
</button>
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
<th>
|
||||
Dateigröße
|
||||
</th>
|
||||
<th>
|
||||
global
|
||||
</th>
|
||||
<th>
|
||||
Upload am
|
||||
</th>
|
||||
@@ -38,10 +35,6 @@
|
||||
<td>
|
||||
{{ document.size|file_size }}
|
||||
</td>
|
||||
<td>
|
||||
{% set icon = document.global ? 'check' : 'minus' %}
|
||||
{{ icon(icon, 'w-4 h-4') }}
|
||||
</td>
|
||||
<td>
|
||||
{{ document.createdAt|date('d.m.Y') }}
|
||||
</td>
|
||||
@@ -85,7 +78,7 @@
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<td colspan="5">
|
||||
Keine Daten...
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
'accepted_files': 'application/pdf',
|
||||
} %}
|
||||
</div>
|
||||
<div class="pb-4">
|
||||
{{ form_row(form.global) }}
|
||||
</div>
|
||||
<button type="submit" class="btn">
|
||||
Uploads speichern
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user