# HG changeset patch
# User Mario Castello <mario.castello@peoplewalking.com>
# Date 1490975805 21600
#      vie mar 31 09:56:45 2017 -0600
# Node ID 8e7258fcfa725e57ac70ca7a58fe256ec47858b7
# Parent  1e9b8370df59bf2d974efe40530dea156069657f
Fixed issue 0035646: Click several times in Gift cards selector is allowed in hgvol

- Added new function disableFilterButtons to disable the filters buttons in search action
- Added name for filters buttons
- Call the function in the search process for disabled/enabled the filters buttons during the execution process

diff --git a/web/org.openbravo.retail.giftcards/js/components/GiftCardSearchDialog.js b/web/org.openbravo.retail.giftcards/js/components/GiftCardSearchDialog.js
--- a/web/org.openbravo.retail.giftcards/js/components/GiftCardSearchDialog.js
+++ b/web/org.openbravo.retail.giftcards/js/components/GiftCardSearchDialog.js
@@ -33,6 +33,7 @@
           style: 'display: table-cell;',
           components: [{
             kind: 'OB.UI.SmallButton',
+            name: 'clearButton',
             classes: 'btnlink-gray btn-icon-small btn-icon-clear',
             style: 'width: 100px; margin: 0px 5px 8px 19px;',
             ontap: 'clearAction'
@@ -41,6 +42,7 @@
           style: 'display: table-cell;',
           components: [{
             kind: 'OB.UI.SmallButton',
+            name: 'searchButton',
             classes: 'btnlink-yellow btn-icon-small btn-icon-search',
             style: 'width: 100px; margin: 0px 0px 8px 5px;',
             ontap: 'searchAction'
@@ -52,6 +54,10 @@
       this.$.filterText.setValue('');
       this.doClearAction();
     },
+    disableFilterButtons: function (value) {
+      this.$.searchButton.setDisabled(value);
+      this.$.clearButton.setDisabled(value);
+    },
     searchAction: function () {
       this.doSearchAction({
         filter: '%' + this.$.filterText.getValue() + '%'
@@ -143,10 +149,15 @@
       this.prsList.reset();
       return true;
     },
+    disableFilters: function (value) {
+      this.$.body.$.listgiftcards.$.theader.$.searchHeader.disableFilterButtons(value);
+    },
     searchAction: function (inSender, inEvent) {
 
       var me = this;
 
+      me.disableFilters(true);
+
       this.$.body.$.listgiftcards.$.tempty.hide();
       this.$.body.$.listgiftcards.$.tbody.hide();
       this.$.body.$.listgiftcards.$.tlimit.hide();
@@ -158,10 +169,12 @@
       }, function (result) {
         me.$.body.$.renderLoading.hide();
         me.prsList.reset(result);
+        me.disableFilters(false);
       }, function (error) {
         me.$.body.$.renderLoading.hide();
         me.gcsList.reset();
         me.$.body.$.listgiftcards.$.tempty.show();
+        me.disableFilters(false);
         var msgsplit = (error.exception.message || 'GCNV_ErrorGenericMessage').split(':');
         me.doShowPopup({
           popup: 'GCNV_UI_Message',
