? Success

User tests: Successful: Unsuccessful:

avatar dgt41
dgt41
8 Nov 2014

Executive summary

This PR converts the form validation on com_menus to use plain jquery (no mootools call on every form).
Also NO MORE INLINE SCRIPTS!

Testing

  1. Apply first PR #4888 (!important)
  2. Apply this PR
  3. In the admin area go to com_menus 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

Please also check these:
administrator/index.php?option=com_checkin should demonstrate multiselect without mt
administrator/index.php?option=com_users&view=mail should demonstrate form sent and validate without mt
administrator/index.php?option=com_modules should demonstrate multiselect and combobox without mt
http://localhost/administrator/index.php?option=com_admin&view=sysinfo should demonstrate highlighter.js without mt
Logout and log in to demonstrate the use of noframes without mt.

avatar dgt41 dgt41 - open - 8 Nov 2014
avatar jissues-bot jissues-bot - change - 8 Nov 2014
The description was changed
Labels Added: ?
avatar brianteeman brianteeman - change - 8 Nov 2014
Category JavaScript
avatar dgt41 dgt41 - change - 8 Nov 2014
The description was changed
avatar smanzi
smanzi - comment - 11 Nov 2014

@dgt41
Unable to test together with #4661
Tested alone, unable to select Menu Item Type from modal

avatar dgt41
dgt41 - comment - 11 Nov 2014

@smanzi fixed! Thanks!

avatar smanzi
smanzi - comment - 12 Nov 2014

@test success

@dgt41 still cannot test together with 4661 (com_patchtester limitation?)
It is (an it was) possible to create a menu entry without assigning a menu type. Should be fixed?

avatar anibalsanchez
anibalsanchez - comment - 13 Nov 2014

@test success

avatar roland-d roland-d - alter_testresult - 19 Nov 2014 - smanzi: Tested successfully
avatar roland-d roland-d - alter_testresult - 19 Nov 2014 - anibalsanchez: Tested successfully
avatar roland-d roland-d - change - 19 Nov 2014
Status Pending Ready to Commit
avatar roland-d
roland-d - comment - 19 Nov 2014

Moving to RTC as we have 2 successful tests.

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

avatar jissues-bot jissues-bot - change - 21 Nov 2014
Labels Added: ?
avatar dgt41
dgt41 - comment - 21 Nov 2014

@phproberto Also this one needs review dgt41@f26d63f

avatar Fedik
Fedik - comment - 21 Nov 2014

when tried to set a menu type Uncaught ReferenceError: setmenutype is not defined
also syntax error Unexpected token ) when modal opens

looks like method setmenutype in different scope or because syntax error :wink:

avatar infograf768 infograf768 - change - 21 Nov 2014
Labels Removed: ?
avatar infograf768
infograf768 - comment - 21 Nov 2014

There were changes here. Changing status to not RTC

avatar jissues-bot jissues-bot - change - 21 Nov 2014
Labels Added: ?
avatar dgt41
dgt41 - comment - 21 Nov 2014

@infograf768 Yes 3 views had to have some changes so we will end up with a consistent way of adding javascript code. This is what @phproberto asked in #5058. So I just updated this and #5046 to fulfill this request. The last commit in both indicates the changes!

avatar roland-d roland-d - alter_testresult - 21 Nov 2014 - smanzi: Not tested
avatar roland-d roland-d - alter_testresult - 21 Nov 2014 - anibalsanchez: Not tested
avatar roland-d roland-d - change - 21 Nov 2014
Status Ready to Commit Pending
avatar roland-d
roland-d - comment - 21 Nov 2014

Set status back to Pending as there are changes that needs testing.

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

avatar anibalsanchez
anibalsanchez - comment - 22 Nov 2014

@test success, on a brand new staging installation / diff can't be applied on J 3.3.6

