This commit is contained in:
2022-02-28 13:52:41 +01:00
parent fe89704672
commit c12f633829
7 changed files with 35 additions and 42 deletions

View File

@@ -707,7 +707,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* @return $this
*/
public function setCivility(Civility $civility): ThirdParty
public function setCivility(?Civility $civility): ThirdParty
{
$this->civility = $civility;
@@ -812,7 +812,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* @return $this
*/
public function setProfession(ThirdPartyProfession $profession): ThirdParty
public function setProfession(?ThirdPartyProfession $profession): ThirdParty
{
$this->profession = $profession;

View File

@@ -18,6 +18,8 @@ use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Table(name="chill_3party.party_profession")
* @ORM\Entity(repositoryClass=ThirdPartyProfessionRepository::class)
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "third_party_profession": ThirdPartyProfession::class})
*/
class ThirdPartyProfession
{

View File

@@ -27,7 +27,7 @@
<span class="chill-entity badge-thirdparty">{{ parent.text }}</span>
</div>
</div>
<div class="form-floating mb-3" v-else-if="thirdparty.kind !== 'child'">
<div class="form-floating mb-3" v-else-if="kind !== 'child'">
<div class="form-check">
<input class="form-check-input mt-0" type="radio" v-model="kind" value="company" id="tpartyKindInstitution">
<label for="tpartyKindInstitution" class="required">
@@ -64,27 +64,27 @@
}"></third-party-render-box>
</div>
<div v-if="parent">
<div v-if="thirdparty.kind === 'child' || thirdparty.kind === 'contact'">
<div id="child-info">
<div class="input-group mb-3">
<select class="form-select form-select-lg" id="profession"
v-model="thirdparty.civility">
<option selected disabled :value="undefined" >{{ $t('thirdparty.civility') }}</option>
<option v-for="civility in civilities" :key="civility.id" :value="civility.id">{{ civility.name.fr }}</option>
<option selected disabled :value="null" >{{ $t('thirdparty.civility') }}</option>
<option v-for="civility in civilities" :key="civility.id" :value="{type: 'chill_main_civility', id: civility.id }">{{ civility.name.fr }}</option>
</select>
</div>
<div class="input-group mb-3">
<select class="form-select form-select-lg" id="civility"
v-model="thirdparty.profession">
<option selected disabled :value="undefined">{{ $t('thirdparty.profession') }}</option>
<option v-for="profession in professions" :key="profession.id" :value="profession.id">{{ profession.name.fr }}</option>
<option selected disabled :value="null">{{ $t('thirdparty.profession') }}</option>
<option v-for="profession in professions" :key="profession.id" :value="{type: 'third_party_profession', id: profession.id }">{{ profession.name.fr }}</option>
</select>
</div>
</div>
</div>
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="name" v-model="thirdparty.text" v-bind:placeholder="$t('thirdparty.name')" />
<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 v-if="query">
@@ -160,6 +160,8 @@ export default {
kind: 'company',
name: '',
telephone: '',
civility: null,
profession: null,
},
professions: [],
civilities: [],
@@ -214,7 +216,7 @@ export default {
},
methods: {
loadData(){
getThirdparty(this.id).then(thirdparty => new Promise((resolve, reject) => {
return getThirdparty(this.id).then(thirdparty => new Promise((resolve, reject) => {
this.thirdparty = thirdparty;
this.thirdparty.kind = thirdparty.kind;
console.log('get thirdparty', thirdparty);
@@ -229,9 +231,10 @@ export default {
},
loadCivilities() {
const url = `/api/1.0/main/civility.json`;
makeFetch('GET', url)
return makeFetch('GET', url)
.then(response => {
this.$data.civilities = response.results;
return Promise.resolve();
})
.catch((error) => {
console.log(error)
@@ -240,9 +243,10 @@ export default {
},
loadProfessions() {
const url = `/api/1.0/thirdparty/professions.json`;
makeFetch('GET', url)
return makeFetch('GET', url)
.then(response => {
this.$data.professions = response.results;
return Promise.resolve();
})
.catch((error) => {
console.log(error)
@@ -259,21 +263,23 @@ export default {
}
},
addQuery(query) {
this.thirdparty.text = query;
}
this.thirdparty.name = query;
},
},
mounted() {
console.log('mounted', this.action);
mounted() {
let dependencies = [];
dependencies.push(this.loadProfessions());
dependencies.push(this.loadCivilities());
if (this.action !== 'create') {
if (this.id) {
this.loadData();
dependencies.push(this.loadData());
// here we can do something when all promises are resolve, with
// Promise.all(dependencies).then(() => { /* do something */ });
}
if (this.action === 'addContact') {
this.$data.thirdparty.kind = 'child'
// this.$data.thirdparty.parent = this.parent.id
this.$data.thirdparty.address = null
this.loadProfessions();
this.loadCivilities();
}
} else {
this.thirdparty.kind = 'company';

View File

@@ -4,7 +4,7 @@ const thirdpartyMessages = {
name: "Dénomination",
email: "Courriel",
phonenumber: "Téléphone",
comment: "Comment",
comment: "Commentaire",
profession: "Qualité",
civility: "Civilité"
},