You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pi...@apache.org on 2021/09/17 09:49:58 UTC

[royale-asjs] 01/03: Jewel Validator: Add FormValidatorWithoutSnackbar validator which prevents from displaying snackbar in case of errors

This is an automated email from the ASF dual-hosted git repository.

piotrz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit b2906996cfa20a17ae48c06a48cb799227ebf4d3
Author: Piotr Zarzycki <pi...@gmail.com>
AuthorDate: Fri Sep 17 11:46:37 2021 +0200

    Jewel Validator: Add FormValidatorWithoutSnackbar validator which prevents from displaying snackbar in case of errors
---
 .../Jewel/src/main/resources/jewel-manifest.xml    |  1 +
 .../validators/FormValidatorWithoutSnackbar.as     | 52 ++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 5d95488..45b50c7 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -106,6 +106,7 @@
 
     <component id="Validator" class="org.apache.royale.jewel.beads.validators.Validator"/>
     <component id="FormValidator" class="org.apache.royale.jewel.beads.validators.FormValidator"/>
+    <component id="FormValidatorWithoutSnackbar" class="org.apache.royale.jewel.beads.validators.FormValidatorWithoutSnackbar"/>
     <component id="StringValidator" class="org.apache.royale.jewel.beads.validators.StringValidator"/>
     <component id="DateValidator" class="org.apache.royale.jewel.beads.validators.DateValidator"/>
     <component id="SelectedItemNullValidator" class="org.apache.royale.jewel.beads.validators.SelectedItemNullValidator"/>
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/FormValidatorWithoutSnackbar.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/FormValidatorWithoutSnackbar.as
new file mode 100644
index 0000000..6c74240
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/FormValidatorWithoutSnackbar.as
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.validators
+{
+    import org.apache.royale.jewel.beads.validators.FormValidator;
+    import org.apache.royale.events.Event;
+    
+	public class FormValidatorWithoutSnackbar extends FormValidator 
+	{
+		public function FormValidatorWithoutSnackbar()
+		{
+			super();
+		}
+
+		/**
+		 *  Override of the base class dispatchValidEvent in order to remove snackbar notification.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.9
+		 */
+		override protected function dispatchValidEvent():void
+		{
+			//Override this method in order to remove snackbar notification
+			if (isError)
+			{
+				hostComponent.dispatchEvent(new Event("invalid"));
+			}
+			else
+			{
+				hostComponent.dispatchEvent(new Event("valid"));
+			}
+		}
+	}
+}
\ No newline at end of file