Works much better than previous menu validation.

  • Tested trying to create an empty menu item, validation OK
  • Only filling a menu name, validation OK
  • Only filling a menu name and menu type assignment, validation OK

Minor issue, if Menu Item Type="Single Article", and article is not selected, it detects the field as mandatory, but the message does not show the field name: "Error Invalid field: "

avatar dgt41
dgt41 - comment - 22 Nov 2014

@anibalsanchez It is normal that will not apply to 3.3.6 because there was another PR #4517 from @Fedik Actually the Kudos here should go all to @Fedik I just wrapped it to <head>

avatar Fedik
Fedik - comment - 22 Nov 2014

Minor issue, if Menu Item Type="Single Article", and article is not selected, it detects the field as mandatory, but the message does not show the field name: "Error Invalid field: "

As I understand it related to validate.js ... the validation script cannot find the field label in some reason,
I think it not related to the current pull request, as it do nothing with it :wink:

avatar roland-d roland-d - alter_testresult - 22 Nov 2014 - anibalsanchez: Tested successfully
avatar roland-d roland-d - test_item - 22 Nov 2014 - Tested successfully
avatar roland-d
roland-d - comment - 22 Nov 2014

@test successful. No JS errors and all forms work as expected.

Moving to RTC as we have 2 successful tests.

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

avatar roland-d roland-d - change - 22 Nov 2014
Status Pending Ready to Commit
avatar Fedik
Fedik - comment - 22 Nov 2014

I would wait until someone confirm that wrap a simple function definition into jQuery.ready is a good idea.

Currently I see next potential b/c issue:
The extension use ready event for override Joomla.submitbutton, but as we also wrap it into ready the extension can stop working, because no guarantee that our Joomla.submitbutton will be defined before the override from the extension.

avatar dgt41
dgt41 - comment - 22 Nov 2014

@Fedik Aren’t the scripts (also the declarations) chained in series? If no changes are done in the array I don’t see that happening… Maybe I am wrong here

avatar Fedik
Fedik - comment - 22 Nov 2014

@dgt41 I mean next case:

//extension code
jQuery(document).ready(function() {
  // this will be defined first
  Joomla.submitbutton = functin(){ /* do something*/ }
});

// joomla code
jQuery(document).ready(function() {
  // this will override
  Joomla.submitbutton = ....
});

such thing can happens if extension call addScriptDeclaration($script) before it was called in our code.

and when we use it without ready:

// extension code
jQuery(document).ready(function() {
 // this will override
  Joomla.submitbutton = functin(){ /* do something*/ }
});

// joomla code
// this will be defined first
Joomla.submitbutton = ....
avatar dgt41
dgt41 - comment - 22 Nov 2014

I see your point, but I think is invalid because extensions code is always overriding the code in core.js. Theoretically for the ms that the core.js code is executed and our code that is wrapped in .ready() YES we have a problem, but in practice this will never happen because also the DOM is not complete, so no kind of interaction can take place in a blank page. Am I wrong?

avatar Fedik
Fedik - comment - 22 Nov 2014

I mean Joomla.submitbutton that added in menus/tmpl/default.php that already override the same function from core.js :smile:

never happen because also the DOM is not complete

ok, try execute next code (just copy in the index.php in <script> tag, or in simple html file and run):

var myCoolFunction;

// must be override (eg Extension  override Joomla.submitbutton)
jQuery(document).ready(function() {
  myCoolFunction = functin(){ console.log('I am override!'); }
});

// must be initial definition (eg Joomla.submitbutton code)
jQuery(document).ready(function() {
  myCoolFunction = functin(){ console.log('I am the first of the firsts!'); }
});

// run the function
jQuery(document).ready(function() {
 myCoolFunction();
});

and then another:

var myCoolFunction;

// must be override (eg Extension override)
jQuery(document).ready(function() {
  myCoolFunction = functin(){ console.log('I am override!'); }
});

