Minor reworking of the merge button layout, which also allows the visibility to work...
[potlatch2.git] / net / systemeD / potlatch2 / panels / BackgroundMergePanel.mxml
index ca397504347e19b42ec39737c0ed32846202bd0b..9833a5e963dd46935434185a3aa8cf24e3bc271b 100644 (file)
@@ -8,9 +8,18 @@
   <mx:Text id="backgroundMergePanelText" text="W00t!!!" width="100%" styleName="helpInfo" />
   <mx:DataGrid editable="false" id="backgroundPanelDG" width="100%" height="50%">
     <mx:columns>
-      <mx:DataGridColumn editable="false" dataField="k" headerText="key" />
+      <mx:DataGridColumn editable="false" dataField="k" headerText="Key" />
       <mx:DataGridColumn editable="false" dataField="e" headerText="OSM value" />
-      <mx:DataGridColumn editable="false" dataField="b" headerText="Background value" />
+      <mx:DataGridColumn editable="false" headerText="Merge" width="50" textAlign="center">
+        <mx:itemRenderer>
+          <mx:Component>
+            <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" itemRenderer="net.systemeD.potlatch2.panels.BackgroundMergeFieldComponent" dataField="b" headerText="Background value" />
     </mx:columns>
   </mx:DataGrid>
   <mx:Script><![CDATA[
               tagDataProvider.addItem({k:key, e:editableEntity.getTag(key), b:backgroundEntity.getTag(key)});
           }
       }
+
+      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