Skip to content

Conversation

@dgrammatiko
Copy link
Contributor

Pull Request for Issue # .

Summary of Changes

  • Code to ES6 (except sidebyside.js which is....)
  • Fixed some obvious bugs
  • Patched bootstrap-init.js to work with the js in the url (give a cookie to the one who had this brilliant idea)

Testing Instructions

@infograf768 you might be the only one here that knows what was broken, so please test and also provide some info for others to know how to test

Expected result

Modal opens

Actual result

Modal doesnt appear and also there was a console error

Documentation Changes Required

Hopefully not

})();
links.forEach(function (item) {
item.addEventListener('click', function (event) {
if (self !== top) {

Choose a reason for hiding this comment

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

Unexpected use of 'self' no-restricted-globals
Unexpected use of 'top' no-restricted-globals

});
})();
links.forEach(function (item) {
item.addEventListener('click', function (event) {

Choose a reason for hiding this comment

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

Unexpected function expression prefer-arrow-callback
Unexpected unnamed function func-names

}
});
})();
links.forEach(function (item) {

Choose a reason for hiding this comment

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

Unexpected unnamed function func-names
Unexpected function expression prefer-arrow-callback

links = [].slice.call(document.querySelectorAll('.select-link'));
if (Joomla.getOptions('modal-associations')) {
var fnName = Joomla.getOptions('modal-associations').func;
var links = [].slice.call(document.querySelectorAll('.select-link'));

Choose a reason for hiding this comment

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

Unexpected var, use let or const instead no-var
All 'var' declarations must be at the top of the function scope vars-on-top

var fnName = Joomla.getOptions('modal-associations').func,
links = [].slice.call(document.querySelectorAll('.select-link'));
if (Joomla.getOptions('modal-associations')) {
var fnName = Joomla.getOptions('modal-associations').func;

Choose a reason for hiding this comment

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

All 'var' declarations must be at the top of the function scope vars-on-top
Unexpected var, use let or const instead no-var

@@ -1,15 +1,20 @@
/**

Choose a reason for hiding this comment

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

Expected space or tab before '*/' in comment spaced-comment

}
else
{
} else {

Choose a reason for hiding this comment

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

Expected indentation of 12 spaces but found 6 tabs indent
Unexpected tab character no-tabs

} else {
el = document.getElementById(idFieldArr[1]).value;
}
var data_iframe = iframeTextArr[0] + el + iframeTextArr[2];

Choose a reason for hiding this comment

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

Expected indentation of 14 spaces but found 7 tabs indent
Unexpected tab character no-tabs
All 'var' declarations must be at the top of the function scope vars-on-top
Unexpected var, use let or const instead no-var
Identifier 'data_iframe' is not in camel case camelcase

el = idFieldArr;
} else {
el = document.getElementById(idFieldArr[1]).value;
}

Choose a reason for hiding this comment

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

Expected indentation of 14 spaces but found 7 tabs indent
Unexpected tab character no-tabs

if (typeof idFieldArr === 'object') {
el = idFieldArr;
} else {
el = document.getElementById(idFieldArr[1]).value;

Choose a reason for hiding this comment

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

Expected indentation of 16 spaces but found 8 tabs indent
Unexpected tab character no-tabs

}
});
}
});

Choose a reason for hiding this comment

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

Expected indentation of 2 spaces but found 1 tab indent
Unexpected tab character no-tabs

Joomla.hideAssociation(formControl, selectedLanguage);
}
});
}

Choose a reason for hiding this comment

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

Expected indentation of 4 spaces but found 2 tabs indent
Unexpected tab character no-tabs

// Else show the associations fields/buttons and hide the current selected language
Joomla.hideAssociation(formControl, selectedLanguage);
}
});

Choose a reason for hiding this comment

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

Expected indentation of 6 spaces but found 3 tabs indent
Unexpected tab character no-tabs

} else {
// Else show the associations fields/buttons and hide the current selected language
Joomla.hideAssociation(formControl, selectedLanguage);
}

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 4 tabs indent
Unexpected tab character no-tabs

