mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
improve layout of third parties in AddPerson
This commit is contained in:
parent
c54edd8407
commit
08764aa0b4
@ -23,6 +23,7 @@
|
|||||||
namespace Chill\MainBundle\Entity;
|
namespace Chill\MainBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Table(name="chill_main_civility")
|
* @ORM\Table(name="chill_main_civility")
|
||||||
@ -34,16 +35,19 @@ class Civility
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\GeneratedValue
|
* @ORM\GeneratedValue
|
||||||
* @ORM\Column(type="integer")
|
* @ORM\Column(type="integer")
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="json")
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private array $name = [];
|
private array $name = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="json")
|
||||||
|
* @Serializer\Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private array $abbreviation = [];
|
private array $abbreviation = [];
|
||||||
|
|
||||||
|
@ -1,42 +1,102 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container tpartycontainer">
|
||||||
|
<div class="tparty-identification">
|
||||||
|
<span class="name">
|
||||||
|
{{ item.result.text }}
|
||||||
|
</span>
|
||||||
|
<span class="location">
|
||||||
|
<template v-if="hasAddress">
|
||||||
|
{{ getAddress.text }} -
|
||||||
|
{{ getAddress.postcode.name }}
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="tpartyparent" v-if="hasParent">
|
||||||
|
<span class="name">
|
||||||
|
{{ item.result.parent.text }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="right_actions">
|
||||||
|
|
||||||
<span class="name">
|
<span class="badge bg-chill-red" v-if="item.result.kind == 'child'">
|
||||||
{{ item.result.text }}
|
{{ $t('thirdparty.contact')}}
|
||||||
</span>
|
|
||||||
<span class="location">
|
|
||||||
<template v-if="item.result.address != null">
|
|
||||||
{{ item.result.address.text }} -
|
|
||||||
{{ item.result.address.postcode.name }}
|
|
||||||
</template>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="right_actions">
|
|
||||||
|
|
||||||
<span class="badge rounded-pill bg-info" v-if="item.result.isChild">
|
|
||||||
{{ $t('item.thirdparty_contact')}}
|
|
||||||
</span>
|
</span>
|
||||||
<span class="badge rounded-pill bg-secondary" :title="item.key">
|
<span class="badge bg-info" v-else-if="item.result.kind == 'company'">
|
||||||
|
{{ $t('thirdparty.company')}}
|
||||||
|
</span>
|
||||||
|
<span class="badge bg-secondary" v-else="item.result.kind == 'contact'">
|
||||||
|
{{ $t('thirdparty.contact')}}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="badge rounded-pill bg-secondary" :title="item.key">
|
||||||
{{ $t('item.type_thirdparty') }}
|
{{ $t('item.type_thirdparty') }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<on-the-fly
|
<on-the-fly
|
||||||
type="thirdparty"
|
type="thirdparty"
|
||||||
v-bind:id="item.result.id"
|
v-bind:id="item.result.id"
|
||||||
action="show">
|
action="show">
|
||||||
</on-the-fly>
|
</on-the-fly>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
|
import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
|
||||||
|
|
||||||
|
const i18n = {
|
||||||
|
messages: {
|
||||||
|
fr: {
|
||||||
|
thirdparty: {
|
||||||
|
contact: "Contact",
|
||||||
|
company: "Institution",
|
||||||
|
child: "Personne de contact"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'SuggestionThirdParty',
|
name: 'SuggestionThirdParty',
|
||||||
components: {
|
components: {
|
||||||
OnTheFly
|
OnTheFly
|
||||||
},
|
},
|
||||||
props: ['item']
|
props: ['item'],
|
||||||
|
i18n,
|
||||||
|
computed: {
|
||||||
|
hasAddress() {
|
||||||
|
if (this.$props.item.result.address !== null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (this.$props.item.result.parent !== null) {
|
||||||
|
this.$props.item.result.parent.address !== null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hasParent() {
|
||||||
|
return this.$props.item.result.parent !== null;
|
||||||
|
},
|
||||||
|
getAddress() {
|
||||||
|
if (this.$props.item.result.address !== null) {
|
||||||
|
return this.$props.item.result.address;
|
||||||
|
}
|
||||||
|
if (this.$props.item.result.parent.address !== null) {
|
||||||
|
return this.$props.item.result.parent.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.tpartycontainer {
|
||||||
|
.tpartyparent {
|
||||||
|
.name {
|
||||||
|
font-weight: bold;
|
||||||
|
font-variant: all-small-caps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#}
|
#}
|
||||||
|
|
||||||
{% macro raw(thirdparty, options) %}
|
{% macro raw(thirdparty, options) %}
|
||||||
<span class="name">{{ thirdparty.name }}</span>
|
<span class="name">{{ thirdparty|chill_entity_render_string }}</span>
|
||||||
{% endmacro raw %}
|
{% endmacro raw %}
|
||||||
|
|
||||||
{% macro label(thirdparty, options) %}
|
{% macro label(thirdparty, options) %}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace Chill\ThirdPartyBundle\Serializer\Normalizer;
|
namespace Chill\ThirdPartyBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
|
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
@ -12,19 +13,27 @@ class ThirdPartyNormalizer implements NormalizerInterface, NormalizerAwareInterf
|
|||||||
{
|
{
|
||||||
use NormalizerAwareTrait;
|
use NormalizerAwareTrait;
|
||||||
|
|
||||||
|
private ThirdPartyRender $thirdPartyRender;
|
||||||
|
|
||||||
|
public function __construct(ThirdPartyRender $thirdPartyRender)
|
||||||
|
{
|
||||||
|
$this->thirdPartyRender = $thirdPartyRender;
|
||||||
|
}
|
||||||
|
|
||||||
public function normalize($thirdParty, string $format = null, array $context = [])
|
public function normalize($thirdParty, string $format = null, array $context = [])
|
||||||
{
|
{
|
||||||
/** @var $thirdParty ThirdParty */
|
/** @var $thirdParty ThirdParty */
|
||||||
$data['type'] = 'thirdparty';
|
$data['type'] = 'thirdparty';
|
||||||
// TODO should be replaced by a "render entity"
|
$data['text'] = $this->thirdPartyRender->renderString($thirdParty, []);
|
||||||
$data['text'] = $thirdParty->getName();
|
|
||||||
$data['id'] = $thirdParty->getId();
|
$data['id'] = $thirdParty->getId();
|
||||||
|
$data['kind'] = $thirdParty->getKind();
|
||||||
$data['address'] = $this->normalizer->normalize($thirdParty->getAddress(), $format,
|
$data['address'] = $this->normalizer->normalize($thirdParty->getAddress(), $format,
|
||||||
[ 'address_rendering' => 'short' ]);
|
[ 'address_rendering' => 'short' ]);
|
||||||
$data['phonenumber'] = $thirdParty->getTelephone();
|
$data['phonenumber'] = $thirdParty->getTelephone();
|
||||||
$data['email'] = $thirdParty->getEmail();
|
$data['email'] = $thirdParty->getEmail();
|
||||||
$data['isChild'] = $thirdParty->isChild();
|
$data['isChild'] = $thirdParty->isChild();
|
||||||
$data['parent'] = $this->normalizer->normalize($thirdParty->getParent(), $format, $context);
|
$data['parent'] = $this->normalizer->normalize($thirdParty->getParent(), $format, $context);
|
||||||
|
$data['civility'] = $this->normalizer->normalize($thirdParty->getCivility(), $format, $context);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
namespace Chill\ThirdPartyBundle\Templating\Entity;
|
namespace Chill\ThirdPartyBundle\Templating\Entity;
|
||||||
|
|
||||||
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
use Symfony\Component\Templating\EngineInterface;
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
|
||||||
@ -32,10 +33,15 @@ class ThirdPartyRender extends AbstractChillEntityRender
|
|||||||
{
|
{
|
||||||
|
|
||||||
protected EngineInterface $engine;
|
protected EngineInterface $engine;
|
||||||
|
protected TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
public function __construct(EngineInterface $engine)
|
public function __construct(
|
||||||
|
EngineInterface $engine,
|
||||||
|
TranslatableStringHelper $translatableStringHelper
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->engine = $engine;
|
$this->engine = $engine;
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +82,18 @@ class ThirdPartyRender extends AbstractChillEntityRender
|
|||||||
*/
|
*/
|
||||||
public function renderString($entity, array $options): string
|
public function renderString($entity, array $options): string
|
||||||
{
|
{
|
||||||
return $entity->getName();
|
if ($entity->getCivility() !== NULL) {
|
||||||
|
$civility = $this->translatableStringHelper
|
||||||
|
->localize($entity->getCivility()->getAbbreviation()).' ';
|
||||||
|
} else {
|
||||||
|
$civility = '';
|
||||||
|
}
|
||||||
|
if (!empty($entity->getAcronym())) {
|
||||||
|
$acronym = ' ('.$entity->getAcronym().')';
|
||||||
|
} else {
|
||||||
|
$acronym = '';
|
||||||
|
}
|
||||||
|
return $civility.$entity->getName().$acronym;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports($entity, array $options): bool
|
public function supports($entity, array $options): bool
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender:
|
Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender:
|
||||||
arguments:
|
autowire: true
|
||||||
$engine: '@Symfony\Component\Templating\EngineInterface'
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- 'chill.render_entity'
|
- 'chill.render_entity'
|
||||||
|
@ -39,6 +39,7 @@ thirdparty.a_company_explanation: >-
|
|||||||
thirdparty.a_contact_explanation: >-
|
thirdparty.a_contact_explanation: >-
|
||||||
Les personnes physiques ne disposent pas d'acronyme, de service, ou de contacts sous-jacents.
|
Les personnes physiques ne disposent pas d'acronyme, de service, ou de contacts sous-jacents.
|
||||||
thirdparty.Which kind of third party ?: Quel type de tiers souhaitez-vous créer ?
|
thirdparty.Which kind of third party ?: Quel type de tiers souhaitez-vous créer ?
|
||||||
|
thirdparty.Contact data are confidential: Données de contact confidentielles
|
||||||
|
|
||||||
New third party: Ajouter un nouveau tiers
|
New third party: Ajouter un nouveau tiers
|
||||||
Show third party %name%: Tiers "%name%"
|
Show third party %name%: Tiers "%name%"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user