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 4bde571  fix Jewel DateField textinput set to "" when selectedDate is 
null
4bde571 is described below

commit 4bde57166eeb6aa55c5ed3728d63853e0bf3abde
Author: Carlos Rovira <carlosrov...@apache.org>
AuthorDate: Mon Dec 3 23:03:12 2018 +0100

    fix Jewel DateField textinput set to "" when selectedDate is null
---
 .../src/main/royale/DateComponentsPlayGround.mxml      |  5 +++++
 .../apache/royale/jewel/beads/views/DateFieldView.as   | 18 ++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git 
a/examples/royale/JewelExample/src/main/royale/DateComponentsPlayGround.mxml 
b/examples/royale/JewelExample/src/main/royale/DateComponentsPlayGround.mxml
index 188e204..a02e1e6 100644
--- a/examples/royale/JewelExample/src/main/royale/DateComponentsPlayGround.mxml
+++ b/examples/royale/JewelExample/src/main/royale/DateComponentsPlayGround.mxml
@@ -42,6 +42,10 @@ limitations under the License.
                        {
                                dateFieldDefault.selectedDate = new Date();
                        }
+                       private function dateFieldToNull():void
+                       {
+                               dateFieldDefault.selectedDate = null;
+                       }
                        
                        // -- DateChooser Spanish
 
@@ -124,6 +128,7 @@ limitations under the License.
                                                </j:beads>
                                        </j:DateField>
                                        <j:Button text="Select today" 
click="dateFieldToToday()" emphasis="primary"/>   
+                                       <j:Button text="Date to null" 
click="dateFieldToNull()" />      
                                </j:HGroup>
                                <j:Label id="dateFieldDefaultSelectedDate" 
multiline="true" html="&lt;strong>DateField selected date:&lt;/strong> "/>
                        </j:Card>
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/DateFieldView.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/DateFieldView.as
index 46a9593..359dd59 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/DateFieldView.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/DateFieldView.as
@@ -25,26 +25,26 @@ package org.apache.royale.jewel.beads.views
                import flash.utils.setTimeout;
     }
     import org.apache.royale.core.BeadViewBase;
-    import org.apache.royale.core.IBeadModel;
     import org.apache.royale.core.IBeadView;
     import org.apache.royale.core.IDateChooserModel;
     import org.apache.royale.core.IFormatBead;
     import org.apache.royale.core.IPopUpHost;
     import org.apache.royale.core.IStrand;
     import org.apache.royale.core.UIBase;
-       import org.apache.royale.core.ValuesManager;
+    import org.apache.royale.core.ValuesManager;
     import org.apache.royale.events.Event;
     import org.apache.royale.events.IEventDispatcher;
        import org.apache.royale.geom.Point;
     import org.apache.royale.jewel.Button;
     import org.apache.royale.jewel.DateChooser;
+    import org.apache.royale.jewel.Table;
     import org.apache.royale.jewel.TextInput;
     import 
org.apache.royale.jewel.beads.controls.datefield.DateFieldMaskedTextInput;
     import 
org.apache.royale.jewel.beads.controls.textinput.MaxNumberCharacters;
        import org.apache.royale.jewel.supportClasses.ResponsiveSizes;
        import 
org.apache.royale.jewel.supportClasses.util.positionInsideBoundingClientRect;
        import org.apache.royale.jewel.Table;
-       import org.apache.royale.jewel.beads.views.DateChooserView;
+    import org.apache.royale.jewel.beads.views.DateChooserView;
     import org.apache.royale.utils.UIUtils;
 
        /**
@@ -150,12 +150,14 @@ package org.apache.royale.jewel.beads.views
                        
getHost().addEventListener("initComplete",handleInitComplete);
                }
 
+               private var model:IDateChooserModel;
+
                private function handleInitComplete(event:Event):void
                {
                        var formatter:IFormatBead = 
_strand.getBeadByType(IFormatBead) as IFormatBead;
                        
formatter.addEventListener("formatChanged",handleFormatChanged);
 
-                       var model:IBeadModel = 
_strand.getBeadByType(IBeadModel) as IBeadModel;
+                       model = _strand.getBeadByType(IDateChooserModel) as 
IDateChooserModel;
                        
IEventDispatcher(model).addEventListener("selectedDateChanged", 
selectionChangeHandler);
                }
                
@@ -220,8 +222,7 @@ package org.apache.royale.jewel.beads.views
                                        
                                        _popUp.className = "datechooser-popup";
                                        _popUp.addEventListener("initComplete", 
handlePopUpInitComplete);
-
-                                       var model:IDateChooserModel = 
_strand.getBeadByType(IDateChooserModel) as IDateChooserModel;
+                                       
                                        _popUp.selectedDate = 
model.selectedDate;
                                        _popUp.model.dayNames = model.dayNames;
                                        _popUp.model.monthNames = 
model.monthNames;
@@ -276,6 +277,11 @@ package org.apache.royale.jewel.beads.views
                private function selectionChangeHandler(event:Event = null):void
                {
                        getHost().dispatchEvent(new 
Event("selectedDateChanged"));
+
+                       if(model.selectedDate == null)
+                       {
+                               textInput.text = "";
+                       }
                }
 
                private var daysTable:Table;

Reply via email to