partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit c90ac3f678d91b0e5344ab74f84ba24c064c201b
parent 74f2a741ecc4e16fcc60bcbfcac29de96ed38cd1
Author: Felicitus <felicitus@felicitus.org>
Date:   Sun, 21 Jun 2015 20:43:58 +0200

Added serialization groups for SiPrefixes and Units

Diffstat:
Mapp/config/config.yml | 6++++--
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Unit/UnitEditor.js | 5+----
Msrc/PartKeepr/SiPrefixBundle/Entity/SiPrefix.php | 6++++++
Msrc/PartKeepr/UnitBundle/Entity/Unit.php | 5+++++
4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/app/config/config.yml b/app/config/config.yml @@ -107,8 +107,10 @@ services: arguments: [ "PartKeepr\UnitBundle\Entity\Unit" ] tags: [ { name: "api.resource" } ] calls: - - method: "initFilters" - arguments: [ [ "@resource.unit.order_filter" ] ] + - method: "initFilters" + arguments: [ [ "@resource.unit.order_filter" ] ] + - method: "initNormalizationContext" + arguments: [ { groups: [ "default" ] } ] resource.unit.order_filter: parent: "api.doctrine.orm.order_filter" arguments: [ ~ ] # This line can also be omitted diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Unit/UnitEditor.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Unit/UnitEditor.js @@ -42,15 +42,12 @@ Ext.define('PartKeepr.UnitEditor', { this.on("itemSave", this.onItemSave, this); }, onStartEdit: function () { - console.log(this.record.prefixes()); var records = this.record.prefixes().getRange(); - var toSelect = []; var pfxStore = PartKeepr.getApplication().getSiPrefixStore(); for (var i=0;i<records.length;i++) { - console.log(pfxStore.getById(records[i].getId())); - //toSelect.push(pfxStore.getById(records[i].getId())); + toSelect.push(pfxStore.getById(records[i].getId())); } this.gridPanel.getSelectionModel().select(toSelect); diff --git a/src/PartKeepr/SiPrefixBundle/Entity/SiPrefix.php b/src/PartKeepr/SiPrefixBundle/Entity/SiPrefix.php @@ -5,6 +5,7 @@ use PartKeepr\Util\BaseEntity, Doctrine\ORM\Mapping as ORM, Symfony\Component\Validator\Constraints as Assert, PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; +use Symfony\Component\Serializer\Annotation\Groups; /** * Represents an SI Prefix @@ -20,6 +21,7 @@ class SiPrefix * @ORM\Id @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") * @var integer + * @Groups({"default"}) */ private $id; @@ -43,6 +45,7 @@ class SiPrefix * @Assert\Type(type="string") * @Assert\NotBlank(message="siprefix.prefix.not_blank") * @var string + * @Groups({"default"}) */ private $prefix; @@ -53,6 +56,7 @@ class SiPrefix * * @Assert\Type(type="string") * @Assert\NotBlank(message="siprefix.symbol.not_blank") + * @Groups({"default"}) * @var string */ private $symbol; @@ -62,6 +66,7 @@ class SiPrefix * * @ORM\Column(type="integer") * @Assert\Type(type="integer") + * @Groups({"default"}) * @var int */ private $exponent; @@ -71,6 +76,7 @@ class SiPrefix * * @ORM\Column(type="integer") * @Assert\Type(type="integer") + * @Groups({"default"}) * @var int */ private $base; diff --git a/src/PartKeepr/UnitBundle/Entity/Unit.php b/src/PartKeepr/UnitBundle/Entity/Unit.php @@ -6,6 +6,7 @@ use PartKeepr\Util\BaseEntity, PartKeepr\SiPrefixBundle\Entity\SiPrefix, Doctrine\ORM\Mapping as ORM, PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; +use Symfony\Component\Serializer\Annotation\Groups; /** * This object represents an unit. Units can be: Volt, Hertz etc. @@ -17,6 +18,7 @@ class Unit { /** * @ORM\Id @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") + * @Groups({"default"}) * @var integer */ private $id; @@ -38,6 +40,7 @@ class Unit { * @ORM\Column(type="string") * * @var string + * @Groups({"default"}) */ private $name; @@ -45,6 +48,7 @@ class Unit { * The symbol of the unit (e.g. V, A, F, m) * @ORM\Column(type="string") * @var string + * @Groups({"default"}) */ private $symbol; @@ -55,6 +59,7 @@ class Unit { * joinColumns={@ORM\JoinColumn(name="unit_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="siprefix_id", referencedColumnName="id")} * ) + * @Groups({"default"}) * @var ArrayCollection */ private $prefixes;