mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fixes
This commit is contained in:
parent
fe89704672
commit
c12f633829
@ -17,6 +17,7 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
|||||||
/**
|
/**
|
||||||
* @ORM\Table(name="chill_main_civility")
|
* @ORM\Table(name="chill_main_civility")
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
|
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={"chill_main_civility": Civility::class})
|
||||||
*/
|
*/
|
||||||
class Civility
|
class Civility
|
||||||
{
|
{
|
||||||
|
@ -77,14 +77,11 @@ export default {
|
|||||||
return this.$refs.castPerson.$data.person;
|
return this.$refs.castPerson.$data.person;
|
||||||
case 'thirdparty':
|
case 'thirdparty':
|
||||||
let data = this.$refs.castThirdparty.$data.thirdparty;
|
let data = this.$refs.castThirdparty.$data.thirdparty;
|
||||||
data.name = data.text;
|
|
||||||
/*
|
|
||||||
if (data.address !== undefined && data.address !== null) {
|
if (data.address !== undefined && data.address !== null) {
|
||||||
data.address = { id: data.address.address_id }
|
data.address = { id: data.address.address_id }
|
||||||
} else {
|
} else {
|
||||||
data.address = null;
|
data.address = null;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
default:
|
default:
|
||||||
|
@ -219,31 +219,17 @@ export default {
|
|||||||
|
|
||||||
case 'thirdparty':
|
case 'thirdparty':
|
||||||
data = this.$refs.castThirdparty.$data.thirdparty;
|
data = this.$refs.castThirdparty.$data.thirdparty;
|
||||||
|
/* never executed ? */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (typeof this.type === 'undefined') { // action=create or addContact
|
if (typeof this.type === 'undefined') { // action=create or addContact
|
||||||
|
console.log('will rewrite data');
|
||||||
if (this.action === 'addContact') {
|
if (this.action === 'addContact') {
|
||||||
type = 'thirdparty'
|
type = 'thirdparty'
|
||||||
data = this.$refs.castThirdparty.$data.thirdparty;
|
data = this.$refs.castThirdparty.$data.thirdparty;
|
||||||
data = {
|
console.log('data original', data);
|
||||||
"type": "thirdparty",
|
data.parent = {type: "thirdparty", id: this.parent.id};
|
||||||
"kind": "child",
|
|
||||||
"name": data.text,
|
|
||||||
"isChild": true,
|
|
||||||
"parent": {"type": "thirdparty", "id": this.parent.id},
|
|
||||||
"comment": data.comment,
|
|
||||||
"telephone": data.phonenumber,
|
|
||||||
"email": data.email,
|
|
||||||
"address": this.parent.address
|
|
||||||
}
|
|
||||||
if ("civility" in data) {
|
|
||||||
Object.assign(data, {"civility": {"id": data.civility}} )
|
|
||||||
}
|
|
||||||
if ("profession" in data) {
|
|
||||||
Object.assign(data, {"profession": {"id": data.profession}} )
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
type = this.$refs.castNew.radioType;
|
type = this.$refs.castNew.radioType;
|
||||||
data = this.$refs.castNew.castDataByType();
|
data = this.$refs.castNew.castDataByType();
|
||||||
@ -253,7 +239,8 @@ export default {
|
|||||||
throw 'error with object type';
|
throw 'error with object type';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('type', type, 'data', data)
|
console.log('type', type);
|
||||||
|
console.log('data', data);
|
||||||
// pass datas to parent
|
// pass datas to parent
|
||||||
this.$emit('saveFormOnTheFly', { type: type, data: data });
|
this.$emit('saveFormOnTheFly', { type: type, data: data });
|
||||||
},
|
},
|
||||||
|
@ -707,7 +707,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
/**
|
/**
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setCivility(Civility $civility): ThirdParty
|
public function setCivility(?Civility $civility): ThirdParty
|
||||||
{
|
{
|
||||||
$this->civility = $civility;
|
$this->civility = $civility;
|
||||||
|
|
||||||
@ -812,7 +812,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
/**
|
/**
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setProfession(ThirdPartyProfession $profession): ThirdParty
|
public function setProfession(?ThirdPartyProfession $profession): ThirdParty
|
||||||
{
|
{
|
||||||
$this->profession = $profession;
|
$this->profession = $profession;
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
|||||||
/**
|
/**
|
||||||
* @ORM\Table(name="chill_3party.party_profession")
|
* @ORM\Table(name="chill_3party.party_profession")
|
||||||
* @ORM\Entity(repositoryClass=ThirdPartyProfessionRepository::class)
|
* @ORM\Entity(repositoryClass=ThirdPartyProfessionRepository::class)
|
||||||
|
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||||
|
* "third_party_profession": ThirdPartyProfession::class})
|
||||||
*/
|
*/
|
||||||
class ThirdPartyProfession
|
class ThirdPartyProfession
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<span class="chill-entity badge-thirdparty">{{ parent.text }}</span>
|
<span class="chill-entity badge-thirdparty">{{ parent.text }}</span>
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div class="form-check">
|
||||||
<input class="form-check-input mt-0" type="radio" v-model="kind" value="company" id="tpartyKindInstitution">
|
<input class="form-check-input mt-0" type="radio" v-model="kind" value="company" id="tpartyKindInstitution">
|
||||||
<label for="tpartyKindInstitution" class="required">
|
<label for="tpartyKindInstitution" class="required">
|
||||||
@ -64,27 +64,27 @@
|
|||||||
}"></third-party-render-box>
|
}"></third-party-render-box>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="parent">
|
<div v-if="thirdparty.kind === 'child' || thirdparty.kind === 'contact'">
|
||||||
<div id="child-info">
|
<div id="child-info">
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<select class="form-select form-select-lg" id="profession"
|
<select class="form-select form-select-lg" id="profession"
|
||||||
v-model="thirdparty.civility">
|
v-model="thirdparty.civility">
|
||||||
<option selected disabled :value="undefined" >{{ $t('thirdparty.civility') }}</option>
|
<option selected disabled :value="null" >{{ $t('thirdparty.civility') }}</option>
|
||||||
<option v-for="civility in civilities" :key="civility.id" :value="civility.id">{{ civility.name.fr }}</option>
|
<option v-for="civility in civilities" :key="civility.id" :value="{type: 'chill_main_civility', id: civility.id }">{{ civility.name.fr }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<select class="form-select form-select-lg" id="civility"
|
<select class="form-select form-select-lg" id="civility"
|
||||||
v-model="thirdparty.profession">
|
v-model="thirdparty.profession">
|
||||||
<option selected disabled :value="undefined">{{ $t('thirdparty.profession') }}</option>
|
<option selected disabled :value="null">{{ $t('thirdparty.profession') }}</option>
|
||||||
<option v-for="profession in professions" :key="profession.id" :value="profession.id">{{ profession.name.fr }}</option>
|
<option v-for="profession in professions" :key="profession.id" :value="{type: 'third_party_profession', id: profession.id }">{{ profession.name.fr }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-floating mb-3">
|
<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>
|
<label for="name">{{ $t('thirdparty.name') }}</label>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="query">
|
<div v-if="query">
|
||||||
@ -160,6 +160,8 @@ export default {
|
|||||||
kind: 'company',
|
kind: 'company',
|
||||||
name: '',
|
name: '',
|
||||||
telephone: '',
|
telephone: '',
|
||||||
|
civility: null,
|
||||||
|
profession: null,
|
||||||
},
|
},
|
||||||
professions: [],
|
professions: [],
|
||||||
civilities: [],
|
civilities: [],
|
||||||
@ -214,7 +216,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadData(){
|
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 = thirdparty;
|
||||||
this.thirdparty.kind = thirdparty.kind;
|
this.thirdparty.kind = thirdparty.kind;
|
||||||
console.log('get thirdparty', thirdparty);
|
console.log('get thirdparty', thirdparty);
|
||||||
@ -229,9 +231,10 @@ export default {
|
|||||||
},
|
},
|
||||||
loadCivilities() {
|
loadCivilities() {
|
||||||
const url = `/api/1.0/main/civility.json`;
|
const url = `/api/1.0/main/civility.json`;
|
||||||
makeFetch('GET', url)
|
return makeFetch('GET', url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$data.civilities = response.results;
|
this.$data.civilities = response.results;
|
||||||
|
return Promise.resolve();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -240,9 +243,10 @@ export default {
|
|||||||
},
|
},
|
||||||
loadProfessions() {
|
loadProfessions() {
|
||||||
const url = `/api/1.0/thirdparty/professions.json`;
|
const url = `/api/1.0/thirdparty/professions.json`;
|
||||||
makeFetch('GET', url)
|
return makeFetch('GET', url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$data.professions = response.results;
|
this.$data.professions = response.results;
|
||||||
|
return Promise.resolve();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@ -259,21 +263,23 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
addQuery(query) {
|
addQuery(query) {
|
||||||
this.thirdparty.text = query;
|
this.thirdparty.name = query;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log('mounted', this.action);
|
let dependencies = [];
|
||||||
|
dependencies.push(this.loadProfessions());
|
||||||
|
dependencies.push(this.loadCivilities());
|
||||||
if (this.action !== 'create') {
|
if (this.action !== 'create') {
|
||||||
if (this.id) {
|
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') {
|
if (this.action === 'addContact') {
|
||||||
this.$data.thirdparty.kind = 'child'
|
this.$data.thirdparty.kind = 'child'
|
||||||
// this.$data.thirdparty.parent = this.parent.id
|
// this.$data.thirdparty.parent = this.parent.id
|
||||||
this.$data.thirdparty.address = null
|
this.$data.thirdparty.address = null
|
||||||
this.loadProfessions();
|
|
||||||
this.loadCivilities();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.thirdparty.kind = 'company';
|
this.thirdparty.kind = 'company';
|
||||||
|
@ -4,7 +4,7 @@ const thirdpartyMessages = {
|
|||||||
name: "Dénomination",
|
name: "Dénomination",
|
||||||
email: "Courriel",
|
email: "Courriel",
|
||||||
phonenumber: "Téléphone",
|
phonenumber: "Téléphone",
|
||||||
comment: "Comment",
|
comment: "Commentaire",
|
||||||
profession: "Qualité",
|
profession: "Qualité",
|
||||||
civility: "Civilité"
|
civility: "Civilité"
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user