Skip to content

Commit

Permalink
Merge 3.x into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Apr 2, 2019
2 parents ce5dd00 + 9ae3e52 commit a358bf4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ protected function redirectTo($object)
$url = $this->admin->generateObjectUrl(
$route,
$object,
$request->request->has('_tab') ? ['_tab' => $request->request->get('_tab')] : []
$this->getSelectedTab($request)
);

break;
Expand Down Expand Up @@ -1525,6 +1525,11 @@ final protected function trans($id, array $parameters = [], $domain = null, $loc
return $this->get('translator')->trans($id, $parameters, $domain, $locale);
}

private function getSelectedTab(Request $request)
{
return array_filter(['_tab' => $request->request->get('_tab')]);
}

private function checkParentChildAssociation(Request $request, $object): void
{
if (!($parentAdmin = $this->admin->getParent())) {
Expand Down
7 changes: 6 additions & 1 deletion src/Resources/public/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,12 @@ var Admin = {
setTimeout(function() {
form.find('button').prop('disabled', true);
}, 1);

var tabSelected = form.find('.nav-tabs li.active .changer-tab');

if (tabSelected.length > 0) {
form.find('input[name="_tab"]').val(tabSelected.attr('aria-controls'));
}
});
},
/**
Expand Down Expand Up @@ -758,7 +764,6 @@ var Admin = {
window.history.pushState({
path: newurl
}, '', newurl);
jQuery(this).parent('.nav-tabs-custom').find('input[name="_tab"]').val(tab);
});
}
};
Expand Down
2 changes: 2 additions & 0 deletions tests/Controller/HelperControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public function testsetObjectFieldValueAction(): void
$fieldDescription = $this->prophesize(FieldDescriptionInterface::class);
$pool = $this->prophesize(Pool::class);
$template = $this->prophesize(Template::class);
$template->render(Argument::cetera())->willReturn('some value');
$translator = $this->prophesize(TranslatorInterface::class);
$propertyAccessor = new PropertyAccessor();
$templateRegistry = $this->prophesize(TemplateRegistryInterface::class);
Expand Down Expand Up @@ -245,6 +246,7 @@ public function testappendFormFieldElementAction(): void
$fieldDescription = $this->prophesize(FieldDescriptionInterface::class);
$modelManager = $this->prophesize(ModelManagerInterface::class);
$template = $this->prophesize(Template::class);
$template->render(Argument::cetera())->willReturn('some value');
$translator = $this->prophesize(TranslatorInterface::class);
$propertyAccessor = new PropertyAccessor();
$templateRegistry = $this->prophesize(TemplateRegistryInterface::class);
Expand Down

0 comments on commit a358bf4

Please sign in to comment.