improved tag auto-completion and added tag management (#1083)
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user