Merge branch 'person_renderbox_thirdparty_onthefly' into post-prototypage

This commit is contained in:
2021-09-02 12:25:33 +02:00
15 changed files with 343 additions and 105 deletions

View File

@@ -6,7 +6,7 @@
addEntity: false,
addLink: false,
addAltNames: true,
addAge : false,
addAge : true,
hLevel : 3,
}"
:person="participation.person">

View File

@@ -16,7 +16,7 @@
addLink: false,
addId: false,
addEntity: true,
addInfo: true,
addInfo: false,
hLevel: 3,
isMultiline: true
}"

View File

@@ -17,7 +17,7 @@
<third-party-render-box
v-if="resource.resource.type === 'thirdparty'"
:thirdparty="resource.resource"
:options="{ addLink : false, addId : false, addEntity: true, addInfo: true, hLevel: 3 }"
:options="{ addLink : false, addId : false, addEntity: true, addInfo: false, hLevel: 3 }"
>
<template v-slot:record-actions>
<ul class="record_actions">

View File

@@ -27,15 +27,18 @@
</div>
<p v-if="this.options.addInfo == true" class="moreinfo">
<p v-if="options.addInfo == true" class="moreinfo">
<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.deathdate" datetime="{{ person.deathdate }}" title="{{ person.deathdate }}">
<time v-else-if="person.birthdate && person.deathdate" datetime="{{ person.deathdate }}" title="{{ person.deathdate }}">
{{ birthdate }} - {{ deathdate }}
</time>
<!-- <span class="age">{{ person.age }}</span> -->
<time v-else-if="person.deathdate" datetime="{{ person.deathdate }}" title="{{ person.deathdate }}">
{{ $t('renderbox.deathdate') + ' ' + deathdate }}
</time>
<span v-if="options.addAge && person.birthdate" class="age">{{ getAge }} {{ $t('renderbox.years_old')}}</span>
</p>
</div>
</div>
@@ -118,7 +121,7 @@ export default {
},
props: ['person', 'options', 'render'],
computed: {
getGender: function() {
getGenderTranslation: function() {
return this.person.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
},
isMultiline: function() {
@@ -132,13 +135,24 @@ export default {
return this.person.gender == 'woman' ? 'fa-venus' : this.person.gender == 'man' ? 'fa-mars' : 'fa-neuter';
},
birthdate: function(){
var date = new Date(this.person.birthdate.datetime);
return dateToISO(date);
if(this.person.birthdate !== null){
const date = new Date(this.person.birthdate.datetime);
return dateToISO(date)
} else {
return "";
}
},
deathdate: function(){
if (typeof this.person.deathdate !== 'undefined') {
var date = new Date(this.person.deathdate.datetime);
return dateToISO(date);
// TODO FIX edition conflict: if null or undefined ?
// if (typeof this.person.deathdate !== 'undefined') {
// var date = new Date(this.person.deathdate.datetime);
// return dateToISO(date);
//}
if(this.person.deathdate !== null){
const date = new Date(this.person.deathdate.datetime);
return date.toLocaleDateString("fr-FR");
} else {
return "";
}
},
altNameLabel: function(){
@@ -151,8 +165,25 @@ export default {
return this.person.altNames[i].key
}
},
getUrl() {
return `/fr/person/${this.person.id}/general`;
getUrl: function() {
return `/fr/person/${this.person.id}/general`;
},
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"
}
}
}
}
@@ -188,6 +219,12 @@ div.flex-table {
}
}
}
.age{
margin-left: 0.5em;
&:before { content: '('; }
&:after { content: ')'; }
}
</style>

View File

@@ -7,6 +7,7 @@
addInfo: true,
addEntity: false,
addAltNames: true,
addAge: true,
addId: true,
addLink: false,
hLevel: 3,