mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-13 20:04:34 +02:00
Added an simple admin page for users.
This commit is contained in:
parent
0826f5e6aa
commit
8a4d665d2a
12 changed files with 276 additions and 30 deletions
|
@ -38,6 +38,7 @@ use App\Entity\NamedDBElement;
|
|||
use App\Entity\Part;
|
||||
use App\Entity\Storelocation;
|
||||
use App\Entity\Supplier;
|
||||
use App\Entity\User;
|
||||
use App\Exceptions\EntityNotSupported;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
@ -144,6 +145,10 @@ class EntityURLGenerator
|
|||
return $this->urlGenerator->generate("footprint_edit", ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
if($entity instanceof User) {
|
||||
return $this->urlGenerator->generate('user_edit', ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
//Otherwise throw an error
|
||||
throw new EntityNotSupported('The given entity is not supported yet!');
|
||||
}
|
||||
|
@ -189,6 +194,10 @@ class EntityURLGenerator
|
|||
return $this->urlGenerator->generate('footprint_new');
|
||||
}
|
||||
|
||||
if ($entity instanceof User) {
|
||||
return $this->urlGenerator->generate('user_new');
|
||||
}
|
||||
|
||||
throw new EntityNotSupported('The given entity is not supported yet!');
|
||||
}
|
||||
|
||||
|
@ -244,15 +253,19 @@ class EntityURLGenerator
|
|||
}
|
||||
|
||||
if ($entity instanceof Manufacturer) {
|
||||
return $this->urlGenerator->generate('manufacturer_new', ['id' => $entity->getID()]);
|
||||
return $this->urlGenerator->generate('manufacturer_delete', ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
if ($entity instanceof Storelocation) {
|
||||
return $this->urlGenerator->generate('store_location_new', ['id' => $entity->getID()]);
|
||||
return $this->urlGenerator->generate('store_location_delete', ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
if ($entity instanceof Footprint) {
|
||||
return $this->urlGenerator->generate('footprint_new', ['id' => $entity->getID()]);
|
||||
return $this->urlGenerator->generate('footprint_delete', ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
if ($entity instanceof User) {
|
||||
return $this->urlGenerator->generate('user_delete', ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
throw new EntityNotSupported('The given entity is not supported yet!');
|
||||
|
|
|
@ -32,10 +32,12 @@
|
|||
namespace App\Services;
|
||||
|
||||
use App\Entity\DBElement;
|
||||
use App\Entity\NamedDBElement;
|
||||
use App\Entity\StructuralDBElement;
|
||||
use App\Helpers\TreeViewNode;
|
||||
use App\Repository\StructuralDBElementRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\MakerBundle\Str;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
|
@ -66,13 +68,15 @@ class TreeBuilder
|
|||
* @return TreeViewNode The Node for the given Element.
|
||||
* @throws \App\Exceptions\EntityNotSupported
|
||||
*/
|
||||
public function elementToTreeNode(StructuralDBElement $element, ?string $href_type = 'list_parts', DBElement $selectedElement = null) : TreeViewNode
|
||||
public function elementToTreeNode(NamedDBElement $element, ?string $href_type = 'list_parts', DBElement $selectedElement = null) : TreeViewNode
|
||||
{
|
||||
$children = $element->getSubelements();
|
||||
|
||||
$children_nodes = null;
|
||||
foreach ($children as $child) {
|
||||
$children_nodes[] = $this->elementToTreeNode($child, $href_type, $selectedElement);
|
||||
|
||||
if ($element instanceof StructuralDBElement) {
|
||||
$children = $element->getSubelements();
|
||||
foreach ($children as $child) {
|
||||
$children_nodes[] = $this->elementToTreeNode($child, $href_type, $selectedElement);
|
||||
}
|
||||
}
|
||||
|
||||
//Check if we need to generate a href type
|
||||
|
@ -82,7 +86,7 @@ class TreeBuilder
|
|||
$href = $this->url_generator->getURL($element, $href_type);
|
||||
}
|
||||
|
||||
$tree_node = new TreeViewNode($element->getName(), $href, $children_nodes);
|
||||
$tree_node = new TreeViewNode($element->__toString(), $href, $children_nodes);
|
||||
|
||||
if($children_nodes != null) {
|
||||
$tree_node->addTag((string) count($children_nodes));
|
||||
|
@ -113,7 +117,12 @@ class TreeBuilder
|
|||
* @var $repo StructuralDBElementRepository
|
||||
*/
|
||||
$repo = $this->em->getRepository($class_name);
|
||||
$root_nodes = $repo->findRootNodes();
|
||||
|
||||
if (new $class_name() instanceof StructuralDBElement) {
|
||||
$root_nodes = $repo->findRootNodes();
|
||||
} else {
|
||||
$root_nodes = $repo->findAll();
|
||||
}
|
||||
|
||||
$array = array();
|
||||
|
||||
|
@ -134,7 +143,6 @@ class TreeBuilder
|
|||
$href_type = "edit";
|
||||
}
|
||||
|
||||
|
||||
foreach ($root_nodes as $node) {
|
||||
$array[] = $this->elementToTreeNode($node, $href_type, $selectedElement);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue