add 'disableUrl' attribute in node
This commit is contained in:
parent
730fb3e820
commit
40b2798c0c
|
@ -129,7 +129,6 @@ tr.table-primary-light {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
.sidebar {
|
||||
width: 260px;
|
||||
display: inline-block;
|
||||
|
@ -258,6 +257,13 @@ th {
|
|||
}
|
||||
}
|
||||
|
||||
.bg-tiles {
|
||||
background-color: #c1c1c1;
|
||||
background-image: linear-gradient(45deg, #646464 25%, transparent 25%, transparent 75%, #646464 75%), linear-gradient(45deg, #646464 25%, transparent 25%, transparent 75%, #646464 75%);
|
||||
background-size: 20px 20px;
|
||||
background-position: 0 0, 10px 10px;
|
||||
}
|
||||
|
||||
.tab-form {
|
||||
padding: 15px;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,11 @@ class Node implements EntityInterface
|
|||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default"=0})
|
||||
*/
|
||||
private $disableUrl = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default"=0})
|
||||
*/
|
||||
|
@ -298,6 +303,18 @@ class Node implements EntityInterface
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getDisableUrl(): ?bool
|
||||
{
|
||||
return $this->disableUrl;
|
||||
}
|
||||
|
||||
public function setDisableUrl(bool $disableUrl): self
|
||||
{
|
||||
$this->disableUrl = $disableUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTreeLabel()
|
||||
{
|
||||
$prefix = str_repeat('-', ($this->getTreeLevel() - 1) * 5);
|
||||
|
|
|
@ -60,6 +60,12 @@ class NodeEventSubscriber extends EntityManagerEventSubscriber
|
|||
|
||||
$node->setCode($this->codeSlugify->slugify($node->getCode()));
|
||||
|
||||
if ($node->getDisableUrl()) {
|
||||
$node->setUrl(null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($node->getUrl()) {
|
||||
$generatedUrl = $node->getUrl();
|
||||
} else {
|
||||
|
@ -138,6 +144,10 @@ class NodeEventSubscriber extends EntityManagerEventSubscriber
|
|||
$generatedUrl = $generatedUrl.'-'.$number;
|
||||
}
|
||||
|
||||
if (!u($generatedUrl)->startsWith('/')) {
|
||||
$generatedUrl = '/'.$generatedUrl;
|
||||
}
|
||||
|
||||
$node->setUrl($generatedUrl);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
||||
class NodeType extends AbstractType
|
||||
{
|
||||
|
@ -46,6 +47,19 @@ class NodeType extends AbstractType
|
|||
]
|
||||
);
|
||||
|
||||
$builder->add(
|
||||
'disableUrl',
|
||||
CheckboxType::class,
|
||||
[
|
||||
'label' => 'Disable URL',
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
],
|
||||
'constraints' => [
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add(
|
||||
'code',
|
||||
TextType::class,
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
"Yearly": "Annuelle"
|
||||
"Never": "Jamais"
|
||||
"URL": "URL"
|
||||
"Disable URL": "Désactiver l'URL"
|
||||
"Controller": "Contrôleur"
|
||||
"Leave blank for automatic generation": "Laisser vide pour une génération automatique"
|
||||
"Leave blank to use the default one. Example: App\\Controller\\FooController::barAction": "Laisser vide pour utiliser celui par défaut. Exemple : App\\Controller\\FooController::barAction"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{% if value %}
|
||||
{% if value and value.extension in ['jpeg', 'jpg', 'gif', 'png', 'svg'] %}
|
||||
<div class="card">
|
||||
<div class="card-img-top bg-dark text-center">
|
||||
<div class="card-img-top bg-tiles text-center">
|
||||
<a href="{{ asset(value.pathname) }}" target="_blank">
|
||||
<img src="{{ asset(value.pathname) }}" class="img-fluid">
|
||||
</a>
|
||||
|
|
|
@ -144,6 +144,7 @@
|
|||
{{ 'Route name: <code>%routeName%</code>'|trans({'%routeName%': entity.routeName})|raw }}
|
||||
</div>
|
||||
|
||||
{{ form_row(form.disableUrl) }}
|
||||
{{ form_row(form.code) }}
|
||||
{{ form_row(form.controller) }}
|
||||
|
||||
|
|
|
@ -84,23 +84,25 @@
|
|||
<span class="fa fa-sign-out-alt text-muted"></span>
|
||||
</a>
|
||||
{% else %}
|
||||
{% if node.parameters|length %}
|
||||
<span class="btn btn-sm border border-secondary btn-light">
|
||||
{{ node.url }}
|
||||
</span>
|
||||
{% else %}
|
||||
{% set url = safe_node_url(node) %}
|
||||
|
||||
{% if url %}
|
||||
<a href="{{ url ? url : '#' }}" target="_blank" class="btn btn-sm border border-secondary btn-light">
|
||||
{% if not node.disableUrl %}
|
||||
{% if node.parameters|length %}
|
||||
<span class="btn btn-sm border border-secondary btn-light">
|
||||
{{ node.url }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if url is same as(null) %}
|
||||
<span class="btn btn-sm border border-secondary btn-light" title="{{ 'Edit the routing'|trans }}">
|
||||
<span class="fa fa-exclamation"></span>
|
||||
</span>
|
||||
{% else %}
|
||||
{% set url = safe_node_url(node) %}
|
||||
|
||||
{% if url %}
|
||||
<a href="{{ url ? url : '#' }}" target="_blank" class="btn btn-sm border border-secondary btn-light">
|
||||
{{ node.url }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if url is same as(null) %}
|
||||
<span class="btn btn-sm border border-secondary btn-light" title="{{ 'Edit the routing'|trans }}">
|
||||
<span class="fa fa-exclamation"></span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
|
Loading…
Reference in New Issue