update ui of pages and menus

This commit is contained in:
Simon Vieille 2021-03-23 19:05:38 +01:00
parent ad2a92242a
commit a2c61522a4
6 changed files with 45 additions and 10 deletions

View file

@ -10,6 +10,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use function Symfony\Component\String\u;
/**
* @Gedmo\Tree(type="nested")
@ -278,6 +279,13 @@ class Node implements EntityInterface
return $this;
}
public function hasExternalUrl(): bool
{
$string = u($this->getUrl());
return $string->startsWith('http://') || $string->startsWith('https://');
}
public function getIsVisible(): ?bool
{
return $this->isVisible;

View file

@ -39,6 +39,10 @@ class SiteRouteLoader extends Loader
continue;
}
if ($node->hasExternalUrl()) {
continue;
}
$requirements = [];
$defaults = [

View file

@ -42,6 +42,10 @@ class SitemapBuilder
continue;
}
if ($node->hasExternalUrl()) {
continue;
}
$nodeItems = [];
foreach ($this->getNodeUrls($node) as $url) {
@ -63,7 +67,9 @@ class SitemapBuilder
$urls = [];
try {
if ($node->getController()) {
if ($node->hasExternalUrl()) {
$urls[] = $node->getUrl();
} elseif ($node->getController()) {
$annotation = $this->getAnnotation($node);
if (false !== $annotation) {

View file

@ -9,7 +9,9 @@
{{ node.label }}
</a>
{% elseif node.page %}
<a {% if isActive %}style="color: red"{% endif %} href="{{ url(node.routeName) }}">
{% set url = node.hasExternalUrl ? node.url : url(node.routeName) %}
<a {% if isActive %}style="color: red"{% endif %} href="{{ url }}">
{{ node.label }}
</a>
{% else %}

View file

@ -23,11 +23,21 @@
{% set edit = path('admin_site_page_edit', {entity: item.id}) %}
<tr data-dblclick="{{ edit }}">
<td class="col-10">
<td class="col-5">
<a href="{{ edit }}" class="font-weight-bold text-body d-block">
{{ item.name }}
</a>
</td>
<td class="col-5">
{% for node in item.nodes %}
<a href="{{ path('admin_site_tree_navigation', {
navigation: node.menu.navigation.id,
'data-modal': path('admin_site_node_edit', {entity: node.id}),
}) }}" class="btn btn-sm btn-light mr-1">
{{ node.label }}
</a>
{% endfor %}
</td>
<td class="col-2 text-right">
<a href="{{ edit }}" class="btn btn-sm btn-primary mr-1">
<span class="fa fa-edit"></span>

View file

@ -105,7 +105,6 @@
<button type="submit" form="form-node-delete-{{ node.id }}" class="btn btn-sm btn-danger">
<span class="fa fa-trash"></span>
Supprimer
</button>
</div>
@ -113,7 +112,13 @@
{{ node.label }}
<span class="ml-3 btn-group">
{% if node.url %}
{% if node.hasExternalUrl %}
<a href="{{ node.url }}" class="btn btn-sm border border-secondary btn-light">
<span class="fa fa-sign-out-alt text-muted"></span>
{{ node.url }}
</a>
{% else %}
{% if node.parameters|length %}
<span class="btn btn-sm border border-secondary btn-light">
{{ node.url }}
@ -123,12 +128,12 @@
{{ node.url }}
</a>
{% endif %}
{% endif %}
{% if node.controller %}
<span title="{{ node.controller }}" data-toggle="tooltip" data-placement="top" class="btn btn-sm border border-secondary btn-light">
<span class="fa fa-dice-d6"></span>
</span>
{% if node.controller %}
<span title="{{ node.controller }}" data-toggle="tooltip" data-placement="top" class="btn btn-sm border border-secondary btn-light">
<span class="fa fa-dice-d6"></span>
</span>
{% endif %}
{% endif %}
</span>
</div>