amalgame/commit

first steps towards direct editing of the reference alignment

authorJacco van Ossenbruggen
Wed Jul 30 18:41:59 2014 +0200
committerJacco van Ossenbruggen
Wed Jul 30 18:41:59 2014 +0200
commit2f2eabe5160f06c2807cfd8ffbbdead1a4ee5fa4
treeeaaa81384c32141d77b7aa2088667f796a1b1fe8
parent4dc61ef7e4dfbdb7e8f3519cc2686fb968074e12
Diff style: patch stat
diff --git a/api/mapping.pl b/api/mapping.pl
index 77592e2..311bf81 100644
--- a/api/mapping.pl
+++ b/api/mapping.pl
@@ -217,6 +217,10 @@ http_correspondence(Request) :-
 			  mapping(Mapping,
 				  [description('URI of the mapping')]),
 			  strategy(Strategy, [description('URL of strategy')]),
+			  mode(Mode, [
+                                   oneof(empty, 'fill-in'),
+                                   default(empty),
+                                   description('Fill-in the form or leave it empty')]),
 			  allsource(AllSource,
 				 [boolean, default(false),
 				  description('Include all sources')]),
@@ -227,7 +231,7 @@ http_correspondence(Request) :-
 	find_correspondences(Mapping, Strategy, Source, Target, AllSource, AllTarget, Cs),
 	html_current_option(content_type(Type)),
 	findall(R-L, mapping_relation(L, R), Relations),
-	phrase(html_correspondences(Cs, Relations), HTML),
+	phrase(html_correspondences(Cs, Relations, [mode(Mode)]), HTML),
 	format('Content-type: ~w~n~n', [Type]),
 	print_html(HTML).
 
@@ -298,21 +302,26 @@ assert_relation(Source, Target, Options) :-
 	assert_cell(Source, Target, NewOptions).
 
 
-html_correspondences([], _) --> !.
-html_correspondences([align(Source,Target,Evidence)|Cs], Relations) -->
-	html_correspondence(Source, Target, Evidence, Relations),
-	html_correspondences(Cs, Relations).
+html_correspondences([], _,_) --> !.
+html_correspondences([align(Source,Target,Evidence)|Cs], Relations, Options) -->
+        html_correspondence(Source, Target, Evidence, Relations, Options),
+        html_correspondences(Cs, Relations, Options).
 
-html_correspondence(Source, Target, Evidence, Relations) -->
-	{ Relation = '',
-	  length(Evidence, EvLength)
-	},
+html_correspondence(Source, Target, Evidence, Relations, Options) -->
+        { length(Evidence, EvLength),
+	  (   option(mode('fill-in'), Options)
+	  ->  member(Method, Evidence),
+	      member(relation(Relation), Method),
+	      member(comment(Comment), Method)
+	  ;   Comment = '', Relation = undefined
+	  )
+        },
 	html([div(class('yui3-g'),
 		  [ div(class('yui3-u-1-2'),
 			\html_resource_context(Source, Evidence)),
 		    div(class('yui3-u-1-2'),
 			\html_resource_context(Target, Evidence))
-		  ]),
+                  ]),
 	      div(class([manualfixes, 'yui3-g']),
 		  [ div([class([sourcediv, 'yui3-u-1-5'])],
 			[div([class(sourceuri)], Source),
@@ -320,21 +329,21 @@ html_correspondence(Source, Target, Evidence, Relations) -->
 			 input([type(text), class([skos_ac_field]), name(source)])
 			]),
 		    div([class([relations, 'yui3-u-3-5'])],
-			\html_relations(Relations, Relation)),
-		    div([class([targetdiv, 'yui3-u-1-5'])],
-			[div([class(targeturi)], Target),
-			 input([type(hidden), class(original), value(Target)]),
-			 input([type(text), class([skos_ac_field]), name(target)])
-			]),
-		    div(class([comment, 'yui3-u-1']),
-			['because: ', input([type(text), name(comment)], [])
-			])
-		  ]),
-	      div(class(evcount),
-		  [ '~w individual motivations: '-(EvLength)]),
-	      div(class(evidences),
-		  \html_evidences(Evidence, Source, Target))
-	     ]).
+                        \html_relations(Relations, Relation)),
+                    div([class([targetdiv, 'yui3-u-1-5'])],
+                        [div([class(targeturi)], Target),
+                         input([type(hidden), class(original), value(Target)]),
+                         input([type(text), class([skos_ac_field]), name(target)])
+                        ]),
+                    div(class([comment, 'yui3-u-1']),
+                        ['because: ', input([type(text), name(comment), value(Comment)])
+                        ])
+                  ]),
+              div(class(evcount),
+                  [ '~w individual motivations: '-(EvLength)]),
+              div(class(evidences),
+                  \html_evidences(Evidence, Source, Target))
+             ]).
 
 html_evidences([],_,_) --> !.
 html_evidences([E|Es],Source,Target) -->
