accurator/commit

Made loaded alternatives depend on scheme defined in fields.ttl.

authorChris Dijkshoorn
Wed Mar 30 17:03:38 2016 +0200
committerChris Dijkshoorn
Wed Mar 30 17:03:38 2016 +0200
commitfdf1a7f45d15a2193a327a3544a46b01c90bf324
treed94b422e5347524730934b9331797c27ada0727b
parent468a721fa5d91ee94f021efcca9c6479a4713b54
Diff style: patch stat
diff --git a/rdf/domain/bible/ui/fields.ttl b/rdf/domain/bible/ui/fields.ttl
index 7b95b46..81a82b5 100644
--- a/rdf/domain/bible/ui/fields.ttl
+++ b/rdf/domain/bible/ui/fields.ttl
@@ -30,8 +30,8 @@ abibui:ICBibleTheme a auis:DropdownField ;
 	auis:source abibui:ICBibleThemeSource .
 
 abibui:ICBibleThemeSource a auis:AlternativesSource ;
-    auis:api "/api/autocomplete" ;
-    auis:filterScheme "http://accurator.nl/bible%23BiblicalThemeConceptScheme" .
+    auis:api "/api/autocomplete/all" ;
+    auis:filterScheme "http://accurator.nl/bible#BiblicalThemeConceptScheme" .
 
 abibui:BibleCharacter a auis:DropdownField ;
 	rdfs:label "Biblical person"@en ;
@@ -42,7 +42,7 @@ abibui:BibleCharacter a auis:DropdownField ;
 
 abibui:BibleCharacterSource a auis:AlternativesSource ;
     auis:api "/api/autocomplete/all" ;
-    auis:filterScheme "http://accurator.nl/bible%23BiblicalFigureConceptScheme" .
+    auis:filterScheme "http://accurator.nl/bible#BiblicalFigureConceptScheme" .
 
 abibui:Emotion a auis:SelectField ;
 	rdfs:label "Emotie"@nl ;
diff --git a/web/js/components/field.js b/web/js/components/field.js
index f2c58ba..769634e 100644
--- a/web/js/components/field.js
+++ b/web/js/components/field.js
@@ -62,7 +62,7 @@ Field.prototype.initDropdown = function() {
 		this.addDropdownListeners();
 	} else if (this.source.api === "/api/autocomplete/all") {
 		// 2. all alternatives should be obtained
-		this.getAllAlternatives(this.source)
+		this.getAllAlternatives()
 		.then(function(alternativesArray){
 			_field.alternatives = alternativesArray;
 			_field.addTypeAhead();
@@ -203,30 +203,16 @@ Field.prototype.addDropdownListeners = function() {
 	});
 }
 
-// Field.prototype.getAlternatives = function(defenition) {
-// 	// Get autocomplete alternatives
-// 	var filter = JSON.stringify({scheme:"http://accurator.nl/bible#BiblicalFigureConceptScheme"});
-// 	var labelRank = "['http://www.w3.org/2004/02/skos/core#prefLabel'-1]";
-//
-// 	// Return promise
-// 	return $.getJSON("api/autocomplete", {
-// 		q:string,
-// 		filter:filter,
-// 		labelrank:labelRank,
-// 		 locale:this.locale
-// 	 });
-// }
-
 Field.prototype.getAllAlternatives = function() {
 	// Get autocomplete alternatives
-	var filter = JSON.stringify({scheme:"http://accurator.nl/bible#BiblicalFigureConceptScheme"});
-	var labelRank = "['http://www.w3.org/2004/02/skos/core#prefLabel'-1]";
+	var filter = JSON.stringify({scheme: this.source.filterScheme});
+	// var labelRank = "['http://www.w3.org/2004/02/skos/core#prefLabel'-1]";
 
 	// Return promise
 	return $.getJSON("api/autocomplete", {
 		q:"stub",
 		filter:filter,
-		labelrank:labelRank,
+		// labelrank:labelRank,
 		method:"all",
 		locale:this.locale
 	});
@@ -260,7 +246,7 @@ Field.prototype.createBloodhound = function() {
 	} else if (this.source instanceof Array) {
 		// list of labels from source (different array, since we have no uri)
 		for(var i=0; i<this.alternatives.length; i++)
-			array[i] = {value: alternatives[i]};
+			array[i] = {value: this.alternatives[i]};
 
 		return new Bloodhound({
 			datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),