// must be initial definition (eg Joomla code)
myCoolFunction = functin(){ console.log('I am the first of the firsts!'); }


// run the function
jQuery(document).ready(function() {
 myCoolFunction();
});

what you got? :wink:

Expected result is I am override! in browser console.

avatar dgt41
dgt41 - comment - 22 Nov 2014

Hmmm I see your point
First example should be:

        var myCoolFunction;

        // must be initial definition (eg Joomla.submitbutton code)
        jQuery(document).ready(function() {
            myCoolFunction = function(){ console.log('I am the first of the firs!'); }
        });

        // must be override (eg Extension  override Joomla.submitbutton)
        jQuery(document).ready(function() {
            myCoolFunction = function(){ console.log('I am override!'); }
        });


        // run the function
        jQuery(document).ready(function() {
            myCoolFunction();
        });

But again the initial Joomla code is not wrapped in .ready() so will never happen. Also I cannot imagine declaring multiple times the submit button in one component. Am I just thinking too narrow?

avatar Fedik
Fedik - comment - 22 Nov 2014

First example should be

yes right, but if the extension (I mean 3p extensions) run addScriptDeclaration before it executed in menus/tmpl/default.php then we will get a wrong result.

But again the initial Joomla code is not wrapped in .ready() so will never happen

no matters where was initial, in javascript you can override it 1000 times :smile:
In my example replace var myCoolFunction to:

var myCoolFunction = function(){console.log('I am initial')};

it will demonstrate initial :wink:

maybe I just bad explained :smile:

avatar anibalsanchez
anibalsanchez - comment - 22 Nov 2014

@Fedik A race condition is very rare in this com_menus case. If we expect several competing submitbutton functions, all functions would have to be ready to call a previous submitbutton to avoid conflicts and run all of them.

In practice, components just assign Joomla.submitbutton at any time. I think it is safe to keep with the current style.

avatar dgt41
dgt41 - comment - 22 Nov 2014

@Fedik @anibalsanchez Stupid question but I have to ask: In 3.3.6 if you were about to override the joomla.submitbutton how will you do it? You have the option to add the script through addScriptDeclaration() but it will end up in <head> and the current code is inline script. So in 3.3.6 you had to make sure that DOM was parsed before you replace the function, so you have to use .ready() or domready on mootools. Am I right on this? If that’s the case then I don’t see a problem here ????

avatar Fedik
Fedik - comment - 22 Nov 2014

@dgt41 in 3.3.6 you can make it in the custom field or in the system plugin, using addScriptDeclaration

had to make sure that DOM was parsed

not really, you had to make sure that your override will be after the Joomla definition

the browser execute javascript when the parser found it, no matter whether DOM fully parsed or not

avatar anibalsanchez
anibalsanchez - comment - 22 Nov 2014

@dgt41 According to the loading order, core.js defines default Joomla.submitbutton. Following script files or inline code can define new submitbutton functions in anyway. No relation with DOM definition.

avatar Fedik
Fedik - comment - 22 Nov 2014

@anibalsanchez I just not very liked idea: wrap a simple function definition into jQuery.ready :wink:

avatar dgt41
dgt41 - comment - 22 Nov 2014

