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

[FEATURE] Allowing dynamic css classes definition per field in tables #4594

Open
wants to merge 47 commits into
base: 4.x
Choose a base branch
from

Conversation

bertoferrero
Copy link

@bertoferrero bertoferrero commented Aug 19, 2021

This is based on the same idea used for dynamically formatting each field's value.

It is quite simple, just calling the dynamicCssClass method on the field definition:
yield DateTimeField::new('effectiveDate', 'Effective date')->setFormat('full', 'short')->dynamicCssClass(function($value, $entity){ $date = $entity->getEffectiveDate(); if($date==null){ return $value.' table-danger'; } return $value; });

The new code replaces td's class line by the new one got from the callable function.

That allowed me to warn users about rows without dates:
imagen

And to create a visual mark based on the entity type:
imagen

Berto added 3 commits August 19, 2021 10:02
…fining the css clases per each row, based on the same idea used to format the value
@bertoferrero bertoferrero changed the title Allowing dynamic css classes definition per field in tables [FEATURE] Allowing dynamic css classes definition per field in tables Aug 19, 2021
bertoferrero and others added 24 commits August 19, 2021 11:05
Co-authored-by: Oskar Stark <[email protected]>
This PR was merged into the 3.x branch.

Discussion
----------

Add missing catalan translations

Add missing catalan translations

Commits
-------

c083e9e Add missing catalan translations
This PR was submitted for the master branch but it was merged into the 3.x branch instead.

Discussion
----------

fix delete file

Hello
The following fix fixes the failure to delete a file by clicking the trash button

Test in Upload file and Upload files multiple.

Solved:
EasyCorp#4785
EasyCorp#4668

Commits
-------

5534c19 fix delete file
…JeromeEngelnAdeliom)

This PR was submitted for the master branch but it was squashed and merged into the 3.x branch instead.

Discussion
----------

[FEATURE] EasyCorp#4725 Add Form Tabs support

[3.X] Add Form Tabs support EasyCorp#4725

### Add feature to support form tabs on cruds

I've found a rapid way to make it works.
What do you think about it ?

Example of how to use this feature

_

In pages where you display lots of fields, you can divide them in tabs using
the "tabs" created with the special FormField object::

```php
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;

    use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;

    public function configureFields(string $pageName): iterable
    {
        return [
            IdField::new('id')->hideOnForm(),

            // Add a tab
            FormField::addTab('First Tab'),

            // You can use a Form Panel inside a Form Tab
            FormField::addPanel('User Details'),

            // Your fields
            TextField::new('firstName'),
            TextField::new('lastName'),

            // Add a second Form Tab
            // Tabs can also define their icon, CSS class and help message
            FormField::addTab('Contact information Tab')
                ->setIcon('phone')->addCssClass('optional')
                ->setHelp('Phone number is preferred'),

            TextField::new('phone'),

        ];
    }

```
_

Commits
-------

ac0dec4 [FEATURE] EasyCorp#4725 Add Form Tabs support
…aviereguiluz, JeromeEngelnAdeliom)

This PR was merged into the 3.x branch.

Discussion
----------

Fix for PR : Tweak form tab design  EasyCorp#4869

- The problem was linked to the function preProcessFields() in src/Factory/FieldFactory.php when a panel is created to avoid orphaned fields.

```php
private function preProcessFields(FieldCollection $fields, EntityDto $entityDto): void
    {
        if ($fields->isEmpty()) {
            return;
        }

        // this is needed to handle this edge-case: the list of fields include one or more form panels,
        // but the first fields of the list don't belong to any panel. We must create an automatic empty
        // form panel for those "orphaned fields" so they are displayed as expected
        $firstFieldIsAFormPanel = $fields->first()->isFormDecorationField();
        foreach ($fields as $fieldDto) {
            if (!$firstFieldIsAFormPanel && $fieldDto->isFormDecorationField()) {
                $fields->prepend(FormField::addPanel()->getAsDto());
                break;
            }
        }
```

I have add the "form_tab" class test to avoid the empty panel creation.

```php
public function isFormDecorationField(): bool
    {
           return null !== u($this->getCssClass())->containsAny(['field-form_panel', 'field-form_tab']);
    }
```

- \+ I have had to remove the "setTemplateName" method in formField.php file. I'm not sure about the impact.
Can you confirm my initiative `@javiereguiluz`  ?
During my tests an error was triggered because those templates names are not included in the ```phpfinal class TemplateRegistry```.

Commits
-------

143090f improve isFormDecorationField test syntax
034c79a Fix : Remove the first empty panel
5609c9c Tweak form tab design
This PR was merged into the 3.x branch.

Discussion
----------

keep sort query parameter

With this PR the current page is being kept after an action has been performed.

Commits
-------

2548553 keep sort query parameter
I just guessed this - please doublecheck.
The Dot-Notation `seller.email` isn't working here, right?
This PR was submitted for the master branch but it was merged into the 3.x branch instead.

Discussion
----------

Adding AssociationField

I just guessed this - please doublecheck.
The Dot-Notation `seller.email` isn't working here, right?

Commits
-------

053a673 Adding AssociationField
bertoferrero and others added 19 commits December 9, 2021 08:53
This PR was submitted for the master branch but it was merged into the 3.x branch instead.

Discussion
----------

Add Guadeloupe / Martinique flags

This pull request add Guadeloupe and Martinique Flags

Guadeloupe and Martinique being a French overseas region I used the French flag.

Commits
-------

7f0f939 Add Guadeloupe / Martinique flags
…eguiluz)

This PR was merged into the 3.x branch.

Discussion
----------

Relax Doctrine DBAL version constraints

Fixes EasyCorp#4895.

Commits
-------

b4d8466 Relax Doctrine DBAL version constraints
…viereguiluz)

This PR was merged into the 3.x branch.

Discussion
----------

Fix PHP 8.1 deprecation about nullable argument

Fixes EasyCorp#4821.

This argument was never really nullable (except when using named PHP arguments), because you must provide the route name after it, so you must pass at least `null` to that argument. Let's do this change, required to fix a PHP 8.1 deprecation, and let's move on 😄

Commits
-------

4b5638e Fix PHP 8.1 deprecation about nullable argument
…reguiluz)

This PR was merged into the 3.x branch.

Discussion
----------

Backport some fixes for PHP 8.1 deprecations

This backports EasyCorp#4904 to 3.x branch.

Commits
-------

f87c885 Backport some fixes for PHP 8.1 deprecations
This PR was merged into the 3.x branch.

Discussion
----------

Added missing Dutch translation

<!--
Thanks for your contribution! If you are proposing a new feature that is complex,
please open an issue first so we can discuss about it.

Note: all your contributions adhere implicitly to the MIT license
-->

Commits
-------

e8b8537 Added missing Dutch translation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants