Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Remove jquery-form (#8232)" #8237

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import 'jquery-ui/ui/widget';
import 'jquery-ui/ui/widgets/sortable';
import 'bootstrap';

import 'jquery-form';

// Boostrap 3 JavaScript for the X-editable library
import 'x-editable/dist/bootstrap3-editable/js/bootstrap-editable';

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"twig/twig": "^3.0"
},
"require-dev": {
"doctrine/persistence": "^3.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

until /~https://github.com/symfony/security-acl is compatible. Will look into it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"friendsofphp/php-cs-fixer": "^3.4",
"matthiasnoback/symfony-config-test": "^4.2 || ^5.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.2 || ^5.0",
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"bootstrap": "^3.3",
"icheck": "^1.0",
"jquery": "^3.7.0",
"jquery-form": "^4.3",
"jquery-slimscroll": "^1.3",
"jquery-ui": "^1.13",
"jquery.scrollto": "^2.1",
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/public/app.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/Resources/skeleton/Admin.tpl.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?= "<?php\n" ?>
<?php echo "<?php\n"; ?>

declare(strict_types=1);

namespace <?= $namespace ?>;
namespace <?php echo $namespace; ?>;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;

final class <?= $class_name ?> extends AbstractAdmin
final class <?php echo $class_name; ?> extends AbstractAdmin
{

protected function configureDatagridFilters(DatagridMapper $filter): void
{
$filter
<?= $fields ?>;
<?php echo $fields; ?>;
}

protected function configureListFields(ListMapper $list): void
{
$list
<?= $fields ?>->add(ListMapper::NAME_ACTIONS, null, [
<?php echo $fields; ?>->add(ListMapper::NAME_ACTIONS, null, [
'actions' => [
'show' => [],
'edit' => [],
Expand All @@ -34,12 +34,12 @@ protected function configureListFields(ListMapper $list): void
protected function configureFormFields(FormMapper $form): void
{
$form
<?= $fields ?>;
<?php echo $fields; ?>;
}

protected function configureShowFields(ShowMapper $show): void
{
$show
<?= $fields ?>;
<?php echo $fields; ?>;
}
}
8 changes: 4 additions & 4 deletions src/Resources/skeleton/AdminController.tpl.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?= "<?php\n" ?>
<?php echo "<?php\n"; ?>

declare(strict_types=1);

namespace <?= $namespace ?>;
namespace <?php echo $namespace; ?>;

use <?= $default_controller ?>;
use <?php echo $default_controller; ?>;

final class <?= $class_name ?> extends <?= $default_controller_short_name ?>
final class <?php echo $class_name; ?> extends <?php echo $default_controller_short_name; ?>
{

}
6 changes: 3 additions & 3 deletions tests/Action/AppendFormFieldElementActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function setUp(): void
{
$this->twig = $this->createMock(Environment::class);
$this->admin = $this->createMock(AdminInterface::class);
$this->adminFetcher = $this->createStub(AdminFetcherInterface::class);
$this->adminFetcher = static::createStub(AdminFetcherInterface::class);
$this->adminFetcher->method('get')->willReturn($this->admin);
$this->helper = $this->createMock(AdminHelper::class);
$this->action = new AppendFormFieldElementAction(
Expand All @@ -81,15 +81,15 @@ public function testAppendFormFieldElementAction(): void

$modelManager = $this->createMock(ModelManagerInterface::class);
$formView = new FormView();
$form = $this->createStub(Form::class);
$form = static::createStub(Form::class);
$renderer = $this->configureFormRenderer();

$this->admin->method('getObject')->with(42)->willReturn($object);
$this->admin->method('getClass')->willReturn($object::class);
$this->admin->expects(static::once())->method('setSubject')->with($object);
$this->admin->method('getFormTheme')->willReturn([]);
$this->helper->method('appendFormFieldElement')->with($this->admin, $object, 'element_42')->willReturn([
$this->createStub(FieldDescriptionInterface::class),
static::createStub(FieldDescriptionInterface::class),
$form,
]);
$this->helper->method('getChildFormView')->with($formView, 'element_42')->willReturn($formView);
Expand Down
2 changes: 1 addition & 1 deletion tests/Action/DashboardActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class DashboardActionTest extends TestCase

protected function setUp(): void
{
$this->templateRegistry = $this->createStub(MutableTemplateRegistryInterface::class);
$this->templateRegistry = static::createStub(MutableTemplateRegistryInterface::class);

$twig = $this->createMock(Environment::class);

Expand Down
2 changes: 1 addition & 1 deletion tests/Action/GetShortObjectDescriptionActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function setUp(): void
{
$this->twig = new Environment(new ArrayLoader(['short_object_description' => 'renderedTemplate']));
$this->admin = $this->createMock(AdminInterface::class);
$this->adminFetcher = $this->createStub(AdminFetcherInterface::class);
$this->adminFetcher = static::createStub(AdminFetcherInterface::class);

$this->action = new GetShortObjectDescriptionAction(
$this->twig,
Expand Down
26 changes: 13 additions & 13 deletions tests/Action/RetrieveAutocompleteItemsActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class RetrieveAutocompleteItemsActionTest extends TestCase
protected function setUp(): void
{
$this->admin = $this->createMock(AdminInterface::class);
$this->adminFetcher = $this->createStub(AdminFetcherInterface::class);
$this->adminFetcher = static::createStub(AdminFetcherInterface::class);
$this->adminFetcher->method('get')->willReturn($this->admin);
$this->action = new RetrieveAutocompleteItemsAction($this->adminFetcher);
}
Expand Down Expand Up @@ -77,7 +77,7 @@ public function testRetrieveAutocompleteItemsActionDisabledFormelememt(): void
'field' => 'barField',
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_GET, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']);

$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->configureFormConfig('barField', true);

Expand Down Expand Up @@ -106,8 +106,8 @@ public function testRetrieveAutocompleteItemsTooShortSearchString(): void
'q' => 'so',
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_GET, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']);

$targetAdmin = $this->createStub(AdminInterface::class);
$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$targetAdmin = static::createStub(AdminInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->configureFormConfig('barField');

Expand Down Expand Up @@ -228,9 +228,9 @@ private function configureAutocompleteItemsDatagrid(): MockObject

$targetAdmin = $this->createMock(AdminInterface::class);
$datagrid = $this->createMock(DatagridInterface::class);
$metadata = $this->createStub(MetadataInterface::class);
$pager = $this->createStub(PagerInterface::class);
$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$metadata = static::createStub(MetadataInterface::class);
$pager = static::createStub(PagerInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->admin->method('getNewInstance')->willReturn($model);
$this->admin->expects(static::once())->method('setSubject')->with($model);
Expand All @@ -257,8 +257,8 @@ private function configureAutocompleteItemsDatagrid(): MockObject
private function configureFormConfig(string $field, bool $disabled = false): void
{
$form = $this->createMock(Form::class);
$formType = $this->createStub(Form::class);
$formConfig = $this->createStub(FormConfigInterface::class);
$formType = static::createStub(Form::class);
$formConfig = static::createStub(FormConfigInterface::class);

$this->admin->method('getForm')->willReturn($form);
$form->method('get')->with($field)->willReturn($formType);
Expand All @@ -279,8 +279,8 @@ private function configureFormConfig(string $field, bool $disabled = false): voi
private function configureFormConfigComplexProperty(string $field): void
{
$form = $this->createMock(Form::class);
$formType = $this->createStub(Form::class);
$formConfig = $this->createStub(FormConfigInterface::class);
$formType = static::createStub(Form::class);
$formConfig = static::createStub(FormConfigInterface::class);

$this->admin->method('getForm')->willReturn($form);
$form->method('get')->with($field)->willReturn($formType);
Expand All @@ -300,8 +300,8 @@ private function configureFormConfigComplexProperty(string $field): void
private function configureFormConfigComplexPropertyArray(string $field): void
{
$form = $this->createMock(Form::class);
$formType = $this->createStub(Form::class);
$formConfig = $this->createStub(FormConfigInterface::class);
$formType = static::createStub(Form::class);
$formConfig = static::createStub(FormConfigInterface::class);

$this->admin->method('getForm')->willReturn($form);
$form->method('get')->with($field)->willReturn($formType);
Expand Down
4 changes: 2 additions & 2 deletions tests/Action/RetrieveFormFieldElementActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function setUp(): void
{
$this->twig = $this->createMock(Environment::class);
$this->admin = $this->createMock(AdminInterface::class);
$this->adminFetcher = $this->createStub(AdminFetcherInterface::class);
$this->adminFetcher = static::createStub(AdminFetcherInterface::class);
$this->adminFetcher->method('get')->willReturn($this->admin);
$this->helper = $this->createMock(AdminHelper::class);
$this->action = new RetrieveFormFieldElementAction(
Expand All @@ -82,7 +82,7 @@ public function testRetrieveFormFieldElementAction(): void
$modelManager = $this->createMock(ModelManagerInterface::class);
$formView = new FormView();
$form = $this->createMock(Form::class);
$formBuilder = $this->createStub(FormBuilder::class);
$formBuilder = static::createStub(FormBuilder::class);

$renderer = $this->configureFormRenderer();

Expand Down
16 changes: 8 additions & 8 deletions tests/Action/SetObjectFieldValueActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function setUp(): void
'field_template' => 'renderedTemplate',
]));
$this->admin = $this->createMock(AdminInterface::class);
$this->adminFetcher = $this->createStub(AdminFetcherInterface::class);
$this->adminFetcher = static::createStub(AdminFetcherInterface::class);
$this->adminFetcher->method('get')->willReturn($this->admin);
$this->validator = $this->createMock(ValidatorInterface::class);
$this->modelManager = $this->createMock(ModelManagerInterface::class);
Expand Down Expand Up @@ -107,7 +107,7 @@ public function testSetObjectFieldValueAction(): void
'context' => 'list',
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']);

$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->admin->method('getObject')->with(42)->willReturn($object);
$this->admin->method('getCode')->willReturn('sonata.post.admin');
Expand Down Expand Up @@ -162,7 +162,7 @@ public function testSetObjectFieldValueActionWithDate(
'context' => 'list',
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']);

$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->admin->method('getObject')->with(42)->willReturn($object);
$this->admin->method('getCode')->willReturn('sonata.post.admin');
Expand Down Expand Up @@ -209,7 +209,7 @@ public function testSetObjectFieldValueActionOnARelationField(): void
'context' => 'list',
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']);

$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->admin->method('getObject')->with(42)->willReturn($object);
$this->admin->method('getCode')->willReturn('sonata.post.admin');
Expand Down Expand Up @@ -252,7 +252,7 @@ public function testSetObjectFieldValueActionWithViolations(): void
'context' => 'list',
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']);

$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->admin->method('getObject')->with(42)->willReturn($object);
$this->admin->method('hasAccess')->with('edit', $object)->willReturn(true);
Expand Down Expand Up @@ -285,7 +285,7 @@ public function testSetObjectFieldEditableMultipleValue(): void
'context' => 'list',
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']);

$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->admin->method('getObject')->with(42)->willReturn($object);
$this->admin->method('getCode')->willReturn('sonata.post.admin');
Expand Down Expand Up @@ -328,7 +328,7 @@ public function testSetObjectFieldTransformed(): void
static fn (mixed $value): bool => filter_var($value, \FILTER_VALIDATE_BOOLEAN)
);

$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->admin->method('getObject')->with(42)->willReturn($object);
$this->admin->method('getCode')->willReturn('sonata.post.admin');
Expand Down Expand Up @@ -375,7 +375,7 @@ static function (mixed $value) use (&$isOverridden): bool {
}
);

$fieldDescription = $this->createStub(FieldDescriptionInterface::class);
$fieldDescription = static::createStub(FieldDescriptionInterface::class);

$this->admin->method('getObject')->with(42)->willReturn($object);
$this->admin->method('getCode')->willReturn('sonata.post.admin');
Expand Down
Loading