don't allow users to set empty keys
authorRichard Fairhurst <richard@systemed.net>
Tue, 4 Jan 2011 19:19:39 +0000 (19:19 +0000)
committerRichard Fairhurst <richard@systemed.net>
Tue, 4 Jan 2011 19:19:39 +0000 (19:19 +0000)
net/systemeD/halcyon/connection/actions/SetTagAction.as
net/systemeD/halcyon/connection/actions/SetTagKeyAction.as
net/systemeD/potlatch2/TagGrid.mxml

index 991ef5b..625d039 100644 (file)
@@ -17,8 +17,8 @@ package net.systemeD.halcyon.connection.actions {
         public override function doAction():uint {
             var tags:Object = entity.getTagsHash();
             oldValue = tags[key];
-            if ( oldValue != value ) {
-                if ( value == null || value == "" )
+            if ( oldValue != value || key == '' ) {
+                if ( value == null || value == "" || key == '' )
                     delete tags[key];
                 else
                     tags[key] = value;
index ac486e9..b052a8e 100644 (file)
@@ -5,6 +5,7 @@ package net.systemeD.halcyon.connection.actions {
     public class SetTagKeyAction extends UndoableEntityAction {
         private var oldKey:String;
         private var newKey:String;
+        private var oldValue:String;
         
         public function SetTagKeyAction(entity:Entity, oldKey:String, newKey:String) {
             super(entity, "Rename tag "+oldKey+"->"+newKey);
@@ -14,12 +15,18 @@ package net.systemeD.halcyon.connection.actions {
             
         public override function doAction():uint {
             var tags:Object = entity.getTagsHash();
-            var value:String = tags[oldKey];
+            oldValue = tags[oldKey];
+            var newValue:String;
             if ( oldKey != newKey ) {
                 delete tags[oldKey];
-                tags[newKey] = value;
+                if (newKey=='') {
+                    newValue = null;
+                } else {
+                    tags[newKey] = oldValue;
+                    newValue = oldValue;
+                               } 
                 markDirty();
-                entity.dispatchEvent(new TagEvent(Connection.TAG_CHANGED, entity, oldKey, newKey, value, value));
+                entity.dispatchEvent(new TagEvent(Connection.TAG_CHANGED, entity, oldKey, newKey, oldValue, newValue));
                 return SUCCESS;
             } else {
                 return NO_CHANGE;
@@ -28,11 +35,10 @@ package net.systemeD.halcyon.connection.actions {
             
         public override function undoAction():uint {
             var tags:Object = entity.getTagsHash();
-            var value:String = tags[newKey];
             delete tags[newKey];
-            tags[oldKey] = value;
+            tags[oldKey] = oldValue;
             markClean();
-            entity.dispatchEvent(new TagEvent(Connection.TAG_CHANGED, entity, newKey, oldKey, value, value));
+            entity.dispatchEvent(new TagEvent(Connection.TAG_CHANGED, entity, newKey, oldKey, oldValue, oldValue));
             
             return SUCCESS;
         }
index a89909f..9f9e01f 100644 (file)
@@ -78,7 +78,6 @@
                }
 
                private function updateTagDataProvider():void {
-                       validateNow();
                        if (editedItemPosition) return;
                        tagDataProvider.removeAll();
                        if (selectedEntity==null) { return; }