- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 3.7k
 
Introduce jquery formvalidator for com_users #5058
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
Conversation
| 
           @test success  | 
    
| 
           @test success!  | 
    
| 
           @smanzi @anibalsanchez Thank you very much for testing all these PRs. I owe you some beers 🍻  | 
    
| 
           @DGT41 @anibalsanchez That would be great! 🍺  | 
    
| 
           Moving to RTC as we have 2 successful tests.  | 
    
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.
Can we please avoid this $script .= thing? You do it right later with:
JFactory::getDocument()->addScriptDeclaration("
    // JS code here
");So it's easier to modify it or move it to a js file.
Thanks!
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.
@phproberto I also dislike $script .= or $script[] = but in this occasion there is a foreach loop that populates some part of the script. I guess I can simplify it to three parts:
- code before the foreach
 - code generated in the loop
 - the rest
 
Or use JFactory::getDocument()->addScriptDeclaration(“…”); 3 times (i am not sure if this is gonna work flawlessly)
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.
@phproberto is this ok?
$script = '
jQuery(document).ready(function() {
    Joomla.submitbutton = function(task) {
        if (task == "groups.delete")
        {
            var f = document.adminForm;
            var cb="";';
foreach ($this->items as $i => $item)
{
    if ($item->user_count > 0)
    {
        $script .= '
            cb = f["cb"+' . $i . '];
            if (cb && cb.checked) { 
                if (confirm(Joomla.JText._("COM_USERS_GROUPS_CONFIRM_DELETE"))) {
                    Joomla.submitform(task);
                }
                return;
            }';
    }
}
$script .= '
        }
    Joomla.submitform(task);
    }
});';
JFactory::getDocument()->addScriptDeclaration($script);
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.
Just my 2cents, I agree the $script .= is not ideal but the former looks more readable to me than the latter.
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.
@DGT41 please see my PR against your branch: https://github.com/dgt41/joomla-cms/pull/10
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.
@phproberto thanks! there are also some bad $script .= on admin com_languages and com_menus, I will try to fix them tomorrow.
I'm on the iPhone right now so can't do much
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.
If other files using $script .= are not related to this PR I think we can do that on a different PR and merge this.
| 
           I think we need at least an extra test to validate that my latest changes to the group management work. How to test it
  | 
    
| 
           test  | 
    
| 
           @test OK 
  | 
    
| 
           @Fedik @anibalsanchez Thanks, your help is really appreciated. Can I ask you to check also, if you have spare time,  | 
    
| 
           @test success (all groups deletion conditions too...) Just be a little bit picky, I hate alert messages (the "standard" ones), also because they can be switched off at the browser level. I think we should design our own modal-based alert/confirmation message...  | 
    
| 
           sorry, misplaced comment above!  | 
    
| 
           The strange thing is that in commit https://github.com/dgt41/joomla-cms/commit/9999882bcbce06b6adc24c13f4b2936c3f24c01a the code is there and disappears out of the blue!  | 
    
| 
           @smanzi @phproberto here is ok!  | 
    
| 
           here too! e.g.: the patch downloaded by com_patchtester has at line 26-31 of administrator/components/com_users/views/groups/tmpl/default.php:  | 
    
| 
           Yeah I pushed the code again…  | 
    
| 
           ... but I didn't reapply the patch: this is from my original patch that applied when started testing tonight...  | 
    
| 
           do you want me to re-apply & re-test this?  | 
    
| 
           if you can but give me a minute  | 
    
| 
           no prob, give me the "go"...  | 
    
| 
           go!  | 
    
| 
           Is looking good here!  | 
    
| 
           Yes, now code different and anyway @test success!  | 
    
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.
We have to remove this one too.
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.
but this is jquery dependent ? jQuery('#jform_twofactor_method').val();
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.
If it was attached to an element's event it should be done on document.ready but this is only a function declaration that is called by other elements (in this case is fired when a select box changes) so it's done when the DOM is ready.
Also this code was executed like that originally so let's keep it. We have enough problems :D
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.
done
| 
           Thanks. All seems ok now. We need to wait to travis so I'll go to sleep. You did an awesome work tonight. Thanks!!  | 
    
| 
           again @test success!  | 
    
| 
           Good night, everybody! 😴  | 
    
| 
           Its time 💤  | 
    
| 
           test  | 
    
| 
           @test OK 
  | 
    
| 
           Merged into   | 
    
Executive summary
This PR converts the form validation on com_users to use plain jquery (no mootools call on every form ).
Also NO MORE INLINE SCRIPTS!
Testing
If no javascript errors are logged in your browser and the functionality remains the same your test is a pass in any other case please report the errors here