Skip to content

Commit ba0ea69

Browse files
committed
Add dropdown support
1 parent ad8e032 commit ba0ea69

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/graph/node/edit/ShaclQuizFormNode.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,34 @@ export class ShaclQuizFormNode extends Node {
284284

285285
let createIndividualsOfClass = row.class
286286

287-
let input = document.createElement("input")
288-
input.type = "text"
289-
input.style = "margin-right: 10px"
290-
container.appendChild(input)
287+
query = `
288+
PREFIX ff: <https://foerderfunke.org/default#>
289+
PREFIX sh: <http://www.w3.org/ns/shacl#>
290+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
291+
SELECT * WHERE {
292+
?propertyShape sh:path <${datafield}> ;
293+
sh:in/rdf:rest*/rdf:first ?option .
294+
?option ff:title ?label .
295+
}`
296+
rows = await runSparqlSelectQueryOnStore(query, datafieldsStore)
297+
298+
let input
299+
if (rows.length === 0) {
300+
input = document.createElement("input")
301+
input.type = "text"
302+
input.style.marginRight = "10px"
303+
container.appendChild(input)
304+
} else {
305+
input = document.createElement("select")
306+
input.style.marginRight = "10px"
307+
container.appendChild(input)
308+
for (let row of rows) {
309+
let option = document.createElement("option")
310+
option.value = row.option
311+
option.textContent = row.label
312+
input.appendChild(option)
313+
}
314+
}
291315

292316
let submitBtn = document.createElement("input")
293317
submitBtn.type = "button"

0 commit comments

Comments
 (0)