? Pending

User tests: Successful: Unsuccessful:

avatar Ruud68
Ruud68
9 Oct 2017

Pull Request for Issue # #18285

Summary of Changes

set backdrop to static, disable (X) button and disable keyboard outside modal to prevent closing modal without executing the close logic.
Changed the close button (footer) to execute the plugin.cancel task

Testing Instructions

  1. [tab 1]open com_redirect
  2. [tab 2] open second tab with com_plugins and filter on 'redirect' plugin
  3. in [tab 2] enable the redirect plugin and disable the collect urls > save the plugin
  4. in [tab 1] in com_redirect click the 'Redirect System Plugin' link in the notice
  5. clicking the backdrop, 'X' and [Close] button will close the modal

Expected result

The plg_system_redirect should be checked in

Actual result

The plg_system_redirect is NOT checked in.
in [tab 2] press ctrl-f5 and you can see that although the modal in tab 1 is closed, the plugin is not checked in correct.


With patch applied:

  1. the 'X' is not displayed in the modal so cannot be used.
  2. the keyboard is disabled outside the modal and the backdrop is set to static, so the modal cannot be closed by using the keyboard or clicking outside the modal
  3. the [Close] button now correctly call the 'plugin.cancel' task and thereby correctly closing AND checking in the redirect plugin.

Documentation Changes Required

not that I know of.

avatar joomla-cms-bot joomla-cms-bot - change - 9 Oct 2017
Category Administration com_redirect
avatar Ruud68 Ruud68 - open - 9 Oct 2017
avatar Ruud68 Ruud68 - change - 9 Oct 2017
Status New Pending
avatar infograf768
infograf768 - comment - 10 Oct 2017

While testing this, I tried to normalise further that modal by adding a Save (apply) button, but it fails, i.e. Save also closes the modal.
Here is my patch. Can you look at what is missing?


diff --git a/administrator/components/com_plugins/views/plugin/tmpl/modal.php b/administrator/components/com_plugins/views/plugin/tmpl/modal.php
index 69d18a3..f1249d5 100644
--- a/administrator/components/com_plugins/views/plugin/tmpl/modal.php
+++ b/administrator/components/com_plugins/views/plugin/tmpl/modal.php
@@ -19,4 +19,5 @@
 ');
 ?>
+<button id="applyBtn" type="button" class="hidden" onclick="Joomla.submitbutton('plugin.apply');"></button>
 <button id="saveBtn" type="button" class="hidden" onclick="Joomla.submitbutton('plugin.save');"></button>
 <button id="closeBtn" type="button" class="hidden" onclick="Joomla.submitbutton('plugin.cancel');"></button>
diff --git a/administrator/components/com_redirect/views/links/tmpl/default.php b/administrator/components/com_redirect/views/links/tmpl/default.php
index 00d0cd0..7986aec 100644
--- a/administrator/components/com_redirect/views/links/tmpl/default.php
+++ b/administrator/components/com_redirect/views/links/tmpl/default.php
@@ -17,4 +17,6 @@
 JHtml::_('formbehavior.chosen', 'select');
 
+$uri       = JUri::getInstance();
+$return    = base64_encode($uri);
 $user      = JFactory::getUser();
 $listOrder = $this->escape($this->state->get('list.ordering'));
@@ -25,5 +27,5 @@
 		<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
 		<?php if ($this->redirectPluginId) : ?>
-			<?php $link = JRoute::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id=' . $this->redirectPluginId . '&tmpl=component&layout=modal'); ?>
+			<?php $link = JRoute::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id=' . $this->redirectPluginId . '&return=' . $return . '&tmpl=component&layout=modal'); ?>
 			<?php echo JHtml::_(
 				'bootstrap.renderModal',
@@ -32,10 +34,20 @@
 					'url'        => $link,
 					'title'      => JText::_('COM_REDIRECT_EDIT_PLUGIN_SETTINGS'),
-					'height'     => '400px',
-					'modalWidth' => '60',
-					'footer'     => '<button class="btn" data-dismiss="modal" aria-hidden="true">'
-						. JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</button>'
-						. '<button class="btn btn-success" data-dismiss="modal" aria-hidden="true" onclick="jQuery(\'#plugin' . $this->redirectPluginId . 'Modal iframe\').contents().find(\'#saveBtn\').click();">'
+					'height'      => '400px',
+					'width'       => '800px',
+					'bodyHeight'  => '70',
+					'modalWidth'  => '80',
+					'closeButton' => false,
+					'backdrop'    => 'static',
+					'keyboard'    => false,
+					'footer'     => '<button type="button" class="btn" data-dismiss="modal" aria-hidden="true"'
+						. ' onclick="jQuery(\'#plugin' . $this->redirectPluginId . 'Modal iframe\').contents().find(\'#closeBtn\').click();">'
+						. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
+						. '<button type="button" class="btn btn-primary" aria-hidden="true"'
+						. ' onclick="jQuery(\'#plugin' . $this->redirectPluginId . 'Modal iframe\').contents().find(\'#saveBtn\').click();">'
 						. JText::_("JSAVE") . '</button>'
+						. '<button type="button" class="btn btn-success" aria-hidden="true"'
+						. ' onclick="jQuery(\'#plugin' . $this->redirectPluginId . 'Modal iframe\').contents().find(\'#applyBtn\').click();">'
+						. JText::_("JAPPLY") . '</button>',
 				)
 			); ?>
