add node urls list
This commit is contained in:
parent
ff6465a64a
commit
ad2a92242a
|
@ -261,13 +261,13 @@ table.table-fixed, .table-fixed > table {
|
|||
.toast-container {
|
||||
display: flex;
|
||||
position: relative;
|
||||
z-index: 1000;
|
||||
z-index: 1060;
|
||||
|
||||
.toast-wrapper {
|
||||
position: fixed;
|
||||
top: 80px;
|
||||
right: calc(50% - 150px);
|
||||
z-index: 1000;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
z-index: 1060;
|
||||
width: 300px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const $ = require('jquery');
|
||||
|
||||
module.exports = function() {
|
||||
$('*[data-modal]').click((e) => {
|
||||
$('body').on('click', '*[data-modal]', (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
|
@ -21,4 +21,11 @@ module.exports = function() {
|
|||
$(container).modal('show');
|
||||
});
|
||||
});
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const dataModal = urlParams.get('data-modal')
|
||||
|
||||
if (dataModal) {
|
||||
$('*[data-modal="' + dataModal + '"]').first().click();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ use Symfony\Component\Form\FormError;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use App\Core\Sitemap\SitemapBuilder;
|
||||
|
||||
/**
|
||||
* @Route("/admin/site/node")
|
||||
|
@ -73,6 +74,11 @@ class NodeAdminController extends AdminController
|
|||
$entityManager->update($entity);
|
||||
|
||||
$this->addFlash('success', 'Donnée enregistrée.');
|
||||
|
||||
return $this->redirectToRoute('admin_site_tree_navigation', [
|
||||
'navigation' => $node->getMenu()->getNavigation()->getId(),
|
||||
'data-modal' => $this->generateUrl('admin_site_node_edit', ['entity' => $entity->getId()]),
|
||||
]);
|
||||
} else {
|
||||
$this->addFlash('warning', 'Le formulaire est invalide.');
|
||||
}
|
||||
|
@ -86,14 +92,16 @@ class NodeAdminController extends AdminController
|
|||
'form' => $form->createView(),
|
||||
'node' => $node,
|
||||
'entity' => $entity,
|
||||
'tab' => 'content',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/edit/{entity}", name="admin_site_node_edit")
|
||||
* @Route("/edit/{entity}/{tab}", name="admin_site_node_edit")
|
||||
*/
|
||||
public function edit(
|
||||
Entity $entity,
|
||||
string $tab = 'content',
|
||||
EntityManager $entityManager,
|
||||
PageFactory $pageFactory,
|
||||
PageLocator $pageLocator,
|
||||
|
@ -125,12 +133,25 @@ class NodeAdminController extends AdminController
|
|||
|
||||
return $this->redirectToRoute('admin_site_tree_navigation', [
|
||||
'navigation' => $entity->getMenu()->getNavigation()->getId(),
|
||||
'data-modal' => $this->generateUrl('admin_site_node_edit', ['entity' => $entity->getId()]),
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render('site/node_admin/edit.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'entity' => $entity,
|
||||
'tab' => $tab,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/urls/{entity}", name="admin_site_node_urls")
|
||||
*/
|
||||
public function urls(Entity $entity, SitemapBuilder $builder): Response
|
||||
{
|
||||
return $this->render('site/node_admin/urls.html.twig', [
|
||||
'entity' => $entity,
|
||||
'urls' => $builder->getNodeUrls($entity),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
namespace App\Core\Sitemap;
|
||||
|
||||
use App\Core\Annotation\UrlGenerator;
|
||||
use App\Core\Entity\Site\Navigation;
|
||||
use App\Core\Entity\Site\Node;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use App\Core\Entity\Site\Navigation;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
/**
|
||||
* class SitemapBuilder.
|
||||
|
@ -44,36 +44,8 @@ class SitemapBuilder
|
|||
|
||||
$nodeItems = [];
|
||||
|
||||
try {
|
||||
if ($node->getController()) {
|
||||
$annotation = $this->getAnnotation($node);
|
||||
|
||||
if (false === $annotation) {
|
||||
continue;
|
||||
}
|
||||
if (null === $annotation) {
|
||||
$nodeItems[] = $this->createItem($parameters, $this->urlGenerator->generate(
|
||||
$node->getRouteName(),
|
||||
[],
|
||||
UrlGeneratorInterface::ABSOLUTE_URL
|
||||
));
|
||||
} else {
|
||||
$service = $this->container->get($annotation->service);
|
||||
$method = $annotation->method;
|
||||
$urls = $service->{$method}($node, $annotation->options);
|
||||
|
||||
foreach ($urls as $url) {
|
||||
$nodeItems[] = $this->createItem($parameters, $url);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$nodeItems[] = $this->createItem($parameters, $this->urlGenerator->generate(
|
||||
$node->getRouteName(),
|
||||
[],
|
||||
UrlGeneratorInterface::ABSOLUTE_URL
|
||||
));
|
||||
}
|
||||
} catch (MissingMandatoryParametersException $e) {
|
||||
foreach ($this->getNodeUrls($node) as $url) {
|
||||
$nodeItems[] = $this->createItem($parameters, $url);
|
||||
}
|
||||
|
||||
$items = array_merge(
|
||||
|
@ -86,7 +58,41 @@ class SitemapBuilder
|
|||
return $items;
|
||||
}
|
||||
|
||||
public function createItem(array $parameters, string $location): array
|
||||
public function getNodeUrls(Node $node)
|
||||
{
|
||||
$urls = [];
|
||||
|
||||
try {
|
||||
if ($node->getController()) {
|
||||
$annotation = $this->getAnnotation($node);
|
||||
|
||||
if (false !== $annotation) {
|
||||
if (null === $annotation) {
|
||||
$urls[] = $this->urlGenerator->generate(
|
||||
$node->getRouteName(),
|
||||
[],
|
||||
UrlGeneratorInterface::ABSOLUTE_URL
|
||||
);
|
||||
} else {
|
||||
$service = $this->container->get($annotation->service);
|
||||
$method = $annotation->method;
|
||||
$urls = $service->{$method}($node, $annotation->options);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$urls[] = $this->urlGenerator->generate(
|
||||
$node->getRouteName(),
|
||||
[],
|
||||
UrlGeneratorInterface::ABSOLUTE_URL
|
||||
);
|
||||
}
|
||||
} catch (MissingMandatoryParametersException $e) {
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
|
||||
protected function createItem(array $parameters, string $location): array
|
||||
{
|
||||
return array_merge(
|
||||
[
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<ul class="nav nav-pills" id="myTab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link active" data-toggle="tab" href="#form-node-edit-content">Contenu</a>
|
||||
<a class="nav-link {% if tab == 'content' %}active{% endif %}" data-toggle="tab" href="#form-node-edit-content">Contenu</a>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" data-toggle="tab" href="#form-node-edit-routing">Routage</a>
|
||||
<a class="nav-link {% if tab == 'routing' %}active{% endif %}" data-toggle="tab" href="#form-node-edit-routing">Routage</a>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" data-toggle="tab" href="#form-node-edit-attributes">Attributs</a>
|
||||
<a class="nav-link {% if tab == 'attributes' %}active{% endif %}" data-toggle="tab" href="#form-node-edit-attributes">Attributs</a>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" data-toggle="tab" href="#form-node-edit-sitemap">Sitemap</a>
|
||||
<a class="nav-link {% if tab == 'sitemap' %}active{% endif %}" data-toggle="tab" href="#form-node-edit-sitemap">Sitemap</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content pt-4">
|
||||
<div class="tab-pane show active" id="form-node-edit-content">
|
||||
<div class="tab-pane {% if tab == 'content' %}show active{% endif %}" id="form-node-edit-content">
|
||||
{{ form_row(form.label) }}
|
||||
|
||||
{% if form.position is defined %}
|
||||
|
@ -121,7 +121,15 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="form-node-edit-routing">
|
||||
<div class="tab-pane {% if tab == 'routing' %}show active{% endif %}" id="form-node-edit-routing">
|
||||
{% if entity.id %}
|
||||
<div class="float-right">
|
||||
<span data-modal="{{ path('admin_site_node_urls', {entity: entity.id}) }}" class="btn" title="Afficher toutes les URLs du nœud">
|
||||
<span class="fa fa-list" data-modal="{{ path('admin_site_node_urls', {entity: entity.id}) }}"></span>
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{{ form_row(form.url) }}
|
||||
|
||||
<div class="pb-1">
|
||||
|
@ -164,7 +172,7 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="form-node-edit-attributes">
|
||||
<div class="tab-pane {% if tab == 'attributes' %}show active{% endif %}" id="form-node-edit-attributes">
|
||||
<div class="accordion mb-3" data-collection="collection-node-attributes" id="form-node-edit-attributes-collection">
|
||||
{% for item in form.attributes %}
|
||||
<div class="card" data-collection-item="{{ loop.index }}">
|
||||
|
@ -197,7 +205,7 @@
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="form-node-edit-sitemap">
|
||||
<div class="tab-pane {% if tab == 'sitemap' %}show active{% endif %}" id="form-node-edit-sitemap">
|
||||
{{ form_row(form.sitemapParameters) }}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">URLs de « {{ entity.label }} »</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul class="list-group">
|
||||
{% for url in urls %}
|
||||
<li class="list-group-item">
|
||||
<a href="{{ url }}" target="_blank">{{ url }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-modal="{{ path('admin_site_node_edit', {entity: entity.id, tab: 'routing'}) }}">Retour</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue