Skip to content

Commit

Permalink
Merge pull request #537 from SolidOS/formChoice#535
Browse files Browse the repository at this point in the history
data source option
  • Loading branch information
bourgeoa committed Apr 6, 2023
2 parents 00ab6c9 + 4665661 commit f9084b4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/widgets/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ field[ns.ui('Classifier').uri] = function (
** <select id=dropDownSelect>
** <option> ....
** <subForm>
** Alternative implementatons caould be:
** Alternative implementatons could be:
** -- pop-up menu (as here)
** -- radio buttons
** -- auto-complete typing
Expand Down Expand Up @@ -783,11 +783,11 @@ field[ns.ui('Choice').uri] = function (

const opts = { form, subForm, disambiguate: false }

function getSelectorOptions () {
function getSelectorOptions (dataSource) {
let possible = []
let possibleProperties
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc)
for (const x in findMembersNT(kb, uiFrom, dataDoc)) {
for (const x in findMembersNT(kb, uiFrom, dataSource)) {
possible.push(kb.fromNT(x))
} // Use rdfs

Expand Down Expand Up @@ -821,12 +821,15 @@ field[ns.ui('Choice').uri] = function (
const multiSelect = kb.any(form, ui('multiselect')) // Optional
if (multiSelect) opts.multiSelect = true

// by default searches the dataDoc graph or optionally the full store
const dataSource = kb.any(form, ui('search-full-store')).length ? null : dataDoc // optional

let selector
rhs.refresh = function () {
// from ui:property
let selectedOptions = kb.each(subject, property, null, dataDoc).map(object => object.value)
// from ui:from + ui:property
let possibleOptions = getSelectorOptions()
let possibleOptions = getSelectorOptions(dataSource)
possibleOptions.push(selectedOptions)
possibleOptions = sortByLabel(possibleOptions)

Expand Down

0 comments on commit f9084b4

Please sign in to comment.