Skip to content

Commit

Permalink
Merge pull request #989 from simon-leech/edit-options-query
Browse files Browse the repository at this point in the history
Allow a Query to Set the Edit Options
  • Loading branch information
dbauszus-glx authored Nov 1, 2023
2 parents b960ccf + e7480cc commit 952a878
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/ui/locations/entries/text.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ function edit(entry) {
// Create dropdown from options.
options(entry)

}
}
// If options is empty array, we need to query the table to populate it.
else {

// Query distinct field values from the layer table.
// We can query a particular template or Query distinct field values from the layer table.
mapp.utils.xhr(
`${entry.location.layer.mapview.host}/api/query?` +
mapp.utils.paramString({
template: 'distinct_values',
template: entry.edit.query || 'distinct_values',
dbs: entry.location.layer.dbs,
locale: entry.location.layer.mapview.locale.key,
layer: entry.location.layer.key,
Expand All @@ -49,8 +49,8 @@ function edit(entry) {
// Return first value from object row as options array.
entry.edit.options = [response].flat().map(row => {
return Object.values(row)[0]
})//.filter(val => val !== null)
})

// Create dropdown from options.
options(entry)
})
Expand Down Expand Up @@ -81,20 +81,20 @@ function options(entry) {
const optionEntries = entry.edit.options.map(option => ({

// Assign null if option is null.
title: option === null ? null :
title: option === null ? null :

// Assign string as title.
typeof option === 'string' && option

// Assign first key as title.
|| Object.keys(option)[0],

// Assign null if option is null.
option: option === null ? null :
option: option === null ? null :

// Assign string as option.
typeof option === 'string' && option

// Assign first value as option.
|| Object.values(option)[0]
}))
Expand Down

0 comments on commit 952a878

Please sign in to comment.