X-Git-Url: https://git.openstreetmap.org/potlatch2.git/blobdiff_plain/cbf62608e07c3086ee0e7495f56ed3bb984eb7df..300a5b751f2845a6bdf8308333669f10cebf7271:/net/systemeD/potlatch2/TagViewer.mxml diff --git a/net/systemeD/potlatch2/TagViewer.mxml b/net/systemeD/potlatch2/TagViewer.mxml index 26acee8..dd1fefb 100644 --- a/net/systemeD/potlatch2/TagViewer.mxml +++ b/net/systemeD/potlatch2/TagViewer.mxml @@ -1,6 +1,13 @@ + + rowHeight="32" columnWidth="32" updateComplete="resizePOIGrid(event)" styleName="dndPanelTileList"> - + - - + ]]> + - + @@ -54,8 +63,8 @@ - - + + @@ -69,7 +78,7 @@ - + No Selection]]> @@ -88,17 +97,17 @@ - + - + - + @@ -120,7 +129,7 @@ - + @@ -142,7 +151,7 @@ disabledIcon="@Embed('../../../embedded/view_accordion_disabled.png')" click="setEditorStackUI(false)" id="accordionLabel" paddingTop="6" toolTip="Show in sliding windows" - enabled="{editorStack is SuperTabNavigator && stack.selectedIndex==0}" /> + enabled="{editorStack is TabNavigator && stack.selectedIndex==0}" /> @@ -163,17 +172,17 @@ - + - + - + @@ -204,43 +213,80 @@ + + + + + + + + + + + + - = components.length ) - return; - for each (var component:DisplayObject in components ) { - tab.addChild(component); - } - } + // ** FIXME: Order probably shouldn't be hard-coded, but configurable + private static var categoryOrder:Array=["Restrictions","Transport","Cycle","Walk","Address","Details"]; // reverse order + private function sortCategories(a:VBox,b:VBox):int { + var a1:int=categoryOrder.indexOf(a.label); + var a2:int=categoryOrder.indexOf(b.label); + if (a1a2) { return -1; } + return 0; + } + + private function createEditorBox():VBox { + var box:VBox = new VBox(); + box.percentWidth = 100; + box.percentHeight = 100; + box.styleName = "dndEditorContainer"; + addConstrainedForm(box); + return box; + } + + private function addConstrainedForm(parentObject:DisplayObjectContainer):void { + var form:Form = new Form(); + form.name = "form"; + form.percentWidth=100; + form.addEventListener(mx.events.ResizeEvent.RESIZE, formResizeHandler, false, 0, true); + parentObject.addChild(form); + if (parentObject.width>0) form.maxWidth=parentObject.width; + } + + private function formResizeHandler(e:Event):void { + var form:Form=Form(e.target); + if (form.parent.width>0) form.maxWidth=form.parent.width; + } + + private function ensureEditorsPopulated(tab:VBox):void { + var components:Array = tabComponents[tab]; + var form:Form=Form(tab.getChildByName("form")); + if ( components == null || tab == null || form.numElements >= components.length ) return; + for each (var component:DisplayObject in components ) { + form.addElement(UIComponent(component)); + } + } private function initEditorStackUIs():void { - editorStackTabNavigator = new SuperTabNavigator(); - editorStackTabNavigator.allowTabSqueezing=false; - editorStackTabNavigator.minTabWidth=10; - editorStackTabNavigator.closePolicy="close_never"; - editorStackTabNavigator.scrollSpeed=20; + editorStackTabNavigator = new TabNavigator(); +// editorStackTabNavigator.allowTabSqueezing=false; +// editorStackTabNavigator.minTabWidth=10; +// editorStackTabNavigator.closePolicy="close_never"; +// editorStackTabNavigator.scrollSpeed=20; editorStackTabNavigator.creationPolicy="auto"; editorStackTabNavigator.percentWidth=100; editorStackTabNavigator.percentHeight=100; editorStackTabNavigator.styleName="dndStackTab"; - editorStackTabNavigator.popUpButtonPolicy="off" +// editorStackTabNavigator.popUpButtonPolicy="off" editorStackAccordion = new Accordion(); @@ -434,6 +561,10 @@ editorStackAccordion.percentHeight=100; editorStackAccordion.creationPolicy="auto"; editorStackAccordion.styleName="dndStackAccordion"; + /* FIXME: the accordion icons should be right-aligned. See: + http://www.kristoferjoseph.com/blog/2008/11/06/positioning-the-flex-accordion-header-icon + http://blog.flexexamples.com/2007/09/13/changing-text-alignment-in-an-flex-accordion-header/ + */ setEditorStackUI(true); } @@ -464,8 +595,8 @@ } private function editorStackUIUpdate(event:Event):void { - if (editorStack is SuperTabNavigator) { - var e:SuperTabNavigator = editorStack as SuperTabNavigator; + if (editorStack is TabNavigator) { + var e:TabNavigator = editorStack as TabNavigator; if (e.selectedIndex<0) { return; } for (var i:uint=0; i"+entity.id+""; + advancedID.htmlText = entityText+": "+entity.id+" "+(entity.status ? entity.status : ''); } removeRelationListeners(); @@ -527,8 +658,8 @@ } public function addNewTag():void { - if (stack.selectedChild!=advancedContainer) { return; } - advancedTagGrid.addNewTag(); + if (sidebar.selectedChild==multiplePanel) { multiAdvancedTagGrid.addNewTag(); } + else if (stack.selectedChild==advancedContainer) { advancedTagGrid.addNewTag(); } } private function addedToRelation(event:RelationMemberEvent):void { @@ -621,8 +752,7 @@ // but is at least robust for any kind of change. // Figuring out a better way is someone else's FIXME - var conn:Connection = Connection.getConnectionInstance(); - var rel:Relation = selectedEntity as Relation + var rel:Relation = selectedEntity as Relation; var action:CompositeUndoableAction = new CompositeUndoableAction("Rearrange relation members for "+rel); // drop members @@ -634,12 +764,10 @@ for each(var memberObject:Object in membersGrid.dataProvider) { var e:Entity; var id:Number = memberObject.id; - if(memberObject.type == 'node') { - e = conn.getNode(id); - } else if (memberObject.type == 'way') { - e = conn.getWay(id); - } else if (memberObject.type == 'relation') { - e = conn.getRelation(id); + switch (memberObject.type) { + case 'node': e = connection.getNode(id); break; + case 'way': e = connection.getWay(id); break; + case 'relation': e = connection.getRelation(id); break; } rel.appendMember(new RelationMember(e, memberObject.role), action.push); } @@ -648,8 +776,8 @@ private function editRelation(id:Number):void { var panel:RelationEditorPanel = RelationEditorPanel( - PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true)); - panel.setRelation(Connection.getConnectionInstance().getRelation(id)); + PopUpManager.createPopUp(Application(FlexGlobals.topLevelApplication), RelationEditorPanel, true)); + panel.setRelation(connection.getRelation(id)); PopUpManager.centerPopUp(panel); } @@ -659,7 +787,8 @@ 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; @@ -686,7 +815,7 @@ public function selectRelationMenu(event:MenuEvent):void { var rel:Relation=rowData.relation; var entities:Array; - var controller:EditController=Application.application.theController; + var controller:EditController=FlexGlobals.topLevelApplication.theController; switch (event.index) { case 0: // Select all members entities=selectedEntity.entities.concat(rel.memberEntities); @@ -710,6 +839,16 @@ } MainUndoStack.getGlobalStack().addAction(undo); break; + + case 3: // Delete relation + var warning:String="This relation has # members. Deleting it will affect all of them and erase this $. Are you really sure?"; + warning=warning.replace("#",rel.length).replace("$",rel.getRelationType()); + Alert.show(warning,"Are you sure?",Alert.YES | Alert.CANCEL,null, + function(event:CloseEvent):void { + if (event.detail==Alert.CANCEL) return; + rel.remove(MainUndoStack.getGlobalStack().addAction); + } , null, Alert.CANCEL); + break; } } @@ -728,21 +867,12 @@ navigateToURL(new URLRequest(feature.helpURL), "potlatch_help"); } - /** Open up a new browser page showing OSM's view of the current entity. */ - public function openEntityPage():void { - if (selectedEntity != null && selectedEntity.id >= 0) { - // This is slightly hard-coded, but not drastically. The ../s could be changed for string manipulation of the apiBase - var urlBase:String = Connection.getConnectionInstance().apiBase + '../../browse/' - navigateToURL(new URLRequest(urlBase+selectedEntity.getType()+'/'+selectedEntity.id), "potlatch_browse"); - } - } - public function addToRelation():void { new RelationSelectPanel().init(selectedEntity,new Object()); } private function removeFromRelation(id:Number, index:int=-1):void { - var rel:Relation=Connection.getConnectionInstance().getRelation(id); + var rel:Relation=connection.getRelation(id); if (index>-1) { rel.removeMemberByIndex(index, MainUndoStack.getGlobalStack().addAction); } else if (selectedEntity is EntityCollection) { @@ -762,11 +892,22 @@ 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); + } } } @@ -789,6 +930,7 @@ if (rows!=Math.floor(rows)) { rows=Math.floor(rows+1); } event.target.height=rows*(event.target.rowHeight+1); } - ]]> + + ]]>