From 9f22d63b41a8801c8c9cef797e9260e4718596be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Drga?=
Date: Thu, 25 Jul 2024 15:53:30 +0200
Subject: [PATCH] Fixed form errors, updated the old ones
---
app/assets/javascripts/autoform_form.js | 57 ++++++++++---------
app/assets/javascripts/consultations_form.js | 19 +++++++
app/assets/javascripts/datahub_form.js | 24 ++++++++
.../javascripts/slovensko_sk_api_form.js | 25 ++++++++
.../services/consultations/index.html.erb | 11 +++-
app/views/services/datahub/index.html.erb | 11 +++-
.../services/slovensko_sk_api/index.html.erb | 11 +++-
7 files changed, 124 insertions(+), 34 deletions(-)
diff --git a/app/assets/javascripts/autoform_form.js b/app/assets/javascripts/autoform_form.js
index 317cc1a..e6b25fb 100644
--- a/app/assets/javascripts/autoform_form.js
+++ b/app/assets/javascripts/autoform_form.js
@@ -1,4 +1,19 @@
$(document).ready(function() {
+ var autoformError = $('#autoform-error').get(0);
+ if (autoformError) {
+ autoform.addCloseButtonListener(autoformError);
+
+ var emailInputField = $('#autoform-email').get(0);
+ emailInputField.addEventListener('click', function (){
+ autoform.removeErrors(autoformError)
+ });
+
+ var domainInputField = $('#autoform-domain').get(0);
+ domainInputField.addEventListener('click', function (){
+ autoform.removeErrors(autoformError)
+ });
+ }
+
$('#autoform-form').submit(function() {
if ($('#autoform-email').val() == '' || $('#autoform-domain').val() == '') {
$('#autoform-form-sent').hide();
@@ -29,33 +44,19 @@ $(document).ready(function() {
return true;
}
});
-
- var autoformError = $('#autoform-error').get(0);
- addCloseButtonListener(autoformError);
-
- var emailInputField = $('#autoform-email').get(0);
- emailInputField.addEventListener('click', function (){
- removeErrors(autoformError)
- });
-
- var domainInputField = $('#autoform-domain').get(0);
- domainInputField.addEventListener('click', function (){
- removeErrors(autoformError)
- });
});
-function addCloseButtonListener(node) {
- var closeButton = node.querySelector('.alert .close');
- closeButton.addEventListener("click", function (){
- removeErrors(node);
- });
-}
-
-function removeErrors(node) {
- $('#autoform-email').parent('.form-group').removeClass('has-error');
- $('#autoform-domain').parent('.form-group').removeClass('has-error');
- $('#' + node.id).hide();
-}
-
-
-
+var autoform = {
+ addCloseButtonListener: function(node) {
+ var closeButton = node.querySelector('.alert .close');
+ closeButton.addEventListener("click", function (){
+ autoform.removeErrors(node);
+ });
+ },
+
+ removeErrors: function(node) {
+ $('#autoform-email').parent('.form-group').removeClass('has-error');
+ $('#autoform-domain').parent('.form-group').removeClass('has-error');
+ $('#' + node.id).hide();
+ }
+};
\ No newline at end of file
diff --git a/app/assets/javascripts/consultations_form.js b/app/assets/javascripts/consultations_form.js
index 573ff3d..d8b0617 100644
--- a/app/assets/javascripts/consultations_form.js
+++ b/app/assets/javascripts/consultations_form.js
@@ -1,4 +1,14 @@
$(document).ready(function() {
+ var consultationsError = $('#consultations-error').get(0);
+ if (consultationsError) {
+ consultations.addCloseButtonListener(consultationsError);
+
+ var emailInputField = $('#consultations-email').get(0);
+ emailInputField.addEventListener('click', function (){
+ $('#' + consultationsError.id).hide();
+ });
+ }
+
$('#consultations-form').submit(function() {
if ($('#consultations-email').val() == '') {
$('#consultations-sent').hide();
@@ -18,3 +28,12 @@ $(document).ready(function() {
}
});
});
+
+var consultations = {
+ addCloseButtonListener: function(node) {
+ var closeButton = node.querySelector('.alert .close');
+ closeButton.addEventListener("click", function (){
+ $('#' + node.id).hide();
+ });
+ }
+};
\ No newline at end of file
diff --git a/app/assets/javascripts/datahub_form.js b/app/assets/javascripts/datahub_form.js
index 1e85c40..04598ce 100644
--- a/app/assets/javascripts/datahub_form.js
+++ b/app/assets/javascripts/datahub_form.js
@@ -1,4 +1,14 @@
$(document).ready(function() {
+ var datahubError = $('#datahub-error').get(0);
+ if (datahubError) {
+ datahub.addCloseButtonListener(datahubError);
+
+ var emailInputField = $('#datahub-email').get(0);
+ emailInputField.addEventListener('click', function (){
+ datahub.removeErrors(datahubError);
+ });
+ }
+
$('#datahub-form').submit(function() {
if ($('#datahub-email').val() == '') {
$('#datahub-form-sent').hide();
@@ -18,3 +28,17 @@ $(document).ready(function() {
}
});
});
+
+var datahub = {
+ addCloseButtonListener: function(node) {
+ var closeButton = node.querySelector('.alert .close');
+ closeButton.addEventListener("click", function (){
+ datahub.removeErrors(node);
+ });
+ },
+
+ removeErrors: function(node) {
+ $('#datahub-email').parent('.form-group').removeClass('has-error');
+ $('#' + node.id).hide();
+ }
+};
\ No newline at end of file
diff --git a/app/assets/javascripts/slovensko_sk_api_form.js b/app/assets/javascripts/slovensko_sk_api_form.js
index c664f79..810e7a1 100644
--- a/app/assets/javascripts/slovensko_sk_api_form.js
+++ b/app/assets/javascripts/slovensko_sk_api_form.js
@@ -1,4 +1,14 @@
$(document).ready(function() {
+ var skApiError = $('#sk-api-error').get(0);
+ if (skApiError) {
+ slovensko_sk_api.addCloseButtonListener(skApiError);
+
+ var emailInputField = $('#sk-api-email').get(0);
+ emailInputField.addEventListener('click', function (){
+ slovensko_sk_api.removeErrors(skApiError);
+ });
+ }
+
$('#sk-api-form').submit(function() {
if ($('#sk-api-email').val() == '') {
$('#sk-api-form-sent').hide();
@@ -18,3 +28,18 @@ $(document).ready(function() {
}
});
});
+
+
+var slovensko_sk_api = {
+ addCloseButtonListener: function(node) {
+ var closeButton = node.querySelector('.alert .close');
+ closeButton.addEventListener("click", function (){
+ slovensko_sk_api.removeErrors(node);
+ });
+ },
+
+ removeErrors: function(node) {
+ $('#sk-api-email').parent('.form-group').removeClass('has-error');
+ $('#' + node.id).hide();
+ }
+};
\ No newline at end of file
diff --git a/app/views/services/consultations/index.html.erb b/app/views/services/consultations/index.html.erb
index 0ab6354..815ca56 100644
--- a/app/views/services/consultations/index.html.erb
+++ b/app/views/services/consultations/index.html.erb
@@ -53,10 +53,17 @@
Nechajte nám Váš emailový kontakt alebo nám napíšte na ekosystem@slovensko.digital.
- <%= render 'services/share/flash_message', {type: :alert, message: 'Vyplňte prosím email a skúste znova.'} %>
+
+
+ <%= 'Vyplňte prosím email a skúste znova.' %>
+
diff --git a/app/views/services/datahub/index.html.erb b/app/views/services/datahub/index.html.erb
index c333eff..af4b4fb 100644
--- a/app/views/services/datahub/index.html.erb
+++ b/app/views/services/datahub/index.html.erb
@@ -134,10 +134,17 @@
- <%= render 'services/share/flash_message', {type: :alert, message: 'Vyplňte prosím email a skúste znova.'} %>
+
+
+ <%= 'Vyplňte prosím email a skúste znova.' %>
+
diff --git a/app/views/services/slovensko_sk_api/index.html.erb b/app/views/services/slovensko_sk_api/index.html.erb
index e4f9502..16cca0e 100644
--- a/app/views/services/slovensko_sk_api/index.html.erb
+++ b/app/views/services/slovensko_sk_api/index.html.erb
@@ -121,10 +121,17 @@
- <%= render 'services/share/flash_message', {type: :alert, message: 'Vyplňte prosím email a skúste znova.'} %>
+
+
+ <%= 'Vyplňte prosím email a skúste znova.' %>
+