Honestly I am confused here. We have the initial definition in core.js and then we override it (either with .ready() or without, in this particular occasion with .ready(). Is there a reason to override it again? This is what are we talking about? Or the case that core.js will not be overridden?

avatar Fedik
Fedik - comment - 22 Nov 2014

@dgt41 I just tried to explain that use .ready() here can make problem for someone who already use ready() for make the override, maybe I am too picky :smile:

anyway the last word not after me, so let's make some rest :tropical_drink:

avatar anibalsanchez
anibalsanchez - comment - 22 Nov 2014

In my opinion, it is perfectly fine to override Joomla.submitbutton in any way, either in plain inline script, in a JS file, or using .ready().

There is no other style guideline or general definition.

cc3c891 30 Nov 2014 avatar dgt41 fixes
3a3b094 30 Nov 2014 avatar dgt41 fixes
387a8a2 30 Nov 2014 avatar dgt41 CS
b0e15e1 30 Nov 2014 avatar dgt41 JS CS
avatar dgt41
dgt41 - comment - 30 Nov 2014

@smanzi @anibalsanchez @Fedik Can you verify that nothing is broken here?

avatar smanzi
smanzi - comment - 30 Nov 2014

@dgt41 no problems creating/editing menu items. Is that enough?

avatar dgt41
dgt41 - comment - 30 Nov 2014

@smanzi Thanks Sergio, if menu types are also not throwing any errors that should be enough!

avatar smanzi
smanzi - comment - 30 Nov 2014

@dgt41 no problem with menu types either: @test success
Can you IM me on Skype when you have a minute? tnxs!

avatar Fedik
Fedik - comment - 30 Nov 2014

test
it still works :smile:
all good, but

jQuery(document).ready(function (){
    Joomla.submitbutton = function(task, type){
....

still here :stuck_out_tongue_closed_eyes:

avatar dgt41
dgt41 - comment - 30 Nov 2014

@Fedik but this is your code ????

avatar dgt41
dgt41 - comment - 30 Nov 2014

@Fedik Missed this one sorry ????

avatar Fedik
Fedik - comment - 30 Nov 2014

test
all good :wink:

avatar Fedik Fedik - test_item - 30 Nov 2014 - Tested successfully
avatar smanzi
smanzi - comment - 30 Nov 2014

You still have jQuery(document).ready(function ($){ at line 27 of administrator/components/com_menus/views/item/tmpl/edit.php - Expected?

avatar dgt41
dgt41 - comment - 30 Nov 2014

@smanzi There is a jquery ajax call there, so it is ok!

avatar smanzi
smanzi - comment - 30 Nov 2014

.. and item/tmpl/edit_modules.php

avatar dgt41
dgt41 - comment - 30 Nov 2014

Can you also confirm that #5042 and #5058 are still good to go?

avatar dgt41
dgt41 - comment - 30 Nov 2014

@sergio done!

avatar smanzi
smanzi - comment - 30 Nov 2014

#5042 OK (changed site name) #5058 OK (added user)

avatar smanzi
smanzi - comment - 30 Nov 2014

@dgt41: how can I test item/tmpl/edit_modules.php by itself?

avatar Fedik
Fedik - comment - 30 Nov 2014

please revert @ad2301a as it important there, to wait when DOM is ready before bind the clic event

avatar Fedik
Fedik - comment - 30 Nov 2014

:+1:

avatar smanzi
smanzi - comment - 30 Nov 2014

@dgt41 & @Fedik We should be all-set with this, right?

avatar dgt41
dgt41 - comment - 30 Nov 2014

Sorry carried away ????

avatar smanzi
smanzi - comment - 30 Nov 2014

my fault! :-1:

avatar anibalsanchez
anibalsanchez - comment - 1 Dec 2014

@test success

I have manually applied this file administrator/components/com_menus/views/item/tmpl/edit_modules.php on J 3.4 Alpha.... it only have some spaces x tabs changes, but the diff file can't be applied with Eclipse ... weird.

avatar anibalsanchez anibalsanchez - test_item - 1 Dec 2014 - Tested successfully
avatar roland-d
roland-d - comment - 1 Dec 2014

@anibalsanchez I just tested applying this PR via the command line and no errors there. Still a mystery :)

avatar Bakual Bakual - close - 2 Dec 2014
avatar zero-24 zero-24 - close - 2 Dec 2014
avatar Bakual Bakual - change - 2 Dec 2014
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2014-12-02 20:08:33
avatar Bakual
Bakual - comment - 2 Dec 2014

Merged into staging. Thanks!

avatar zero-24 zero-24 - change - 14 Oct 2015
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment