From: <cos...@us...> - 2011-08-18 00:00:18
|
Revision: 5485 http://jaffa.svn.sourceforge.net/jaffa/?rev=5485&view=rev Author: cosbor11 Date: 2011-08-18 00:00:12 +0000 (Thu, 18 Aug 2011) Log Message: ----------- Criteria Number fields were not supported fully in the framework so I had to do the following JaffaRia changes: 1) (CriteriaPanel.js) Added support to strip out non-numeric characters in the valueField. Exceptions to this is when the operator is "In" or "Between" a comma is allowed. Also, periods are allowed when allowDecimals is not false. 2) (PanelController.js) The allowDecimals was not being applied to the criteria fields by the panelController so I added code to apply allowDecimals to the valueField. Modified Paths: -------------- branches/JAFFA_5_10_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/component/PanelController.js branches/JAFFA_5_10_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaPanel.js Modified: branches/JAFFA_5_10_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/component/PanelController.js =================================================================== --- branches/JAFFA_5_10_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/component/PanelController.js 2011-08-17 21:50:39 UTC (rev 5484) +++ branches/JAFFA_5_10_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/component/PanelController.js 2011-08-18 00:00:12 UTC (rev 5485) @@ -1075,6 +1075,14 @@ if (includeList.indexOf('MAXVALUE') >= 0 && Ext.isNumber(meta.maxValue)) { field.maxValue = meta.maxValue; } + + //Enforces allowDecimals for number criteria fields even when MAXLENGTH is not in the includeList + if(field.isCriteriaField){ + if (meta.allowDecimals !== undefined && meta.allowDecimals !== null){ + field.allowDecimals = meta.allowDecimals; + } + } + } } } Modified: branches/JAFFA_5_10_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaPanel.js =================================================================== --- branches/JAFFA_5_10_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaPanel.js 2011-08-17 21:50:39 UTC (rev 5484) +++ branches/JAFFA_5_10_RELEASE/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaPanel.js 2011-08-18 00:00:12 UTC (rev 5485) @@ -870,15 +870,32 @@ metaField: config.metaField || config.mapping, operator: true, store: config.store ? config.store : null, - excludeNull: config.excludeNull ? config.excludeNull : false + excludeNull: config.excludeNull ? config.excludeNull : false, + listeners:{ + change: function(cbo, newVal, oldVal){ + var valueField = cbo.ownerCt.findBy(function(item){ + return item.isValueField === true; + })[0]; + if(valueField){ + if(newVal === 'In' || newVal === 'Between'){ + valueField.stripCharsRe = new RegExp('[^0123456789,' +((valueField.allowDecimals) ? '.' : '' )+ ']', 'gi'); + } else { + valueField.stripCharsRe = new RegExp('[^0123456789' +((valueField.allowDecimals) ? '.' : '' )+ ']', 'gi'); + } + valueField.validate(); + } + } + } }), { xtype: 'textfield', adjacentSeparator: '', noLabel: true, metaClass: config.metaClass, metaField: config.metaField || config.mapping, - validationEvent: false, - isValueField: true, // used to label the value fields for search + //validationEvent: false, ------- removed so that stripCharsRe is enforced + allowDecimals: config.allowDecimals, + stripCharsRe : new RegExp('[^0123456789' +((config.allowDecimals) ? '.' : '' )+ ']', 'gi'), + isValueField: true, // flag used to label the value fields for search isCriteriaField: true, // builds criteria object rather than string during getCriteriaFromPanel value: config.value || null }]; @@ -1167,10 +1184,11 @@ xtype: xtype, excludeNull: true }; + if(fieldMeta.type === 'number'){ + fieldConfig.allowDecimals = fieldMeta.allowDecimals; + } Ext.applyIf(fieldConfig, config.defaults); - - // Add a panel containing the field and corresponding operator-dropdown config.items.push(Jaffa.finder.CriteriaPanelFactory.createPanel(fieldConfig)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |