Minor reworking of the merge button layout, which also allows the visibility to work...
[potlatch2.git] / net / systemeD / potlatch2 / panels / BackgroundMergePanel.mxml
index 7af12ee1b8bd62ede75fb5ca9ff16cfbd47b49e7..9833a5e963dd46935434185a3aa8cf24e3bc271b 100644 (file)
     <mx:columns>
       <mx:DataGridColumn editable="false" dataField="k" headerText="Key" />
       <mx:DataGridColumn editable="false" dataField="e" headerText="OSM value" />
-      <mx:DataGridColumn editable="false" headerText="Merge" width="30">
+      <mx:DataGridColumn editable="false" headerText="Merge" width="50" textAlign="center">
         <mx:itemRenderer>
           <mx:Component>
-            <mx:Button label="&lt;&lt;" visible="{data.b == null}" click="trace('b is '+data.b);parentDocument.mergeForKey(data.k);" />
+            <mx:HBox horizontalAlign="center" verticalAlign="middle">
+              <mx:Button label="&lt;&lt;" visible="{parentDocument.buttonVisible(data.b, data.e)}" click="parentDocument.mergeForKey(data.k);" />
+            </mx:HBox>
           </mx:Component>
         </mx:itemRenderer>
       </mx:DataGridColumn>
-      <mx:DataGridColumn editable="false" dataField="b" headerText="Background value" />
+      <mx:DataGridColumn editable="false" itemRenderer="net.systemeD.potlatch2.panels.BackgroundMergeFieldComponent" dataField="b" headerText="Background value" />
     </mx:columns>
   </mx:DataGrid>
   <mx:Script><![CDATA[
           }
       }
 
+      public function buttonVisible(b:String, e:String):Boolean {
+          if (b != null && b != e) {
+              return true;
+          }
+          return false;
+      }
+
       public function mergeForKey(key:String):void {
           trace("merge for " + key);
       }
+
+      public function getColorFor(i:int):int {
+          if (tagDataProvider[i].e == tagDataProvider[i].b) {
+              return 0xDDFFDD; // matching, green
+           } else if (tagDataProvider[i].e == null) {
+              return 0xDDDDFF; // new value, blue
+           } else {
+              return 0xFFDDDD; // conflicting, red
+           }
+      }
   ]]>
   </mx:Script>
 </mx:VBox>
\ No newline at end of file