You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/03/17 13:02:10 UTC
[royale-asjs] branch develop updated: jewel-validation: beads to
remove all validation errors when navigation to other parts of the app
This is an automated email from the ASF dual-hosted git repository.
carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 6e7be70 jewel-validation: beads to remove all validation errors when navigation to other parts of the app
6e7be70 is described below
commit 6e7be70e4efaa28df5a0ac8eb557055476f84cb3
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Sun Mar 17 14:02:02 2019 +0100
jewel-validation: beads to remove all validation errors when navigation to other parts of the app
---
.../TourDeJewel/src/main/royale/MainContent.mxml | 5 +-
.../Jewel/src/main/resources/jewel-manifest.xml | 3 +
.../beads/controls/NavigationActionNotifier.as | 80 ++++++++++++++++++++++
.../controls/application/CleanValidationErrors.as | 76 ++++++++++++++++++++
.../royale/jewel/beads/validators/Validator.as | 3 +
5 files changed, 166 insertions(+), 1 deletion(-)
diff --git a/examples/royale/TourDeJewel/src/main/royale/MainContent.mxml b/examples/royale/TourDeJewel/src/main/royale/MainContent.mxml
index d29a252..eb4d3b2 100644
--- a/examples/royale/TourDeJewel/src/main/royale/MainContent.mxml
+++ b/examples/royale/TourDeJewel/src/main/royale/MainContent.mxml
@@ -93,7 +93,8 @@ limitations under the License.
<j:beads>
<js:ContainerDataBinding/>
- <js:BrowserOrientation localId="bo"/>
+ <js:BrowserOrientation localId="bo"/>
+ <j:CleanValidationErrors/>
</j:beads>
<j:Drawer localId="drawer">
@@ -107,12 +108,14 @@ limitations under the License.
<j:Navigation change="changeHandler(event)" className="navIconLinkItemRenderer">
<j:beads>
<js:ConstantBinding sourceID="mainNavigationModel" sourcePropertyName="containerDrawerNavigation" destinationPropertyName="dataProvider"/>
+ <j:NavigationActionNotifier/>
</j:beads>
</j:Navigation>
<j:Divider/>
<j:Navigation change="changeHandler(event)" className="navIconLinkItemRenderer">
<j:beads>
<js:ConstantBinding sourceID="mainNavigationModel" sourcePropertyName="controlsDrawerNavigation" destinationPropertyName="dataProvider"/>
+ <j:NavigationActionNotifier/>
</j:beads>
</j:Navigation>
</j:DrawerContent>
diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 3b28fdd..2f2b39c 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -124,6 +124,9 @@
<component id="ResponsiveDrawer" class="org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer"/>
+ <component id="NavigationActionNotifier" class="org.apache.royale.jewel.beads.controls.NavigationActionNotifier"/>
+ <component id="CleanValidationErrors" class="org.apache.royale.jewel.beads.controls.application.CleanValidationErrors"/>
+
<component id="MultilineLabel" class="org.apache.royale.jewel.beads.controls.button.MultilineLabel"/>
<component id="DispatchChangeOnStartup" class="org.apache.royale.jewel.beads.controls.DispatchChangeOnStartup"/>
<component id="DropDownListTextPrompt" class="org.apache.royale.jewel.beads.controls.dropdownlist.DropDownListTextPrompt"/>
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/NavigationActionNotifier.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/NavigationActionNotifier.as
new file mode 100644
index 0000000..ec4e136
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/NavigationActionNotifier.as
@@ -0,0 +1,80 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.jewel.beads.controls
+{
+ import org.apache.royale.core.IBead;
+ import org.apache.royale.core.IStrand;
+ import org.apache.royale.events.Event;
+ import org.apache.royale.events.IEventDispatcher;
+
+ /**
+ * The NavigationActionNotifier notifies when a control's "change" or "click" event is thrown
+ * Other application parts can listen for "navigationAction" event to respond accordingly.
+ *
+ * This bead should be used with Navigation, TabBar or a Button (that could be located in TobAppBar)
+ * or any other navigation component that triggers some navigation action
+ *
+ * An example of use case is to use with CleanValidationErrors bead
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ */
+ public class NavigationActionNotifier implements IBead
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ */
+ public function NavigationActionNotifier()
+ {
+ }
+
+ private var _strand:IStrand;
+
+ /**
+ * @copy org.apache.royale.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9
+ */
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ IEventDispatcher(_strand).addEventListener("change", changeOrClickNotifier);
+ IEventDispatcher(_strand).addEventListener("click", changeOrClickNotifier);
+ }
+
+ /**
+ * dispatch "navigationAction" event that bubbles all the DOM tree
+ * @param ev
+ */
+ private function changeOrClickNotifier(ev:Event):void
+ {
+ IEventDispatcher(_strand).dispatchEvent(new Event("navigationAction", true));
+ }
+ }
+}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/application/CleanValidationErrors.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/application/CleanValidationErrors.as
new file mode 100644
index 0000000..bac6cab
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/application/CleanValidationErrors.as
@@ -0,0 +1,76 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.jewel.beads.controls.application
+{
+ import org.apache.royale.core.IBead;
+ import org.apache.royale.core.IStrand;
+ import org.apache.royale.events.Event;
+ import org.apache.royale.events.IEventDispatcher;
+
+ /**
+ * The CleanValidationErrors listen for "navigationAction" event signaling some navigation
+ * was performed and we want to clean all validation errors in that could be left
+ * in the previous content
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ */
+ public class CleanValidationErrors implements IBead
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.6
+ */
+ public function CleanValidationErrors()
+ {
+ }
+
+ private var _strand:IStrand;
+
+ /**
+ * @copy org.apache.royale.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9
+ */
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ IEventDispatcher(_strand).addEventListener("navigationAction", navigationActionHandler);
+ }
+
+ /**
+ * dispatch "cleanValidationErrors" event that could be received by Validator beads
+ * to remove validation errors
+ * @param ev
+ */
+ private function navigationActionHandler(ev:Event):void
+ {
+ IEventDispatcher(_strand).dispatchEvent(new Event("cleanValidationErrors"));
+ }
+ }
+}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as
index 79ab2e8..4328333 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/Validator.as
@@ -352,6 +352,7 @@ package org.apache.royale.jewel.beads.validators
_host = UIUtils.findPopUpHost(hostComponent);
_host.popUpParent.addElement(_errorTip, false);
+ IEventDispatcher(_host.popUpParent).addEventListener("cleanValidationErrors", destroyErrorTip);
}
COMPILE::JS
{
@@ -389,6 +390,7 @@ package org.apache.royale.jewel.beads.validators
window.removeEventListener('scroll', repositionHandler, true);
}
if(_errorTip){
+ IEventDispatcher(_errorTip.parent).removeEventListener("cleanValidationErrors", destroyErrorTip);
_errorTip.parent.removeElement(_errorTip);
_errorTip = null;
}
@@ -454,6 +456,7 @@ package org.apache.royale.jewel.beads.validators
window.removeEventListener('scroll', repositionHandler, true);
}
if (_errorTip) {
+ IEventDispatcher(_host.popUpParent).removeEventListener("cleanValidationErrors", destroyErrorTip);
_host.popUpParent.removeElement(_errorTip);
_errorTip = null;
}