Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a Query to Set the Edit Options #989

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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