Adaptations for display of age and deathdate (different scenarios not all finished)

This commit is contained in:
Julie Lenaerts 2021-08-26 14:53:04 +02:00
parent 88362bd284
commit 5194cad354
2 changed files with 20 additions and 4 deletions

View File

@ -77,6 +77,7 @@ const messages = {
man: "Né le",
woman: "Née le"
},
deathdate: "Date de décès",
years_old: "ans",
no_data: "Aucune information renseignée",
type: {

View File

@ -28,12 +28,16 @@
</div>
<p v-if="options.addInfo == true" class="moreinfo">
{{ person.deathdate }}
<i :class="'fa fa-fw ' + getGenderIcon" title="{{ getGender }}"></i>
<time v-if="person.birthdate" datetime="{{ person.birthdate }}" title="{{ birthdate }}">
{{ $t(getGender) + ' ' + $d(birthdate, 'text') }}
<time v-if="person.birthdate && !person.deathdate" datetime="{{ person.birthdate }}" title="{{ birthdate }}">
{{ $t(getGenderTranslation) + ' ' + $d(birthdate, 'text') }}
</time>
<time v-else-if="person.birthdate && person.deathdate" datetime="{{ person.deathdate }}" title="{{ person.deathdate }}">
{{ birthdate }} - {{ deathdate }}
</time>
<time v-else-if="person.deathdate" datetime="{{ person.deathdate }}" title="{{ person.deathdate }}">
{{ birthdate }} - {{ deathdate }}
{{ $t('renderbox.deathdate') + ' ' + deathdate }}
</time>
<span v-if="options.addAge" class="age">{{ getAge }} {{ $t('renderbox.years_old')}}</span>
</p>
@ -100,7 +104,7 @@ export default {
},
props: ['person', 'options'],
computed: {
getGender: function() {
getGenderTranslation: function() {
return this.person.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
},
isMultiline: function() {
@ -138,6 +142,17 @@ export default {
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"
}
}
}
}