mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
fix merge conflicts
This commit is contained in:
@@ -140,4 +140,29 @@ final class ThirdPartyController extends CRUDController
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $action
|
||||
* @param ThirdParty $entity
|
||||
*/
|
||||
protected function onPostFetchEntity($action, Request $request, $entity): ?Response
|
||||
{
|
||||
if ('view' === $action && $entity->getParent() instanceof ThirdParty) {
|
||||
$params = [
|
||||
'id' => $entity->getParent()->getId(),
|
||||
];
|
||||
|
||||
if ($request->query->has('returnPath')) {
|
||||
$params['returnPath'] = $request->query->get('returnPath');
|
||||
}
|
||||
|
||||
if ($request->query->has('returnLabel')) {
|
||||
$params['returnLabel'] = $request->query->get('returnLabel');
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('chill_crud_3party_3party_view', $params);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -126,6 +126,21 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\ThirdPartyBundle\Entity\ThirdPartyProfession::class,
|
||||
// 'controller' => \Chill\MainBundle\Controller\ProfessionApiController::class,
|
||||
'name' => 'profession',
|
||||
'base_path' => '/api/1.0/thirdparty/professions',
|
||||
'base_role' => 'ROLE_USER',
|
||||
'actions' => [
|
||||
'_index' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
@@ -45,6 +45,41 @@ use function spl_object_hash;
|
||||
* all users with the right 'CHILL_3PARTY_3PARTY_SEE', 'CHILL_3PARTY_3 to see, select and edit parties for this
|
||||
* center.
|
||||
*
|
||||
* A ThirdParty may have:
|
||||
*
|
||||
* * 0, one or more categories;
|
||||
* * 0, one or more type
|
||||
* * 1 kind.
|
||||
*
|
||||
* ## Kind
|
||||
*
|
||||
* The kind indicate if a thirdparty is a:
|
||||
*
|
||||
* * company ("personne morale");
|
||||
* * a contact ("personne morale")
|
||||
* * a child inside a company ("contact" in French). Only companies may have childs
|
||||
*
|
||||
* **take care** the french translation may lead to misinterpretation, as the string "contact" is the translation of
|
||||
* kind "child".
|
||||
*
|
||||
* ## Categories and types
|
||||
*
|
||||
* ThirdParty may have zero, one or more categories and/or type.
|
||||
*
|
||||
* Categories are managed in the database. The Chill administrator may create or desactivate categories.
|
||||
*
|
||||
* Types are also a way to categorize the thirdparties, but this is done **into the code**, through
|
||||
*
|
||||
* @see{Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeProviderInterface}. The type is stored into the
|
||||
* database by a Php array, mapped by a jsonb into the database. This has one advantage: it is easily searchable.
|
||||
*
|
||||
* As the list of type is hardcoded into database, it is more easily searchable. (for chill 2.0, the
|
||||
* @see{Chill\ThirdPartyBundle\Form\Type\PickThirdPartyDynamicType} does not support it yet, but
|
||||
* the legacy @see{Chill\ThirdPartyBundle\Form\Type\PickThirdPartyType} does.
|
||||
*
|
||||
* The difference between categories and types is transparent for user: they choose the same fields into the UI, without
|
||||
* noticing a difference.
|
||||
*
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_3party.third_party")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
@@ -126,13 +161,14 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @var Civility
|
||||
* @ORM\ManyToOne(targetEntity=Civility::class)
|
||||
* ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true)
|
||||
* @Groups({"docgen:read", "read", "docgen:read:3party:parent"})
|
||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?Civility $civility = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="comment", type="text", nullable=true)
|
||||
* @Groups({"read", "write"})
|
||||
*/
|
||||
private ?string $comment = null;
|
||||
|
||||
@@ -165,7 +201,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||
* @Groups({"read", "docgen:read", "docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
@@ -200,7 +236,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
* @Groups({"read", "docgen:read"})
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
* @Context(normalizationContext={"groups": "docgen:read:3party:parent"}, groups={"docgen:read"})
|
||||
*/
|
||||
private ?ThirdParty $parent = null;
|
||||
@@ -211,7 +247,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @var ThirdPartyProfession
|
||||
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
|
||||
* ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
|
||||
* @Groups({"docgen:read", "docgen:read:3party:parent"})
|
||||
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
|
||||
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
|
||||
*/
|
||||
private ?ThirdPartyProfession $profession = null;
|
||||
@@ -671,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;
|
||||
|
||||
@@ -776,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;
|
||||
|
||||
|
@@ -18,11 +18,14 @@ 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
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $active = true;
|
||||
|
||||
@@ -30,13 +33,13 @@ class ThirdPartyProfession
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"docgen:read", "read", "write"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"docgen:read", "read"})
|
||||
*/
|
||||
private array $name = [];
|
||||
|
||||
|
@@ -11,11 +11,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\ThirdPartyBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Entity\Civility;
|
||||
use Chill\MainBundle\Form\Type\ChillCollectionType;
|
||||
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||
use Chill\MainBundle\Form\Type\PickAddressType;
|
||||
use Chill\MainBundle\Form\Type\PickCenterType;
|
||||
use Chill\MainBundle\Form\Type\PickCivilityType;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
@@ -101,16 +101,8 @@ class ThirdPartyType extends AbstractType
|
||||
// Contact Person ThirdParty (child)
|
||||
if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) {
|
||||
$builder
|
||||
->add('civility', EntityType::class, [
|
||||
->add('civility', PickCivilityType::class, [
|
||||
'label' => 'thirdparty.Civility',
|
||||
'class' => Civility::class,
|
||||
'choice_label' => function (Civility $civility): string {
|
||||
return $this->translatableStringHelper->localize($civility->getName());
|
||||
},
|
||||
'query_builder' => static function (EntityRepository $er): QueryBuilder {
|
||||
return $er->createQueryBuilder('c')
|
||||
->where('c.active = true');
|
||||
},
|
||||
'placeholder' => 'thirdparty.choose civility',
|
||||
'required' => false,
|
||||
])
|
||||
|
@@ -19,9 +19,15 @@
|
||||
></third-party-render-box>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="action === 'edit' || action === 'create'">
|
||||
|
||||
<div class="form-floating mb-3" v-if="thirdparty.kind !== 'child'">
|
||||
<div v-else-if="action === 'edit' || action === 'create' || action === 'addContact'">
|
||||
<div v-if="parent">
|
||||
<div class="parent-info">
|
||||
<i class="fa fa-li fa-hand-o-right"></i>
|
||||
<b class="me-2">{{ $t('child_of') }}</b>
|
||||
<span class="chill-entity badge-thirdparty">{{ parent.text }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
@@ -55,10 +61,30 @@
|
||||
addCenter: false,
|
||||
addNoData: true,
|
||||
isMultiline: false
|
||||
}"></third-party-render-box>
|
||||
}"></third-party-render-box>
|
||||
</div>
|
||||
|
||||
<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="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="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">
|
||||
@@ -98,6 +124,15 @@
|
||||
aria-describedby="phonenumber" />
|
||||
</div>
|
||||
|
||||
<div v-if="parent">
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="comment"><i class="fa fa-fw fa-pencil"></i></span>
|
||||
<textarea class="form-control form-control-lg"
|
||||
v-bind:placeholder="$t('thirdparty.comment')"
|
||||
v-model="thirdparty.comment"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -106,10 +141,11 @@ import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue';
|
||||
import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress';
|
||||
import { getThirdparty } from '../../_api/OnTheFly';
|
||||
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||
|
||||
export default {
|
||||
name: "OnTheFlyThirdParty",
|
||||
props: ['id', 'type', 'action', 'query'],
|
||||
props: ['id', 'type', 'action', 'query', 'parent'],
|
||||
components: {
|
||||
ThirdPartyRenderBox,
|
||||
AddAddress,
|
||||
@@ -124,8 +160,11 @@ export default {
|
||||
kind: 'company',
|
||||
name: '',
|
||||
telephone: '',
|
||||
|
||||
civility: null,
|
||||
profession: null,
|
||||
},
|
||||
professions: [],
|
||||
civilities: [],
|
||||
addAddress: {
|
||||
options: {
|
||||
openPanesInModal: true,
|
||||
@@ -177,10 +216,10 @@ 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);
|
||||
console.log('get thirdparty', thirdparty);
|
||||
if (this.action !== 'show') {
|
||||
if (thirdparty.address !== null) {
|
||||
// bof! we force getInitialAddress because addressId not available when mounted
|
||||
@@ -190,6 +229,30 @@ export default {
|
||||
resolve();
|
||||
}));
|
||||
},
|
||||
loadCivilities() {
|
||||
const url = `/api/1.0/main/civility.json`;
|
||||
return makeFetch('GET', url)
|
||||
.then(response => {
|
||||
this.$data.civilities = response.results;
|
||||
return Promise.resolve();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
this.$toast.open({message: error.body})
|
||||
})
|
||||
},
|
||||
loadProfessions() {
|
||||
const url = `/api/1.0/thirdparty/professions.json`;
|
||||
return makeFetch('GET', url)
|
||||
.then(response => {
|
||||
this.$data.professions = response.results;
|
||||
return Promise.resolve();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
this.$toast.open({message: error.body})
|
||||
})
|
||||
},
|
||||
submitAddress(payload) {
|
||||
console.log('submitAddress', payload);
|
||||
if (typeof payload.addressId !== 'undefined') { // <--
|
||||
@@ -200,13 +263,24 @@ 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') {
|
||||
this.loadData();
|
||||
if (this.id) {
|
||||
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
|
||||
}
|
||||
} else {
|
||||
this.thirdparty.kind = 'company';
|
||||
}
|
||||
@@ -229,5 +303,16 @@ dl {
|
||||
margin-left: 1em;
|
||||
}
|
||||
}
|
||||
.parent-info {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
#child-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
div {
|
||||
width: 49%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@@ -4,7 +4,12 @@ const thirdpartyMessages = {
|
||||
name: "Dénomination",
|
||||
email: "Courriel",
|
||||
phonenumber: "Téléphone",
|
||||
}
|
||||
comment: "Commentaire",
|
||||
profession: "Qualité",
|
||||
civility: "Civilité"
|
||||
},
|
||||
child_of: "Contact de: ",
|
||||
children: "Personnes de contact: ",
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -23,15 +23,15 @@
|
||||
{{ form_row(form.contactDataAnonymous) }}
|
||||
{% endif %}
|
||||
|
||||
{% if form.address is defined %}
|
||||
{{ form_row(form.address) }}
|
||||
{% endif %}
|
||||
|
||||
{% if form.activeChildren is defined %}
|
||||
<h2>{{ 'Contacts'|trans }}</h2>
|
||||
{{ form_widget(form.activeChildren) }}
|
||||
{% endif %}
|
||||
|
||||
{% if form.address is defined %}
|
||||
{{ form_row(form.address) }}
|
||||
{% endif %}
|
||||
|
||||
{{ form_row(form.comment) }}
|
||||
|
||||
{% if form.centers is defined %}
|
||||
|
@@ -43,6 +43,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
|
||||
{
|
||||
return [
|
||||
'type' => 'thirdparty',
|
||||
'name' => $thirdParty->getName(),
|
||||
'text' => $this->thirdPartyRender->renderString($thirdParty, []),
|
||||
'id' => $thirdParty->getId(),
|
||||
'kind' => $thirdParty->getKind(),
|
||||
@@ -66,6 +67,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
|
||||
'isChild' => $thirdParty->isChild(),
|
||||
'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context),
|
||||
'civility' => $this->normalizer->normalize($thirdParty->getCivility(), $format, $context),
|
||||
'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context),
|
||||
'contactDataAnonymous' => $thirdParty->isContactDataAnonymous(),
|
||||
];
|
||||
}
|
||||
|
@@ -110,3 +110,14 @@ paths:
|
||||
description: "OK"
|
||||
422:
|
||||
description: "Object with validation errors"
|
||||
|
||||
/1.0/thirdparty/professions.json:
|
||||
get:
|
||||
tags:
|
||||
- thirdparty
|
||||
summary: Return all thirdparty professions
|
||||
responses:
|
||||
200:
|
||||
description: "ok"
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
|
Reference in New Issue
Block a user