amalgame/commit

basic event handling after mapping has changed

authorJacco van Ossenbruggen
Sat Aug 9 14:42:49 2014 +0200
committerJacco van Ossenbruggen
Sat Aug 9 14:42:49 2014 +0200
commit6baaf70af8aca4f9e2592bfc6524d7c52ff6ea55
tree4f31c0c5ea9f5f7931306a3d742be5e24117d73f
parent768fb3ad0d08a788762bee1c605890cb4a395c1b
Diff style: patch stat
diff --git a/web/js/evaluater.js b/web/js/evaluater.js
index 523cd7e..a99e331 100644
--- a/web/js/evaluater.js
+++ b/web/js/evaluater.js
@@ -73,6 +73,9 @@ YUI.add('evaluater', function(Y) {
 				mappings:this.get("mappings"),
 				selected:this.get("selected")
 			}).render(NODE_MAPPING_LIST);
+			this.on('mappingsChange', function(e) { 
+				this.mappinglist.set('mappings', e.newVal); 
+			}, this);
 		},
 
 		_initTable : function() {
@@ -209,17 +212,18 @@ YUI.add('evaluater', function(Y) {
 		},
 
 		_submitCorrespondence : function(c) {
-			var oSelf  = this;
-			var server = this.get("paths").evaluate;
-			var record = this._selectedRecord;
+			var oSelf  =   this;
+			var mappings = this.get("mappings")
+			var server =   this.get("paths").evaluate;
+			var record =   this._selectedRecord;
 			var conceptsUnchanged = (c.new == c.originals);
 
 			Y.io(server, {
 				method: 'POST',
 				data:c,
 				on:{success:function(e,o) {
+					var r = Y.JSON.parse(o.responseText);
 					if (c.applyTo == "one" && conceptsUnchanged) {
-						var r = Y.JSON.parse(o.responseText);
 						if (c.remove) {
 							oSelf.mappingtable.removeRow(record);
 						} else if (r.overruled) {
@@ -231,6 +235,10 @@ YUI.add('evaluater', function(Y) {
 			  			oSelf.mappingtable.loadData(); // reload if too much has changed
 					}
 					oSelf._fetchInfo(c.mapping);
+					if (r.mapping.uri && r.mapping.stats) {
+						mappings[r.mapping.uri].stats = r.mapping.stats;
+					       	oSelf.set("mappings", mappings);
+					}
 				}}
 			});
 		},
diff --git a/web/js/mappinglist.js b/web/js/mappinglist.js
index 95d8342..2c7ada4 100644
--- a/web/js/mappinglist.js
+++ b/web/js/mappinglist.js
@@ -22,7 +22,7 @@ YUI.add('mappinglist', function(Y) {
 		},
 		destructor : function() {},
 		renderUI : function() {
-			this.listNode = this.get("contentBox").appendChild(Y.Node.create("<table class='mappinglist'></table>"));
+			this.listNode = this.get("contentBox").appendChild(Y.Node.create("<table/>"));
 		},
 		bindUI : function() {
 			this._history.on('selectedChange', this._onSelectChange, this);
@@ -56,6 +56,8 @@ YUI.add('mappinglist', function(Y) {
 
 		_setMappings : function() {
 			var listNode = this.listNode;
+			listNode.empty();
+			listNode.addClass('mappinglist');
 			listNode.append("<tr>"+
 				"<th>Mapping</a></th>"+
 				"<th colspan='1' class='src_mapped'># sources</th>"+
diff --git a/web/js/mappingtable.js b/web/js/mappingtable.js
index 9f1f769..398253d 100644
--- a/web/js/mappingtable.js
+++ b/web/js/mappingtable.js
@@ -154,8 +154,8 @@ YUI.add('mappingtable', function(Y) {
 				};
 			Y.all(".yui3-datatable tr").removeClass("yui3-datatable-selected");
 			row.addClass("yui3-datatable-selected");
-			Y.log("selected correspondence in mappingtable: "+source.uri+ " - " +target.uri);
-			Y.log(current);
+			// Y.log("selected correspondence in mappingtable: "+source.uri+ " - " +target.uri);
+			// Y.log(current);
 			this.fire("rowSelect", data);
 		},