-
Notifications
You must be signed in to change notification settings - Fork 29
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
Use bootstrap modals instead of javascript confirm #263
Conversation
Hi @calvera Sounds like a good idea! I'll check the PR ASAP ;) Thanks, |
</div> | ||
</div> | ||
</div> | ||
{{ echo_endblock() }} |
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.
This looks like a duplication of the code in the ListBuilderTemplate. So, it would be better to create a separate template which is included here: also makes it easier to customize :)
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.
Good point, I will deduplicate
Hi, I've seen some little things you need to change to make this working as expected.
Previous behavior was:
If I'm not wrong, in your new implementation:
|
@@ -35,17 +35,23 @@ | |||
|
|||
{% spaceless %} | |||
{{ echo_spaceless() }} | |||
<div {% if builder.yamlKey is same as('list') or builder.yamlKey is same as('nested_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.
Are you sure this new "parent" doesn't break buttons display?
Given that object actions are wrapped by this code:
<div class="col-md-12 btn-group">
{{ block('object_actions') }}
</div>
I'm wondering if:
<div class="col-md-12 btn-group">
<div>
<a class="btn btn-default">button1</a>
<a class="btn btn-default">button2</a>
<a class="btn btn-default">button3</a>
<div>
</div>
Would be rendered the same as:
<div class="col-md-12 btn-group">
<a class="btn btn-default">button1</a>
<a class="btn btn-default">button2</a>
<a class="btn btn-default">button3</a>
</div>
(Just a question, I don't remember how BS handle btn-group
)
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.
addition div is wrong, span would be better, but i will remove addional tag at all, which is the best
about dynamic forms:
I think, the correct behavior would be:
- confirmation is needed -> show bs modal and POST a form with or without csrf protection if confirmed
- no confirmation and csrf protection -> POST a dynamic form with csrf
- no confirmation and no protection -> do not change, href link is followed
Do you agree?
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.
👍
thank you for your comments, i'll improve the PR |
so, now all should work, object actions, batch actions and generic actions as well. I have tested it on demo https://github.com/symfony2admingenerator/symfony2-admingenerator-demo-edition |
$(this.options.containerSelector).on('click', this.options.buttonSelector, this.clickHandler.bind(this)); | ||
$(this.options.containerSelector) | ||
.find(this.options.buttonSelector) | ||
.on('click',this.clickHandler.bind(this)); |
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.
Could you please come back to the previous implementation here. The difference is small, but previous version permit to handle AJAX loaded content (while the find
version doesn't AFAIK).
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.
yes, I will do, thanks for noticing this
Hi @calvera I see you added the If you let the Thank you, |
some rework, for demo see https://github.com/calvera/symfony2-admingenerator-demo-edition/tree/modals |
Hi @calvera Everything seems good... I'm just wondering if your proposition about modals with additional fields is the right way to recommend. I agree with you: it works, and is fairly simple. But, with that solution I think you miss something important which is Symfony Form bidning and all validation process. What if the field required a valid unique email but is not valid (because already in the database). With this solution, the user doesn't have an easy way to manage that situation. I already pushed a solution to that following an issue if I'm not wrong, based on Ajax, real form and managing validation constraints (actually based on Get / Post requests and form submitted or not). Could you please so complete your documentation based on that? |
I agree with @sescandell. The idea is good, but this should be improved to handle the form via AJAX and display server-side validation messages. |
@sescandell i'm not sure what you mean by 'I already pushed a solution to that following an issue...'. What you pushed and where? I have an example of full Symfony form in my symfony2-admingenerator-demo-edition/src/Admingenerator/DoctrineOrmDemoBundle/Resources/views/PostActions/index.html.twig but this is not ideal... i'm not sure if we could somehow make all action twig templates to be ajax compatible... |
Hi @calvera We discussed about that there is some times now here and following comment. I took a look to your fork of the demo. In that code, you create a new modal with a form not binded to any Symfony2 Form (here. My proposition is to manage that more globally with dynamic forms (as discussed here a long time ago). Actually, if I clearly understand your fork, this is really near to how you handle If you prefer, I can propose you to split this PR in 2 parts: first one is moving to bootstrap modals (what you already made and is pretty good IMO) ; then, secondly, AJAX and dynamic form loading in modals (with documentation and/or helpers). |
@sescandell - the ajax/form part is now in cookbook only. I think someone could use the 'no-form' approach for simple task. it is his/her decision. let's make it clear in cookbook. but I agree we could leave the full ajax/form for another PR. thanks for comments and proposals... p.s. after i read that discussion about ajaxification, i'll think about it. |
Where are we now? Am I supposed to do something more? :) |
Looks good to me. Ping @bobvandevijver and @loostro. If everybody is ok, I'll merge it 👍 Many thanks @calvera |
@calvera could you please rebase the PR (otherwise, I'll do it :)) thanks |
squashed and rebased |
Merged, many thanks @calvera 👍 |
I'm not sure if you are interested in...
this PR does not introduce BC break... nothing needs to be changed in the code...
please comment...