-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
bertoferrero
wants to merge
47
commits into
EasyCorp:4.x
Choose a base branch
from
bertoferrero:dynamic-css
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…fining the css clases per each row, based on the same idea used to format the value
OskarStark
reviewed
Aug 19, 2021
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:

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