diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ec146ea7..c2bf5a5ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to * date versioning for test releases ## Unreleased +* AddPersons: remove ul-li html tags from AddPersons (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/419) * [person] Order social issues by the field "ordering" (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/388) @@ -28,6 +29,7 @@ and this project adheres to * [person]: AddPersons: add suggestion of name when creating new person or thirdparty (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/422) * [main] Address: fix small bug: when modifying an address without street (isNoAddress), also check errors if street is an empty string as back-end change null value to empty string for street (and streetNumber) * [main] Address: stronger client-side validation of addresses (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/449) +* [thirdparty] Add a contact to a thirdparty from within onTheFly (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/345) * [person] accompanying course: filter suggested entities by open participations (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/415) [activity] can click through the cross icon for removing person in concerned group (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/476) [activity] correct associated persons by considering only open participations (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/476) @@ -86,7 +88,19 @@ and this project adheres to * [AddAddress] disable multiselect search, and rely only on most pertinent Cities and Street computed backend * [fast_actions] improve fast-actions buttons override mechanism, fix https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/413 * [homepage widget] add vue homepage_widget with asynchone loading, give a global view resume of the user concerned actions, notifications, etc. +* [thirdparty] Add a contact to a thirdparty from within onTheFly (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/345) + +## Test releases +======= +* [homepage widget] add vue homepage_widget with asynchone loading, give a global view resume of the user concerned actions, notifications, etc. +>>>>>>> issue422_and_others_on_AddPersons + +======= +* [homepage widget] add vue homepage_widget with asynchone loading, give a global view resume of the user concerned actions, notifications, etc. +* [thirdparty] Add a contact to a thirdparty from within onTheFly (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/345) + +>>>>>>> b0d50d315c8e00959a967badac9cf5057ab2b4bc ### test release 2021-01-31 * [person] accompanying course: optimisation: do not fetch some resources for the banner (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/409) diff --git a/src/Bundle/ChillMainBundle/Controller/CivilityApiController.php b/src/Bundle/ChillMainBundle/Controller/CivilityApiController.php new file mode 100644 index 000000000..3db55ae0e --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/CivilityApiController.php @@ -0,0 +1,24 @@ +addOrderBy('e.order', 'ASC'); + } +} diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index fa561b7e7..6e3d6d85e 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\DependencyInjection; use Chill\MainBundle\Controller\AddressApiController; +use Chill\MainBundle\Controller\CivilityApiController; use Chill\MainBundle\Controller\LocationController; use Chill\MainBundle\Controller\LocationTypeController; use Chill\MainBundle\Controller\UserController; @@ -559,6 +560,21 @@ class ChillMainExtension extends Extension implements ], ], ], + [ + 'class' => \Chill\MainBundle\Entity\Civility::class, + 'name' => 'civility', + 'base_path' => '/api/1.0/main/civility', + 'base_role' => 'ROLE_USER', + 'controller' => CivilityApiController::class, + 'actions' => [ + '_index' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + ], + ], + ], ], ]); } diff --git a/src/Bundle/ChillMainBundle/Entity/Civility.php b/src/Bundle/ChillMainBundle/Entity/Civility.php index c91016a63..e5d15a751 100644 --- a/src/Bundle/ChillMainBundle/Entity/Civility.php +++ b/src/Bundle/ChillMainBundle/Entity/Civility.php @@ -17,6 +17,7 @@ use Symfony\Component\Serializer\Annotation as Serializer; /** * @ORM\Table(name="chill_main_civility") * @ORM\Entity + * @Serializer\DiscriminatorMap(typeProperty="type", mapping={"chill_main_civility": Civility::class}) */ class Civility { @@ -29,6 +30,7 @@ class Civility /** * @ORM\Column(type="boolean") + * @Serializer\Groups({"read"}) */ private bool $active = true; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue index dcc12bc5f..22b0181e5 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue @@ -77,14 +77,11 @@ export default { return this.$refs.castPerson.$data.person; case 'thirdparty': let data = this.$refs.castThirdparty.$data.thirdparty; - data.name = data.text; - /* if (data.address !== undefined && data.address !== null) { data.address = { id: data.address.address_id } } else { data.address = null; } - */ return data; default: diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index b03b98b23..e84496d31 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -18,7 +18,8 @@ @close="modal.showModal = false"> @@ -44,13 +45,22 @@ ref="castThirdparty">
-

{{ $t('onthefly.resource_comment_title') }}

-
- {{ parent.comment }} -
+

{{ $t('onthefly.resource_comment_title') }}

+
+ {{ parent.comment }} +
+ + diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php index 1981d6daf..124f5b7f3 100644 --- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php +++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php @@ -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, + ], + ], + ], + ], ], ]); } diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 593d1c14c..25ef1be65 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -161,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; @@ -200,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; @@ -235,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; @@ -246,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; @@ -706,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; @@ -811,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; diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php index 1963b34a7..896888a73 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdPartyProfession.php @@ -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({"docgen:read"}) + * @Serializer\Groups({"docgen:read", "read", "write"}) */ private ?int $id = null; /** * @ORM\Column(type="json") - * @Serializer\Groups({"docgen:read"}) + * @Serializer\Groups({"docgen:read", "read"}) */ private array $name = []; diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 4b012e3f0..40efa9bfb 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -19,9 +19,15 @@ > -
- -
+
+
+
+ + {{ $t('child_of') }} + {{ parent.text }} +
+
+
+ +
+
+
+ +
+
+ +
+
+
+
- +
@@ -98,6 +124,15 @@ aria-describedby="phonenumber" />
+
+
+ + +
+
@@ -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%; + } +} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js index 37d09320d..76f01e3f4 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js @@ -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: ", } }; diff --git a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php index 6ffcc2dea..d518a9f2b 100644 --- a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php +++ b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php @@ -36,6 +36,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf { return [ 'type' => 'thirdparty', + 'name' => $thirdParty->getName(), 'text' => $this->thirdPartyRender->renderString($thirdParty, []), 'id' => $thirdParty->getId(), 'kind' => $thirdParty->getKind(), @@ -45,6 +46,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(), ]; } diff --git a/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml b/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml index 52db7589c..eb303a4f0 100644 --- a/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml @@ -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"