From: <b_c...@us...> - 2011-06-28 17:45:28
|
Revision: 5388 http://jaffa.svn.sourceforge.net/jaffa/?rev=5388&view=rev Author: b_calderwood Date: 2011-06-28 17:45:22 +0000 (Tue, 28 Jun 2011) Log Message: ----------- Date criteria fields now support the 'Between' operator. If 'Between' is selected an additional date field appears, the two date fields represent the to and from dates for the between query. Criteria date fields will also no longer parse out 'n' and 't' values. This allows the user to save a query where a date criteria is set as eg. '>=n-7', which will consistently return results from the last 7 days. Modified Paths: -------------- trunk/JaffaRIA/source/html/js/extjs/ext-extensions.js trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaOptionsFactory.js trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaPanel.js trunk/JaffaRIA/source/html/js/extjs/jaffa/metadata/classMetaData.jsp Modified: trunk/JaffaRIA/source/html/js/extjs/ext-extensions.js =================================================================== --- trunk/JaffaRIA/source/html/js/extjs/ext-extensions.js 2011-06-28 17:43:09 UTC (rev 5387) +++ trunk/JaffaRIA/source/html/js/extjs/ext-extensions.js 2011-06-28 17:45:22 UTC (rev 5388) @@ -409,36 +409,103 @@ */ Ext.override(Ext.form.DateField, { beforeBlur : function(){ - - if (this.getRawValue().indexOf('t')>=0||this.getRawValue().indexOf('T')>=0) - this.ntFilter = 't'; - - if (this.getRawValue().indexOf('n')>=0||this.getRawValue().indexOf('N')>=0) - this.ntFilter = 'n'; - - if (this.getRawValue().indexOf('t')>=0||this.getRawValue().indexOf('T')>=0 || this.getRawValue().indexOf('n')>=0||this.getRawValue().indexOf('N')>=0) { - if (this.getRawValue().indexOf('+') > 0) - { - var a = (this.getRawValue().split('+'))[1]; + var v; + if (!this.isCriteriaField) { + if (this.getRawValue().indexOf('t') >= 0 || this.getRawValue().indexOf('T') >= 0) + this.ntFilter = 't'; + + if (this.getRawValue().indexOf('n') >= 0 || this.getRawValue().indexOf('N') >= 0) + this.ntFilter = 'n'; + + if (this.getRawValue().indexOf('t') >= 0 || this.getRawValue().indexOf('T') >= 0 || this.getRawValue().indexOf('n') >= 0 || this.getRawValue().indexOf('N') >= 0) { + if (this.getRawValue().indexOf('+') > 0) { + var a = (this.getRawValue().split('+'))[1]; var d = new Date(); - d.setDate(d.getDate()+parseInt(a)); + d.setDate(d.getDate() + parseInt(a)); this.setValue(d); - }else if (this.getRawValue().indexOf('-') > 0) - { - var a = (this.getRawValue().split('-'))[1]; - var d = new Date(); - d.setDate(d.getDate()-parseInt(a)); - this.setValue(d); - } else{ - var d = new Date(); - this.setValue(d); + } + else + if (this.getRawValue().indexOf('-') > 0) { + var a = (this.getRawValue().split('-'))[1]; + var d = new Date(); + d.setDate(d.getDate() - parseInt(a)); + this.setValue(d); + } + else { + var d = new Date(); + this.setValue(d); + } } + + v = this.parseDate(this.getRawValue()); + } else{ + v = this.getRawValue(); } - - var v = this.parseDate(this.getRawValue()); if(v){ this.setValue(v); } + }, + setValue : function(date){ + if (this.isCriteriaField && (this.getRawValue().indexOf('n') || this.getRawValue().indexOf('t'))) { + return Ext.form.DateField.superclass.setValue.call(this, date); + } + else { + return Ext.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date))); + } + }, + getValue : function(){ + if (this.isCriteriaField) { + return Ext.form.DateField.superclass.getValue.call(this); + }else{ + return this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) || ""; + } + }, + validateValue : function(value) { + if (!this.isCriteriaField){ + var error = this.getErrors(value)[0]; + if (error == undefined) { + return true; + } else { + this.markInvalid(error); + return false; + } + }else{ + var error = this.getErrors(this.evalDate(value))[0]; + if (error == undefined) { + return true; + } else { + this.markInvalid(error); + return false; + } + } + }, + evalDate: function(value){ + if (this.parseDate(value)) + return value; + + if (value == 't' || value == 'n') { + return new Date(); + } + + if (value.indexOf('t') == 0 || value.indexOf('n') == 0) { + if (value.indexOf('+') == 1) { + var a = (value.split('+'))[1]; + if (Ext.isNumber(Ext.num(a))) { + var d = new Date(); + d.setDate(d.getDate() + parseInt(a)); + return d; + } + } + if (value.indexOf('-') == 1) { + var a = (value.split('-'))[1]; + if (Ext.isNumber(Ext.num(a))) { + var d = new Date(); + d.setDate(d.getDate() - parseInt(a)); + return d; + } + } + } + return 'invalid date'; } }); Modified: trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaOptionsFactory.js =================================================================== (Binary files differ) Modified: trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaPanel.js =================================================================== --- trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaPanel.js 2011-06-28 17:43:09 UTC (rev 5387) +++ trunk/JaffaRIA/source/html/js/extjs/jaffa/finder/CriteriaPanel.js 2011-06-28 17:45:22 UTC (rev 5388) @@ -57,7 +57,7 @@ split: true, collapsible: true, titleCollapse: true, - width: 490, + width: 540, minWidth: 450, autoScroll: true, frame: true, @@ -449,20 +449,35 @@ if (ownerField.isArray && valueField.getValue()) { addValue = []; if (addOp == 'Between' || addOp == 'In') { - var tmp = valueField.getValue().split(','); - for (var k = 0; k < tmp.length; k++) { - var tmpValue = tmp[k].replace(/^\s+|\s+$/g, ''); - if (tmpValue.length == 0) - tmpValue = null; - addValue.push(tmpValue); + if (fld.xtype=='datefield'){ + addValue.push(valueField.getValue()); + if (ownerField.toDate) { + var toDate = ownerField.toDate; + addValue.push(toDate.getValue()); + } + }else{ + var tmp = valueField.getValue().split(','); + for (var k = 0; k < tmp.length; k++) { + var tmpValue = tmp[k].replace(/^\s+|\s+$/g, ''); + if (tmpValue.length == 0) + tmpValue = null; + addValue.push(tmpValue); + } } } else { addValue.push(valueField.getValue()); } } else if (valueField.getValue()) { - if (fld.isCriteriaField) addValue = [valueField.getValue()]; - else addValue = valueField.getValue(); + if (fld.isCriteriaField) { + addValue = [valueField.getValue()]; + if (valueField.xtype=='datefield' && opr[0].getValue()=='Between'){ + if (valueField.ownerCt.toDate) + addValue.push(valueField.ownerCt.toDate.getValue()); + } + } + else + addValue = valueField.getValue(); } } } @@ -538,9 +553,15 @@ } if (ownerField.isArray || valueField.isDirty()) { valueField.reset(); + if (valueField.xtype == 'datefield' && valueField.ownerCt.toDate){ + valueField.ownerCt.toDate.reset(); + valueField.ownerCt.toDate.hide(); + } } else if (valueField.xtype == 'datefield') { valueField.reset(); + if (valueField.ownerCt.toDate) + valueField.ownerCt.toDate.reset(); } } } @@ -571,6 +592,9 @@ if (opr && opr[0]) { opr = opr[0]; opr.setValue(decodeURIComponent(crt[i].operator)); + if (decodeURIComponent(crt[i].operator)=='Between' && fld.find('isValueField', true)[0].xtype=='datefield' && fld.toDate){ + fld.toDate.show(); + } } } if (crt[i].values) { @@ -578,9 +602,31 @@ if (fld.isArray) vf.setValue(decodeURIComponent(crt[i].values)); else { if (vf.xtype == 'datefield') { - if (typeof crt[i].values[0] == 'object') var dt = crt[i].values[0]; - else var dt = Date.parseDate(crt[i].values[0], "Y-m-d\\TH:i:s"); + var dt; + if (typeof crt[i].values[0] == 'object') { + dt = crt[i].values[0]; + } + else if (crt[i].values[0].indexOf('n') || crt[i].values[0].indexOf('t')){ + dt = crt[i].values[0]; + }else{ + dt = Date.parseDate(crt[i].values[0], "Y-m-d\\TH:i:s"); + } vf.setValue(dt); + + if (crt[i].values.length > 1 && vf.ownerCt.toDate) { + var td; + if (typeof crt[i].values[1] == 'object') { + td = crt[i].values[1]; + } + else + if (crt[i].values[1].indexOf('n') || crt[i].values[1].indexOf('t')) { + td = crt[i].values[1]; + } + else { + td = Date.parseDate(crt[i].values[1], "Y-m-d\\TH:i:s"); + } + vf.ownerCt.toDate.setValue(td); + } } else vf.setValue(decodeURIComponent(crt[i].values[0])); } @@ -824,7 +870,30 @@ fieldLabelToken: config.fieldLabelToken, metaField: config.metaField || config.mapping, operator: true, - excludeNull: config.excludeNull ? config.excludeNull : false + excludeNull: config.excludeNull ? config.excludeNull : false, + listeners: { + select: function(combo, record, index){ + if (combo.ownerCt.toDate) { + if (record.get('value')=='Between'){ + this.ownerCt.toDate.show(); + }else{ + combo.ownerCt.toDate.setValue(''); + this.ownerCt.toDate.hide(); + } + } + }, + change: function(combo, newValue, oldValue){ + if (combo.ownerCt.toDate) { + if (newValue == 'Between') { + combo.ownerCt.toDate.show(); + } + else { + combo.ownerCt.toDate.setValue(''); + combo.ownerCt.toDate.hide(); + } + } + } + } }), { xtype: config.fieldType, adjacentSeparator: '', @@ -832,7 +901,17 @@ metaField: config.metaField || config.mapping, isValueField: true, isCriteriaField: true, - value: config.value || null + value: config.value || null, + ref: 'fromDate' + }, { + xtype: config.fieldType, + adjacentSeparator: '', + noLabel: true, + metaField: config.metaField || config.mapping, + isCriteriaField: true, + value: config.value || null, + hidden: true, + ref: 'toDate' }]; config.isArray = config.isArray == null ? false : config.isArray; } Modified: trunk/JaffaRIA/source/html/js/extjs/jaffa/metadata/classMetaData.jsp =================================================================== --- trunk/JaffaRIA/source/html/js/extjs/jaffa/metadata/classMetaData.jsp 2011-06-28 17:43:09 UTC (rev 5387) +++ trunk/JaffaRIA/source/html/js/extjs/jaffa/metadata/classMetaData.jsp 2011-06-28 17:45:22 UTC (rev 5388) @@ -215,7 +215,6 @@ MappingFilter mappingFilter = MappingFilter.getInstance(mapping, filter); DataTransformer.buildGraphFromDomain(domainInstance, graphInstance, mapping, mappingFilter, null, false); } catch (Exception e){ - log.warn("Failed to create new instance of " + className); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |