diff --git a/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php b/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php index d253cd3..13627d5 100644 --- a/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php +++ b/administrator/components/com_patchtester/PatchTester/View/Pulls/tmpl/default_items.php @@ -66,10 +66,10 @@ foreach ($this->items as $i => $item) : applied) : ?> + data-task="revert" data-id="applied; ?>"> + data-task="apply" data-id="pull_id; ?>"> diff --git a/media/com_patchtester/js/patchtester.js b/media/com_patchtester/js/patchtester.js index 2f80987..a2f3c29 100644 --- a/media/com_patchtester/js/patchtester.js +++ b/media/com_patchtester/js/patchtester.js @@ -10,9 +10,7 @@ if (typeof Joomla === 'undefined') { } document.addEventListener("DOMContentLoaded", function (event) { - var submitPatch = document.querySelectorAll(".submitPatch"); - var pullIdForm = document.querySelector("#pull_id"); /** * EventListener which listens on submitPatch Button, @@ -24,10 +22,35 @@ document.addEventListener("DOMContentLoaded", function (event) { submitPatch.forEach(function (element) { element.addEventListener("click", function (event) { var currentTarget = event.currentTarget; - var data = currentTarget.dataset.task.split("-"); + var task = currentTarget.dataset.task + var id = currentTarget.dataset.id - pullIdForm.value = data[1]; - Joomla.submitform(data[0]); + PatchTester.submitpatch(task, id); }); }); }); + +!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);