annotation_dashboard/commit

ADDED: delete button

authorJacco van Ossenbruggen
Tue Sep 23 13:31:12 2014 +0200
committerJacco van Ossenbruggen
Tue Sep 23 13:31:12 2014 +0200
commit7326f1c4a488372dc22606154b2fe5d21b3e6284
treef038610bfbfa8c3301b640015708b1101bfa3eef
parent55e5a0c9048f90618e083178c3c523a9d50fc5af
Diff style: patch stat
diff --git a/components/dashboard/show_annotations.pl b/components/dashboard/show_annotations.pl
index 1d91aa7..c1b08d1 100644
--- a/components/dashboard/show_annotations.pl
+++ b/components/dashboard/show_annotations.pl
@@ -45,7 +45,8 @@ show_annotation_summery(A, Options) -->
 	    td([class(judgebuttoncell)],
 	       div([class('btn-group'), 'data-toggle'(buttons)],
 		   [ \judge_button(agree, A, Field, Js),
-		     \judge_button(disagree, A, Field, Js)
+		     \judge_button(disagree, A, Field, Js),
+		     \delete_button(A, Field)
 		   ])
 	      ),
 	    td(\rdf_link(Field, [resource_format(label)])),
@@ -57,6 +58,16 @@ is_judgement_of(A, J) :-
 	rdf_has(J, oa:hasTarget, A).
 
 
+delete_button(Annotation, Field) -->
+	html([
+	    button([class([btn,'btn-primary', dashboard, delete]),
+		    field(Field),
+		    annotation(Annotation)
+		   ],
+		   \button_glyph(remove)
+		  )
+	]).
+
 judge_button(Type, Annotation, Field, Judgements) -->
 	{  current_judgment(Type, Annotation, Judgements, J, Checked),
 	   checked_active(Checked, Active)
@@ -91,6 +102,7 @@ button_glyph(agree) -->
 	html(span([class([glyphicon,'glyphicon-thumbs-up'])],[' agree'])).
 button_glyph(disagree) -->
 	html(span([class([glyphicon,'glyphicon-thumbs-down'])],[' disagree'])).
-
+button_glyph(remove) -->
+	html(span([class([glyphicon,'glyphicon-remove'])],[' remove'])).
 checked_active(checked, active).
 checked_active(_, '').
diff --git a/web/js/dashboard.js b/web/js/dashboard.js
index afa0e39..c113a94 100644
--- a/web/js/dashboard.js
+++ b/web/js/dashboard.js
@@ -2,6 +2,7 @@ YUI().use('event', 'json', 'io', 'querystring', function(Y) {
     Y.on('domready', function() {
 	Y.all(   '.judgebutton.agree.unchecked').on('click', submitJudgement, null, 'agree', 'disagree', 'add');
 	Y.all('.judgebutton.disagree.unchecked').on('click', submitJudgement, null, 'disagree', 'agree', 'add');
+	Y.all('.dashboard.delete').each(function(node) { node.on('click', deleteAnnotation, null, node); });
 	Y.all('.pagination a').on('click', pagination);
     });
     MOTIVATION = {
@@ -16,6 +17,15 @@ YUI().use('event', 'json', 'io', 'querystring', function(Y) {
 	    var parameters = Y.QueryString.stringify({ task:task,limit:limit, offset:offset });
 	    location.assign(location.pathname + '?' + parameters);
     }
+    function deleteAnnotation(ev,button) {
+	var annotation = button.getAttribute('annotation');
+	Y.io('../../api/annotation/remove', {
+		method: 'DELETE',
+		data:{ annotation:annotation, comment:"Removed from dashboard application" },
+		on: { success: function() { button.get('parentNode').get('parentNode').get('parentNode').remove(true); }
+		    }
+		});
+    }
     function submitJudgement(ev, type, toggleto, mode) {
 	var button = ev.currentTarget;
 	button.detach('click');