-
-
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] Column chooser #5495
base: 4.x
Are you sure you want to change the base?
[FEATURE] Column chooser #5495
Conversation
…syAdminBundle into feature-column-chooser
nice feature <3 . great job mann |
…: fix 6 "errors" with message "Call to function is_callable() with callable(): mixed will always evaluate to true."
@javiereguiluz please review this PR and tell me what you think about it. Thanks in advance. |
|
Hi @TheoD02 !
Yes, it's strange.
What storage class are you using? Session?
AFAIK with empty
Ought, my bad. Fix it. Thanks!
Good idea. I thought about it. For example, make it configurable in class EmployeeCrudController extends AbstractCrudController
{
public function configureFields(string $pageName): iterable
{
public function configureFields(string $pageName): iterable
{
yield FormField::addTab('admin_label.common.panel.main');
yield FormField::addPanel('admin_label.employee.panel.name')->setIcon('fa fa-user')->addCssClass('danger');
yield TextField::new('imageName', 'admin_label.employee.field.imageName'); // ->setFormType(VichImageType::class);;
// $this->getParameter('app.dirs.profile');
yield TextField::new('familyName', 'admin_label.employee.field.familyName')->setColumns(4)
->addToDefaultColumns(); // <= add it to default columns in list
yield TextField::new('givenName', 'admin_label.employee.field.givenName')->setColumns(4)
->addToDefaultColumns(); // <= add it to default columns in list
yield TextField::new('patronymic', 'admin_label.employee.field.patronymic')->setColumns(4);
yield DateField::new('birthday', 'admin_label.employee.field.birthday');
yield FormField::addPanel('admin_label.employee.panel.contacts')->setIcon('fa fa-phone');
yield EmailField::new('email', 'admin_label.employee.field.email')
->addToDefaultColumns(); // <= add it to default columns in list
yield TelephoneField::new('phone', 'admin_label.employee.field.phone')
->addToDefaultColumns(); // <= add it to default columns in list
yield FormField::addPanel('admin_label.employee.panel.work')->setIcon('fa fa-briefcase');
yield AssociationField::new('department', 'admin_label.employee.field.department');
yield TextField::new('position', 'admin_label.employee.field.position');
if ($this->security->isGranted('ROLE_SUPER_ADMIN')) {
yield FormField::addTab('admin_label.employee.panel.settings');
yield FormField::addPanel('admin_label.employee.panel.auth')->setIcon('fa fa-key')->addCssClass('required');
yield BooleanField::new('active', 'admin_label.employee.field.active');
yield TextField::new('username', 'admin_label.employee.field.username')->hideOnIndex();
yield TextField::new('plainPassword', 'admin_label.employee.field.plainPassword')->onlyOnForms()
->excludeFromColumnChooser() // never show this field in columnChooser
yield FormField::addPanel('admin_label.employee.panel.access')->setIcon('fa fa-user-lock');
yield ArrayField::new('roles', 'admin_label.employee.field.roles')->onlyOnForms();
}
yield FormField::addTab('admin_label.common.panel.additional');
yield IdField::new('id', 'admin_label.common.field.id')->onlyOnDetail();
yield DateTimeField::new('createdAt', 'admin_label.common.field.createdAt')->onlyOnDetail();
yield DateTimeField::new('updatedAt', 'admin_label.common.field.updatedAt')->onlyOnDetail();
yield AssociationField::new('createdBy', 'admin_label.common.field.createdBy')->onlyOnDetail();
yield AssociationField::new('updatedBy', 'admin_label.common.field.updatedBy')->onlyOnDetail();
yield DateTimeField::new('deletedAt', 'admin_label.common.field.deletedAt')->onlyOnDetail();
yield TextField::new('virtualField')->onlyOnDetail();
}
} But I'd like to hear comments from @javiereguiluz first. |
I rebuild from my side (Docker on WSL2) i didn't have any issue during build, but just this padding added.
Currently yes, i don't have any User entity i don't have test with entity
Exactly ! I think about the same idea with EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait we can add on each EA included Field and for user custom Field too ! That would be the best implementation we wait for @javiereguiluz response about that 😄 Default : If at least one call addToDefaultColumns() set only thoses who have called this method And I just thought of a feature, it would be cool to be able to propose a preset for example in the case of a company with several services that use the data differently, only possible via DB or then via a config file or function like configureCrud for configureColumnChooserPresets([]) Config 1: Config 2 : |
What tool are you using to build assets? Yarn? What is the version number?
I did NOT change any stylesheets. May be it comes from
I'll try to reproduce and fix it.
Yep! Still waiting...
it's looks great to me.
I understand your point of view. |
Using version 1.22.15 (using http://devilbox.org/ stack with docker)
I tested without import "sortablejs" but have the same result, in changed files in didn't see anything about styles too.
Yes, have time to reflect about what is the best for this implementation |
Hi @TheoD02 !
Please take a look. I hope that finally fixed it. |
Hello @TheoD02 !
O! Great news! PS: Just in time! I just started building a test project from scratch https://github.com/ksn135/ea-cc-test PS2: I didn't see your last edit in the GitHub's letter |
|
Hi, Seem to be fine now 😄 I found a case that just for user experience : Another one idea come in my head, is to add a bridge for manage column for each entity directly from admin. I imagine that with optional extension package to install to let user the choice to use this if wanted and not overload EA with table. Adding one function to choose between configuration in code, or through the package from admin (DashboardController, possible override in each Crud ? Is really necessary ?) |
Hello, Ok this function is a luxury, but imagine that you want to change the default configuration on the "order" table for all users. That is, for example, currently you have the fields :
Today the default fields are configured in the code, we would have something like this:
Let's say you want to change this field to default, but without having to do any development, deployment or code changes. Wouldn't it be interesting to be able to change this columns directly from a user interface to configure the fields defined by default? This is a proposal, it can be useless for many people, that's why I indicate in my previous message that it could be configurable either via the code, or via an interface if you wish. |
Hi, I'm ready to help. Apparently we don't fully understand each other. |
…syAdminBundle into feature-column-chooser
Sometimes you have too many columns/properties in entity, but some of them required by one user, some other by another one.

Let's assume we have a list of employees with many fields. By default you need to scroll page left and right to see them all.
Just add the following lines to your existing code and see the results.
Now you can see new global action button on index page named "Column chooser".

It allows you choose which columns to hide/show and reorder them as you wish:
Add video:
second-2.mov
Selected columns saved in user session:

Another suggested option is to save selected columns in your user object in database.
Your user entity MUST implement interface
EasyCorp\Bundle\EasyAdminBundle\Interfaces\UserParametersStorageInterface
In my case I store parameters in related table. But your implementation may be slightly different.

By default
column chooser
use all fields fromindex
anddetail
pages.Sometimes you want to setup it more precisely.
You may globally setup in your dashboard controller and then make customisation on controller basis.