-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update filter js #8230
base: 4.x
Are you sure you want to change the base?
Update filter js #8230
Conversation
} | ||
|
||
prepareSubmit(event) { | ||
const defaults = convertQueryStringToObject(qs.stringify({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this, we could do this on the backend.
Eslint rules are updated you might try to rebase |
2626ab1
to
68c261e
Compare
@VincentLanglet any idias why failed ci? |
Every time you modify js files you have to update the build and commit it.
|
9a3bdd6
to
6f58d3c
Compare
Thanks, can you udpate the changelog you kept the template
Also, ping @jordisala1991 if you want to review. I think after all the JS-Pr merged, releasing a beta-release might be safer (?). |
There will be a lot of changes. And some with mini BC as #8232 or next pr with remove jquery.scrollto after update SonataPage because he use plugin. IMHO it is better to small releases and get feedback than one big one. |
Sure I can make more release. I just would like to avoid using user as feedback for BC-break/bugs and having some beta testers since I cannot test this bundle anymore. If you or someone else has a big enough projet and target 4.x-dev without any issue before next releases ; it's good enough for me to release it. I'm currently unsure about
|
yes, I am testing on a large project, we have been using sonata it for many years. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's not safer to keep the sonata-filter-count in case someone use it for css or query selector.
It not an issue to keep some unused classes, no ?
This class was used only in binding js, I have not a special opinion on this, but if you think about it this way, then any change on the frontend, even a change in the nesting of tags, will be a kind of BC for css. If necessary, let's revert class, fine to me. |
@@ -259,13 +259,13 @@ file that was distributed with this source code. | |||
{# NEXT_MAJOR: Remove |default(filter.option('show_filter')) #} | |||
{% set displayableFilters = admin.datagrid.filters|filter(filter => filter.showFilter|default(filter.option('show_filter')) is not same as (false)) %} | |||
{%- if displayableFilters|length %} | |||
<ul class="nav navbar-nav navbar-right"> | |||
<ul class="nav navbar-nav navbar-right" id="filter-list-{{ admin.uniqid() }}" {{ stimulus_controller('filter_list', {}, { 'active': 'active' }, { 'filter': '#filter-container-' ~ admin.uniqid() }) }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't used stimulus that much, but we should add a vendor prefix here so it won't clash wish other "list_filter" controller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, we should use sonata-
prefix in the safe way we're prefixing twig function with sonata_
https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Twig/Extension/SonataAdminExtension.php#L43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by default controller registration is automatic based on file name, file name filter_controller.js
matches filter
controller in app. We can name the file sonata_filter_controller.js
or use manual registration
import { Application } from '@hotwired/stimulus'
import FilterController from '/controllers/filter'
window.Stimulus = Application.start();
Stimulus.register('sonata-filter', FilterController);
if use manual registration, the structure folder could be
contollers/
- filter.js
- filter_list.js
- revision.js
- treeview.js
- confirm_exit.js
IMHO this looks nicer than using auto registration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symfony is using a @symfony/
prefix for all components:
https://symfony.com/bundles/StimulusBundle/current/index.html#with-webpackencorebundle
Following that guide, we should use something like this:
{{ stimulus_controller('@sonata-project/admin/filter-list', { //...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, with this approach, using outles will be one big pain hotwired/stimulus#641
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's use defaults registration and events as communications between controllers, because to use outlets looks crazy with this approach
export default class extends Controller {
static outlets = ['symfony--ux-chartjs--chart'];
connect() { this.symfonyUxChartjsChartOutlet.method() }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symfony is using a
@symfony/
prefix for all components: https://symfony.com/bundles/StimulusBundle/current/index.html#with-webpackencorebundleFollowing that guide, we should use something like this:
{{ stimulus_controller('@sonata-project/admin/filter-list', { //...
after reading the documentation and https://github.com/symfony/stimulus-bridge I don't see how stimulus-bridge
in current configuration resolve name like {{ stimulus_controller('@sonata-project/admin/filter-list', { //...
other than subdirectories or manual registration, any thoughts and ideas are welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what have worked on my projects, you need to add this to the package.json
:
{
"name": "@sonata-project/admin-bundle",
"symfony": {
"controllers": {
"filter": {
"main": "dist/calendar.controller.js",
"fetch": "lazy",
"enabled": true,
"autoimport": {
"@sonata-project/admin-bundle/dist/style.css": true
}
}
}
}
}
Not sure, but the composer.json
file might also need a tag with the name "symfony-ux":
{
"keywords": [
"symfony-ux"
]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would go with the simplest solution to have a sonata prefix.
If renaming files give them the prefix, it may be the easiest solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what have worked on my projects, you need to add this to the
package.json
:{ "name": "@sonata-project/admin-bundle", "symfony": { "controllers": { "filter": { "main": "dist/calendar.controller.js", "fetch": "lazy", "enabled": true, "autoimport": { "@sonata-project/admin-bundle/dist/style.css": true } } } } }Not sure, but the
composer.json
file might also need a tag with the name "symfony-ux":{ "keywords": [ "symfony-ux" ] }
I don't think it will work in our case. If you follow this guide https://symfony.com/doc/current/frontend/create_ux_bundle.html for each controller we must specify entrypoint
but webpack build one file app.js
in output.
The approach you describe could make a package https://github.com/sonata-project/form-extensions and will would resuable ux package, but curently form-extensions
trying to access our SonataAdmin app from window https://github.com/sonata-project/form-extensions/blob/2.x/assets/js/app.js#L16 and register controller.
SonataAdmin is the central app because create stimulus application
Subject
Need #2870
Part #7156, #7158
Migrate from jquery to vanilla(stimulus) js
Changelog