31
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-06-10 09:12:22 +00:00

Restore warning message and clean up code #236

This commit is contained in:
Roland Dalmulder 2020-03-21 11:26:42 +01:00
parent fa314fbcc0
commit fe536a49b7
No known key found for this signature in database
GPG Key ID: FD49814C56AE3AF9
2 changed files with 30 additions and 7 deletions

View File

@ -66,10 +66,10 @@ foreach ($this->items as $i => $item) :
<td class="text-center"> <td class="text-center">
<?php if ($item->applied) : ?> <?php if ($item->applied) : ?>
<button type="button" class="btn btn-sm btn-success submitPatch" <button type="button" class="btn btn-sm btn-success submitPatch"
data-task="revert-<?php echo (int) $item->applied; ?>"><?php echo Text::_('COM_PATCHTESTER_REVERT_PATCH'); ?></button> data-task="revert" data-id="<?php echo (int) $item->applied; ?>"><?php echo Text::_('COM_PATCHTESTER_REVERT_PATCH'); ?></button>
<?php else : ?> <?php else : ?>
<button type="button" class="btn btn-sm btn-primary submitPatch" <button type="button" class="btn btn-sm btn-primary submitPatch"
data-task="apply-<?php echo (int) $item->pull_id; ?>"><?php echo Text::_('COM_PATCHTESTER_APPLY_PATCH'); ?></button> data-task="apply" data-id="<?php echo (int) $item->pull_id; ?>"><?php echo Text::_('COM_PATCHTESTER_APPLY_PATCH'); ?></button>
<?php endif; ?> <?php endif; ?>
</td> </td>
</tr> </tr>

View File

@ -10,9 +10,7 @@ if (typeof Joomla === 'undefined') {
} }
document.addEventListener("DOMContentLoaded", function (event) { document.addEventListener("DOMContentLoaded", function (event) {
var submitPatch = document.querySelectorAll(".submitPatch"); var submitPatch = document.querySelectorAll(".submitPatch");
var pullIdForm = document.querySelector("#pull_id");
/** /**
* EventListener which listens on submitPatch Button, * EventListener which listens on submitPatch Button,
@ -24,10 +22,35 @@ document.addEventListener("DOMContentLoaded", function (event) {
submitPatch.forEach(function (element) { submitPatch.forEach(function (element) {
element.addEventListener("click", function (event) { element.addEventListener("click", function (event) {
var currentTarget = event.currentTarget; var currentTarget = event.currentTarget;
var data = currentTarget.dataset.task.split("-"); var task = currentTarget.dataset.task
var id = currentTarget.dataset.id
pullIdForm.value = data[1]; PatchTester.submitpatch(task, id);
Joomla.submitform(data[0]);
}); });
}); });
}); });
!function (Joomla, window, document) {
'use strict';
window.PatchTester = {
/**
* Process the patch action
*
* @param {String} task The task to perform
* @param {Number} id The item ID
*/
submitpatch: function (task, id) {
var idField = document.getElementById('pull_id');
idField.value = id;
Joomla.submitform(task);
}
};
Joomla.submitbutton = function (task) {
if (task !== 'reset' || confirm(Joomla.JText._('COM_PATCHTESTER_CONFIRM_RESET', 'Resetting will attempt to revert all applied patches and removes all backed up files. This may result in a corrupted environment. Are you sure you want to continue?'))) {
Joomla.submitform(task);
}
};
}(Joomla, window, document);