From 65424c294446a6fb96d0ff2554d46fbe78e41b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Tue, 2 May 2023 01:03:39 +0200 Subject: [PATCH] RVRNEXT-26 show confirmation modal before deleting something --- public/static/css/rvr.css | 2 ++ public/static/js/rvr.js | 26 +++++++++++++++++++ views/account/account.php | 2 +- views/communities/community_currencies.php | 6 ++--- views/communities/community_edit.php | 2 +- views/communities/community_members.php | 6 ++--- views/communities/currency_exchange_rates.php | 6 ++--- views/communities/transaction_edit.php | 4 +-- 8 files changed, 41 insertions(+), 13 deletions(-) diff --git a/public/static/css/rvr.css b/public/static/css/rvr.css index 8d30b86..89982ea 100644 --- a/public/static/css/rvr.css +++ b/public/static/css/rvr.css @@ -238,6 +238,7 @@ button.noRightRadius, a.button.noRightRadius { button.gray, a.button.gray { background-color: #808080; + color: #ffffff; } button.gray:enabled:hover, button.gray:enabled:focus, a.button.gray:hover, a.button.gray:focus { @@ -246,6 +247,7 @@ button.gray:enabled:hover, button.gray:enabled:focus, a.button.gray:hover, a.but button.red, a.button.red { background-color: #aa5e5e; + color: #ffffff; } button.red:enabled:hover, button.red:enabled:focus, a.button.red:hover, a.button.red:focus { diff --git a/public/static/js/rvr.js b/public/static/js/rvr.js index ccf30b6..b0da778 100644 --- a/public/static/js/rvr.js +++ b/public/static/js/rvr.js @@ -88,6 +88,28 @@ var RVR = { } }, + setOnclickForFormConfirmation: function (button) { + button.onclick = function(e) { + e.preventDefault(); + + var self = this; + + RVR.showModalWithContent('Confirmation', this.dataset.confirmation, [ + { + type: 'button', + text: self.textContent, + classNames: ['red'], + onclick: function() { + var event = new Event('submit', {'bubbles': true, 'cancelable': true}); + self.form.dispatchEvent(event); + + RVR.hideModal(); + } + } + ]); + }; + }, + showModal: function (id) { document.getElementById(id).style.visibility = 'visible'; document.getElementById('cover').style.visibility = 'visible'; @@ -234,6 +256,10 @@ var RVR = { if (form.dataset.observeInputs) { RVR.observeInputsInForm(form, form.dataset.observeInputs.split(',')); } + + if (form.elements['submit_button'] && form.elements['submit_button'].dataset.confirmation) { + RVR.setOnclickForFormConfirmation(form.elements['submit_button']); + } } document.getElementById('cover').onclick = function () { diff --git a/views/account/account.php b/views/account/account.php index 10eb87a..128e14e 100644 --- a/views/account/account.php +++ b/views/account/account.php @@ -34,7 +34,7 @@

- +
diff --git a/views/communities/community_currencies.php b/views/communities/community_currencies.php index 5b2f5ea..6e92174 100644 --- a/views/communities/community_currencies.php +++ b/views/communities/community_currencies.php @@ -26,9 +26,9 @@ - + getId() !== $community->getMainCurrencyId()): ?> - + @@ -42,7 +42,7 @@ - + diff --git a/views/communities/community_edit.php b/views/communities/community_edit.php index 6614a0e..b7b7cee 100644 --- a/views/communities/community_edit.php +++ b/views/communities/community_edit.php @@ -23,7 +23,7 @@

- +
diff --git a/views/communities/community_members.php b/views/communities/community_members.php index 4646804..214a72b 100644 --- a/views/communities/community_members.php +++ b/views/communities/community_members.php @@ -32,8 +32,8 @@ - + @@ -47,7 +47,7 @@ - + diff --git a/views/communities/currency_exchange_rates.php b/views/communities/currency_exchange_rates.php index c17e82d..53e885f 100644 --- a/views/communities/currency_exchange_rates.php +++ b/views/communities/currency_exchange_rates.php @@ -32,8 +32,8 @@ - + getExchangeRate() ?> @@ -51,7 +51,7 @@ - + diff --git a/views/communities/transaction_edit.php b/views/communities/transaction_edit.php index 7539303..9193e0e 100644 --- a/views/communities/transaction_edit.php +++ b/views/communities/transaction_edit.php @@ -41,9 +41,9 @@

- + - +