Skip to content

Commit

Permalink
IBX-6724: Simplify context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
tischsoic committed Jan 4, 2024
1 parent a936090 commit 77fe15d
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 @@ -87,7 +89,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 @@ -99,6 +101,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 77fe15d

Please sign in to comment.