diff --git a/components/amalgame/util.pl b/components/amalgame/util.pl
index d41afdf..7d0b493 100644
--- a/components/amalgame/util.pl
+++ b/components/amalgame/util.pl
@@ -21,7 +21,8 @@ html_ag_header(Options) -->
 	html(div(id(header),
 		 [ div(class(title),
 		       a(href(location_by_id(http_amalgame_main_page)), 'Amalgame')),
-		   ul(\html_ag_menu(Items, Options))
+		   ul(\html_ag_menu(Items, Options)),
+		   span([id(agMessages)],[''])
 		 ])).
 
 html_showlist([]) --> !.
diff --git a/web/css/application.css b/web/css/application.css
index e636fbf..3ae69e6 100644
--- a/web/css/application.css
+++ b/web/css/application.css
@@ -6,12 +6,12 @@ body {
 /* header */
 #header {
 	border-bottom: 2px solid #3875D7;
-    padding: 5px 10px;
+	padding: 5px 10px;
 	height: 19px;
 }
 #header .title {
-    font-size: 120%;
-    font-weight: bold;
+	font-size: 120%;
+	font-weight: bold;
 	margin-right: 10px;
 	display: inline;
 }
@@ -20,6 +20,7 @@ body {
 	display: inline;
 }
 #header li {
+	color: black;
 	list-style: none;
 	margin: 0 10px;
 	padding: 0 2px;
@@ -33,3 +34,7 @@ body {
 	text-decoration: none;
 	color: #3875D7;
 }
+
+#agMessages {
+	padding-left: 10%;
+}
diff --git a/web/js/evaluater.js b/web/js/evaluater.js
index 378cc42..e8cf448 100644
--- a/web/js/evaluater.js
+++ b/web/js/evaluater.js
@@ -21,6 +21,7 @@ YUI.add('evaluater', function(Y) {
 		paths:      { value: {}    },
 		mappings:   { value: {}    },
 		selected:   { value: null  },
+		editmode:   { value: 'eval'}, // or edit. 
 		allsources: { value: false },
 		alltargets: { value: false }
 	};
@@ -38,6 +39,7 @@ YUI.add('evaluater', function(Y) {
 			this.mappinglist.on("mappingSelect", this._onMappingSelect, this);
 			this.mappinglist.on("wrapAround", this._onWrapAround, this);
 			this.mappingtable.on("rowSelect", this._onCorrespondenceSelect, this);
+			this.after('editmodeChange', this._onEditModeChange, this);
 			NODE_DETAIL.all(".setall").on("click", this._onSubmit, this, "setall");
 			NODE_DETAIL.all(".submit").on("click", this._onSubmit, this, "submit");
 			NODE_DETAIL.all(".next").on(  "click", this._onSubmit, this, "next");
@@ -47,8 +49,11 @@ YUI.add('evaluater', function(Y) {
 			NODE_SOURCE_ALL.on("click", this._fetchDetail, this);
 			NODE_TARGET_ALL.on("click", this._fetchDetail, this);
 
-			var selected = this.get("selected");
-			if (selected) this.mappinglist.fire('mappingSelect', {uri:selected});
+			var selected = this.get('selected');
+			if (selected) {
+				var isReference =this.get('mappings')[selected].agStatus == 'reference' 
+				this.mappinglist.fire('mappingSelect', {uri:selected, isReference:isReference});
+			}
 
 		},
 
@@ -105,11 +110,11 @@ YUI.add('evaluater', function(Y) {
 		},
 
 		_onMappingSelect : function(e) {
-			var uri = e.uri;
-			this.set("selected", uri);
+			if (e.isReference) this.set('editmode', "edit"); else this.set('editmode', "eval");
+			this.set("selected", e.uri);
 			this.detailOverlay.set("visible", false);
-			this._fetchInfo(uri);
-			this.mappingtable.set("mapping", uri);
+			this._fetchInfo(e.uri);
+			this.mappingtable.set("mapping", e.uri);
 		},
 
 		_onCorrespondenceSelect : function(e) {
@@ -155,6 +160,19 @@ YUI.add('evaluater', function(Y) {
 			}
 		},
 
+		_onEditModeChange: function(e) {
+			Y.log('_onEditModeChange');
+			Y.log(e);
+			if (e.newVal == 'edit') {
+				Y.all('#header, #header a').setStyle('color', '#ACCF89');
+				Y.one('#detail').setStyle('background-color', '#ACCF89');
+				Y.one('#agMessages').setContent('Warning: editing reference alignment directly');
+			} else {
+				Y.all('#header, #header a').setStyle('color', '#3875D7');
+				Y.one('#detail').setStyle('background-color', '#DDD');
+				Y.one('#agMessages').setContent('Submissions will be recorded in the manual reference alignment');
+			}
+		},
 		_onWrapAround : function(e) {
 				  Y.log("got wraparound event");
 				  window.scrollTo(e);
@@ -235,12 +253,14 @@ YUI.add('evaluater', function(Y) {
 				points:[Y.WidgetPositionAlign.TR, Y.WidgetPositionAlign.BR]
 				});
 
+			var mode = (this.get('editmode') == "eval")?"empty":"fill-in";
 			// call the server
 			var data = {
 				strategy:this.get("strategy"),
 				mapping:this.get("selected"),
 				source: this._source,
 				target: this._target,
+				mode:   mode,
 				allsource: NODE_SOURCE_ALL.get("checked"),
 				alltarget: NODE_TARGET_ALL.get("checked")
 			};