add link to tree in navigation index

This commit is contained in:
Simon Vieille 2021-05-18 10:09:02 +02:00
parent 6eb8a73914
commit d18b77c83a
6 changed files with 63 additions and 53 deletions

View file

@ -83,6 +83,7 @@ class NavigationAdminController extends CrudController
->setForm('edit', Type::class, [])
->setForm('new', Type::class)
->setView('index', '@Core/site/navigation_admin/index.html.twig')
->setView('show_entity', '@Core/site/navigation_admin/_show.html.twig')
->setView('form', '@Core/site/navigation_admin/_form.html.twig')

View file

@ -22,34 +22,34 @@ class Menu implements EntityInterface
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
protected $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $label;
protected $label;
/**
* @ORM\Column(type="string", length=255)
*/
private $code;
protected $code;
/**
* @ORM\ManyToOne(targetEntity=Navigation::class, inversedBy="menus")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $navigation;
protected $navigation;
/**
* @ORM\OneToMany(targetEntity=Node::class, mappedBy="menu", orphanRemoval=true, cascade={"remove", "persist"})
*/
private $nodes;
protected $nodes;
/**
* @ORM\OneToOne(targetEntity=Node::class, cascade={"persist"})
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $rootNode;
protected $rootNode;
public function __construct()
{

View file

@ -26,112 +26,112 @@ class Node implements EntityInterface
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
protected $id;
/**
* @ORM\ManyToOne(targetEntity=Menu::class, inversedBy="nodes", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $menu;
protected $menu;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $label;
protected $label;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $url;
protected $url;
/**
* @ORM\Column(type="boolean", options={"default"=0})
*/
private $disableUrl = false;
protected $disableUrl = false;
/**
* @ORM\Column(type="boolean", options={"default"=0})
*/
private $isVisible = false;
protected $isVisible = false;
/**
* @Gedmo\TreeLeft
* @ORM\Column(type="integer")
*/
private $treeLeft;
protected $treeLeft;
/**
* @Gedmo\TreeLevel
* @ORM\Column(type="integer")
*/
private $treeLevel;
protected $treeLevel;
/**
* @Gedmo\TreeRight
* @ORM\Column(type="integer")
*/
private $treeRight;
protected $treeRight;
/**
* @Gedmo\TreeRoot
* @ORM\ManyToOne(targetEntity="Node")
* @ORM\JoinColumn(referencedColumnName="id", onDelete="CASCADE")
*/
private $treeRoot;
protected $treeRoot;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="Node", inversedBy="children")
* @ORM\JoinColumn(referencedColumnName="id", onDelete="CASCADE")
*/
private $parent;
protected $parent;
/**
* @ORM\OneToMany(targetEntity="Node", mappedBy="parent")
* @ORM\OrderBy({"treeLeft"="ASC"})
*/
private $children;
protected $children;
/**
* @ORM\ManyToOne(targetEntity=Page::class, inversedBy="nodes", cascade={"persist"})
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private $page;
protected $page;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $code;
protected $code;
/**
* @ORM\Column(type="array", nullable=true)
*/
private $parameters = [];
protected $parameters = [];
/**
* @ORM\Column(type="array", nullable=true)
*/
private $attributes = [];
protected $attributes = [];
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $controller;
protected $controller;
/**
* @ORM\Column(type="array", nullable=true)
*/
private $sitemapParameters = [];
protected $sitemapParameters = [];
/**
* @ORM\ManyToOne(targetEntity=Node::class, inversedBy="aliasNodes")
*/
private $aliasNode;
protected $aliasNode;
/**
* @ORM\OneToMany(targetEntity=Node::class, mappedBy="aliasNode")
*/
private $aliasNodes;
protected $aliasNodes;
public function __construct()
{

View file

@ -21,23 +21,23 @@ class Block
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
protected $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
protected $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $value;
protected $value;
/**
* @ORM\ManyToOne(targetEntity=Page::class, inversedBy="blocks")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $page;
protected $page;
public function getId(): ?int
{

View file

@ -150,32 +150,34 @@
</td>
{% endfor %}
{% if configuration.action('index', 'show', true) or configuration.action('index', 'edit', true) or configuration.action('index', 'delete', true) %}
<td class="col-2 miw-200 text-right">
{% if configuration.action('index', 'show', true) %}
<a href="{{ path(configuration.pageRoute('show'), {entity: item.id}) }}" class="btn btn-sm btn-secondary mr-1">
<span class="fa fa-eye"></span>
</a>
{% endif %}
<td class="col-2 miw-200 text-right">
{% block list_item_actions_before %}{% endblock %}
{% if configuration.action('index', 'edit', true) %}
<a href="{{ path(configuration.pageRoute('edit'), {entity: item.id}) }}" class="btn btn-sm btn-primary mr-1">
<span class="fa fa-edit"></span>
</a>
{% endif %}
{% if configuration.action('index', 'show', true) %}
<a href="{{ path(configuration.pageRoute('show'), {entity: item.id}) }}" class="btn btn-sm btn-secondary mr-1">
<span class="fa fa-eye"></span>
</a>
{% endif %}
{% if configuration.action('index', 'delete', true) %}
<button type="submit" form="form-delete-{{ item.id }}" class="btn btn-sm btn-danger">
<span class="fa fa-trash"></span>
</button>
{% if configuration.action('index', 'edit', true) %}
<a href="{{ path(configuration.pageRoute('edit'), {entity: item.id}) }}" class="btn btn-sm btn-primary mr-1">
<span class="fa fa-edit"></span>
</a>
{% endif %}
<form method="post" action="{{ path(configuration.pageRoute('delete'), {entity: item.id}) }}" id="form-delete-{{ item.id }}" data-form-confirm>
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ item.id) }}">
</form>
{% endif %}
</td>
{% endif %}
{% if configuration.action('index', 'delete', true) %}
<button type="submit" form="form-delete-{{ item.id }}" class="btn btn-sm btn-danger">
<span class="fa fa-trash"></span>
</button>
<form method="post" action="{{ path(configuration.pageRoute('delete'), {entity: item.id}) }}" id="form-delete-{{ item.id }}" data-form-confirm>
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ item.id) }}">
</form>
{% endif %}
{% block list_item_actions_after %}{% endblock %}
</td>
</tr>
{% endblock %}
{% else %}

View file

@ -0,0 +1,7 @@
{% extends '@Core/admin/crud/index.html.twig' %}
{% block list_item_actions_before %}
<a href="{{ path('admin_site_tree_navigation', {navigation: item.id}) }}" class="btn btn-sm btn-success mr-1">
<span class="fa fa-sitemap"></span>
</a>
{% endblock %}