improved tag auto-completion and added tag management (#1083)

This commit is contained in:
Kevin Papst
2019-09-04 23:47:33 +02:00
committed by GitHub
parent 3ea05cb705
commit d041a3f4f9
25 changed files with 368 additions and 17 deletions

View File

@@ -266,6 +266,11 @@ class SystemConfigurationController extends AbstractController
->setLabel('theme.markdown_content')
->setType(CheckboxType::class)
->setTranslationDomain('system-configuration'),
(new Configuration())
->setName('theme.autocomplete_chars')
->setLabel('theme.autocomplete_chars')
->setType(IntegerType::class)
->setTranslationDomain('system-configuration'),
// FIXME should that be configurable per user?
/*
(new Configuration())

View File

@@ -9,9 +9,12 @@
namespace App\Controller;
use App\Entity\Tag;
use App\Form\TagEditForm;
use App\Form\Toolbar\TagToolbarForm;
use App\Repository\Query\TagQuery;
use App\Repository\TagRepository;
use Doctrine\ORM\ORMException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -51,6 +54,68 @@ class TagController extends AbstractController
]);
}
/**
* @Route(path="/{id}/edit", name="tags_edit", methods={"GET", "POST"})
* @Security("is_granted('manage_tag')")
*/
public function editAction(Tag $tag, TagRepository $repository, Request $request)
{
$editForm = $this->createForm(TagEditForm::class, $tag, [
'action' => $this->generateUrl('tags_edit', ['id' => $tag->getId()]),
'method' => 'POST',
]);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
try {
$repository->saveTag($tag);
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('tags');
} catch (ORMException $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
return $this->render('tags/edit.html.twig', [
'tag' => $tag,
'form' => $editForm->createView()
]);
}
/**
* @Route(path="/create", name="tags_create", methods={"GET", "POST"})
* @Security("is_granted('manage_tag')")
*/
public function createAction(TagRepository $repository, Request $request)
{
$tag = new Tag();
$editForm = $this->createForm(TagEditForm::class, $tag, [
'action' => $this->generateUrl('tags_create'),
'method' => 'POST',
]);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
try {
$repository->saveTag($tag);
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('tags');
} catch (ORMException $ex) {
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
}
}
return $this->render('tags/edit.html.twig', [
'tag' => $tag,
'form' => $editForm->createView()
]);
}
/**
* @param TagQuery $query
* @return \Symfony\Component\Form\FormInterface