details:   /erp/devel/pi/rev/75564115c2c2
changeset: 12027:75564115c2c2
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri May 06 12:17:55 2011 +0200
summary:   Fixes issue 16297: I cannot open the date picker using the keyboard, 
Fixes issue 16314: Keyboard operation for date range filter popup

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
                                                      |  29 ++-
 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-form-styles.js
 |  97 ++++-----
 2 files changed, 63 insertions(+), 63 deletions(-)

diffs (198 lines):

diff -r 764f71e47b7a -r 75564115c2c2 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
   Fri May 06 12:16:31 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
   Fri May 06 12:17:55 2011 +0200
@@ -663,23 +663,27 @@
   initWidget: function() {
     this.Super('initWidget', arguments);
     this.rangeForm.setFocusItem(this.rangeItem);
-  },
+   },
   
   show: function() {
     this.Super('show', arguments);
+    this.rangeForm.items[0].fromField.calculatedDateField.canFocus = false;
+    this.rangeForm.items[0].toField.calculatedDateField.canFocus = false;
+    this.rangeForm.items[0].fromField.valueField.focusInItem();
     this.rangeForm.focus();
   },
   
   // trick: overridden to let the ok and clear button change places
   addAutoChild: function(name, props) {
     if (name === 'okButton') {
-      return this.Super('addAutoChild', ['clearButton', { title: 
this.clearButtonTitle}]);
+      return this.Super('addAutoChild', ['clearButton', {canFocus:true, title: 
this.clearButtonTitle}]);
     } else if (name === 'clearButton') {
-      return this.Super('addAutoChild', ['okButton', { title: 
this.okButtonTitle}]);
+      return this.Super('addAutoChild', ['okButton', {canFocus:true, title: 
this.okButtonTitle}]);
     } else {
       return this.Super('addAutoChild', arguments);
     }
   }
+
 });
 
 isc.ClassFactory.defineClass('OBMiniDateRangeItem', isc.MiniDateRangeItem);
@@ -690,15 +694,28 @@
   rangeDialogConstructor: isc.OBDateRangeDialog,
   
   // prevent illegal values from showing up
-  updateValue : function(data) {
-    var illegalStart = data && data.start && !isc.isA.Date(data.start);
-    var illegalEnd = data && data.end && !isc.isA.Date(data.end);
+  updateValue: function(data) {
+    var illegalStart = data && data.start && 
!this.isCorrectRangeValue(data.start);
+    var illegalEnd = data && data.end && !this.isCorrectRangeValue(data.end);
     if (illegalStart || illegalEnd) {
       return;
     }
     this.Super('updateValue', arguments);
   },
   
+  isCorrectRangeValue: function(value) {
+    if (!value) {
+      return false;
+    }
+    if (isc.isA.Date(value)) {
+      return true;
+    }
+    if (value._constructor && value._constructor === 'RelativeDate') {
+      return true;
+    }
+    return false;
+  },
+  
   keyPress: function(item, form, keyName, characterValue){
     if (keyName === 'Enter') {
       this.showRangeDialog();
diff -r 764f71e47b7a -r 75564115c2c2 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-form-styles.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-form-styles.js
      Fri May 06 12:16:31 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-form-styles.js
      Fri May 06 12:17:55 2011 +0200
@@ -282,8 +282,8 @@
 
   showShadow: false,
   shadowDepth: 5,
-  width: 400,
-  height: 160
+  width: 420,
+  height: 170
 });
 
 isc.OBDateRangeDialog.changeDefaults('headerDefaults', {
@@ -361,6 +361,7 @@
 });
 
 isc.RelativeDateItem.addProperties({
+  showChooserIcon: false,
   cellStyle: 'OBFormField',
   titleStyle: 'OBFormFieldLabel',
   textBoxStyle: 'OBFormFieldSelectInput',
@@ -399,6 +400,23 @@
   }
 });
 
+isc.RelativeDateItem.changeDefaults('quantityFieldDefaults', {
+  cellStyle: 'OBFormField',
+  titleStyle: 'OBFormFieldLabel',
+  textBoxStyle: 'OBFormFieldSelectInput',
+  controlStyle: 'OBFormFieldSelectControl',
+  // max 1000 days/months in the past/future
+  max: 1000,
+  alwaysTakeSpace: false,
+  
+  // after leaving the quantity field the next time the rangeitem is visited 
the 
+  // focus should go to the value field again
+  blur: function() {
+    this.Super('blur', arguments);
+    this.form.setFocusItem(this.form.getItem('valueField'));
+  }
+});
+
 isc.RelativeDateItem.changeDefaults('valueFieldDefaults', {
   cellStyle: 'OBFormField',
   titleStyle: 'OBFormFieldLabel',
@@ -415,65 +433,30 @@
       return false;
     }
     return true;
+  },
+  
+  init: function() {
+    this.icons = [{
+      width: 21,
+      height: 21,
+      hspace: 0,
+      canFocus: false,
+      showFocused: false,
+      item: this,
+      src: 
'[SKIN]/../../org.openbravo.client.application/images/form/date_control.png',
+      click: function() {
+        this.item.form.canvasItem.showPicker();
+      }
+    }];
+    this.Super('init', arguments);
   }
-
+ 
 });
 
 isc.RelativeDateItem.changeDefaults('calculatedDateFieldDefaults', {
-  canFocus: false
-});
-
-isc.RelativeDateItem.changeDefaults('pickerIconDefaults', {
-  width: 21,
-  height: 21,
-  src: 
'[SKIN]/../../org.openbravo.client.application/images/form/date_control.png'
-});
-
-isc.RelativeDateItem.addProperties({
-  displayFormat: OB.Format.date,
-  inputFormat: OB.Format.date,
-  pickerConstructor: 'OBDateChooser',
-
-  fieldChanged: function () {
-    if (!this.valueField || !this.quantityField) {
-      return;
-    }
-    
-    var value = this.valueField.getValue(),
-      quantity = this.quantityField.getValue();
-
-    var showQuantity = (value && isc.isA.String(value) && 
this.relativePresets[value]);
-
-    if (!showQuantity) {
-      this.editor.colWidths[1] = 0;
-      this.quantityField.setWidth(0);
-      this.quantityField.hide();
-    } else {
-      this.editor.colWidths[1] = '*';
-      this.quantityField.setWidth('*');
-      this.quantityField.show();
-    }
-    
-    if (this.calculatedDateField) {
-      value = this.getValue();
-      var displayValue = this.editor.getValue('valueField');
-      // only show if the value is not a direct date
-      // https://issues.openbravo.com/view.php?id=16295
-      if (displayValue && displayValue.length > 0) {
-        displayValue = OB.Utilities.trim(displayValue);
-        // if it starts with a number then it must be a real date
-        if (displayValue.charAt(0) < '0' || displayValue.charAt(0) > '9' ) {
-          this.calculatedDateField.setValue(!value ? '' : 
-            '(' + this.formatDate(value) + ')');          
-        } else {
-          this.calculatedDateField.setValue('');                  
-        }
-      } else {
-        this.calculatedDateField.setValue('');                  
-      }
-    }
-  }
-
+  canFocus: false,
+  disabled: true,
+  showDisabled: false
 });
 
 /* =====================================================================

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to