avatar Ruud68
Ruud68 - comment - 10 Oct 2017

Hi, been testing and trying that yesterday. Run into the same issue that the save button when added closes the modal.
This is because (my best guess) the save function does a post of the form and a post closes the modal.
I have not sufficient javascript / jquery knowledge to fix that: that is the reason why I left it out in the first place.

So in short: help needed :)


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

avatar infograf768
infograf768 - comment - 10 Oct 2017

Also, I guess we do need to add a conditional
if ($user->authorise('core.edit', 'com_plugins')) etc.

avatar Ruud68
Ruud68 - comment - 10 Oct 2017

Agree but I think that (authorization check and Apply button) are out of scope for this commit which addresses the incorrect close behavior.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 28 Oct 2017

@Ruud68 can you please test again? I tested without PR and Step 4 and 5 works as expected (Plugin is enabled in Tab 1).

avatar Ruud68
Ruud68 - comment - 29 Oct 2017

@franz-wohlkoenig true, it enables the plugin, but that is not what this fix is fixing. It fixes the ability to close the modal and by doing that bypassing the proper close function: the plugin is checked out. That means that another administrator cannot handle it anymore

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 29 Oct 2017

If in that Scenario in Tab 1 the Redirect-Plugin is enabled even "Close" is used in Modal its a successfully Test?

avatar Ruud68
Ruud68 - comment - 29 Oct 2017

Hi, let me explain with video: https://office.onlinecommunityhub.nl/nextcloud/s/Aa94YsNtXY377vB

  1. close button, no checkin of plugin (plugin is checked out to super user)
  2. X , no checking of plugin
  3. click on backdrip (outside modal), no checkin of plugin
  4. then save and close button: Yeay, plugin is checked in.

After my patch:
1, close button > plugin correctly checked in
2. X > not possible (there is no X)
3. click on backdrop: disabled
4. click save and close > same as before

avatar dgt41
dgt41 - comment - 29 Oct 2017

@Ruud68 another way to solve this without removing the X button and forcing the backdrop is to setup a listener for the Bootstrap Modal hide event and then click on the cancel button on the modal Iframe. Something like:

$doc->addScriptDeclaration(
"jQuery('#plugin" . $this->redirectPluginId . "Modal').on('bs.modal.hide', function(e) {
     jQuery('#plugin" . $this->redirectPluginId . "Modal iframe').contents().find('#closeBtn').click();
});"
);
avatar Ruud68
Ruud68 - comment - 30 Oct 2017

@dgt41 I have considered that, but I 'decided' to standardize and use the same config for the modal as the edit article modal in the menu 'Single article'.
I am only utilizing the variables that are already present, so no need to add code (and maintain it).

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 31 Oct 2017 - Tested successfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 31 Oct 2017

I have tested this item successfully on fe1e7d6

Thanks for Patience, @Ruud68


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

avatar Ruud68
Ruud68 - comment - 31 Oct 2017

@franz-wohlkoenig Top!
Now waiting patiently for second test :)

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 12 Nov 2017

@infograf768 do you have Time for 2nd Test?


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

avatar infograf768
infograf768 - comment - 15 Nov 2017

To be normalized (even if we can't add Apply), the code still needs imho to be modified to get

+					'height'      => '400px',
+					'width'       => '800px',
+					'bodyHeight'  => '70',
+					'modalWidth'  => '80',
+					'closeButton' => false,
+					'backdrop'    => 'static',
+					'keyboard'    => false,
etc.
avatar Ruud68
Ruud68 - comment - 17 Nov 2017

Hi, as said before: this change is not about normalizing, but is a fix for a bug.
I agree that things need to be normalized, but that would then need investigation of what normal is, and things need to be tested on multiple devices (how do the height and width that are put here as an example behave on mobile devices, etc.
For me that is (way) beyond the scope of this 'quick' fix and should be addressed in a separate PR... or not :S

avatar infograf768
infograf768 - comment - 17 Nov 2017

While correcting a bug, if code has to be normalized at the same time, one should do it instead of creating a new PR. Cost is little and saves time for testers.
See
https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_content/models/fields/modal/article.php#L197-L218

avatar Ruud68
Ruud68 - comment - 19 Nov 2017

@infograf768 agree, but... that code limits the usage on mobile devices, so normalizing would not be an option for me. The way to go when normalizing is that it is normalized so that it will work cross device.
That (for me) is no little cost as that would involve looking at all modal code and all use cases / devices.

Anyway, the whole discussion regarding this simple patch (mind you, my first step to becoming a contributer) is taking so much time and attention that I could have normalized all modal code.
That is why I now stop putting time in this PR: feel free to test or not.

avatar infograf768 infograf768 - test_item - 19 Nov 2017 - Tested successfully
avatar infograf768
infograf768 - comment - 19 Nov 2017

I have tested this item successfully on fe1e7d6

I don't want to discourage you. Maintainers will decide. Test OK here.


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

avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Nov 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 19 Nov 2017

Ready to Commit after two successful tests.

avatar mbabker mbabker - change - 19 Nov 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-11-19 13:06:46
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 19 Nov 2017
avatar mbabker mbabker - merge - 19 Nov 2017
avatar Ruud68
Ruud68 - comment - 29 Nov 2017

@infograf768 Here you go: normalized and save (apply) button :)
#18913


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

Add a Comment

Login with GitHub to post a comment