mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
feat: add basic autocompletion on inputs expecting a field name (#2281)
Eg. the labelKey or filterKey input.
This commit is contained in:
commit
171aba6676
4 changed files with 22 additions and 5 deletions
|
@ -428,6 +428,10 @@ export class DataLayer extends ServerStored {
|
||||||
if (idx !== -1) this._propertiesIndex.splice(idx, 1)
|
if (idx !== -1) this._propertiesIndex.splice(idx, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allProperties() {
|
||||||
|
return this._propertiesIndex
|
||||||
|
}
|
||||||
|
|
||||||
sortedValues(property) {
|
sortedValues(property) {
|
||||||
return Object.values(this._features)
|
return Object.values(this._features)
|
||||||
.map((feature) => feature.properties[property])
|
.map((feature) => feature.properties[property])
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { uMapAlert as Alert } from '../components/alerts/alert.js'
|
import { uMapAlert as Alert } from '../components/alerts/alert.js'
|
||||||
import { AjaxAutocomplete, AjaxAutocompleteMultiple } from './autocomplete.js'
|
import { AjaxAutocomplete, AjaxAutocompleteMultiple, AutocompleteDatalist } from './autocomplete.js'
|
||||||
import Help from './help.js'
|
import Help from './help.js'
|
||||||
import { ServerRequest } from './request.js'
|
import { ServerRequest } from './request.js'
|
||||||
import { SCHEMA } from './schema.js'
|
import { SCHEMA } from './schema.js'
|
||||||
|
@ -17,6 +17,7 @@ window.U = {
|
||||||
Alert,
|
Alert,
|
||||||
AjaxAutocomplete,
|
AjaxAutocomplete,
|
||||||
AjaxAutocompleteMultiple,
|
AjaxAutocompleteMultiple,
|
||||||
|
AutocompleteDatalist,
|
||||||
Help,
|
Help,
|
||||||
Icon,
|
Icon,
|
||||||
LAYER_TYPES,
|
LAYER_TYPES,
|
||||||
|
|
|
@ -684,7 +684,7 @@ export default class Umap extends ServerStored {
|
||||||
}
|
}
|
||||||
|
|
||||||
allProperties() {
|
allProperties() {
|
||||||
return [].concat(...this.datalayersIndex.map((dl) => dl._propertiesIndex))
|
return [].concat(...this.datalayersIndex.map((dl) => dl.allProperties()))
|
||||||
}
|
}
|
||||||
|
|
||||||
sortedValues(property) {
|
sortedValues(property) {
|
||||||
|
|
|
@ -448,6 +448,17 @@ L.FormBuilder.BlurInput.include({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Adds an autocomplete using all available user defined properties
|
||||||
|
L.FormBuilder.PropertyInput = L.FormBuilder.BlurInput.extend({
|
||||||
|
build: function () {
|
||||||
|
L.FormBuilder.BlurInput.prototype.build.call(this)
|
||||||
|
const autocomplete = new U.AutocompleteDatalist(this.input)
|
||||||
|
// Will be used on Umap and DataLayer
|
||||||
|
const properties = this.builder.obj.allProperties()
|
||||||
|
autocomplete.suggestions = properties
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
|
L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
|
||||||
type: () => 'hidden',
|
type: () => 'hidden',
|
||||||
|
|
||||||
|
@ -1110,10 +1121,11 @@ U.FormBuilder = L.FormBuilder.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
customHandlers: {
|
customHandlers: {
|
||||||
sortKey: 'BlurInput',
|
sortKey: 'PropertyInput',
|
||||||
easing: 'Switch',
|
easing: 'Switch',
|
||||||
facetKey: 'BlurInput',
|
facetKey: 'PropertyInput',
|
||||||
slugKey: 'BlurInput',
|
slugKey: 'PropertyInput',
|
||||||
|
labelKey: 'PropertyInput',
|
||||||
},
|
},
|
||||||
|
|
||||||
computeDefaultOptions: function () {
|
computeDefaultOptions: function () {
|
||||||
|
|
Loading…
Reference in a new issue