When changing feature, save tags that have editors in new feature
authorIlya Zverev <zverik@textual.ru>
Mon, 7 Nov 2011 13:47:51 +0000 (17:47 +0400)
committerRichard Fairhurst <richard@systemeD.net>
Fri, 18 Nov 2011 17:08:41 +0000 (17:08 +0000)
net/systemeD/potlatch2/TagViewer.mxml

index 1e1070de2feb39e088d5afb7008b1d84b5203a6f..57ec9b4c3750267f6f5f48cc9113c3ac2faf8bd8 100644 (file)
           var action:CompositeUndoableAction = new CompositeUndoableAction(
                   "Set "+selectedEntity.getType()+" "+selectedEntity.id+" to "+newFeature.name);
                  selectedEntity.suspend();
+          
+          // build a list of tags that are editable in new feature
+          var editableTags:Array = new Array();
+          for each( var editor:EditorFactory in newFeature.editors ) {
+              if ( editor is SingleTagEditorFactory ) {
+                  var singleTagEditor:SingleTagEditorFactory = editor as SingleTagEditorFactory;
+                  editableTags.push(singleTagEditor.key);
+              }
+          }
 
           // remove tags from the current feature
           if ( feature != null ) {
               for each( var oldtag:Object in feature.tags ) {
-                  selectedEntity.setTag(oldtag["k"], null, action.push);
+                  if ( editableTags.indexOf(oldtag["k"]) < 0 ) {
+                      selectedEntity.setTag(oldtag["k"], null, action.push);
+                  }
               }
           }