Permalink
Browse files

LCRange Handler Fixes to allow comma pattern

  • Loading branch information...
1 parent 6ad6d16 commit 65cdac14a0eb7bd6da68f1e8b9a8d87e85bd5305 gbyndoor committed with flongo Jan 15, 2014
View
49 src/aria/resources/handlers/LCRangeResourceHandler.js
@@ -49,8 +49,10 @@
typesUtil = null;
},
$prototype : {
-
- rangePattern : /^[a-z]{1}\d+-\d+/,
+ rangePattern : {
+ pattern1 : /^[a-z]{1}\d+-\d+/,
+ pattern2 : /^[a-z]{1}\d+,\d+/
+ },
/**
* Call the callback with an array of suggestions in its arguments. Suggestions that are exact match are
@@ -63,28 +65,55 @@
this.$callback(callback, null);
return;
}
- textEntry = stringUtil.stripAccents(textEntry).toLowerCase();
- if (this.allowRangeValues && this.rangePattern.test(textEntry)) {
- var firstLetter = textEntry.charAt(0);
- var rangeV = textEntry.substring(1).split("-");
+ var textEntry = stringUtil.stripAccents(textEntry).toLowerCase(), rangePattern = this.rangePattern;
+ if (this.allowRangeValues) {
+ var rangeV = [], firstLetter = textEntry.substring(0, 1);
+ if (rangePattern.pattern1.test(textEntry)) {
+ var valArray = textEntry.substring(1).split("-");
+ for (var l = valArray[0]; l <= valArray[1]; l++) {
+ rangeV.push(l);
+ }
+ }
+ if (rangePattern.pattern2.test(textEntry)) {
+ rangeV = textEntry.substring(1).split(",");
+ }
+ if (!rangeV.length > 0) {
+ this.__getSuggestion(textEntry, callback);
+ return;
+ }
var results = {
suggestions : [],
multipleValues : true
};
- for (var k = rangeV[0]; k <= rangeV[1]; k++) {
- var textEntry = firstLetter + k;
- this.$LCResourcesHandler.getSuggestions.call(this, textEntry, {
+ for (var k = 0, len = rangeV.length; k < len; k++) {
+ var searchEntry = firstLetter + rangeV[k];
+ this.$LCResourcesHandler.getSuggestions.call(this, searchEntry, {
fn : this.__appendSuggestions,
scope : this,
args : results
});
}
this.$callback(callback, results);
} else {
- this.$LCResourcesHandler.getSuggestions.call(this, textEntry, callback);
+ this.__getSuggestion(textEntry, callback);
}
+
},
+ /**
+ * Internal method to call LCResourcesHandler
+ * @param {String} textEntry Search string
+ * @param {aria.core.CfgBeans.Callback} callback Called when suggestions are ready
+ * @private
+ */
+ __getSuggestion : function (textEntry, callback) {
+
+ this.$LCResourcesHandler.getSuggestions.call(this, textEntry, callback);
+ },
+ /**
+ * Internal method to append the suggestions.
+ * @private
+ */
__appendSuggestions : function (suggestions, results) {
if (suggestions) {
results.suggestions = results.suggestions.concat(suggestions);
View
2 src/aria/widgets/form/MultiAutoComplete.js
@@ -363,4 +363,4 @@ Aria.classDefinition({
this.__resizeInput();
}
}
-});
+});
View
3 test/aria/widgets/form/autocomplete/AutoCompleteTestSuite.js
@@ -54,7 +54,8 @@ Aria.classDefinition({
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test3.MultiAutoDataCheck");
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test4.MultiAutoPrefill");
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test5.MultiAutoEdit");
- this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test6.MultiAutoRange");
+ this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test6.MultiAutoRange1");
+ this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test6.MultiAutoRange2");
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test7.MultiAutoError");
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test8.MultiAutoMaxOptions");
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test9.MultiAutoBackSpace");
View
14 test/aria/widgets/form/autocomplete/multiautocomplete/template/MultiAutoTplScript.js
@@ -42,7 +42,19 @@ Aria.tplScriptDefinition({
}, {
label : 'P4.redd',
code : 'P4'
- }, {
+ },{
+ label : 'P5.loreum',
+ code : 'P5'
+ },{
+ label : 'P6.ipsum',
+ code : 'P6'
+ },{
+ label : 'P7.lomeo',
+ code : 'P7'
+ },{
+ label : 'P8.amino',
+ code : 'P8'
+ },{
label : 'Scandinavian Airlines System',
code : 'SK'
}]);
View
54 ...multiautocomplete/test6/MultiAutoRange.js → ...omplete/multiautocomplete/test6/Common.js
@@ -14,7 +14,7 @@
*/
Aria.classDefinition({
- $classpath : "test.aria.widgets.form.autocomplete.multiautocomplete.test6.MultiAutoRange",
+ $classpath : "test.aria.widgets.form.autocomplete.multiautocomplete.test6.Common",
$extends : "aria.jsunit.TemplateTestCase",
$constructor : function () {
this.$TemplateTestCase.constructor.call(this);
@@ -31,19 +31,24 @@ Aria.classDefinition({
},
$prototype : {
+ rangePattern1 : "",
+ rangePattern2 : "",
+ rangeLabels : "",
+ rangeCount : "",
+
/**
* This method is always the first entry point to a template test Start the test by focusing the first field
*/
runTemplateTest : function () {
this.synEvent.click(this.getInputField("MultiAutoId"), {
- fn : this.typeSomething,
+ fn : this._typeSomething,
scope : this
});
},
- typeSomething : function (evt, callback) {
+ _typeSomething : function (evt, callback) {
// give it the time to open a drop down
- this.synEvent.type(this.getInputField("MultiAutoId"), "p1-5", {
+ this.synEvent.type(this.getInputField("MultiAutoId"), this.rangePattern1, {
fn : this._wait,
scope : this,
args : this._selectVal
@@ -59,18 +64,53 @@ Aria.classDefinition({
_selectVal : function () {
this.synEvent.type(this.getInputField("MultiAutoId"), "[enter]", {
fn : this._checkValues,
+ scope : this,
+ args : {
+ count : this.rangeCount[0],
+ cb : this._focusBack
+ }
+ });
+ },
+
+ _focusBack : function () {
+ this.synEvent.click(this.getInputField("MultiAutoId"), {
+ fn : this._typeAgain,
scope : this
});
},
- _checkValues : function () {
+ _typeAgain : function () {
+ // give it the time to open a drop down
+ this.synEvent.type(this.getInputField("MultiAutoId"), this.rangePattern2, {
+ fn : this._wait,
+ scope : this,
+ args : this._selectVal2
+ });
+ },
+ _selectVal2 : function () {
+ this.synEvent.type(this.getInputField("MultiAutoId"), "[enter]", {
+ fn : this._checkValues,
+ scope : this,
+ args : {
+ count : this.rangeCount[1],
+ cb : this._endRangeCheckTest
+ }
+ });
+
+ },
+ _checkValues : function (arg, argValue) {
var value = this.data.ac_airline_values;
- var rangeLabels = ['P1.some', 'P2.kon', 'P3.red', 'P4.redd'];
- this.assertEquals(value.length, 4, "The Wrong range of elements are prefilled. Expected = 4, Prefilled = "
+ var rangeLabels = this.rangeLabels;
+
+ this.assertEquals(value.length, argValue.count, "The Wrong range of elements are prefilled. Prefilled = "
+ value.length);
for (var k = 0; k < value.length; k++) {
this.assertEquals(value[k].label, rangeLabels[k], "The Wrong range of elements are prefilled. Expected = "
+ value[k].label + " Prefilled = " + rangeLabels[k]);
}
+ this.$callback(argValue.cb);
+
+ },
+ _endRangeCheckTest : function () {
this.notifyTemplateTestEnd();
}
}
View
26 test/aria/widgets/form/autocomplete/multiautocomplete/test6/MultiAutoRange1.js
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2013 Amadeus s.a.s.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Aria.classDefinition({
+ $classpath : "test.aria.widgets.form.autocomplete.multiautocomplete.test6.MultiAutoRange1",
+ $extends : "test.aria.widgets.form.autocomplete.multiautocomplete.test6.Common",
+ $prototype : {
+ rangePattern1 : "p1-2",
+ rangePattern2 : "p3-6",
+ rangeLabels : ['P1.some', 'P2.kon', 'P3.red', 'P4.redd', 'P5.loreum', 'P6.ipsum'],
+ rangeCount : [2, 6]
+
+ }
+});
View
26 test/aria/widgets/form/autocomplete/multiautocomplete/test6/MultiAutoRange2.js
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2013 Amadeus s.a.s.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Aria.classDefinition({
+ $classpath : "test.aria.widgets.form.autocomplete.multiautocomplete.test6.MultiAutoRange2",
+ $extends : "test.aria.widgets.form.autocomplete.multiautocomplete.test6.Common",
+
+ $prototype : {
+ rangePattern1 : "p3,7",
+ rangePattern2 : "p2,4",
+ rangeLabels : ['P3.red', 'P7.lomeo', 'P2.kon', 'P4.redd'],
+ rangeCount : [2, 4]
+ }
+});
View
2 test/aria/widgets/form/autocomplete/multiautocomplete/test9/MultiAutoBackSpace.js
@@ -43,7 +43,7 @@ Aria.classDefinition({
typeSomething : function (evt, callback) {
// give it the time to open a drop down
- this.synEvent.type(this.getInputField("MultiAutoId"), "p1-5", {
+ this.synEvent.type(this.getInputField("MultiAutoId"), "p1-4", {
fn : this._wait,
scope : this,
args : this._selectVal

0 comments on commit 65cdac1

Please sign in to comment.