New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.0] Replace js alerts for joomla alerts #15315
Conversation
https://travis-ci.org/joomla/joomla-cms/jobs/222232149 Looks good to me 👍 and is working well. Can you fix the travis error above. The other ones are not realted to your PR. I'm going to open a new issue for that. |
@NunoLopes96 - that last commit you just made in incorrect. This is PHP, not JS ;) |
@NunoLopes96 in Order to fix the test you need to edit the test itself your code was correct before the last commit ;) |
Ok I'm sorry never used travis before I need to research first a little bit, any tip? |
@NunoLopes96 please check this file + line in your branch: https://github.com/NunoLopes96/joomla-cms/blob/replaceJSalerts/tests/unit/suites/libraries/cms/toolbar/JToolbarButtonTest.php#L126 There is the expeced value stored. So this value needs to be changed as we want to change the output. |
@zero-24 I just changed that, that error no longer appears on travis, thank you for the help |
I have tested this item ✅ successfully on 746f8d1 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15315. |
I have tested this item ✅ successfully on 746f8d1 The Joomla alert appears normally after clicking publish item with no item selected after the patch. Before patch:After patch:System informationJoomla! 4.0.0-dev This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15315. |
RTC after two successful tests. |
Please remove RTC label. You cannot simply change JText::script to JText::_ as look like JText::script has some code to deal with special character in string For example, with this change, you can edit the file , change administrator\language\en-GB\en-GB.lib_joomla.ini, change the language item JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST="Please first make a selection from the list." To: JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST="Please first ' make a selection from the list." (note the special character ' in the change string). You will get javascript error. Note that the original code works well with this special character in language string |
|
||
$cmd = "Joomla.submitbutton('" . $task . "');"; | ||
|
||
if ($list) | ||
{ | ||
$alert = "alert(Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'));"; | ||
$messages = "{'warning': ['" . $alert . "', '<h4>" . JText::_('WARNING') . "</h4>']}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you sure it will not fail when the translation contain the quote?
and why do not use Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use JText::script and do not do this trap, with hard mix of PHP and JavaScript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fedik Thank you for the tip, while using your advice I found that no '<h4>" . JText::_('WARNING') . "</h4>'
was required if I had a JText::script('WARNING');
$alert = JText::_('WARNING'); | ||
|
||
$expected = "\n<button onclick=\"if (document.adminForm.boxchecked.value == 0) { Joomla.renderMessages({'warning': ['JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST', '<h4>" | ||
. $alert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
I am against this. Please DO NO MERGE this! |
CSP?
On 15 Apr 2017 11:06 a.m., "Dimitri Grammatikogianni" < notifications@github.com> wrote:
I am against this.
There should not be any inline scripts in J4 in order to satisfy CSP
requirements.
So we have to create a toolbar.js file with the logic needed and then pass
form the PHP side the config options, e.g.
JFactory->getDocument()->addScriptOptions('Toolbar',
$optionsArray).
Please DO NO MERGE this!
It's not the right approach!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#15315 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABPH8W1W4nie8QvQ5Ds6PfUC2CeddN1Tks5rwJa9gaJpZM4M-JnG>
.
|
Thanks. I understand exactly your comment now. However you can have a CSP
that allows inline scripts.
…On 15 Apr 2017 12:57 p.m., "Dimitri Grammatikogianni" < ***@***.***> wrote:
CSP: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#15315 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABPH8XURxb3k_eU8vsjknQhSYWEeMwo-ks5rwLDCgaJpZM4M-JnG>
.
|
@@ -431,7 +431,7 @@ JLIB_HTML_MOVE_UP="Move Up" | |||
JLIB_HTML_NO_PARAMETERS_FOR_THIS_ITEM="There are no parameters for this item." | |||
JLIB_HTML_NO_RECORDS_FOUND="No records found." | |||
JLIB_HTML_PAGE_CURRENT_OF_TOTAL="Page %s of %s" | |||
JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST="Please first make a selection from the list." | |||
JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST="Please first ' make a selection from the list." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be here
Sorry, done |
Merged - thanks :) |
Summary of Changes
Replace the JS alert() for the Joomla alerts in standart buttons where are no boxes checked
Testing Instructions
Go Components -> Banners -> Banners
Without any box checked, hit publish item
Expected result
Also, I think the close button is white because the class is not completed, here is where the class is called:
https://github.com/joomla/joomla-cms/blob/4.0-dev/media/system/js/core.js#L333
Actual result
Documentation Changes Required
none