Skip to content

[4.0] Showon init only once, public method Joomla.Showon.initialise()#32069

Merged
wilsonge merged 3 commits intojoomla:4.0-devfrom
Fedik:showon-once
Jan 27, 2021
Merged

[4.0] Showon init only once, public method Joomla.Showon.initialise()#32069
wilsonge merged 3 commits intojoomla:4.0-devfrom
Fedik:showon-once

Conversation

@Fedik
Copy link
Member

@Fedik Fedik commented Jan 17, 2021

Summary of Changes

Same as #32061
The code make sure that showon initialised only once, no mater how often Joomla.Showon.initilise was called.
Also add public Joomla.Showon.initilise (to be in sync with 3.10)

Testing Instructions

Apply path, run npm install
Make sure showon still works.

Example, go to global config change "Debug Language" on/off, should downup/hides "Language Display" field.
Also the field "Language Display" will have extra attribute data-showon-initialised

Actual result BEFORE applying this Pull Request

showon works,
the showon field do not have data-showon-initialised

Expected result AFTER applying this Pull Request

showon works,
the showon field do have data-showon-initialised attribute

// @todo refactor this, dry
this.showonFields.forEach((field) => {
// Set up only once
if (field.hasAttribute('data-showon-initialised')) {
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 change this to field.dataset.hasOwnProperty('showonInitialised')

Copy link
Member Author

Choose a reason for hiding this comment

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

in the end it the same, but use the attribute is more clear for "visual debuging" ;)

if (field.hasAttribute('data-showon-initialised')) {
return;
}
field.setAttribute('data-showon-initialised', '');
Copy link
Contributor

Choose a reason for hiding this comment

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

field.dataset.showonInitialised = '';

@Fedik Fedik changed the title [4.0] Showon init only once, public method Joomla.Showon.initilise() [4.0] Showon init only once, public method Joomla.Showon.initialise() Jan 17, 2021
@dgrammatiko
Copy link
Contributor

I have tested this item ✅ successfully on 1e2b0dd

@wilsonge this can be merged


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

@HLeithner
Copy link
Member

@Fedik
Copy link
Member Author

Fedik commented Jan 18, 2021

done

@ceford
Copy link
Contributor

ceford commented Jan 25, 2021

I have tested this item ✅ successfully on e28aae0

To be clear: it is the control-group div that contains data-showon-initialised.


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

@wilsonge wilsonge merged commit 566f6d1 into joomla:4.0-dev Jan 27, 2021
@wilsonge
Copy link
Contributor

Thanks!

@wilsonge wilsonge added this to the Joomla 4.0 milestone Jan 27, 2021
@Fedik Fedik deleted the showon-once branch January 28, 2021 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NPM Resource Changed This Pull Request can't be tested by Patchtester

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants