mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-01-10 11:21:24 +00:00
Compare commits
5 Commits
master
...
487-addres
| Author | SHA1 | Date | |
|---|---|---|---|
| e48aad487c | |||
| fa5eff1e4c | |||
| d398fad42c | |||
| eee0593700 | |||
| ec5ca626a4 |
6
.changes/unreleased/UX-20260106-142813.yaml
Normal file
6
.changes/unreleased/UX-20260106-142813.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
kind: UX
|
||||
body: Improve the ux of the address field in the person creation form
|
||||
time: 2026-01-06T14:28:13.033420033+01:00
|
||||
custom:
|
||||
Issue: "487"
|
||||
SchemaChange: No schema change
|
||||
@@ -45,10 +45,10 @@
|
||||
:class="getClassButton"
|
||||
type="button"
|
||||
name="button"
|
||||
:title="trans(getTextButton)"
|
||||
:title="getTextButton"
|
||||
>
|
||||
<span v-if="displayTextButton">{{
|
||||
trans(getTextButton)
|
||||
getTextButton
|
||||
}}</span>
|
||||
</button>
|
||||
</template>
|
||||
@@ -73,10 +73,10 @@
|
||||
:class="getClassButton"
|
||||
type="button"
|
||||
name="button"
|
||||
:title="trans(getTextButton)"
|
||||
:title="getTextButton"
|
||||
>
|
||||
<span v-if="displayTextButton">{{
|
||||
trans(getTextButton)
|
||||
getTextButton
|
||||
}}</span>
|
||||
</button>
|
||||
</template>
|
||||
@@ -97,11 +97,9 @@
|
||||
:class="getClassButton"
|
||||
type="button"
|
||||
name="button"
|
||||
:title="trans(getTextButton)"
|
||||
:title="getTextButton"
|
||||
>
|
||||
<span v-if="displayTextButton">{{
|
||||
trans(getTextButton)
|
||||
}}</span>
|
||||
<span v-if="displayTextButton">{{ getTextButton }}</span>
|
||||
</button>
|
||||
</template>
|
||||
</action-buttons>
|
||||
@@ -177,16 +175,18 @@ export default {
|
||||
},
|
||||
getTextButton() {
|
||||
if (
|
||||
typeof this.options.button.text !== "undefined" &&
|
||||
(this.options.button.text.edit !== null ||
|
||||
this.options.button.text.create !== null)
|
||||
typeof this.options.button !== "undefined" &&
|
||||
typeof this.options.button.text !== "undefined"
|
||||
) {
|
||||
// console.log('this.options.button.text', this.options.button.text)
|
||||
return this.context.edit
|
||||
? ACTIVITY_CREATE_ADDRESS
|
||||
: ACTIVITY_EDIT_ADDRESS;
|
||||
const customText = this.context.edit
|
||||
? this.options.button.text.edit
|
||||
: this.options.button.text.create;
|
||||
|
||||
if (customText !== null) {
|
||||
return customText;
|
||||
}
|
||||
}
|
||||
console.log("defaultz", this.defaultz);
|
||||
|
||||
return this.context.edit
|
||||
? this.defaultz.button.text.edit
|
||||
: this.defaultz.button.text.create;
|
||||
|
||||
@@ -135,15 +135,13 @@ final class PersonController extends AbstractController
|
||||
$this->lastPostDataReset();
|
||||
|
||||
$address = $form->get('address')->getData();
|
||||
$addressForm = (bool) $form->get('addressForm')->getData();
|
||||
|
||||
if (null !== $address && $addressForm) {
|
||||
if (null !== $address) {
|
||||
$household = new Household();
|
||||
|
||||
$member = new HouseholdMember();
|
||||
$member->setPerson($person);
|
||||
$member->setStartDate(new \DateTimeImmutable());
|
||||
|
||||
$household->addMember($member);
|
||||
$household->setForceAddress($address);
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Form\Event\CustomizeFormEvent;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Form\Type\ChillPhoneNumberType;
|
||||
@@ -27,12 +26,9 @@ use libphonenumber\PhoneNumberType;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
final class CreationPersonType extends AbstractType
|
||||
{
|
||||
@@ -77,16 +73,10 @@ final class CreationPersonType extends AbstractType
|
||||
->add('email', EmailType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
->add('addressForm', CheckboxType::class, [
|
||||
'label' => 'Create a household and add an address',
|
||||
'required' => false,
|
||||
'mapped' => false,
|
||||
'help' => 'A new household will be created. The person will be member of this household.',
|
||||
])
|
||||
->add('address', PickAddressType::class, [
|
||||
'required' => false,
|
||||
'mapped' => false,
|
||||
'label' => false,
|
||||
'label' => 'Address',
|
||||
]);
|
||||
|
||||
if ($this->askCenters) {
|
||||
@@ -113,9 +103,6 @@ final class CreationPersonType extends AbstractType
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Person::class,
|
||||
'constraints' => [
|
||||
new Callback($this->validateCheckedAddress(...)),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -126,18 +113,4 @@ final class CreationPersonType extends AbstractType
|
||||
{
|
||||
return self::NAME;
|
||||
}
|
||||
|
||||
public function validateCheckedAddress($data, ExecutionContextInterface $context, $payload): void
|
||||
{
|
||||
/** @var bool $addressFrom */
|
||||
$addressFrom = $context->getObject()->get('addressForm')->getData();
|
||||
/** @var ?Address $address */
|
||||
$address = $context->getObject()->get('address')->getData();
|
||||
|
||||
if ($addressFrom && null === $address) {
|
||||
$context->buildViolation('person_creation.If you want to create an household, an address is required')
|
||||
->atPath('addressForm')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,11 +105,14 @@
|
||||
{{ form_row(form.center) }}
|
||||
{% endif %}
|
||||
|
||||
<div id=addressForm>
|
||||
{{ form_row(form.addressForm) }}
|
||||
</div>
|
||||
<div id=address>
|
||||
{{ form_row(form.address) }}
|
||||
<div id="address" class="row mb-1" style="display:flex;" title="{{ 'A new household will be created. The person will be member of this household.'|trans }}">
|
||||
{{ form_label(form.address, 'Address'|trans) }}
|
||||
<div class="col-sm-8">
|
||||
{{ form_widget(form.address) }}
|
||||
<div class="form-text text-muted">
|
||||
{{ 'A new household will be created. The person will be member of this household.'|trans }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
|
||||
Reference in New Issue
Block a user