mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-04 07:24:34 +02:00
Added an export function to attachment_types admin pages.
This commit is contained in:
parent
09eb3c226a
commit
091311cdf1
6 changed files with 199 additions and 20 deletions
|
@ -77,7 +77,6 @@ class AttachmentType extends StructuralDBElement
|
|||
*/
|
||||
public function getIDString(): string
|
||||
{
|
||||
return '';
|
||||
//return 'AT' . sprintf('%09d', $this->getID());
|
||||
return 'AT' . sprintf('%09d', $this->getID());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* This class is for managing all database objects.
|
||||
|
@ -36,6 +38,23 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* @ORM\MappedSuperclass()
|
||||
*
|
||||
* @ORM\EntityListeners({"App\Security\EntityListeners\ElementPermissionListener"})
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "attachment_type" = "App\Entity\AttachmentType",
|
||||
* "attachment" = "App\Entity\Attachment",
|
||||
* "category" = "App\Entity\Attachment",
|
||||
* "device" = "App\Entity\Device",
|
||||
* "device_part" = "App\Entity\DevicePart",
|
||||
* "footprint" = "App\Entity\Footprint",
|
||||
* "group" = "App\Entity\Group",
|
||||
* "manufacturer" = "App\Entity\Manufacturer",
|
||||
* "orderdetail" = "App\Entity\Orderdetail",
|
||||
* "part" = "App\Entity\Part",
|
||||
* "pricedetail" = "App\Entity\Pricedetail",
|
||||
* "storelocation" = "App\Entity\Storelocation",
|
||||
* "supplier" = "App\Entity\Supplier",
|
||||
* "user" = "App\Entity\User"
|
||||
* })
|
||||
*/
|
||||
abstract class DBElement
|
||||
{
|
||||
|
@ -43,6 +62,7 @@ abstract class DBElement
|
|||
* @ORM\Column(type="integer")
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @Groups({"full"})
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
@ -64,6 +84,7 @@ abstract class DBElement
|
|||
* This should have a form like P000014, for a part with ID 14.
|
||||
*
|
||||
* @return string The ID as a string;
|
||||
*
|
||||
*/
|
||||
abstract public function getIDString(): string;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace App\Entity;
|
|||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* All subclasses of this class have an attribute "name".
|
||||
|
@ -38,18 +39,21 @@ abstract class NamedDBElement extends DBElement
|
|||
* @var string The name of this element.
|
||||
* @ORM\Column(type="string")
|
||||
* @Assert\NotBlank()
|
||||
* @Groups({"simple", "extended", "full"})
|
||||
*/
|
||||
protected $name = '';
|
||||
|
||||
/**
|
||||
* @var \DateTime The date when this element was modified the last time.
|
||||
* @ORM\Column(type="datetimetz", name="last_modified")
|
||||
* @Groups({"extended", "full"})
|
||||
*/
|
||||
protected $lastModified;
|
||||
|
||||
/**
|
||||
* @var \DateTime The date when this element was created.
|
||||
* @ORM\Column(type="datetimetz", name="datetime_added")
|
||||
* @Groups({"extended", "full"})
|
||||
*/
|
||||
protected $addedDate;
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
use Doctrine\ORM\PersistentCollection;
|
||||
use App\Validator\Constraints\NoneOfItsChildren;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* All elements with the fields "id", "name" and "parent_id" (at least).
|
||||
|
@ -52,17 +54,20 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
|||
// subclasses
|
||||
/**
|
||||
* @var StructuralDBElement[]
|
||||
* @Groups({"include_children"})
|
||||
*/
|
||||
protected $children;
|
||||
/**
|
||||
* @var StructuralDBElement
|
||||
* @NoneOfItsChildren()
|
||||
* @Groups({"include_parents"})
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @var string The comment info for this element
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
* @Groups({"simple", "extended", "full"})
|
||||
*/
|
||||
protected $comment;
|
||||
|
||||
|
@ -78,7 +83,9 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
|||
protected $level = 0;
|
||||
|
||||
/** @var string[] all names of all parent elements as a array of strings,
|
||||
* the last array element is the name of the element itself */
|
||||
* the last array element is the name of the element itself
|
||||
*
|
||||
*/
|
||||
private $full_path_strings;
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -154,24 +161,25 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
|||
/**
|
||||
* Get the level.
|
||||
*
|
||||
* The level of the root node is -1.
|
||||
* The level of the root node is -1.
|
||||
*
|
||||
* @return int the level of this element (zero means a most top element
|
||||
* [a subelement of the root node])
|
||||
*
|
||||
*/
|
||||
public function getLevel(): int
|
||||
{
|
||||
if (0 === $this->level) {
|
||||
/**
|
||||
* Only check for nodes that have a parent. In the other cases zero is correct.
|
||||
*/
|
||||
if (0 === $this->level && $this->parent !== null) {
|
||||
$element = $this->parent;
|
||||
$parent_id = $element->getParentID();
|
||||
while ($parent_id > 0) {
|
||||
while ($element !== null) {
|
||||
/** @var StructuralDBElement $element */
|
||||
$element = $element->parent;
|
||||
$parent_id = $element->getParentID();
|
||||
++$this->level;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
|
@ -181,6 +189,7 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
|||
* @param string $delimeter the delimeter of the returned string
|
||||
*
|
||||
* @return string the full path (incl. the name of this element), delimeted by $delimeter
|
||||
*
|
||||
*/
|
||||
public function getFullPath(string $delimeter = self::PATH_DELIMITER_ARROW): string
|
||||
{
|
||||
|
@ -216,6 +225,11 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement
|
|||
return $this->children;
|
||||
}
|
||||
|
||||
public function getChildren(): PersistentCollection
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Setters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue