Add "Delete relation" option
authorRichard Fairhurst <richard@systemeD.net>
Sat, 7 May 2011 18:08:40 +0000 (19:08 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Sat, 7 May 2011 18:08:40 +0000 (19:08 +0100)
net/systemeD/halcyon/connection/actions/DeleteRelationAction.as
net/systemeD/potlatch2/TagViewer.mxml

index 4ca186f..56e6cdb 100644 (file)
@@ -25,7 +25,7 @@ package net.systemeD.halcyon.connection.actions {
                        for each (var member:RelationMember in memberList) {
                            member.entity.removeParent(relation);
                        }
-                       memberList.splice(0, memberList.length);
+                       memberList=[];
                        effects.doAction();
                        setDeleted(true);
             
@@ -52,6 +52,7 @@ package net.systemeD.halcyon.connection.actions {
             effects.undoAction();
             for each(var member:RelationMember in oldMemberList) {
                 memberList.push(member);
+                member.entity.addParent(relation);
                 relation.dispatchEvent(new RelationMemberEvent(
                         Connection.RELATION_MEMBER_ADDED, member.entity, relation, 0));
             }
index b107fe0..a6f961b 100644 (file)
       import mx.core.*;
       import mx.managers.PopUpManager;
       import mx.controls.Menu;
+      import mx.controls.Alert;
       import flash.geom.Point;
       import flash.net.*;
       import mx.events.DragEvent;
                var menu:Menu = new Menu(); 
                var dp:Object = [ {label: "Select all members"}, 
                                                  {label: "Deselect all members"}, 
-                                                 {label: "Add selection to this relation", enabled: false} ]; 
+                                                 {label: "Add selection to this relation", enabled: false},
+                                                 {label: "Delete relation"} ]; 
                menu.dataProvider = dp; 
                menu.addEventListener("itemClick", selectRelationMenu); 
                button.popUp = menu;
                                }
                                MainUndoStack.getGlobalStack().addAction(undo);
                                break;
+                       
+                       case 3: // Delete relation
+                               Alert.show("Do you really want to delete the relation?","Are you sure?",Alert.YES | Alert.CANCEL,null,
+                                       function(event:CloseEvent):void { 
+                                               if (event.detail==Alert.CANCEL) return;
+                                               rel.remove(MainUndoStack.getGlobalStack().addAction);
+                                       } );
+                               break;
                }
        }