accurator/commit

Added check for no recommendations left.

authorChris Dijkshoorn
Mon Jun 13 14:24:58 2016 +0200
committerChris Dijkshoorn
Mon Jun 13 14:24:58 2016 +0200
commit07a38ea2c9f94513015c0b4ee4b62d71fb7c378e
tree399c88da833ef19541ded15b235f31d1811b29e5
parentf192e3d6251261b55df40503af1e2ab8864f3197
Diff style: patch stat
diff --git a/rdf/ui/labels.ttl b/rdf/ui/labels.ttl
index 49f5edc..4add562 100644
--- a/rdf/ui/labels.ttl
+++ b/rdf/ui/labels.ttl
@@ -156,6 +156,7 @@ aui:results a auis:UI ;
 	aui:resultsHdrRecommendedResults "Recommended results based on your expertise"@en ;
 	aui:resultsHdrRandomResults "Random results"@en ;
 	aui:resultsTxtNoResults "No results found for "@en ;
+	aui:resultsTxtNoRecommendations "Nothing left to annotate in this domain."@en ;
 	aui:resultsTxtError "Unfortunately an error has occured"@en ;
 	aui:resultsBtnChooseSubDomain "Choose subdomain"@en ;
 	aui:resultsBtnChangeSubDomain "Change subdomain"@en ;
@@ -174,6 +175,7 @@ aui:resultsHdrResults rdfs:subPropertyOf auis:uiLabel .
 aui:resultsHdrRecommendedResults rdfs:subPropertyOf auis:uiLabel .
 aui:resultsHdrRandomResults rdfs:subPropertyOf auis:uiLabel .
 aui:resultsTxtNoResults rdfs:subPropertyOf auis:uiLabel .
+aui:resultsTxtNoRecommendations rdfs:subPropertyOf auis:uiLabel .
 aui:resultsTxtError rdfs:subPropertyOf auis:uiLabel .
 aui:resultsBtnChooseSubDomain rdfs:subPropertyOf auis:uiLabel .
 aui:resultsBtnChangeSubDomain rdfs:subPropertyOf auis:uiLabel .
diff --git a/rdf/ui/labels_nl.ttl b/rdf/ui/labels_nl.ttl
index 54a0148..bc3600f 100644
--- a/rdf/ui/labels_nl.ttl
+++ b/rdf/ui/labels_nl.ttl
@@ -96,6 +96,7 @@ aui:results a auis:UI ;
 	aui:resultsHdrRecommendedResults "Aanbevolen resultaten op basis van uw expertise"@nl ;
 	aui:resultsHdrRandomResults "Willekeurige resultaten"@nl ;
 	aui:resultsTxtNoResults "Geen resultaten gevonden voor "@nl ;
+	aui:resultsTxtNoRecommendations "In dit domein is er niks meer om informatie aan toe te voegen."@nl ;
 	aui:resultsTxtError "Helaas, er is iets fout gegaan"@nl ;
 	aui:resultsBtnChooseSubDomain "Kies subdomein"@nl ;
 	aui:resultsBtnChangeSubDomain "Verander subdomein"@nl ;
diff --git a/web/js/results.js b/web/js/results.js
index e6e09d3..aef031b 100644
--- a/web/js/results.js
+++ b/web/js/results.js
@@ -99,6 +99,7 @@ function initLabels(labelData) {
 		resultsHdrFirst: labelData.resultsHdrFirst,
 		resultsTxtFirst: labelData.resultsTxtFirst,
 		resultsTxtNoResults: labelData.resultsTxtNoResults,
+		resultsTxtNoRecommendations: labelData.resultsTxtNoRecommendations,
 		resultsTxtError: labelData.resultsTxtError,
 		resultsBtnChooseSubDomain: labelData.resultsBtnChooseSubDomain,
 		resultsBtnChangeSubDomain: labelData.resultsBtnChangeSubDomain,
@@ -199,11 +200,19 @@ function recommend(query, labels, target, domainData) {
 function random(query, labels, target, noResults, domainData) {
 	randomCluster(target, noResults)
 	.then(function(cluster) {
-		var clusters = [];
-		clusters[0] = cluster;
-		resultLayoutButtons(clusters, labels);
-		domainButton(domainData, labels);
-		drawResults(clusters);
+		// if there are any results retrieved, then draw them
+		if (cluster.length > 0) {
+			var clusters = [];
+			clusters[0] = cluster;
+
+			resultLayoutButtons(clusters, labels);
+			domainButton(domainData, labels);
+			drawResults(clusters);
+		} else {
+			// tell the people nothing is found and show domain button to allow changing
+			domainButton(domainData, labels);
+			statusMessage(labels.resultsTxtNoRecommendations);
+		}
 	}, function(data) {
 		statusMessage(labels.resultsTxtError, data.responseText);
 	});