mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Create thirdparty on the fly with institution / contact
This commit is contained in:
parent
08764aa0b4
commit
d7ae279101
@ -74,7 +74,12 @@ export default {
|
|||||||
case 'thirdparty':
|
case 'thirdparty':
|
||||||
let data = this.$refs.castThirdparty.$data.thirdparty;
|
let data = this.$refs.castThirdparty.$data.thirdparty;
|
||||||
data.name = data.text;
|
data.name = data.text;
|
||||||
|
if (data.address !== undefined) {
|
||||||
data.address = { id: data.address.address_id }
|
data.address = { id: data.address.address_id }
|
||||||
|
} else {
|
||||||
|
data.address = null;
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
default:
|
default:
|
||||||
throw Error('Invalid type of entity')
|
throw Error('Invalid type of entity')
|
||||||
|
@ -65,6 +65,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="kind", type="string", length="20", options={"default":""})
|
* @ORM\Column(name="kind", type="string", length="20", options={"default":""})
|
||||||
|
* @Groups({"write"})
|
||||||
*/
|
*/
|
||||||
private ?string $kind = "";
|
private ?string $kind = "";
|
||||||
|
|
||||||
@ -133,14 +134,14 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private ?ThirdParty $parent;
|
private ?ThirdParty $parent = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Civility
|
* @var Civility
|
||||||
* @ORM\ManyToOne(targetEntity=Civility::class)
|
* @ORM\ManyToOne(targetEntity=Civility::class)
|
||||||
* ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true)
|
* ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true)
|
||||||
*/
|
*/
|
||||||
private ?Civility $civility;
|
private ?Civility $civility = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [fr] Qualité
|
* [fr] Qualité
|
||||||
@ -148,7 +149,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
|
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
|
||||||
* ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
|
* ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
|
||||||
*/
|
*/
|
||||||
private ?ThirdPartyProfession $profession;
|
private ?ThirdPartyProfession $profession = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string|null
|
* @var string|null
|
||||||
@ -463,10 +464,10 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Address $address
|
* @param Address|null $address
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setAddress(Address $address)
|
public function setAddress(?Address $address = null)
|
||||||
{
|
{
|
||||||
$this->address = $address;
|
$this->address = $address;
|
||||||
|
|
||||||
|
@ -20,6 +20,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else-if="action === 'edit' || action === 'create'">
|
<div v-else-if="action === 'edit' || action === 'create'">
|
||||||
|
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<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">
|
||||||
|
{{ $t('tparty.company')}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input mt-0" type="radio" v-model="kind" value="contact" id="tpartyKindContact">
|
||||||
|
<label for="tpartyKindContact" class="required">
|
||||||
|
{{ $t('tparty.contact')}}
|
||||||
|
</label>
|
||||||
|
</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.text" v-bind:placeholder="$t('thirdparty.name')" />
|
||||||
<label for="name">{{ $t('thirdparty.name') }}</label>
|
<label for="name">{{ $t('thirdparty.name') }}</label>
|
||||||
@ -59,6 +73,17 @@ import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue';
|
|||||||
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress';
|
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress';
|
||||||
import { getThirdparty } from '../../_api/OnTheFly';
|
import { getThirdparty } from '../../_api/OnTheFly';
|
||||||
|
|
||||||
|
const i18n = {
|
||||||
|
messages: {
|
||||||
|
fr: {
|
||||||
|
tparty: {
|
||||||
|
contact: "Contact",
|
||||||
|
company: "Institution"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "OnTheFlyThirdParty",
|
name: "OnTheFlyThirdParty",
|
||||||
props: ['id', 'type', 'action'],
|
props: ['id', 'type', 'action'],
|
||||||
@ -66,11 +91,12 @@ export default {
|
|||||||
ThirdPartyRenderBox,
|
ThirdPartyRenderBox,
|
||||||
AddAddress
|
AddAddress
|
||||||
},
|
},
|
||||||
|
i18n,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
//context: {}, <--
|
//context: {}, <--
|
||||||
thirdparty: {
|
thirdparty: {
|
||||||
type: 'thirdparty'
|
type: 'thirdparty',
|
||||||
},
|
},
|
||||||
addAddress: {
|
addAddress: {
|
||||||
options: {
|
options: {
|
||||||
@ -88,6 +114,19 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
kind: {
|
||||||
|
get() {
|
||||||
|
// note: there are also default to 'institution' set in the "mounted" method
|
||||||
|
if (this.$data.thirdparty.kind !== undefined) {
|
||||||
|
return this.$data.thirdparty.kind;
|
||||||
|
} else {
|
||||||
|
return 'company';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
set(v) {
|
||||||
|
this.$data.thirdparty.kind = v;
|
||||||
|
}
|
||||||
|
},
|
||||||
context() {
|
context() {
|
||||||
let context = {
|
let context = {
|
||||||
target: {
|
target: {
|
||||||
@ -133,6 +172,8 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
if (this.action !== 'create') {
|
if (this.action !== 'create') {
|
||||||
this.loadData();
|
this.loadData();
|
||||||
|
} else {
|
||||||
|
this.thirdparty.kind = 'company';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user