diff --git a/lib/ui/locations/entries/text.mjs b/lib/ui/locations/entries/text.mjs index 707cc76bb..ec5d0ec9a 100644 --- a/lib/ui/locations/entries/text.mjs +++ b/lib/ui/locations/entries/text.mjs @@ -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, @@ -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) }) @@ -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] }))