Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/284532

Change subject: Remove errors when things look good
......................................................................

Remove errors when things look good

Just a start, works with amount error individually or personal
fields as a group.  When we rewrite validation, we can remove
personal field error messages individually.

Bug: T112323
Change-Id: Ie23556ced899f3f0d7c63aad0396bbc4df00450b
---
M gateway_common/gateway.adapter.php
M gateway_forms/mustache/index.html.mustache
M modules/js/ext.donationInterface.validation.js
3 files changed, 21 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/32/284532/1

diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 609d7ef..2a5a653 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -3670,5 +3670,6 @@
        public function setClientVariables( &$vars ) {
                $vars['wgDonationInterfacePriceFloor'] = $this->getGlobal( 
'PriceFloor' );
                $vars['wgDonationInterfacePriceCeiling'] = $this->getGlobal( 
'PriceCeiling' );
+               $vars['wgDonationInterfaceErrors'] = $this->getAllErrors();
        }
 }
diff --git a/gateway_forms/mustache/index.html.mustache 
b/gateway_forms/mustache/index.html.mustache
index 309ca82..ea57e55 100644
--- a/gateway_forms/mustache/index.html.mustache
+++ b/gateway_forms/mustache/index.html.mustache
@@ -8,7 +8,7 @@
                <td id="donate" valign="top">
                        <div id="greenBackground" class="">
                                {{> no_script }}
-                               <div id="topError" 
class="creditcard-error-msg">{{# errors }}<p class="error">{{{ message 
}}}</p>{{/ errors }}</div>
+                               <div id="topError" 
class="creditcard-error-msg">{{# errors }}<p class="error" data-field="{{ key 
}}">{{{ message }}}</p>{{/ errors }}</div>
 
                        <form name="payment" id="payment-form" method="post" 
action="{{ action }}">
                                <div id="payment_gateway-personal-info">
diff --git a/modules/js/ext.donationInterface.validation.js 
b/modules/js/ext.donationInterface.validation.js
index 0ba984e..1fb9b7f 100644
--- a/modules/js/ext.donationInterface.validation.js
+++ b/modules/js/ext.donationInterface.validation.js
@@ -6,8 +6,25 @@
 ( function ( $, mw ) {
        var di = mw.donationInterface = {};
 
+       function validateAmount() {
+               var result = window.validateAmount();
+               if ( result ) {
+                       $( 'p.error[data-field=amount]' ).remove();
+               }
+               return result;
+       }
+
+       function validateForm() {
+               var result = window.validate_form();
+               if ( result ) {
+                       // Assuming all errors are fixed
+                       $( 'p.error' ).remove();
+               }
+               return result;
+       }
+
        di.validation = {
-               validateAmount: window.validateAmount,
-               validateForm: window.validate_form
+               validateAmount: validateAmount,
+               validateForm: validateForm
        };
 } )( jQuery, mediaWiki );

-- 
To view, visit https://gerrit.wikimedia.org/r/284532
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie23556ced899f3f0d7c63aad0396bbc4df00450b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to