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

gregdove 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 4682ddb  Fix for #337. The Binding was working, but it was happening 
too late for the initialization, which worked fine if the values were directly 
set. Added listeners specific to previous/Next step values, which triggers the 
show/hide previous button functionality when previousStep/nextStep values are 
changed in the current WizardStep
4682ddb is described below

commit 4682ddb54d559cff6051de35a86f8b88d1d74d31
Author: greg-dove <[email protected]>
AuthorDate: Tue Mar 12 18:48:07 2019 +1300

    Fix for #337. The Binding was working, but it was happening too late for 
the initialization, which worked fine if the values were directly set.
    Added listeners specific to previous/Next step values, which triggers the 
show/hide previous button functionality when previousStep/nextStep values are 
changed in the current WizardStep
---
 .../royale/jewel/beads/models/WizardModel.as       | 34 ++++++++++++++---
 .../apache/royale/jewel/beads/models/WizardStep.as | 44 +++++++++++++++-------
 2 files changed, 58 insertions(+), 20 deletions(-)

diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/WizardModel.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/WizardModel.as
index 8864504..e5e4c97 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/WizardModel.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/WizardModel.as
@@ -52,7 +52,7 @@ package org.apache.royale.jewel.beads.models
                
         /**
          *  @copy org.apache.royale.core.IBead#strand
-         *  
+         *
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
@@ -66,7 +66,7 @@ package org.apache.royale.jewel.beads.models
         private var _text:String;
                /**
                 *  The title string for the org.apache.royale.jewel.Wizard.
-                * 
+                *
                 *  @copy org.apache.royale.jewel.beads.models.WizardModel#title
                 *
                 *  @langversion 3.0
@@ -90,7 +90,7 @@ package org.apache.royale.jewel.beads.models
                private var _html:String;
                /**
                 *  The HTML string for the title.
-                * 
+                *
                 *  @copy org.apache.royale.jewel.beads.models.WizardModel#html
                 *
                 *  @langversion 3.0
@@ -114,7 +114,7 @@ package org.apache.royale.jewel.beads.models
                private var _currentStep:WizardStep;
                /**
                 *  the current step or page visualized in this wizard
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
@@ -128,15 +128,37 @@ package org.apache.royale.jewel.beads.models
                public function set currentStep(value:WizardStep):void
                {
                        if(value != _currentStep) {
+                               if (_currentStep) {
+                                       amendCurrentStepListeners(_currentStep, 
true);
+                               }
                                _currentStep = value;
+                               if (value) {
+                                       amendCurrentStepListeners(value, false);
+                               }
                                dispatchEvent(new Event('currentStepChange'));
                        }
                }
+               
+               private function amendCurrentStepListeners(step:WizardStep, 
remove:Boolean):void{
+                       if (remove) {
+                               step.removeEventListener('nextStepChange', 
onCurrentStepNextPreviousChange);
+                               step.removeEventListener('previousStepChange', 
onCurrentStepNextPreviousChange);
+                       } else {
+                               step.addEventListener('nextStepChange', 
onCurrentStepNextPreviousChange);
+                               step.addEventListener('previousStepChange', 
onCurrentStepNextPreviousChange);
+                       }
+               }
+               
+               private function 
onCurrentStepNextPreviousChange(event:Event):void{
+                       //something else changed within the currentStep that is 
important...
+                       dispatchEvent(new Event('currentStepChange'));
+               }
+               
 
                private var _showPreviousButton:Boolean = true;
                /**
                 *  show/hide wizard navigator previous button in the wizard
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
@@ -159,7 +181,7 @@ package org.apache.royale.jewel.beads.models
                private var _showNextButton:Boolean = true;
                /**
                 *  show/hide wizard navigator next button in the wizard
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/WizardStep.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/WizardStep.as
index 6430d64..419480b 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/WizardStep.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/WizardStep.as
@@ -19,6 +19,8 @@
 package org.apache.royale.jewel.beads.models
 {
        import org.apache.royale.jewel.WizardPage;
+       import org.apache.royale.events.EventDispatcher;
+       import org.apache.royale.events.Event;
 
        /**
         *  The WizardModel bead class holds the values for a 
org.apache.royale.html.Panel, such as its
@@ -29,8 +31,8 @@ package org.apache.royale.jewel.beads.models
         *  @playerversion AIR 2.6
         *  @productversion Royale 0.9.4
         */
