Skip to content

Commit

Permalink
IBX-6724: Simplifed context menu (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
tischsoic authored Jan 19, 2024
1 parent 9881c99 commit f40988a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/bundle/Controller/UserSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
use Ibexa\User\Form\Data\UserSettingUpdateData;
use Ibexa\User\Form\Factory\FormFactory;
use Ibexa\User\Form\SubmitHandler;
use Ibexa\User\Form\Type\UserSettingUpdateType;
use Ibexa\User\UserSetting\UserSettingService;
use Ibexa\User\UserSetting\ValueDefinitionRegistry;
use Ibexa\User\View\UserSettings\ListView;
use Ibexa\User\View\UserSettings\UpdateView;
use JMS\TranslationBundle\Annotation\Desc;
use Symfony\Component\Form\Button;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -90,7 +92,7 @@ public function updateAction(Request $request, UpdateView $view)
$form->handleRequest($request);

if ($form->isSubmitted()) {
$result = $this->submitHandler->handle($form, function (UserSettingUpdateData $data) {
$result = $this->submitHandler->handle($form, function (UserSettingUpdateData $data) use ($form) {
foreach ($data->getValues() as $identifier => $value) {
$this->userSettingService->setUserSetting($identifier, (string)$value['value']);
}
Expand All @@ -102,6 +104,14 @@ public function updateAction(Request $request, UpdateView $view)
'ibexa_user_settings'
);

if ($form->getClickedButton() instanceof Button
&& $form->getClickedButton()->getName() === UserSettingUpdateType::BTN_UPDATE_AND_EDIT
) {
return $this->redirectToRoute('ibexa.user_settings.update', [
'identifier' => $data->getIdentifier(),
]);
}

return new RedirectResponse($this->generateUrl('ibexa.user_settings.list'));
});

Expand Down
3 changes: 3 additions & 0 deletions src/lib/Form/Type/UserSettingUpdateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

class UserSettingUpdateType extends AbstractType
{
public const BTN_UPDATE_AND_EDIT = 'update_and_edit';

/** @var \Ibexa\User\UserSetting\FormMapperRegistry */
protected $formMapperRegistry;

Expand Down Expand Up @@ -68,6 +70,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder->add($sub);
}
$builder->add('update', SubmitType::class, []);
$builder->add(self::BTN_UPDATE_AND_EDIT, SubmitType::class);
}

/**
Expand Down

0 comments on commit f40988a

Please sign in to comment.