Skip to content
Browse files

feat #964 Changes for Error tooltip on keydown

close #964
  • Loading branch information...
1 parent 65cdac1 commit 41d50bfe63ce93bc8d3116d28aeeb753d136b9dd @smadapathi smadapathi committed with divdavem Jan 28, 2014
View
2 src/aria/widgets/CfgBeans.js
@@ -256,7 +256,7 @@ Aria.beanDefinitions({
},
"validationEvent" : {
$type : "json:Enum",
- $enumValues : ["onFocus", "onBlur", "none"],
+ $enumValues : ["onFocus", "onBlur", "onError", "none"],
$default : "onFocus",
$description : "contains the event used to display the error tip"
},
View
1 src/aria/widgets/controllers/AutoCompleteController.js
@@ -372,6 +372,7 @@
} else {
if (!this.freeText && suggestionsAvailable && !hasSuggestions) {
report.ok = false;
+ report.errorMessages.push(this.res.errors["40020_WIDGET_AUTOCOMPLETE_VALIDATION"]);
} else {
report.ok = true;
}
View
3 src/aria/widgets/controllers/MultiAutoCompleteController.js
@@ -154,7 +154,7 @@
dataModel.value = null;
report.ok = true;
reportVal = null;
- } else if (value && !typeUtil.isString(value)) {
+ } else if (value && !typeUtil.isString(value) && dataModel.value !== null) {
if (this._checkWithSuggestionBean(value, this._resourcesHandler.SUGGESTION_BEAN)) {
var text = this._getLabelFromSuggestion(value);
dataModel.text = text;
@@ -296,6 +296,7 @@
} else {
if (!this.freeText && suggestionsAvailable && !hasSuggestions) {
report.ok = false;
+ report.errorMessages.push(this.res.errors["40020_WIDGET_AUTOCOMPLETE_VALIDATION"]);
} else {
report.ok = true;
}
View
12 src/aria/widgets/form/MultiAutoComplete.js
@@ -20,7 +20,7 @@ Aria.classDefinition({
$classpath : "aria.widgets.form.MultiAutoComplete",
$extends : "aria.widgets.form.AutoComplete",
$dependencies : ["aria.widgets.controllers.MultiAutoCompleteController", "aria.utils.Event", "aria.utils.Dom",
- "aria.utils.Type", "aria.utils.Array", "aria.utils.Math"],
+ "aria.utils.Type", "aria.utils.Array", "aria.utils.Math", "aria.utils.String"],
$css : ["aria.widgets.form.MultiAutoCompleteStyle", "aria.widgets.form.list.ListStyle",
"aria.widgets.container.DivStyle"],
/**
@@ -85,7 +85,6 @@ Aria.classDefinition({
if (report && report.value !== null) {
this._addMultiselectValues(report, arg);
}
-
},
/**
@@ -269,13 +268,15 @@ Aria.classDefinition({
var inputField = this.getTextInputField();
var inputFieldValue = inputField.value;
var domUtil = aria.utils.Dom;
- if (tabPressed && inputFieldValue !== "") {
+ var stringUtil = aria.utils.String;
+ if (tabPressed && stringUtil.trim(inputFieldValue) !== "" && this.controller.freeText) {
event.preventDefault();
var report = this.controller.checkText(inputFieldValue, false);
this._reactToControllerReport(report);
this.setHelpText(false);
+ inputField.focus();
}
- if (tabPressed && inputFieldValue === "" && inputField.nextSibling != null) {
+ if (tabPressed && stringUtil.trim(inputFieldValue) === "" && inputField.nextSibling != null) {
event.preventDefault();
this._makeInputFieldLastChild();
this.setHelpText(false);
@@ -292,7 +293,6 @@ Aria.classDefinition({
domUtil.removeElement(previousSiblingElement);
this._removeValues(previousSiblingLabel);
}
-
}
this.$DropDownTextInput._dom_onkeydown.call(this, event);
},
@@ -363,4 +363,4 @@ Aria.classDefinition({
this.__resizeInput();
}
}
-});
+});
View
15 src/aria/widgets/form/TextInput.js
@@ -436,9 +436,6 @@ Aria.classDefinition({
if (!performCheckOnly) {
this.changeProperty("value", null);
this.changeProperty("invalidText", text);
- if (this._cfg.directOnBlurValidation) {
- this.changeProperty("formatErrorMessages", report.errorMessages);
- }
}
} else if (this._cfg.formatError === false && aria.utils.Type.isArray(this._cfg.formatErrorMessages)
&& this._cfg.formatErrorMessages.length) {
@@ -508,6 +505,9 @@ Aria.classDefinition({
}
}
+ if (report.errorMessages.length && this._cfg.directOnBlurValidation) {
+ this.changeProperty("formatErrorMessages", report.errorMessages);
+ }
// if the validation originated from a validation with delay we
// do not want to update the input text or
// value. The value will be set to 'undefined' though when the
@@ -711,6 +711,14 @@ Aria.classDefinition({
|| propertyName === 'errorMessages') {
this._cfg[propertyName] = newValue;
this._reactToChange();
+ var cfg = this._cfg;
+ if (cfg && cfg.validationEvent === 'onError' && (this._keepFocus || this._hasFocus)) {
+ if ((cfg.formatError && cfg.formatErrorMessages.length) || (cfg.error && cfg.errorMessages.length)) {
+ this._validationPopupShow();
+ } else {
+ this._validationPopupHide();
+ }
+ }
} else if (propertyName == "prefill") {
this.setPrefillText(true, newValue, true);
} else if (propertyName == "prefillError") {
@@ -812,7 +820,6 @@ Aria.classDefinition({
this.checkValue();
}
},
-
/**
* Internal method to handle the onkeyup event. This is called to set the value property in the data model
* through the setProperty method that also handles all other widgets bound to this value.
View
1 test/aria/widgets/form/autocomplete/AutoCompleteTestSuite.js
@@ -59,5 +59,6 @@ Aria.classDefinition({
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");
+ this.addTests("test.aria.widgets.form.autocomplete.errorhandling.AutoComplete");
}
});
View
65 test/aria/widgets/form/autocomplete/errorhandling/AutoComplete.js
@@ -0,0 +1,65 @@
+/*
+ * 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.errorhandling.AutoComplete",
+ $extends : "aria.jsunit.TemplateTestCase",
+ $prototype : {
+ /**
+ * This method is always the first entry point to a template test Start the test by focusing the first field.
+ * Initially give the field focus.
+ */
+ runTemplateTest : function () {
+ this.synEvent.click(this.getInputField("acDest"), {
+ fn : this.onAcFocused,
+ scope : this
+ });
+ },
+
+ /**
+ * Field should have focus, next trigger an exact match.
+ */
+ onAcFocused : function () {
+ this.synEvent.type(this.getInputField("acDest"), "z", {
+ fn : this.waitForType,
+ scope : this
+ });
+ },
+
+ /**
+ * Need to add a delay to allow the list to open with the returned suggestions including the exact match.
+ */
+ waitForType : function () {
+ this.waitFor({
+ condition : function () {
+ return (this.getWidgetInstance("acDest")._state == "normalErrorFocused");
+ },
+ callback : {
+ fn : this.checkErrorTooltip,
+ scope : this
+ }
+ });
+ },
+ /**
+ * Finalize the test, check the bound widgets value has been updated by a change to the data model when the
+ * enter key was triggered.
+ */
+ checkErrorTooltip : function () {
+ var acWidget = this.getWidgetInstance("acDest");
+ this.assertTrue(!!acWidget._onValidatePopup);
+ this.notifyTemplateTestEnd();
+ }
+ }
+});
View
45 test/aria/widgets/form/autocomplete/errorhandling/AutoCompleteTpl.tpl
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+{Template {
+ $classpath:"test.aria.widgets.form.autocomplete.errorhandling.AutoCompleteTpl",
+ $hasScript:true,
+ $width: {min: 500}
+}}
+
+ {var view_values = {
+ ac_air_value: null
+ }/}
+
+
+ {macro main()}
+ <h2>AutoComplete with LC resources handler</h2> <br />
+
+ {@aria:AutoComplete {
+ id: "acDest",
+ label:"Choose your destination: ",
+ labelPos:"left",
+ labelAlign:"right",
+ width:400,
+ block:false,
+ labelWidth:180,
+ validationEvent:'onError',
+ freeText:false,
+ resourcesHandler:_getCitiesHandler()
+ }/}
+
+ {/macro}
+
+{/Template}
View
41 test/aria/widgets/form/autocomplete/errorhandling/AutoCompleteTplScript.js
@@ -0,0 +1,41 @@
+/*
+ * 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.tplScriptDefinition({
+ $classpath : "test.aria.widgets.form.autocomplete.errorhandling.AutoCompleteTplScript",
+ $dependencies : ["aria.resources.handlers.LCResourcesHandler"],
+ $constructor : function () {
+ this._lcHandler = new aria.resources.handlers.LCResourcesHandler();
+ this._lcHandler.setSuggestions([{
+ label : 'Madrid',
+ code : 'MAD'
+ }, {
+ label : 'Rio de Janeiro',
+ code : 'RIO'
+ }, {
+ label : 'Miami',
+ code : 'MIA'
+ }]);
+ },
+ $destructor : function () {
+ this._lcHandler.$dispose();
+ this._lcHandler = null;
+ },
+ $prototype : {
+ _getCitiesHandler : function () {
+ return this._lcHandler;
+ }
+ }
+});
View
22 test/aria/widgets/form/autocomplete/multiautocomplete/test7/MultiAutoError.js
@@ -35,6 +35,7 @@ Aria.classDefinition({
* 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,
scope : this
@@ -43,23 +44,28 @@ Aria.classDefinition({
typeSomething : function (evt, callback) {
// give it the time to open a drop down
- this.synEvent.type(this.getInputField("MultiAutoId"), "sdafwerew", {
- fn : this._wait,
+ this.synEvent.type(this.getInputField("MultiAutoId"), "az", {
+ fn : this._waitForType,
scope : this,
args : this._assertErrorState
});
},
- _wait : function (evt, callback) {
- aria.core.Timer.addCallback({
- fn : callback,
- scope : this,
- delay : 500
+ _waitForType : function () {
+ var acWidget = this.getWidgetInstance("MultiAutoId");
+ this.waitFor({
+ condition : function () {
+ return (acWidget._state == "normalErrorFocused");
+ },
+ callback : {
+ fn : this._assertErrorState,
+ scope : this
+ }
});
},
_assertErrorState : function () {
// test that the field is in error state
var acWidget = this.getWidgetInstance("MultiAutoId");
- this.assertTrue(acWidget._state == "normalErrorFocused", "The auto-complete should be in the normalErrorFocused state.");
+ this.assertTrue(!!acWidget._onValidatePopup);
this.notifyTemplateTestEnd();
}
}
View
5 test/aria/widgets/form/autocomplete/multiautocomplete/test7/MultiAutoErrorTpl.tpl
@@ -18,18 +18,19 @@
$hasScript:true
}}
-
+
{macro main()}
-
+
<h2>AutoComplete with Multi Options</h2>
<br />
{@aria:MultiAutoComplete{
label:"Choose your city: ",
helptext:"city",
id:"MultiAutoId",
labelPos:"left",
+ validationEvent:'onError',
labelAlign:"right",
width:400,
block:false,

0 comments on commit 41d50bf

Please sign in to comment.
Something went wrong with that request. Please try again.