Joomla.showAssociationMessage();
} else {
// Else show the associations fields/buttons and hide the current selected language
Joomla.hideAssociation(formControl, selectedLanguage);

Choose a reason for hiding this comment

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

Expected indentation of 10 spaces but found 5 tabs indent
Unexpected tab character no-tabs

// If associations existed, send a warning to the user
if (existsAssociations) {
Joomla.renderMessages({warning: [Joomla.JText._('JGLOBAL_ASSOCIATIONS_RESET_WARNING')]});
}

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 4 tabs indent
Unexpected tab character no-tabs


// If associations existed, send a warning to the user
if (existsAssociations) {
Joomla.renderMessages({warning: [Joomla.JText._('JGLOBAL_ASSOCIATIONS_RESET_WARNING')]});

Choose a reason for hiding this comment

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

Expected indentation of 10 spaces but found 5 tabs indent
Unexpected tab character no-tabs
A space is required after '{' object-curly-spacing
A space is required before '}' object-curly-spacing

});

// If associations existed, send a warning to the user
if (existsAssociations) {

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 4 tabs indent
Unexpected tab character no-tabs

}
});

// If associations existed, send a warning to the user

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 4 tabs indent
Unexpected tab character no-tabs

} else if (clear.click) {
clear.click();
}
});

Choose a reason for hiding this comment

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

Expected indentation of 8 spaces but found 4 tabs indent
Unexpected tab character no-tabs

}

// Call the modal clear button
const clear = document.getElementById(formControl + '_associations_' + languageCode + '_clear');

Choose a reason for hiding this comment

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

Unexpected string concatenation prefer-template

element.style.display = 'block';

