? ? Pending

User tests: Successful: Unsuccessful:

avatar chmst
chmst
17 Feb 2020

Summary of Changes

Take loading the script for showon fields out of the foreach loop

Testing Instructions

Go to a view with showon fields, i.e. com_config.
Showon fields must work before and after the patch.

avatar chmst chmst - open - 17 Feb 2020
avatar chmst chmst - change - 17 Feb 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 17 Feb 2020
Category Layout
avatar chmst chmst - change - 17 Feb 2020
Labels Added: ?
avatar brianteeman
brianteeman - comment - 17 Feb 2020

aren't you now loading it even if there are no showon fields?

avatar chmst
chmst - comment - 17 Feb 2020

Yes, but in every view is at least one.


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

avatar richard67
richard67 - comment - 18 Feb 2020

Yes, but in every view is at least one.

@chmst Is this granted forever, or may this change in future? ;-)

avatar brianteeman
brianteeman - comment - 18 Feb 2020

Isnt this the exact use case that @Fedik introduced web assets for

avatar richard67
richard67 - comment - 18 Feb 2020

@brianteeman Not sure if I understand right: You mean web assets are clever enough to handle multiple calls for the same asset so it is included only once, so this PR would not be necessary?

avatar brianteeman
brianteeman - comment - 18 Feb 2020
avatar Fedik
Fedik - comment - 18 Feb 2020

btw, "showon" already exist as an WebAsset item, you can just replace call:

HTMLHelper::_('script', 'system/showon.min.js', array('version' => 'auto', 'relative' => true));

to:

$wa->useScript('showon');

and somwhere at top of file:

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();

The method $wa->useScript() may be called 100 times, it will load the requested script only once, it does not cost performance compared to HTMLHelper::_('script') that will search for the script file on each call.

avatar chmst
chmst - comment - 18 Feb 2020

Thank you @Fedik. Woud it no be better to load this script in the backend generally? So that no developer must load it if he makes a showon field in her extension?

avatar Fedik
Fedik - comment - 18 Feb 2020

it will work, but I would prefer to load it only when it need

avatar chmst
chmst - comment - 18 Feb 2020

I am confused about the whole showon stuff.
https://github.com/joomla/joomla-cms/blob/4.0-dev/layouts/joomla/form/renderfield.php#L26

This param "enableShowon" seems to be unknow in the system.

avatar joomla-cms-bot joomla-cms-bot - change - 21 Feb 2020
Category Layout Front End com_contact com_users Layout
avatar chmst
chmst - comment - 21 Feb 2020

Changed loading showon.js as proposed by @Fedik.
Deleted loading jQuery.

avatar lefabdu51
lefabdu51 - comment - 25 Feb 2020

I have tested this item successfully on 61bb7aa


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

avatar lefabdu51 lefabdu51 - test_item - 25 Feb 2020 - Tested successfully
avatar jwaisner
jwaisner - comment - 28 Feb 2020

I have tested this item successfully on 61bb7aa


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

avatar jwaisner jwaisner - test_item - 28 Feb 2020 - Tested successfully
avatar jwaisner jwaisner - change - 28 Feb 2020
Status Pending Ready to Commit
avatar jwaisner
jwaisner - comment - 28 Feb 2020

RTC


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

avatar chmst chmst - change - 28 Feb 2020
Labels Added: ?
avatar chmst chmst - change - 2 Mar 2020
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2020-03-02 11:38:29
Closed_By chmst
avatar chmst chmst - close - 2 Mar 2020
avatar richard67
richard67 - comment - 2 Mar 2020

@chmst Why closing?

avatar chmst
chmst - comment - 25 Mar 2020

Sorry, this was a mistake, can you re-open?

avatar brianteeman
brianteeman - comment - 25 Mar 2020

if you have deleted your branch then it cant be reopened

Add a Comment

Login with GitHub to post a comment