mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'master' into notification_finitions
This commit is contained in:
@@ -24,6 +24,7 @@ class LocationTypeApiController extends ApiController
|
||||
$query->andWhere(
|
||||
$query->expr()->andX(
|
||||
$query->expr()->eq('e.availableForUsers', "'TRUE'"),
|
||||
$query->expr()->eq('e.editableByUsers', "'TRUE'"),
|
||||
$query->expr()->eq('e.active', "'TRUE'"),
|
||||
)
|
||||
);
|
||||
|
@@ -67,6 +67,12 @@ class LocationType
|
||||
*/
|
||||
private ?string $defaultFor = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private bool $editableByUsers = true;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -107,6 +113,11 @@ class LocationType
|
||||
return $this->defaultFor;
|
||||
}
|
||||
|
||||
public function getEditableByUsers(): ?bool
|
||||
{
|
||||
return $this->editableByUsers;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -152,6 +163,13 @@ class LocationType
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEditableByUsers(bool $editableByUsers): self
|
||||
{
|
||||
$this->editableByUsers = $editableByUsers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTitle(array $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
@@ -97,6 +97,11 @@ class User implements AdvancedUserInterface
|
||||
*/
|
||||
private ?Center $mainCenter = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Location::class)
|
||||
*/
|
||||
private ?Location $mainLocation = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Scope::class)
|
||||
*/
|
||||
@@ -228,6 +233,11 @@ class User implements AdvancedUserInterface
|
||||
return $this->mainCenter;
|
||||
}
|
||||
|
||||
public function getMainLocation(): ?Location
|
||||
{
|
||||
return $this->mainLocation;
|
||||
}
|
||||
|
||||
public function getMainScope(): ?Scope
|
||||
{
|
||||
return $this->mainScope;
|
||||
@@ -405,6 +415,13 @@ class User implements AdvancedUserInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMainLocation(?Location $mainLocation): User
|
||||
{
|
||||
$this->mainLocation = $mainLocation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMainScope(?Scope $mainScope): User
|
||||
{
|
||||
$this->mainScope = $mainScope;
|
||||
|
@@ -39,6 +39,17 @@ final class LocationTypeType extends AbstractType
|
||||
'expanded' => true,
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'editableByUsers',
|
||||
ChoiceType::class,
|
||||
[
|
||||
'choices' => [
|
||||
'Yes' => true,
|
||||
'No' => false,
|
||||
],
|
||||
'expanded' => true,
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'addressRequired',
|
||||
ChoiceType::class,
|
||||
|
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
@@ -75,6 +76,22 @@ class UserType extends AbstractType
|
||||
'choice_label' => function (UserJob $c) {
|
||||
return $this->translatableStringHelper->localize($c->getLabel());
|
||||
},
|
||||
])
|
||||
->add('mainLocation', EntityType::class, [
|
||||
'label' => 'Main location',
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a location',
|
||||
'class' => Location::class,
|
||||
'choice_label' => function (Location $l) {
|
||||
return $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName();
|
||||
},
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('l');
|
||||
$qb->orderBy('l.locationType');
|
||||
$qb->where('l.availableForUsers = TRUE');
|
||||
|
||||
return $qb;
|
||||
},
|
||||
]);
|
||||
|
||||
if ($options['is_creation']) {
|
||||
|
@@ -423,3 +423,8 @@ span.item-key {
|
||||
background-color: #0000000a;
|
||||
//text-decoration: dotted underline;
|
||||
}
|
||||
|
||||
// increase toast message z-index (above all modals)
|
||||
div.v-toast {
|
||||
z-index: 10000!important;
|
||||
}
|
@@ -85,7 +85,9 @@ const fetchScopes = () => {
|
||||
const ValidationException = (response) => {
|
||||
const error = {};
|
||||
error.name = 'ValidationException';
|
||||
error.violations = response.violations.map((violation) => `${violation.title}`);
|
||||
error.violations = response.violations.map((violation) => `${violation.title}: ${violation.propertyPath}`);
|
||||
error.titles = response.violations.map((violation) => violation.title);
|
||||
error.propertyPaths = response.violations.map((violation) => violation.propertyPath);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@@ -98,6 +98,8 @@
|
||||
v-bind:defaultz="this.defaultz"
|
||||
v-bind:entity="this.entity"
|
||||
v-bind:flag="this.flag"
|
||||
v-bind:errors="this.errors"
|
||||
v-bind:checkErrors="this.checkErrors"
|
||||
@getCities="getCities"
|
||||
@getReferenceAddresses="getReferenceAddresses">
|
||||
</edit-pane>
|
||||
@@ -123,6 +125,8 @@
|
||||
v-bind:defaultz="this.defaultz"
|
||||
v-bind:entity="this.entity"
|
||||
v-bind:flag="this.flag"
|
||||
v-bind:errors="this.errors"
|
||||
v-bind:checkErrors="this.checkErrors"
|
||||
v-bind:insideModal="false"
|
||||
@getCities="getCities"
|
||||
@getReferenceAddresses="getReferenceAddresses">
|
||||
@@ -256,8 +260,10 @@ export default {
|
||||
editPane: false,
|
||||
datePane: false,
|
||||
loading: false,
|
||||
success: false
|
||||
success: false,
|
||||
dirty: false
|
||||
},
|
||||
errors: [],
|
||||
defaultz: {
|
||||
button: {
|
||||
text: { create: 'add_an_address_title', edit: 'edit_address' },
|
||||
@@ -529,6 +535,23 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
checkErrors() {
|
||||
this.errors = [];
|
||||
if (this.flag.dirty) {
|
||||
if (this.entity.selected.country === null) {
|
||||
this.errors.push("Un pays doit être sélectionné.");
|
||||
}
|
||||
if (Object.keys(this.entity.selected.city).length === 0) {
|
||||
this.errors.push("Une ville doit être sélectionnée.");
|
||||
}
|
||||
if (!this.entity.selected.isNoAddress) {
|
||||
if (this.entity.selected.address.street === null || this.entity.selected.address.streetNumber === null) {
|
||||
this.errors.push("Une adresse doit être sélectionnée.");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Make form ready for new changes
|
||||
*/
|
||||
|
@@ -12,6 +12,7 @@
|
||||
@search-change="listenInputSearch"
|
||||
ref="addressSelector"
|
||||
@select="selectAddress"
|
||||
@remove="remove"
|
||||
name="field"
|
||||
track-by="id"
|
||||
label="value"
|
||||
@@ -56,7 +57,7 @@ import { searchReferenceAddresses, fetchReferenceAddresses } from '../../api.js'
|
||||
export default {
|
||||
name: 'AddressSelection',
|
||||
components: { VueMultiselect },
|
||||
props: ['entity', 'context', 'updateMapCenter'],
|
||||
props: ['entity', 'context', 'updateMapCenter', 'flag', 'checkErrors'],
|
||||
data() {
|
||||
return {
|
||||
value: this.context.edit ? this.entity.address.addressReference : null,
|
||||
@@ -109,6 +110,13 @@ export default {
|
||||
this.entity.selected.address.streetNumber = value.streetNumber;
|
||||
this.entity.selected.writeNew.address = false;
|
||||
this.updateMapCenter(value.point);
|
||||
this.flag.dirty = true;
|
||||
this.checkErrors();
|
||||
},
|
||||
remove() {
|
||||
this.flag.dirty = true;
|
||||
this.entity.selected.address = {};
|
||||
this.checkErrors();
|
||||
},
|
||||
listenInputSearch(query) {
|
||||
//console.log('listenInputSearch', query, this.isAddressSelectorOpen);
|
||||
@@ -149,6 +157,8 @@ export default {
|
||||
this.entity.selected.address.street = addr.street;
|
||||
this.entity.selected.address.streetNumber = addr.number;
|
||||
this.entity.selected.writeNew.address = true;
|
||||
this.flag.dirty = true;
|
||||
this.checkErrors();
|
||||
}
|
||||
},
|
||||
splitAddress(address) {
|
||||
|
@@ -7,6 +7,7 @@
|
||||
@search-change="listenInputSearch"
|
||||
ref="citySelector"
|
||||
@select="selectCity"
|
||||
@remove="remove"
|
||||
name="field"
|
||||
track-by="id"
|
||||
label="value"
|
||||
@@ -55,12 +56,12 @@ import { searchCities, fetchCities } from '../../api.js';
|
||||
export default {
|
||||
name: 'CitySelection',
|
||||
components: { VueMultiselect },
|
||||
props: ['entity', 'context', 'focusOnAddress', 'updateMapCenter'],
|
||||
props: ['entity', 'context', 'focusOnAddress', 'updateMapCenter', 'flag', 'checkErrors'],
|
||||
emits: ['getReferenceAddresses'],
|
||||
data() {
|
||||
return {
|
||||
value: this.context.edit ? this.entity.address.postcode : null,
|
||||
isLoading: false
|
||||
isLoading: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -123,6 +124,13 @@ export default {
|
||||
if (value.center) {
|
||||
this.updateMapCenter(value.center);
|
||||
}
|
||||
this.flag.dirty = true;
|
||||
this.checkErrors();
|
||||
},
|
||||
remove() {
|
||||
this.flag.dirty = true;
|
||||
this.entity.selected.city = {};
|
||||
this.checkErrors();
|
||||
},
|
||||
listenInputSearch(query) {
|
||||
if (query.length > 2) {
|
||||
|
@@ -12,7 +12,9 @@
|
||||
:select-label="$t('multiselect.select_label')"
|
||||
:deselect-label="$t('multiselect.deselect_label')"
|
||||
:selected-label="$t('multiselect.selected_label')"
|
||||
@select="selectCountry">
|
||||
@select="selectCountry"
|
||||
@remove="remove"
|
||||
>
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
</template>
|
||||
@@ -23,7 +25,7 @@ import VueMultiselect from 'vue-multiselect';
|
||||
export default {
|
||||
name: 'CountrySelection',
|
||||
components: { VueMultiselect },
|
||||
props: ['context', 'entity'],
|
||||
props: ['context', 'entity', 'flag', 'checkErrors'],
|
||||
emits: ['getCities'],
|
||||
data() {
|
||||
return {
|
||||
@@ -34,14 +36,13 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
sortedCountries() {
|
||||
//console.log('sorted countries');
|
||||
const countries = this.entity.loaded.countries;
|
||||
let sortedCountries = [];
|
||||
sortedCountries.push(...countries.filter(c => c.countryCode === 'FR'))
|
||||
sortedCountries.push(...countries.filter(c => c.countryCode === 'BE'))
|
||||
sortedCountries.push(...countries.filter(c => c.countryCode !== 'FR').filter(c => c.countryCode !== 'BE'))
|
||||
return sortedCountries;
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
@@ -50,6 +51,7 @@ export default {
|
||||
init() {
|
||||
if (this.value !== undefined) {
|
||||
this.selectCountry(this.value);
|
||||
this.flag.dirty = false;
|
||||
}
|
||||
},
|
||||
selectCountryByCode(countryCode) {
|
||||
@@ -62,7 +64,13 @@ export default {
|
||||
//console.log('select country', value);
|
||||
this.entity.selected.country = value;
|
||||
this.$emit('getCities', value);
|
||||
}
|
||||
this.checkErrors();
|
||||
},
|
||||
remove() {
|
||||
this.flag.dirty = true;
|
||||
this.entity.selected.country = null;
|
||||
this.checkErrors();
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
|
@@ -7,6 +7,12 @@
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
|
||||
<div v-if="errors.length" class="alert alert-warning" >
|
||||
<ul>
|
||||
<li v-for="(e, i) in errors" :key="i">{{ e }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h4 class="h3">{{ $t('select_an_address_title') }}</h4>
|
||||
<div class="row my-3">
|
||||
<div class="col-lg-6">
|
||||
@@ -25,6 +31,8 @@
|
||||
<country-selection
|
||||
v-bind:context="context"
|
||||
v-bind:entity="entity"
|
||||
v-bind:flag="flag"
|
||||
v-bind:checkErrors="checkErrors"
|
||||
@getCities="$emit('getCities', selected.country)">
|
||||
</country-selection>
|
||||
|
||||
@@ -33,13 +41,17 @@
|
||||
v-bind:context="context"
|
||||
v-bind:focusOnAddress="focusOnAddress"
|
||||
v-bind:updateMapCenter="updateMapCenter"
|
||||
v-bind:flag="flag"
|
||||
v-bind:checkErrors="checkErrors"
|
||||
@getReferenceAddresses="$emit('getReferenceAddresses', selected.city)">
|
||||
</city-selection>
|
||||
|
||||
<address-selection v-if="!isNoAddress"
|
||||
v-bind:entity="entity"
|
||||
v-bind:context="context"
|
||||
v-bind:updateMapCenter="updateMapCenter">
|
||||
v-bind:updateMapCenter="updateMapCenter"
|
||||
v-bind:flag="flag"
|
||||
v-bind:checkErrors="checkErrors">
|
||||
</address-selection>
|
||||
|
||||
</div>
|
||||
@@ -99,7 +111,9 @@ export default {
|
||||
'flag',
|
||||
'entity',
|
||||
'errorMsg',
|
||||
'insideModal'
|
||||
'insideModal',
|
||||
'errors',
|
||||
'checkErrors',
|
||||
],
|
||||
emits: ['getCities', 'getReferenceAddresses'],
|
||||
data() {
|
||||
@@ -128,7 +142,7 @@ export default {
|
||||
get() {
|
||||
return this.entity.selected.isNoAddress;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
focusOnAddress() {
|
||||
|
@@ -90,7 +90,7 @@ export default {
|
||||
OnTheFlyThirdparty,
|
||||
OnTheFlyCreate
|
||||
},
|
||||
props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'parent'],
|
||||
props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'parent', 'canCloseModal'],
|
||||
emits: ['saveFormOnTheFly'],
|
||||
data() {
|
||||
return {
|
||||
@@ -162,7 +162,20 @@ export default {
|
||||
return 'entity-' + this.type + ' badge-' + this.type;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
canCloseModal: {
|
||||
handler: function(val, oldVal) {
|
||||
if (val) {
|
||||
this.closeModal();
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
this.modal.showModal = false;
|
||||
},
|
||||
openModal() {
|
||||
//console.log('## OPEN ON THE FLY MODAL');
|
||||
//console.log('## type:', this.type, ', action:', this.action);
|
||||
@@ -200,8 +213,6 @@ export default {
|
||||
|
||||
// pass datas to parent
|
||||
this.$emit('saveFormOnTheFly', { type: type, data: data });
|
||||
|
||||
this.modal.showModal = false;
|
||||
},
|
||||
buildLocation(id, type) {
|
||||
if (type === 'person') {
|
||||
|
@@ -8,6 +8,7 @@
|
||||
<tr>
|
||||
<th>{{ 'Title'|trans }}</th>
|
||||
<th>{{ 'Available for users'|trans }}</th>
|
||||
<th>{{ 'Editable by users'|trans }}</th>
|
||||
<th>{{ 'Address required'|trans }}</th>
|
||||
<th>{{ 'Contact data'|trans }}</th>
|
||||
<th>{{ 'Active'|trans }}</th>
|
||||
@@ -25,6 +26,13 @@
|
||||
<i class="fa fa-square-o"></i>
|
||||
{%- endif -%}
|
||||
</td>
|
||||
<td style="text-align:center;">
|
||||
{%- if entity.editableByUsers -%}
|
||||
<i class="fa fa-check-square-o"></i>
|
||||
{%- else -%}
|
||||
<i class="fa fa-square-o"></i>
|
||||
{%- endif -%}
|
||||
</td>
|
||||
<td>{{ entity.addressRequired|trans }}</td>
|
||||
<td>{{ entity.contactData|trans }}</td>
|
||||
<td style="text-align:center;">
|
||||
|
@@ -58,7 +58,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
|
||||
);
|
||||
$locationContext = array_merge(
|
||||
$context,
|
||||
['docgen:expects' => Location::class, 'groups' => 'dogen:read']
|
||||
['docgen:expects' => Location::class, 'groups' => 'docgen:read']
|
||||
);
|
||||
|
||||
if (null === $user && 'docgen' === $format) {
|
||||
@@ -67,6 +67,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
|
||||
'main_center' => $this->normalizer->normalize(null, $format, $centerContext),
|
||||
'main_scope' => $this->normalizer->normalize(null, $format, $scopeContext),
|
||||
'current_location' => $this->normalizer->normalize(null, $format, $locationContext),
|
||||
'main_location' => $this->normalizer->normalize(null, $format, $locationContext),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -84,6 +85,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
|
||||
|
||||
if ('docgen' === $format) {
|
||||
$data['current_location'] = $this->normalizer->normalize($user->getCurrentLocation(), $format, $locationContext);
|
||||
$data['main_location'] = $this->normalizer->normalize($user->getMainLocation(), $format, $locationContext);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add editableByUsers field to ChillMain/LocationType.
|
||||
*/
|
||||
final class Version20220112150413 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_location_type DROP editableByUsers');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add editableByUsers field to ChillMain/LocationType';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_main_location_type ADD editableByUsers BOOLEAN DEFAULT TRUE');
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Add mainLocation to User.
|
||||
*/
|
||||
final class Version20220112161136 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE users DROP CONSTRAINT FK_1483A5E9DB622A42');
|
||||
$this->addSql('DROP INDEX IDX_1483A5E9DB622A42');
|
||||
$this->addSql('ALTER TABLE users DROP mainLocation_id');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add mainLocation to User';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE users ADD mainLocation_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE users ADD CONSTRAINT FK_1483A5E9DB622A42 FOREIGN KEY (mainLocation_id) REFERENCES chill_main_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_1483A5E9DB622A42 ON users (mainLocation_id)');
|
||||
}
|
||||
}
|
@@ -202,6 +202,7 @@ Location: Localisation
|
||||
Location type list: Liste des types de localisation
|
||||
Create a new location type: Créer un nouveau type de localisation
|
||||
Available for users: Disponible aux utilisateurs
|
||||
Editable by users: Éditable par les utilisateurs
|
||||
Address required: Adresse requise?
|
||||
Contact data: Données de contact?
|
||||
optional: optionnel
|
||||
|
Reference in New Issue
Block a user