// Check if there was an association selected for this language
if (!existsAssociations && document.getElementById(formControl + '_associations_' + languageCode + '_id').value !== '') {

Choose a reason for hiding this comment

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

Unexpected string concatenation prefer-template


let existsAssociations = false;

// For each language, remove the associations, ie, empty the associations fields and reset the buttons to Select/Create

Choose a reason for hiding this comment

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

Line 70 exceeds the maximum line length of 100 max-len

Joomla.showAssociationMessage();
} else {
// Hide only the associations for the current language
if (formControlLanguage) {

Choose a reason for hiding this comment

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

Unexpected if as the only statement in an else block no-lonely-if

const formControlLanguage = document.getElementById(formControl + '_language');

// Hide the associations tab if needed
if (parseInt(associationsEditOptions.hidden) === 1) {

Choose a reason for hiding this comment

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

Missing radix parameter radix


if (Joomla.getOptions('modal-associations')) {
const fnName = Joomla.getOptions('modal-associations').func;
const links = [].slice.call(document.querySelectorAll('.select-link'));

Choose a reason for hiding this comment

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

Multiple spaces found before '=' no-multi-spaces

'use strict';

document.addEventListener('DOMContentLoaded', () => {

Choose a reason for hiding this comment

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

Trailing spaces not allowed no-trailing-spaces

((Joomla, document) => {
'use strict';

document.addEventListener('DOMContentLoaded', () => {

Choose a reason for hiding this comment

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

Block must not be padded by blank lines padded-blocks

*/
Joomla.submitbutton = (pressbutton) => {
if (pressbutton === 'associations.purge') {
if (confirm(Joomla.JText._('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT'))) {

Choose a reason for hiding this comment

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

Unexpected use of 'confirm' no-restricted-globals

* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
Joomla.submitbutton = (pressbutton) => {

Choose a reason for hiding this comment

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

Expected to return a value at the end of arrow function consistent-return


links.forEach((item) => {
item.addEventListener('click', (event) => {
//eslint-disable-next-line no-restricted-globals

Choose a reason for hiding this comment

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

Expected exception block, space or tab after '//' in comment spaced-comment

Joomla = window.Joomla || {};

((Joomla, document) => {
'use strict';

Choose a reason for hiding this comment

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

Expected newline after "use strict" directive lines-around-directive

*/
Joomla.submitbutton = (pressbutton) => {
if (pressbutton === 'associations.purge') {
//eslint-disable-next-line no-restricted-globals

Choose a reason for hiding this comment

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

Expected exception block, space or tab after '//' in comment spaced-comment

* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
Joomla.submitbutton = (pressbutton) => {

Choose a reason for hiding this comment

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

Expected to return a value at the end of arrow function consistent-return

@infograf768
Copy link
Member

Original Issue is #18552

Test Unsuccessful:
The modal loads fine but it is empty.

Code comparison for menu item (debug ON)
3.8

function jSelectAssociation_jform_modalassociation(id) {
   target = document.getElementById("target-association");
   document.getElementById("target-association").src = target.getAttribute("data-editurl") + "&task=" + target.getAttribute("data-item") + ".edit" + "&id=" + id
	jQuery("#associationSelectjform_modalassociationModal").modal("hide");
}
jQuery(document).ready(function($) {
   $('#associationSelectjform_modalassociationModal').on('show.bs.modal', function() {
       $('body').addClass('modal-open');
       var modalBody = $(this).find('.modal-body');
       modalBody.find('iframe').remove();
       modalBody.prepend('<iframe class="iframe jviewport-height70" src="index.php?option=com_associations&amp;view=associations&amp;layout=modal&amp;tmpl=component&amp;forcedItemType=com_menus.item&amp;function=jSelectAssociation_jform_modalassociation&amp;forcedLanguage=' + document.getElementById('target-association').getAttribute('data-language') + '&amp;8da36713bef8d17c9e99f4bd1ebdedf7=1" name="Select Target" height="400px" width="800px"></iframe>');
   }).on('shown.bs.modal', function() {
       var modalHeight = $('div.modal:visible').outerHeight(true),
           modalHeaderHeight = $('div.modal-header:visible').outerHeight(true),
           modalBodyHeightOuter = $('div.modal-body:visible').outerHeight(true),
           modalBodyHeight = $('div.modal-body:visible').height(),
           modalFooterHeight = $('div.modal-footer:visible').outerHeight(true),
           padding = document.getElementById('associationSelectjform_modalassociationModal').offsetTop,
           maxModalHeight = ($(window).height()-(padding*2)),
           modalBodyPadding = (modalBodyHeightOuter-modalBodyHeight),
           maxModalBodyHeight = maxModalHeight-(modalHeaderHeight+modalFooterHeight+modalBodyPadding);
       var iframeHeight = $('.iframe').height();
       if (iframeHeight > maxModalBodyHeight){;
           $('.modal-body').css({'max-height': maxModalBodyHeight, 'overflow-y': 'auto'});
           $('.iframe').css('max-height', maxModalBodyHeight-modalBodyPadding);

Your PR

<div id="associationSelectjform_modalassociationModal" role="dialog" tabindex="-1" class="joomla-modal modal fade" data-backdrop="static" data-url="index.php?option=com_associations&amp;view=associations&amp;layout=modal&amp;tmpl=component&amp;forcedItemType=com_menus.item&amp;function=jSelectAssociation_jform_modalassociation&amp;forcedLanguage=' + document.getElementById('target-association').getAttribute('data-language') + '&amp;34e9e1234719b19bf400c121347c3d6a=1" data-iframe="&lt;iframe class=&quot;iframe&quot; src=&quot;index.php?option=com_associations&amp;amp;view=associations&amp;amp;layout=modal&amp;amp;tmpl=component&amp;amp;forcedItemType=com_menus.item&amp;amp;function=jSelectAssociation_jform_modalassociation&amp;amp;forcedLanguage=' + document.getElementById('target-association').getAttribute('data-language') + '&amp;amp;34e9e1234719b19bf400c121347c3d6a=1&quot; name=&quot;Select Target&quot; height=&quot;400px&quot; width=&quot;800px&quot;&gt;&lt;/iframe&gt;">

Remark in your PR the use of &amp;amp;

@infograf768
Copy link
Member

Also, can you integrate the changes
#21180
in this PR

@dgrammatiko
Copy link
Contributor Author

Modal restored:
screenshot 2018-07-19 at 12 20 22


links.forEach((item) => {
item.addEventListener('click', (event) => {
target.src = target.getAttribute("data-editurl") + '"&task="' + target.getAttribute("data-item") + ".edit" + "&id=" + parseInt(event.target.getAttribute('data-id'), 10);

Choose a reason for hiding this comment

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

Unexpected string concatenation prefer-template
Strings must use singlequote quotes
Unexpected string concatenation of literals no-useless-concat

'use strict';

document.addEventListener('DOMContentLoaded', () => {
const target = window.parent.document.getElementById("target-association");

Choose a reason for hiding this comment

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

Strings must use singlequote quotes

@infograf768
Copy link
Member

Thanks. It works fine now. Remains to add the same modifications as what has been done in #21180 to get correct contacts and newsfeeds associations fields.

@infograf768
Copy link
Member

will test it OK when conflict fixed.

@dgrammatiko
Copy link
Contributor Author

@infograf768 conflict resolved

@infograf768
Copy link
Member

I have tested this item ✅ successfully on 92a08ec


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

@laoneo laoneo added this to the Joomla 4.0 milestone Jul 19, 2018
@infograf768
Copy link
Member

I have tested this item ✅ successfully on 911b15f


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

@laoneo laoneo merged commit bd29849 into joomla:4.0-dev Jul 19, 2018
@laoneo
Copy link
Member

laoneo commented Jul 19, 2018

Good job!

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.

5 participants