diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue index c9e98c55b..d597f5205 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue @@ -3,10 +3,11 @@ {{ person.firstName }} {{ person.lastName }} - + ({{ altNameLabel }}) - {{ $tc('renderbox.years_old', this.getAge) }} + {{ $tc('renderbox.years_old', person.age) }} + (‡) @@ -16,23 +17,6 @@ export default { name: "PersonText", props: ['person', 'isCut'], computed: { - getAge: function() { - if(this.person.birthdate && !this.person.deathdate){ - const birthday = new Date(this.person.birthdate.datetime) - const now = new Date() - return (now.getFullYear() - birthday.getFullYear()) - } else if(this.person.birthdate && this.person.deathdate){ - const birthday = new Date(this.person.birthdate.datetime) - const deathdate = new Date(this.person.deathdate.datetime) - return (deathdate.getFullYear() - birthday.getFullYear()) - } else if(!this.person.birthdate && this.person.deathdate.datetime) { - // todo: change this - return "Age unknown" - } else { - // todo: change this - return "Age unknown" - } - }, altNameLabel: function() { for(let i = 0; i < this.person.altNames.length; i++){ return this.person.altNames[i].label diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index d6f9ced53..6ea3dda08 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -182,6 +182,7 @@ class PersonJsonNormalizer implements 'lastName' => $person->getLastName(), 'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $context), 'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $context), + 'age' => $this->normalizer->normalize($person->getAge(), $format, $context), 'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context), 'phonenumber' => $person->getPhonenumber(), 'mobilenumber' => $person->getMobilenumber(),