Adding fonction in personrenderbox

This commit is contained in:
Julie Lenaerts 2022-02-22 15:05:43 +01:00
parent 5d530aaae9
commit 262bb13b6c
3 changed files with 44 additions and 11 deletions

View File

@ -30,13 +30,13 @@ class ThirdPartyProfession
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
* @ORM\Column(type="integer") * @ORM\Column(type="integer")
* @Serializer\Groups({"docgen:read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private ?int $id = null; private ?int $id = null;
/** /**
* @ORM\Column(type="json") * @ORM\Column(type="json")
* @Serializer\Groups({"docgen:read"}) * @Serializer\Groups({"read", "docgen:read"})
*/ */
private array $name = []; private array $name = [];

View File

@ -22,8 +22,6 @@
</badge-entity> </badge-entity>
</div> </div>
<p v-if="thirdparty.profession">{{ thirdparty.profession }}</p>
<p v-if="this.options.addInfo === true" class="moreinfo"> <p v-if="this.options.addInfo === true" class="moreinfo">
</p> </p>
</div> </div>
@ -96,10 +94,8 @@
<script> <script>
import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue'; import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRenderBox.vue';
import {dateToISO} from 'ChillMainAssets/chill/js/date.js';
import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue'; import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue';
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue'; import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
//import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
export default { export default {
name: "ThirdPartyRenderBox", name: "ThirdPartyRenderBox",
@ -107,7 +103,6 @@ export default {
AddressRenderBox, AddressRenderBox,
Confidential, Confidential,
BadgeEntity, BadgeEntity,
//OnTheFly
}, },
i18n: { i18n: {
messages: { messages: {
@ -119,7 +114,6 @@ export default {
props: ['thirdparty', 'options'], props: ['thirdparty', 'options'],
computed: { computed: {
isMultiline: function() { isMultiline: function() {
console.log('thirdparty', this.thirdparty)
if (this.options.isMultiline){ if (this.options.isMultiline){
return this.options.isMultiline return this.options.isMultiline
} else { } else {
@ -129,6 +123,15 @@ export default {
hasParent() { hasParent() {
return !(this.thirdparty.parent === null || this.thirdparty.parent === undefined); return !(this.thirdparty.parent === null || this.thirdparty.parent === undefined);
}, },
getProfession() {
let profession = []
if (this.thirdparty.category) {
profession = this.thirdparty.category.map((category) => category.text);
}
return profession
}
/* TODO need backend normalizer to serve children without circular reference /* TODO need backend normalizer to serve children without circular reference
hasChildren() { hasChildren() {
//console.log(this.thirdparty.activeChildren.length > 0) //console.log(this.thirdparty.activeChildren.length > 0)
@ -148,6 +151,15 @@ export default {
font-variant: all-small-caps; font-variant: all-small-caps;
} }
} }
.list-item {
&::after {
content: "|";
}
&:last-child::after {
content: ""
}
}
</style> </style>

View File

@ -11,7 +11,10 @@ declare(strict_types=1);
namespace Chill\ThirdPartyBundle\Serializer\Normalizer; namespace Chill\ThirdPartyBundle\Serializer\Normalizer;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender; use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
@ -23,9 +26,14 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
private ThirdPartyRender $thirdPartyRender; private ThirdPartyRender $thirdPartyRender;
public function __construct(ThirdPartyRender $thirdPartyRender) private TranslatableStringHelperInterface $translatableStringHelper;
{
public function __construct(
ThirdPartyRender $thirdPartyRender,
TranslatableStringHelperInterface $translatableStringHelper
) {
$this->thirdPartyRender = $thirdPartyRender; $this->thirdPartyRender = $thirdPartyRender;
$this->translatableStringHelper = $translatableStringHelper;
} }
/** /**
@ -39,13 +47,26 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
'text' => $this->thirdPartyRender->renderString($thirdParty, []), 'text' => $this->thirdPartyRender->renderString($thirdParty, []),
'id' => $thirdParty->getId(), 'id' => $thirdParty->getId(),
'kind' => $thirdParty->getKind(), 'kind' => $thirdParty->getKind(),
'category' => array_map(function ($el) {
if ($el instanceof ThirdPartyCategory) {
return [
'text' => $this->translatableStringHelper->localize($el->getName()),
'type' => 'thirdparty_category',
];
} else {
return [
'text' => $el,
'type' => 'thirdparty_kind',
];
}
}, $thirdParty->getTypesAndCategories()),
'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context),
'address' => $this->normalizer->normalize($thirdParty->getAddress(), $format, ['address_rendering' => 'short']), 'address' => $this->normalizer->normalize($thirdParty->getAddress(), $format, ['address_rendering' => 'short']),
'phonenumber' => $thirdParty->getTelephone(), 'phonenumber' => $thirdParty->getTelephone(),
'email' => $thirdParty->getEmail(), 'email' => $thirdParty->getEmail(),
'isChild' => $thirdParty->isChild(), 'isChild' => $thirdParty->isChild(),
'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context), 'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context),
'civility' => $this->normalizer->normalize($thirdParty->getCivility(), $format, $context), 'civility' => $this->normalizer->normalize($thirdParty->getCivility(), $format, $context),
'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context),
'contactDataAnonymous' => $thirdParty->isContactDataAnonymous(), 'contactDataAnonymous' => $thirdParty->isContactDataAnonymous(),
]; ];
} }