Merge pull request #2009 from umap-project/fix-sortkey-help

fix: broken sortKey help
This commit is contained in:
Yohan Boniface 2024-07-22 15:57:45 +02:00 committed by GitHub
commit 8d39932e94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 41 deletions

View file

@ -112,6 +112,7 @@ export const SCHEMA = {
type: Boolean, type: Boolean,
impacts: [], impacts: [],
default: false, default: false,
label: translate('Animated transitions'),
}, },
editinosmControl: { editinosmControl: {
type: Boolean, type: Boolean,
@ -130,6 +131,9 @@ export const SCHEMA = {
facetKey: { facetKey: {
type: String, type: String,
impacts: ['ui'], impacts: ['ui'],
helpEntries: ['facetKey'],
placeholder: translate('Example: key1,key2|Label 2,key3|Label 3|checkbox'),
label: translate('Filters keys'),
}, },
fill: { fill: {
type: Boolean, type: Boolean,
@ -160,6 +164,10 @@ export const SCHEMA = {
filterKey: { filterKey: {
type: String, type: String,
impacts: [], impacts: [],
helpEntries: ['filterKey'],
placeholder: translate('Default: name'),
label: translate('Search keys'),
inheritable: true,
}, },
fromZoom: { fromZoom: {
type: Number, type: Number,
@ -437,6 +445,9 @@ export const SCHEMA = {
slugKey: { slugKey: {
type: String, type: String,
impacts: [], impacts: [],
helpEntries: ['slugKey'],
placeholder: translate('Default: name'),
label: translate('Feature identifier key'),
}, },
smoothFactor: { smoothFactor: {
type: Number, type: Number,
@ -452,6 +463,10 @@ export const SCHEMA = {
sortKey: { sortKey: {
type: String, type: String,
impacts: ['datalayer-index', 'data'], impacts: ['datalayer-index', 'data'],
helpEntries: ['sortKey'],
placeholder: translate('Default: name'),
label: translate('Sort key'),
inheritable: true,
}, },
starControl: { starControl: {
type: Boolean, type: Boolean,

View file

@ -220,9 +220,9 @@ L.FormBuilder.Element.include({
if (this.options.label) { if (this.options.label) {
this.label = L.DomUtil.create('label', '', this.getLabelParent()) this.label = L.DomUtil.create('label', '', this.getLabelParent())
this.label.textContent = this.label.title = this.options.label this.label.textContent = this.label.title = this.options.label
if (this.options.helpEntries) if (this.options.helpEntries) {
this.builder.map.help.button(this.label, this.options.helpEntries) this.builder.map.help.button(this.label, this.options.helpEntries)
else if (this.options.helpTooltip) { } else if (this.options.helpTooltip) {
const info = L.DomUtil.create('i', 'info', this.label) const info = L.DomUtil.create('i', 'info', this.label)
L.DomEvent.on( L.DomEvent.on(
info, info,
@ -1098,6 +1098,13 @@ U.FormBuilder = L.FormBuilder.extend({
className: 'umap-form', className: 'umap-form',
}, },
customHandlers: {
sortKey: 'BlurInput',
easing: 'Switch',
facetKey: 'BlurInput',
slugKey: 'BlurInput',
},
computeDefaultOptions: function () { computeDefaultOptions: function () {
for (const [key, schema] of Object.entries(U.SCHEMA)) { for (const [key, schema] of Object.entries(U.SCHEMA)) {
if (schema.type === Boolean) { if (schema.type === Boolean) {
@ -1135,6 +1142,9 @@ U.FormBuilder = L.FormBuilder.extend({
break break
} }
} }
if (this.customHandlers[key]) {
schema.handler = this.customHandlers[key]
}
// FormBuilder use this key for the input type itself // FormBuilder use this key for the input type itself
delete schema.type delete schema.type
this.defaultOptions[key] = schema this.defaultOptions[key] = schema

View file

@ -1219,46 +1219,12 @@ U.Map = L.Map.extend({
_editDefaultProperties: function (container) { _editDefaultProperties: function (container) {
const optionsFields = [ const optionsFields = [
'options.zoomTo', 'options.zoomTo',
['options.easing', { handler: 'Switch', label: L._('Animated transitions') }], 'options.easing',
'options.labelKey', 'options.labelKey',
[ 'options.sortKey',
'options.sortKey', 'options.filterKey',
{ 'options.facetKey',
handler: 'BlurInput', 'options.slugKey',
helpEntries: 'sortKey',
placeholder: L._('Default: name'),
label: L._('Sort key'),
inheritable: true,
},
],
[
'options.filterKey',
{
handler: 'Input',
helpEntries: 'filterKey',
placeholder: L._('Default: name'),
label: L._('Search keys'),
inheritable: true,
},
],
[
'options.facetKey',
{
handler: 'BlurInput',
helpEntries: 'facetKey',
placeholder: L._('Example: key1,key2|Label 2,key3|Label 3|checkbox'),
label: L._('Filters keys'),
},
],
[
'options.slugKey',
{
handler: 'BlurInput',
helpEntries: 'slugKey',
placeholder: L._('Default: name'),
label: L._('Feature identifier key'),
},
],
] ]
builder = new U.FormBuilder(this, optionsFields) builder = new U.FormBuilder(this, optionsFields)