-       [Bindable]
-       public class WizardStep
+
+       public class WizardStep extends EventDispatcher
        {
                /**
                 *  constructor.
@@ -52,12 +54,13 @@ package org.apache.royale.jewel.beads.models
         private var _name:String;
                /**
                 *  the name of the step
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
+               [Bindable('nameChange')]
                public function get name():String
                {
                        return _name;
@@ -66,20 +69,22 @@ package org.apache.royale.jewel.beads.models
                {
                        if(value != _name) {
                                _name = value;
+                               dispatchEvent(new Event('nameChange'));
                        }
                }
-        
+  
                private var _previousStep:String = null;
                /**
                 *  the previous step to go
-                * 
+                *
                 *  defaults to null if there's no previous step
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
+               [Bindable('previousStepChange')]
                public function get previousStep():String
                {
                        return _previousStep;
@@ -88,20 +93,22 @@ package org.apache.royale.jewel.beads.models
                {
                        if(value != _previousStep) {
                                _previousStep = value;
+                               dispatchEvent(new Event('previousStepChange'));
                        }
                }
-        
+  
                private var _nextStep:String = null;
                /**
                 *  the next step to go
-                * 
+                *
                 *  defaults to null if there's no next step
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
+               [Bindable('nextStepChange')]
                public function get nextStep():String
                {
                        return _nextStep;
@@ -110,18 +117,20 @@ package org.apache.royale.jewel.beads.models
                {
                        if(value != _nextStep) {
                                _nextStep = value;
+                               dispatchEvent(new Event('nextStepChange'));
                        }
                }
                
                private var _page:WizardPage;
                /**
                 *  the page associated with this data
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
+               [Bindable('pageChange')]
                public function get page():WizardPage
                {
                        return _page;
@@ -130,18 +139,20 @@ package org.apache.royale.jewel.beads.models
                {
                        if(value != _page) {
                                _page = value;
+                               dispatchEvent(new Event('pageChange'));
                        }
                }
                
                private var _stepLabel:String;
                /**
                 *  the label for this step
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
+               [Bindable('stepLabelChange')]
                public function get stepLabel():String
                {
                        return _stepLabel;
@@ -150,18 +161,20 @@ package org.apache.royale.jewel.beads.models
                {
                        if(value != _stepLabel) {
                                _stepLabel = value;
+                               dispatchEvent(new Event('stepLabelChange'));
                        }
                }
                
                private var _initialPage:Boolean;
                /**
                 *  the initial page to show in the wizard
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
+               [Bindable('initialPageChange')]
                public function get initialPage():Boolean
                {
                        return _initialPage;
@@ -170,18 +183,20 @@ package org.apache.royale.jewel.beads.models
                {
                        if(value != _initialPage) {
                                _initialPage = value;
+                               dispatchEvent(new Event('initialPageChange'));
                        }
                }
 
                private var _autoSkip:Boolean = false;
                /**
                 *  true to skip automatically next step
-                * 
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
                 */
+               [Bindable('autoSkipChange')]
                public function get autoSkip():Boolean
                {
                        return _autoSkip;
@@ -192,7 +207,8 @@ package org.apache.royale.jewel.beads.models
                        if(value != _autoSkip)
                        {
                                _autoSkip=value;
+                               dispatchEvent(new Event('autoSkipChange'));
                        }
                }
     }
-}
\ No newline at end of file
+}

Reply via email to