From caaebd593bf7d663b3f58a0e85b6d75b7ab2c7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 17 Feb 2022 22:42:52 +0100 Subject: [PATCH] misc fixes for Thirdparty / addPerson * set default values for ThirdParty in ThirdParty.vue * set correct value for binding with phone (telephone instead of phonenumber) * add validation on ThirdParty/denomination: at least two characters, no Null value --- src/Bundle/ChillMainBundle/Entity/Address.php | 4 +- .../vuejs/OnTheFly/components/Create.vue | 2 +- .../ChillMainBundle/chill.api.specs.yaml | 66 ++++++++++--------- .../Entity/ThirdParty.php | 2 + .../vuejs/_components/OnTheFly/ThirdParty.vue | 7 +- 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 0e6cd549b..4ccafa8c2 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -139,12 +139,10 @@ class Address private $point; /** - * @var PostalCode - * * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode") * @Groups({"write"}) */ - private $postcode; + private ?PostalCode $postcode; /** * @var string|null 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 d242037b8..061d728a0 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/Create.vue @@ -78,7 +78,7 @@ export default { case 'thirdparty': let data = this.$refs.castThirdparty.$data.thirdparty; data.name = data.text; - if (data.address !== undefined) { + if (data.address !== null) { data.address = { id: data.address.address_id } } else { data.address = null; diff --git a/src/Bundle/ChillMainBundle/chill.api.specs.yaml b/src/Bundle/ChillMainBundle/chill.api.specs.yaml index 034dfe74b..b2d6cb7de 100644 --- a/src/Bundle/ChillMainBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillMainBundle/chill.api.specs.yaml @@ -165,13 +165,6 @@ paths: 200: description: "OK" /1.0/main/address.json: - get: - tags: - - address - summary: Return a list of all Chill addresses - responses: - 200: - description: "ok" post: tags: - address @@ -222,10 +215,44 @@ paths: description: "Unprocessable entity (validation errors)" 400: description: "transition cannot be applyed" + /1.0/main/address/{id}.json: + get: + tags: + - address + summary: Return an address by id + parameters: + - name: id + in: path + required: true + description: The address id + schema: + type: integer + format: integer + minimum: 1 + responses: + 200: + description: "ok" + content: + application/json: + schema: + $ref: '#/components/schemas/Address' + 404: + description: "not found" + 401: + description: "Unauthorized" patch: tags: - address summary: patch an address + parameters: + - name: id + in: path + required: true + description: The address id + schema: + type: integer + format: integer + minimum: 1 requestBody: required: true content: @@ -277,31 +304,6 @@ paths: 400: description: "transition cannot be applyed" - /1.0/main/address/{id}.json: - get: - tags: - - address - summary: Return an address by id - parameters: - - name: id - in: path - required: true - description: The address id - schema: - type: integer - format: integer - minimum: 1 - responses: - 200: - description: "ok" - content: - application/json: - schema: - $ref: '#/components/schemas/Address' - 404: - description: "not found" - 401: - description: "Unauthorized" /1.0/main/address/{id}/duplicate.json: post: diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 95c930956..390427d74 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -179,6 +179,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * @var string * @ORM\Column(name="name", type="string", length=255) * @Assert\Length(min="2") + * @Assert\NotNull + * @Assert\NotBlank * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ private ?string $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 5dacee2c0..02515981b 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -92,7 +92,7 @@
@@ -120,6 +120,11 @@ export default { //context: {}, <-- thirdparty: { type: 'thirdparty', + address: null, + kind: 'company', + name: '', + telephone: '', + }, addAddress: { options: {