kill stupid tab bug
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / NumberEditor.mxml
old mode 100755 (executable)
new mode 100644 (file)
index a80dd14..e35e419
 
        <mx:Label text="{fieldName}:"/>
     <mx:HBox horizontalGap="3" verticalAlign="middle">
+        <!-- it would be great if the numericStepper showed something other than zero when unset -->
            <mx:NumericStepper id="input"
                  minimum="{minimum}" maximum="{maximum}"
                  stepSize="{stepSize}"
                  value="{translatedValue}"
                  enabled="{isValueValid}"
                                 change="value = input.value.toString()" />
-        <mx:Label text="{prompt}" visible="{value == null || value == ''}"/>
+        <mx:LinkButton label="Clear" click="clear()" enabled="{isValueClearable}" />
+        <mx:Label text="{prompt}" visible="{value == null || value == ''}" includeInLayout="{value == null || value == ''}" styleName="promptText"/>
+        <mx:Label text="{warning}" visible="{!isValueValid}" includeInLayout="{!isValueValid}" styleName="warningText" />
     </mx:HBox>
 
   <mx:Script><![CDATA[
     protected function get prompt():String {
         return _factory == null ? null : NumberEditorFactory(_factory).notPresentText;
     }
+    
+    [Bindable(event="factory_set")]
+    protected function get warning():String {
+        return _factory == null ? null : NumberEditorFactory(_factory).notValidText;
+    }
 
     [Bindable(event="factory_set")]
     public function get minimum():Number {
         var validatedValue:Number = getValidatedValue();
         return !(isNaN(validatedValue) && value != null && value != "");
     }
+    
+    [Bindable(event="tag_changed")]
+    private function get isValueClearable():Boolean {
+        var validatedValue:Number = getValidatedValue();
+        return !isNaN(validatedValue);
+    }
 
     private function getValidatedValue():Number {
         var valueStr:String = value;
             return Number.NaN;
         return parsed;
     }
+    
+    private function clear():void {
+        value = null;
+    }
        
   ]]></mx:Script>
 </edit:SingleTagEditor>