Navigation Menu

Skip to content

Commit

Permalink
LCRange Handler Fixes to allow comma pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
gbyndoor authored and flongo committed Feb 12, 2014
1 parent 6ad6d16 commit 65cdac1
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 21 deletions.
49 changes: 39 additions & 10 deletions src/aria/resources/handlers/LCRangeResourceHandler.js
Expand Up @@ -49,8 +49,10 @@
typesUtil = null; typesUtil = null;
}, },
$prototype : { $prototype : {

rangePattern : {
rangePattern : /^[a-z]{1}\d+-\d+/, 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 * Call the callback with an array of suggestions in its arguments. Suggestions that are exact match are
Expand All @@ -63,28 +65,55 @@
this.$callback(callback, null); this.$callback(callback, null);
return; return;
} }
textEntry = stringUtil.stripAccents(textEntry).toLowerCase(); var textEntry = stringUtil.stripAccents(textEntry).toLowerCase(), rangePattern = this.rangePattern;
if (this.allowRangeValues && this.rangePattern.test(textEntry)) { if (this.allowRangeValues) {
var firstLetter = textEntry.charAt(0); var rangeV = [], firstLetter = textEntry.substring(0, 1);
var rangeV = textEntry.substring(1).split("-"); 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 = { var results = {
suggestions : [], suggestions : [],
multipleValues : true multipleValues : true
}; };
for (var k = rangeV[0]; k <= rangeV[1]; k++) { for (var k = 0, len = rangeV.length; k < len; k++) {
var textEntry = firstLetter + k; var searchEntry = firstLetter + rangeV[k];
this.$LCResourcesHandler.getSuggestions.call(this, textEntry, { this.$LCResourcesHandler.getSuggestions.call(this, searchEntry, {
fn : this.__appendSuggestions, fn : this.__appendSuggestions,
scope : this, scope : this,
args : results args : results
}); });
} }
this.$callback(callback, results); this.$callback(callback, results);
} else { } 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) { __appendSuggestions : function (suggestions, results) {
if (suggestions) { if (suggestions) {
results.suggestions = results.suggestions.concat(suggestions); results.suggestions = results.suggestions.concat(suggestions);
Expand Down
2 changes: 1 addition & 1 deletion src/aria/widgets/form/MultiAutoComplete.js
Expand Up @@ -363,4 +363,4 @@ Aria.classDefinition({
this.__resizeInput(); this.__resizeInput();
} }
} }
}); });
3 changes: 2 additions & 1 deletion test/aria/widgets/form/autocomplete/AutoCompleteTestSuite.js
Expand Up @@ -54,7 +54,8 @@ Aria.classDefinition({
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test3.MultiAutoDataCheck"); 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.test4.MultiAutoPrefill");
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test5.MultiAutoEdit"); 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.test7.MultiAutoError");
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test8.MultiAutoMaxOptions"); this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test8.MultiAutoMaxOptions");
this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test9.MultiAutoBackSpace"); this.addTests("test.aria.widgets.form.autocomplete.multiautocomplete.test9.MultiAutoBackSpace");
Expand Down
Expand Up @@ -42,7 +42,19 @@ Aria.tplScriptDefinition({
}, { }, {
label : 'P4.redd', label : 'P4.redd',
code : 'P4' 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', label : 'Scandinavian Airlines System',
code : 'SK' code : 'SK'
}]); }]);
Expand Down
Expand Up @@ -14,7 +14,7 @@
*/ */


Aria.classDefinition({ Aria.classDefinition({
$classpath : "test.aria.widgets.form.autocomplete.multiautocomplete.test6.MultiAutoRange", $classpath : "test.aria.widgets.form.autocomplete.multiautocomplete.test6.Common",
$extends : "aria.jsunit.TemplateTestCase", $extends : "aria.jsunit.TemplateTestCase",
$constructor : function () { $constructor : function () {
this.$TemplateTestCase.constructor.call(this); this.$TemplateTestCase.constructor.call(this);
Expand All @@ -31,19 +31,24 @@ Aria.classDefinition({


}, },
$prototype : { $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 * This method is always the first entry point to a template test Start the test by focusing the first field
*/ */
runTemplateTest : function () { runTemplateTest : function () {
this.synEvent.click(this.getInputField("MultiAutoId"), { this.synEvent.click(this.getInputField("MultiAutoId"), {
fn : this.typeSomething, fn : this._typeSomething,
scope : this scope : this
}); });
}, },


typeSomething : function (evt, callback) { _typeSomething : function (evt, callback) {
// give it the time to open a drop down // 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, fn : this._wait,
scope : this, scope : this,
args : this._selectVal args : this._selectVal
Expand All @@ -59,18 +64,53 @@ Aria.classDefinition({
_selectVal : function () { _selectVal : function () {
this.synEvent.type(this.getInputField("MultiAutoId"), "[enter]", { this.synEvent.type(this.getInputField("MultiAutoId"), "[enter]", {
fn : this._checkValues, 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 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 value = this.data.ac_airline_values;
var rangeLabels = ['P1.some', 'P2.kon', 'P3.red', 'P4.redd']; var rangeLabels = this.rangeLabels;
this.assertEquals(value.length, 4, "The Wrong range of elements are prefilled. Expected = 4, Prefilled = "
this.assertEquals(value.length, argValue.count, "The Wrong range of elements are prefilled. Prefilled = "
+ value.length); + value.length);
for (var k = 0; k < value.length; k++) { for (var k = 0; k < value.length; k++) {
this.assertEquals(value[k].label, rangeLabels[k], "The Wrong range of elements are prefilled. Expected = " this.assertEquals(value[k].label, rangeLabels[k], "The Wrong range of elements are prefilled. Expected = "
+ value[k].label + " Prefilled = " + rangeLabels[k]); + value[k].label + " Prefilled = " + rangeLabels[k]);
} }
this.$callback(argValue.cb);

},
_endRangeCheckTest : function () {
this.notifyTemplateTestEnd(); this.notifyTemplateTestEnd();
} }
} }
Expand Down
@@ -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]

}
});
@@ -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]
}
});
Expand Up @@ -43,7 +43,7 @@ Aria.classDefinition({


typeSomething : function (evt, callback) { typeSomething : function (evt, callback) {
// give it the time to open a drop down // 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, fn : this._wait,
scope : this, scope : this,
args : this._selectVal args : this._selectVal
Expand Down

0 comments on commit 65cdac1

Please sign in to comment.