Commit 8548ad82 authored by Élodie Thiéblin's avatar Élodie Thiéblin
Browse files

fix: Use custom handler when specified

parent c453b00e984c
......@@ -193,6 +193,7 @@
<!-- YASGUI stuff -->
<script src="https://cdn.jsdelivr.net/npm/yasgui-yasr@2.12.19/dist/yasr.bundled.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/yasgui-yasqe@2.11.22/dist/yasqe.bundled.min.js"></script>
<script type="text/javascript" src="sparnatural.js"></script>
<script>
$.urlParam = function (name) {
......@@ -208,6 +209,25 @@
var sparnatural;
$(document).ready(function ($) {
var defaultSparqlHandler = new SimpleSparqlAutocompleteAndListHandler(
$('#endpoint').text(),
{
semanticPostProcess : function(sparql) {
return sparql;
}
},
null,
"rdfs:label",
);
defaultSparqlHandler.listOrder="count";
// list order is alphabetical by default
var rangeBasedHandler = new RangeBasedAutocompleteAndListHandler(
defaultSparqlHandler,
{
"http://rcfexpense.logilab.fr/Period" : defaultSparqlHandler,
}
);
sparnatural = $("#ui-search").Sparnatural({
config: "./rcfexpense_sparnatural.ttl",
language: "fr",
......@@ -216,7 +236,7 @@
sendQueryOnFirstClassSelected: true,
backgroundBaseColor: "2,184,117",
autocomplete: null,
list: null,
list: rangeBasedHandler,
defaultEndpoint: "http://localhost:3030/rcf/sparql",
sparqlPrefixes: {
RCF: "http://rcfexpense.logilab.fr/",
......@@ -300,6 +320,5 @@
// link yasqe and yasr
yasqe.options.sparql.callbacks.complete = yasr.setResponse;
</script>
<script type="text/javascript" src="sparnatural.js"></script>
</body>
</html>
......@@ -1281,7 +1281,7 @@ var Datasources = require("./SparnaturalConfigDatasources.js");
this.createWidgetComponent = function createWidgetComponent(widgetType, objectPropertyId, rangeClassId) {
switch (widgetType) {
case Config.LIST_PROPERTY:
var handler = this.settings.list;
var handler = this.settings.list;
// to be passed in anonymous functions
var theSpecProvider = this.specProvider;
......@@ -1290,7 +1290,7 @@ var Datasources = require("./SparnaturalConfigDatasources.js");
if(datasource == null) {
// try to read it on the class
datasource = this.specProvider.getDatasource(rangeClassId);
datasource = this.specProvider.getDatasource(rangeClassId);
}
if(datasource == null) {
......@@ -1301,7 +1301,7 @@ var Datasources = require("./SparnaturalConfigDatasources.js");
}
}
if(datasource != null) {
if(datasource != null && handler == null) {
// if we have a datasource, possibly the default one, provide a config based
// on a SparqlTemplate, otherwise use the handler provided
handler = new SparqlTemplateListHandler(
......@@ -1334,7 +1334,7 @@ var Datasources = require("./SparnaturalConfigDatasources.js");
this.cssClasses.ListeWidget = true ;
break;
case Config.AUTOCOMPLETE_PROPERTY:
var handler = this.settings.autocomplete;
var handler = this.settings.autocomplete;
// to be passed in anonymous functions
var theSpecProvider = this.specProvider;
......@@ -1343,7 +1343,7 @@ var Datasources = require("./SparnaturalConfigDatasources.js");
if(datasource == null) {
// try to read it on the class
datasource = this.specProvider.getDatasource(rangeClassId);
datasource = this.specProvider.getDatasource(rangeClassId);
}
if(datasource == null) {
......@@ -1354,7 +1354,7 @@ var Datasources = require("./SparnaturalConfigDatasources.js");
}
}
if(datasource != null) {
if(datasource != null && handler == null) {
// if we have a datasource, possibly the default one, provide a config based
// on a SparqlTemplate, otherwise use the handler provided
handler = new SparqlTemplateAutocompleteHandler(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment