[process] Hide buttons when there's no exactly 1 selected record
authorAsier Lostalé <asier.lostale@openbravo.com>
Wed, 12 Jan 2011 17:37:50 +0100
changeset 9736 beff16ac0034
parent 9735 271dd023d1c8
child 9737 078027b29e33
[process] Hide buttons when there's no exactly 1 selected record
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js	Wed Jan 12 16:41:12 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js	Wed Jan 12 17:37:50 2011 +0100
@@ -93,19 +93,20 @@
     }
   },
   
-  refresh: function(record) {
-    if (!record){
+  refresh: function(record, hide) {
+    if (hide || !record) {
+      this.hide();
       return;
     }
     
+    //TODO: implement display/read only logic
+    this.show();
+    
     var label = this.labelValue[record[this.property]];
     if (!label){
       label = this.title;
     }
     this.setTitle(label);
-    
-   // console.log('currentVAlue'+record[this.property]+'r:',record);
-    
   }
   
 });
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js	Wed Jan 12 16:41:12 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js	Wed Jan 12 17:37:50 2011 +0100
@@ -560,10 +560,11 @@
   //
   refreshToolbarButtons: function() {
     var buttons = this.getRightMembers();
-    //console.log('sel records: '+this.view.viewGrid.getSelectedRecords().length);
+    var hideAllButtons = this.view.viewGrid.getSelectedRecords().length !== 1;
+    
     for (var i = 0; i < buttons.length; i++){
       if (buttons[i].refresh){
-        buttons[i].refresh(this.view.getCurrentValues());
+        buttons[i].refresh(this.view.getCurrentValues(), hideAllButtons);
       }
     }
   },