mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix Location POST endpoint and saveNewLocation event method in vue_activity Location
This commit is contained in:
parent
e6845326d7
commit
d0dd99db9a
@ -71,20 +71,19 @@ export default {
|
||||
},
|
||||
saveNewLocation(selected) {
|
||||
console.log('saveNewLocation', selected);
|
||||
console.log('post location')
|
||||
let body = {
|
||||
type: 'location',
|
||||
name: selected.name,
|
||||
address: { id: selected.addressId },
|
||||
locationtype: { id: selected.type },
|
||||
locationType: { id: selected.type, type: 'location-type' },
|
||||
email: selected.email,
|
||||
phonenumber1: selected.phonenumber1,
|
||||
phonenumber2: selected.phonenumber2,
|
||||
}
|
||||
//this.$store.dispatch('addLocationSelected', body);
|
||||
postLocation(body).then(location => new Promise(resolve => {
|
||||
console.log('postLocation', location);
|
||||
this.locations.push(location);
|
||||
this.location.set(location);
|
||||
this.$store.dispatch('updateLocation', location);
|
||||
resolve();
|
||||
}));
|
||||
}
|
||||
|
@ -55,7 +55,10 @@
|
||||
|
||||
</template>
|
||||
<template v-slot:footer>
|
||||
<button class="btn btn-save" @click.prevent="$emit('saveNewLocation', selected)">Enregistrer</button>
|
||||
<button class="btn btn-save"
|
||||
@click.prevent="$emit('saveNewLocation', selected); modal.showModal = false;">
|
||||
Enregistrer
|
||||
</button>
|
||||
</template>
|
||||
|
||||
</modal>
|
||||
|
@ -31,26 +31,26 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=LocationType::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?LocationType $locationType = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity=Address::class, cascade={"persist", "remove"})
|
||||
* @ORM\ManyToOne(targetEntity=Address::class, cascade={"persist"})
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?Address $address = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?string $name = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64, nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
* @Assert\Regex(pattern="/^([\+{1}])([0-9\s*]{4,20})$/")
|
||||
* @PhonenumberConstraint(type="any")
|
||||
*/
|
||||
@ -58,7 +58,7 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=64, nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
* @Assert\Regex(pattern="/^([\+{1}])([0-9\s*]{4,20})$/")
|
||||
* @PhonenumberConstraint(type="any")
|
||||
*/
|
||||
@ -66,7 +66,7 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?string $email = null;
|
||||
|
||||
|
@ -574,11 +574,13 @@ paths:
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
locationtype:
|
||||
locationType:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
type:
|
||||
type: string
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
@ -591,6 +593,26 @@ paths:
|
||||
400:
|
||||
description: "transition cannot be applyed"
|
||||
|
||||
/1.0/main/location/{id}.json:
|
||||
get:
|
||||
tags:
|
||||
- location
|
||||
summary: Return the given location
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
description: The location id
|
||||
schema:
|
||||
type: integer
|
||||
format: integer
|
||||
minimum: 1
|
||||
responses:
|
||||
200:
|
||||
description: "ok"
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
|
||||
/1.0/main/location-type.json:
|
||||
get:
|
||||
tags:
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20211015084653 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Location entity: change Address to ManyToOne';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX uniq_90e4736af5b7af75');
|
||||
$this->addSql('CREATE INDEX IDX_90E4736AF5B7AF75 ON chill_main_location (address_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX IDX_90E4736AF5B7AF75');
|
||||
$this->addSql('CREATE UNIQUE INDEX uniq_90e4736af5b7af75 ON chill_main_location (address_id)');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user