Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Always register a binding to section processing

If section processing is not bound to any data model, a spinner overlay created using setProcessingIndicator on the SectionWrapper does not follow it as one of its parent is moved and not closed if the section is deleted. Thus if the user does not specify any binding the overlay remains at its initial place forever.

Binding it to a dummy container allows both of the shortcomings to be solved: spinner follows its parent section and is closed upon section removal.
  • Loading branch information...
commit edf11858134efb7a289c27fb8421061d05e61307 1 parent 862f4e5
@mathbruyen mathbruyen authored flongo committed
View
6 src/aria/templates/CfgBeans.js
@@ -768,7 +768,11 @@ Aria.beanDefinitions({
"bindProcessingTo" : {
$type : "BindingConfiguration",
$description : "Loading overlay binding configurations for this section. If specified, this section will be hidden by a loading indicator when the value in the datamodel is true.",
- $mandatory : false
+ $default : {
+ inside : {},
+ to : "processing",
+ recursive : false
+ }
},
"keyMap" : {
$type : "json:Array",
View
4 src/aria/templates/Section.js
@@ -608,7 +608,7 @@
* @private
*/
__isValidProcessingBind : function (bind) {
- if (!bind || bind.to == null) {
+ if (bind.to == null) {
// bind.to is mandatory
this.$logError(this.MISSING_TO_BINDING);
return false;
@@ -637,7 +637,7 @@
* </pre>
*/
registerProcessing : function (bind) {
- if (!bind || !this.__isValidProcessingBind(bind)) {
+ if (!this.__isValidProcessingBind(bind)) {
return;
}
View
5 test/aria/templates/SectionTest.js
@@ -87,10 +87,7 @@ Aria.classDefinition({
id : "parentSection"
});
- var result = section.__isValidProcessingBind();
- this.assertFalse(result);
-
- result = section.__isValidProcessingBind({});
+ var result = section.__isValidProcessingBind({});
this.assertFalse(result);
this.assertErrorInLogs(section.MISSING_TO_BINDING);
View
1  test/aria/templates/TemplatesTestSuite.js
@@ -92,6 +92,7 @@ Aria.classDefinition({
this.addTests("test.aria.templates.section.SectionTestCase");
this.addTests("test.aria.templates.section.sectionAttributes.SectionAttributes");
this.addTests("test.aria.templates.section.autorefresh.SectionAutorefreshTestCase");
+ this.addTests("test.aria.templates.section.processingIndicator.ProcessingIndicatorOnSection");
this.addTests("test.aria.templates.repeater.RepeaterTestCase");
this.addTests("test.aria.templates.visualFocus.VisualFocusTestCase");
this.addTests("test.aria.templates.testmode.TestIdsTestCase");
View
108 test/aria/templates/section/processingIndicator/ProcessingIndicatorOnSection.js
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+
+/**
+ * Test that the loading indicator follows the section
+ */
+Aria.classDefinition({
+ $classpath : "test.aria.templates.section.processingIndicator.ProcessingIndicatorOnSection",
+ $extends : "aria.jsunit.TemplateTestCase",
+ $dependencies : ["test.aria.utils.overlay.loadingIndicator.IndicatorHelper", "aria.utils.Json", "aria.utils.Dom"],
+ $constructor : function () {
+ this.$TemplateTestCase.constructor.call(this);
+ this.data = {
+ visible : true,
+ xpos : 0,
+ ypos : 0
+ };
+
+ this.setTestEnv({
+ data : this.data
+ });
+
+ this._indHelper = test.aria.utils.overlay.loadingIndicator.IndicatorHelper;
+ this._json = aria.utils.Json;
+ },
+ $prototype : {
+
+ runTemplateTest : function () {
+ this.assertEquals(this._indHelper.totalOverlays(), 0);
+
+ // create explicitly an overlay
+ this.templateCtxt.$getElementById("testSectionInDialog").setProcessingIndicator(true);
+ this.assertEquals(this._indHelper.totalOverlays(), 1);
+ this.__checkOverlayOnSection("testSectionInDialog");
+
+ // move the section
+ this._json.setValue(this.data, "xpos", 50);
+ this.__checkOverlayOnSection("testSectionInDialog");
+
+ // destroy the section
+ this._json.setValue(this.data, "visible", false);
+ this.assertEquals(this._indHelper.totalOverlays(), 0);
+
+ // recreate the section and check that the lack of binding prevents the redesplay of the loading indicator
+ this._json.setValue(this.data, "visible", true);
+ this.assertEquals(this._indHelper.totalOverlays(), 0);
+
+ // check that the status of the overaly can be changed on the wrapper
+ this.templateCtxt.$getElementById("testSectionInDialog").setProcessingIndicator(true);
+ this.assertEquals(this._indHelper.totalOverlays(), 1);
+ this.__checkOverlayOnSection("testSectionInDialog");
+ this.templateCtxt.$getElementById("testSectionInDialog").setProcessingIndicator(false);
+ this.assertEquals(this._indHelper.totalOverlays(), 0);
+ this._json.setValue(this.data, "xpos", 25);
+ this.assertEquals(this._indHelper.totalOverlays(), 0);
+
+ // check that the refresh of the section makes the overlay stay
+ this.templateCtxt.$getElementById("testSectionInDialog").setProcessingIndicator(true);
+ this.assertEquals(this._indHelper.totalOverlays(), 1);
+ this.__checkOverlayOnSection("testSectionInDialog");
+ this.templateCtxt.$refresh({
+ section : "testSectionInDialog"
+ });
+ this.assertEquals(this._indHelper.totalOverlays(), 1);
+ this.__checkOverlayOnSection("testSectionInDialog");
+
+ aria.core.Timer.addCallback({
+ fn : this._finishTest,
+ scope : this,
+ delay : 100
+ });
+ },
+
+ _finishTest : function () {
+ // check that the refresh of the container makes the overlay disapper
+ this.templateCtxt.$refresh();
+ this.assertEquals(this._indHelper.totalOverlays(), 0);
+ this.end();
+ },
+
+ __checkOverlayOnSection : function (sectionId) {
+ var section = this.getElementById(sectionId, true);
+ var overlay = this._indHelper.getOverlay(section).overlay.overlay;
+ var domUtil = aria.utils.Dom;
+ var sectionGeo = domUtil.getGeometry(section);
+ var overlayGeo = domUtil.getGeometry(overlay);
+ var sectionZIndex = this.computeZIndex(section);
+ var overlayZIndex = this.computeZIndex(overlay);
+ this.assertJsonEquals(sectionGeo, overlayGeo, "The overlay was not positioned correctly on section "
+ + sectionId + ".");
+ this.assertTrue(overlayZIndex > sectionZIndex, "The overlay is behind the corresponding element.");
+
+ }
+
+ }
+});
View
45 test/aria/templates/section/processingIndicator/ProcessingIndicatorOnSectionTpl.tpl
@@ -0,0 +1,45 @@
+{Template {
+ $classpath : "test.aria.templates.section.processingIndicator.ProcessingIndicatorOnSectionTpl"
+}}
+
+ {macro main()}
+
+ {@aria:Dialog {
+ macro : "dialogContent",
+ bind : {
+ visible : {
+ to : "visible",
+ inside : data
+ },
+ xpos : {
+ to : "xpos",
+ inside : data
+ },
+ ypos : {
+ to : "ypos",
+ inside : data
+ }
+ }
+ }/}
+
+
+
+ {/macro}
+
+ {macro dialogContent()}
+ {section {
+ id : "testSectionInDialog",
+ macro : "sectionContent",
+ attributes: {
+ style: "display: inline-block"
+ }
+ }/}
+ {/macro}
+
+ {macro sectionContent()}
+ <div style="height: 200px;background: blue;width: 300px; display: inline-block;">Some random text</div>
+ {/macro}
+
+
+
+{/Template}
Please sign in to comment.
Something went wrong with that request. Please try again.