Skip to content

Conversation

@dgrammatiko
Copy link
Contributor

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

  1. Apply first PR Reduce unneeded calls for mootools #4888 (!important)
  2. Apply this PR
  3. In the admin area go to com_users and try to submit any form.

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

@smanzi
Copy link

smanzi commented Nov 11, 2014

@test success

@anibalsanchez
Copy link
Contributor

@test success!

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5058.

@dgrammatiko
Copy link
Contributor Author

@smanzi @anibalsanchez Thank you very much for testing all these PRs. I owe you some beers 🍻

@smanzi
Copy link

smanzi commented Nov 13, 2014

@DGT41 @anibalsanchez That would be great! 🍺

@roland-d
Copy link
Contributor

Moving to RTC as we have 2 successful tests.

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5058.

@roland-d roland-d added RTC This Pull Request is Ready To Commit and removed RTC This Pull Request is Ready To Commit labels Nov 18, 2014
@jissues-bot jissues-bot added the RTC This Pull Request is Ready To Commit label Nov 18, 2014
Copy link
Contributor

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!

Copy link
Contributor Author

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:

  1. code before the foreach
  2. code generated in the loop
  3. the rest

Or use JFactory::getDocument()->addScriptDeclaration(“…”); 3 times (i am not sure if this is gonna work flawlessly)

Copy link
Contributor Author

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);

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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

Copy link
Contributor

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.

@phproberto
Copy link
Contributor

I think we need at least an extra test to validate that my latest changes to the group management work.

How to test it

  • When trying to delete a group with users inside you should see an alert box asking you confirmation
  • When trying to delete a group with no users you should be able to delete it without confirmation

@Fedik
Copy link
Member

Fedik commented Nov 21, 2014

test
works good for me

@anibalsanchez
Copy link
Contributor

@test OK

  • Group deletion without users, Ok
  • Group deletion with users, standard alert, confirmation Yes, OK (group deleted)
  • Group deletion with users, standard alert, confirmation No, OK (group not deleted)

@dgrammatiko
Copy link
Contributor Author

@Fedik @anibalsanchez Thanks, your help is really appreciated. Can I ask you to check also, if you have spare time,
#5047 (administrator/components/com_menus/views/item/tmpl/edit_modules.php AND administrator/components/com_menus/views/menutypes/tmpl/default.php)
#5046 (administrator/components/com_languages/views/override/tmpl/edit.php)

@smanzi
Copy link

smanzi commented Nov 25, 2014

@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...

@smanzi
Copy link

smanzi commented Nov 30, 2014

@test success for this PR
Tested the set of: #5046 #5048 #5049 #5050 #5051 #5052 #5053 #5054 #5056 #5058 #5113 #5255

@smanzi
Copy link

smanzi commented Nov 30, 2014

@test success for this PR (created new article in front-end, no prob!)
Tested the set of: #5046 #5048 #5049 #5050 #5051 #5052 #5053 #5054 #5056 #5058 #5113 #5255

@smanzi
Copy link

smanzi commented Nov 30, 2014

sorry, misplaced comment above!

This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5058.

@dgrammatiko
Copy link
Contributor Author

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!
Can we test it one more time?

@dgrammatiko
Copy link
Contributor Author

@smanzi @phproberto here is ok!

@smanzi
Copy link

smanzi commented Nov 30, 2014

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:

$script = '
    Joomla.submitbutton = function(task) {
        if (task == "groups.delete")
        {
            var f = document.adminForm;
            var cb="";';

@dgrammatiko
Copy link
Contributor Author

Yeah I pushed the code again…

@smanzi
Copy link

smanzi commented Nov 30, 2014

... but I didn't reapply the patch: this is from my original patch that applied when started testing tonight...

@smanzi
Copy link

smanzi commented Nov 30, 2014

do you want me to re-apply & re-test this?

@dgrammatiko
Copy link
Contributor Author

if you can but give me a minute

@smanzi
Copy link

smanzi commented Nov 30, 2014

no prob, give me the "go"...

@dgrammatiko
Copy link
Contributor Author

go!

@dgrammatiko
Copy link
Contributor Author

Is looking good here!

@smanzi
Copy link

smanzi commented Nov 30, 2014

Yes, now code different and anyway @test success!

Copy link
Contributor

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.

Copy link
Contributor Author

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();

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@phproberto
Copy link
Contributor

Thanks. All seems ok now. We need to wait to travis so I'll go to sleep.

You did an awesome work tonight. Thanks!!

@smanzi
Copy link

smanzi commented Nov 30, 2014

again @test success!

@smanzi
Copy link

smanzi commented Nov 30, 2014

Good night, everybody! 😴

@dgrammatiko
Copy link
Contributor Author

Its time 💤

@Fedik
Copy link
Member

Fedik commented Nov 30, 2014

test
works good for me

@anibalsanchez
Copy link
Contributor

@test OK

  • New user,mandatory fields
  • User Modification, mandatory fields
  • Group deletion without users, Ok
  • Group deletion with users, standard alert, confirmation Yes, OK (group deleted)
  • Group deletion with users, standard alert, confirmation No, OK (group not deleted)

@Bakual Bakual added this to the Joomla! 3.4.0 milestone Dec 2, 2014
@Bakual Bakual closed this in fe29555 Dec 2, 2014
@Bakual
Copy link
Contributor

Bakual commented Dec 2, 2014

Merged into staging. Thanks!

@dgrammatiko dgrammatiko deleted the _form_jq_com_users branch December 2, 2014 21:16
@zero-24 zero-24 removed the RTC This Pull Request is Ready To Commit label Oct 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants