hell's teeth that was painful. Make relation roles editable within TagViewer
authorRichard Fairhurst <richard@systemed.net>
Sat, 12 Jun 2010 20:40:28 +0000 (20:40 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sat, 12 Jun 2010 20:40:28 +0000 (20:40 +0000)
TODO.txt
net/systemeD/potlatch2/TagViewer.mxml

index 66d0cf9..38d8b50 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -31,8 +31,7 @@ Potlatch 2: main outstanding issues
 
 ** Doesn't always update selected tab when you select a new entity
 ** Doesn't update selected tab when you change the relations on an entity
-** Direct click-to-edit of relation role should actually work
-** Double-clicking a relation to edit it comes up with the POIs!
+* Double-clicking a relation to edit it sometimes comes up with the POIs (how to reproduce?)
 * Dynamic reloading of stylesheet/map_features, so that you don't need to reload the full page when editing them
 * If a select name is too long then, the select menu seems to give a horizontal scrollbar instead of the name of the item e.g. cuisine#Coffee Shop
 * If you have both inputSets names and buildingAddress, and name= key is filled in then the basic tab will get both, surely only name should be shown and building name should be ignored e.g. cafes. [Actually this was an issue of addr: being missing from one of them, however this may still be a problem for other overlapping inputSets]
index 99c78ef..a8b2e42 100644 (file)
               rel.removeEventListener(Connection.RELATION_MEMBER_REMOVED, entityRelationMemberChanged);
           }
           listeningToRelations = [];
+          relationsGrid.removeEventListener(DataGridEvent.ITEM_EDIT_END, relationRoleChanged);
       }
             
       private function resetRelationsGrid(entity:Entity):void {
               listeningToRelations.push(rel);
           }
           relationsGrid.dataProvider = relations;
+          relationsGrid.addEventListener(DataGridEvent.ITEM_EDIT_END, relationRoleChanged, false, -100);
       }
       
+      private function relationRoleChanged(event:DataGridEvent):void {
+               if (event.dataField != 'role') { return; }      // shouldn't really happen
+
+               var relations:Array=event.currentTarget.dataProvider.toArray();
+               var props:Object=relations[event.rowIndex];
+
+               var relation:Relation=props['relation'];
+               var index:uint=props['index'];
+               var newRole:String=event.itemRenderer.data['role'];
+
+               relation.setMember(index, new RelationMember(selectedEntity,newRole));
+      }
+
       private function relationTagChanged(event:TagEvent):void {
           resetRelationsGrid(selectedEntity);
       }