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('edit', Type::class, [])
->setForm('new', 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('show_entity', '@Core/site/navigation_admin/_show.html.twig')
->setView('form', '@Core/site/navigation_admin/_form.html.twig') ->setView('form', '@Core/site/navigation_admin/_form.html.twig')

View file

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

View file

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

View file

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

View file

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