Merge branch 'onTheFly' of gitlab.com:Chill-Projet/chill-bundles into onTheFly

This commit is contained in:
Julie Lenaerts 2021-09-29 14:40:23 +02:00
commit 440e21a83b
13 changed files with 90 additions and 38 deletions

View File

@ -4,9 +4,9 @@ const fetchScopes = () => {
return response.json();
}
}).then(data => {
console.log(data);
//console.log(data);
return new Promise((resolve, reject) => {
console.log(data);
//console.log(data);
resolve(data.results);
});
});

View File

@ -134,6 +134,8 @@ export default {
},
methods: {
openModal() {
console.log('## OPEN ON THE FLY MODAL');
console.log('## type:', this.type, ', action:', this.action);
this.modal.showModal = true;
this.$nextTick(function() {
//this.$refs.search.focus();
@ -173,11 +175,11 @@ export default {
this.modal.showModal = false;
},
goToLocation(id, type){
if(type == 'person'){
window.location = `../../person/${id}/general`
} else if(type == 'thirdparty') {
window.location = `../../thirdparty/thirdparty/${id}/show`
goToLocation(id, type) {
if (type == 'person') {
window.location = `../../person/${id}/general`;
} else if (type == 'thirdparty') {
window.location = `../../thirdparty/thirdparty/${id}/show`;
}
}
}

View File

@ -3,7 +3,7 @@
<li class="nav-item">
<a class="nav-link" :class="{ active: isActive('person') }">
<label for="person">
<input type="radio" name="person" v-model="radioType" value="person">
<input type="radio" name="person" id="person" v-model="radioType" value="person">
{{ $t('onthefly.create.person') }}
</label>
</a>
@ -11,7 +11,7 @@
<li class="nav-item">
<a class="nav-link" :class="{ active: isActive('thirdparty') }">
<label for="thirdparty">
<input type="radio" name="thirdparty" v-model="radioType" value="thirdparty">
<input type="radio" name="thirdparty" id="thirdparty" v-model="radioType" value="thirdparty">
{{ $t('onthefly.create.thirdparty') }}
</label>
</a>
@ -56,6 +56,7 @@ export default {
radioType: {
set(type) {
this.type = type;
console.log('## type:', type, ', action:', this.action);
},
get() {
return this.type;

View File

@ -153,9 +153,9 @@ export default {
created() {
this.initAddressContext();
console.log('ac.locationStatus', this.accompanyingCourse.locationStatus);
console.log('ac.location (temporary location)', this.accompanyingCourse.location);
console.log('ac.personLocation', this.accompanyingCourse.personLocation);
//console.log('ac.locationStatus', this.accompanyingCourse.locationStatus);
//console.log('ac.location (temporary location)', this.accompanyingCourse.location);
//console.log('ac.personLocation', this.accompanyingCourse.personLocation);
}
}
</script>

View File

@ -1,4 +1,5 @@
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n';
import { thirdpartyMessages } from 'ChillThirdPartyAssets/vuejs/_js/i18n';
import { addressMessages } from 'ChillMainAssets/vuejs/Address/i18n';
const appMessages = {
@ -137,7 +138,7 @@ const appMessages = {
}
};
Object.assign(appMessages.fr, personMessages.fr, addressMessages.fr);
Object.assign(appMessages.fr, personMessages.fr, thirdpartyMessages.fr, addressMessages.fr);
export {
appMessages

View File

@ -48,7 +48,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
return state.accompanyingCourse.location !== null;
},
isScopeValid(state) {
console.log('is scope valid', state.accompanyingCourse.scopes.length > 0);
//console.log('is scope valid', state.accompanyingCourse.scopes.length > 0);
return state.accompanyingCourse.scopes.length > 0;
},
validationKeys(state, getters) {

View File

@ -229,7 +229,7 @@ export default {
return item.result.type + item.result.id;
},
addPriorSuggestion() {
console.log('echo', this.hasPriorSuggestion);
//console.log('addPriorSuggestion', this.hasPriorSuggestion);
if (this.hasPriorSuggestion) {
console.log('addPriorSuggestion',);
this.suggested.unshift(this.priorSuggestion);

View File

@ -27,7 +27,7 @@
</div>
<p v-if="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 && !person.deathdate" datetime="{{ person.birthdate }}" title="{{ birthdate }}">
{{ $t(getGenderTranslation) + ' ' + $d(birthdate, 'text') }}
@ -142,7 +142,7 @@ export default {
props: ['person', 'options', 'render', 'returnPath'],
computed: {
getGenderTranslation: function() {
return this.person.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
return this.person.gender === 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
},
isMultiline: function() {
if(this.options.isMultiline){
@ -152,7 +152,7 @@ export default {
}
},
getGenderIcon: function() {
return this.person.gender == 'woman' ? 'fa-venus' : this.person.gender == 'man' ? 'fa-mars' : 'fa-neuter';
return this.person.gender === 'woman' ? 'fa-venus' : this.person.gender === 'man' ? 'fa-mars' : 'fa-neuter';
},
birthdate: function(){
if(this.person.birthdate !== null){

View File

@ -40,7 +40,7 @@
<option value="man">{{ $t('person.gender.man') }}</option>
<option value="neuter">{{ $t('person.gender.neuter') }}</option>
</select>
<label for="gender">{{ $t('person.gender.title') }}</label>
<label>{{ $t('person.gender.title') }}</label>
</div>
<div class="input-group mb-3">
@ -159,9 +159,17 @@ export default {
getPerson(this.id)
.then(person => new Promise((resolve, reject) => {
this.person = person;
//console.log('get person', this.person);
console.log('get person', this.person);
resolve();
}));
},
postData() {
postPerson(this.person)
.then(person => new Promise((resolve, reject) => {
this.person = person;
console.log('post person', this.person);
resolve();
}))
}
}
}

View File

@ -8,17 +8,17 @@
<div :class="'denomination h' + options.hLevel">
<a v-if="this.options.addLink == true" href="#">
<a v-if="this.options.addLink === true" href="#">
<span class="name">{{ thirdparty.text }}</span>
</a>
<span class="name">{{ thirdparty.text }}</span>
<span v-if="options.addId == true" class="id-number" :title="'n° ' + thirdparty.id">{{ thirdparty.id }}</span>
<span v-if="options.addEntity == true && thirdparty.type == 'thirdparty'" class="badge rounded-pill bg-secondary">{{ $t('renderbox.type.thirdparty') }}</span>
<span v-if="options.addEntity == true && thirdparty.type === 'thirdparty'" class="badge rounded-pill bg-secondary">{{ $t('renderbox.type.thirdparty') }}</span>
</div>
<p v-if="this.options.addInfo == true" class="moreinfo">
<p v-if="this.options.addInfo === true" class="moreinfo">
<i v-if="thirdparty.birthdate" :class="'fa fa-fw ' + getGenderIcon" title="{{ getGender }}"></i>
<time v-if="thirdparty.birthdate" datetime="{{ thirdparty.birthdate.datetime }}" title="{{ birthdate }}">
{{ $t(getGender) + ' ' + $d(birthdate, 'short') }}
@ -26,7 +26,7 @@
<time v-else-if="thirdparty.deathdate" datetime="{{ thirdparty.deathdate.datetime }}" title="{{ thirdparty.deathdate }}">
{{ birthdate }} - {{ deathdate }}
</time>
<span v-if="options.addAge == true" class="age">{{ thirdparty.age }}</span>
<span v-if="options.addAge === true" class="age">{{ thirdparty.age }}</span>
</p>
</div>
</div>
@ -80,10 +80,10 @@ export default {
}
},
getGender: function() {
return this.thirdparty.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
return this.thirdparty.gender === 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
},
getGenderIcon: function() {
return this.thirdparty.gender == 'woman' ? 'fa-venus' : this.thirdparty.gender == 'man' ? 'fa-mars' : 'fa-neuter';
return this.thirdparty.gender === 'woman' ? 'fa-venus' : this.thirdparty.gender === 'man' ? 'fa-mars' : 'fa-neuter';
},
birthdate: function(){
var date = new Date(this.thirdparty.birthdate.datetime);

View File

@ -1,5 +1,5 @@
<template>
<div v-if="action === 'show'">
<div v-if="action === 'show'">
<div class="flex-table">
<third-party-render-box
:thirdparty="thirdparty"
@ -19,15 +19,10 @@
</div>
</div>
<div v-else-if="action === 'edit' || action === 'create'">
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="firstname" v-model="thirdparty.firstName" v-bind:placeholder="$t('thirdparty.firstname')" />
<label for="firstname">{{ $t('thirdparty.firstname') }}</label>
</div>
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="lastname" v-model="thirdparty.lastName" v-bind:placeholder="$t('thirdparty.lastname')" />
<label for="lastname">{{ $t('thirdparty.lastname') }}</label>
<input class="form-control form-control-lg" id="name" v-model="thirdparty.name" v-bind:placeholder="$t('thirdparty.name')" />
<label for="name">{{ $t('thirdparty.name') }}</label>
</div>
<div class="input-group mb-3">
@ -48,11 +43,18 @@
aria-describedby="phonenumber" />
</div>
<add-address
:options="this.addAddress.options"
:context="this.addAddress.context"
:address-changed-callback="submitAddress">
</add-address>
</div>
</template>
<script>
import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue';
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress';
import { getThirdparty, postThirdparty } from '../../_api/OnTheFly';
export default {
@ -60,31 +62,56 @@ export default {
props: ['id', 'type', 'action'],
components: {
ThirdPartyRenderBox,
AddAddress
},
data: function() {
return {
thirdparty: {
type: 'thirdparty'
},
addAddress: {
context: {
},
options: {
//button: {
// text: {
// create: 'courselocation.add_temporary_address',
// edit: 'courselocation.edit_temporary_address'
// }
//},
//title: {
// create: 'courselocation.add_temporary_address',
// edit: 'courselocation.edit_temporary_address'
//},
openPanesInModal: true,
hideAddress: true
}
}
}
},
methods: {
loadThirdparty(){
loadData(){
getThirdparty(this.id).then(thirdparty => new Promise((resolve, reject) => {
this.thirdparty = thirdparty;
console.log('get thirdparty', thirdparty);
resolve();
}));
},
postData() {
postThirdparty(this.thirdparty).then(thirdparty => new Promise((resolve, reject) => {
this.thirdparty = thirdparty;
console.log('post thirdparty', thirdparty);
resolve();
}))
},
submitAddress(payload) {
console.log('submitAddress', payload);
}
},
mounted() {
if (this.action !== 'create'){
this.loadThirdparty();
if (this.action !== 'create') {
this.loadData();
}
},
}

View File

@ -0,0 +1,11 @@
const thirdpartyMessages = {
fr: {
thirdparty: {
name: "Dénomination",
email: "Courriel",
phonenumber: "Téléphone",
}
}
};
export { thirdpartyMessages };

View File

@ -56,6 +56,8 @@ class ThirdPartyVoter extends AbstractChillVoter implements ProvideRoleHierarchy
*/
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
{
return true;
$user = $token->getUser();
if (!$user instanceof User) {