mirror of
https://github.com/umap-project/umap.git
synced 2025-05-05 22:11:50 +02:00
Merge 82abfeb8ff
into 56244cf701
This commit is contained in:
commit
4faa6d29aa
4 changed files with 188 additions and 1 deletions
|
@ -11,6 +11,8 @@ import { translate } from './i18n.js'
|
||||||
* - `impacts`: A list of impacts than happen when this property is updated, among
|
* - `impacts`: A list of impacts than happen when this property is updated, among
|
||||||
* 'ui', 'data', 'limit-bounds', 'datalayer-index', 'remote-data',
|
* 'ui', 'data', 'limit-bounds', 'datalayer-index', 'remote-data',
|
||||||
* 'background' 'sync'.
|
* 'background' 'sync'.
|
||||||
|
* - `belongsTo`: A list of conceptual objects this property belongs to, among
|
||||||
|
* 'map', 'feature', 'datalayer'.
|
||||||
*
|
*
|
||||||
* - Extra keys are being passed to the FormBuilder automatically.
|
* - Extra keys are being passed to the FormBuilder automatically.
|
||||||
*/
|
*/
|
||||||
|
@ -20,16 +22,19 @@ export const SCHEMA = {
|
||||||
browsable: {
|
browsable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['datalayer'],
|
||||||
},
|
},
|
||||||
captionBar: {
|
captionBar: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Do you want to display a caption bar?'),
|
label: translate('Do you want to display a caption bar?'),
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
captionControl: {
|
captionControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the caption control'),
|
label: translate('Display the caption control'),
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -37,12 +42,14 @@ export const SCHEMA = {
|
||||||
captionMenus: {
|
captionMenus: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Do you want to display caption menus?'),
|
label: translate('Do you want to display caption menus?'),
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
handler: 'ColorPicker',
|
handler: 'ColorPicker',
|
||||||
label: translate('color'),
|
label: translate('color'),
|
||||||
helpEntries: 'colorValue',
|
helpEntries: 'colorValue',
|
||||||
|
@ -52,14 +59,17 @@ export const SCHEMA = {
|
||||||
choropleth: {
|
choropleth: {
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['datalayer'],
|
||||||
},
|
},
|
||||||
cluster: {
|
cluster: {
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['datalayer'],
|
||||||
},
|
},
|
||||||
dashArray: {
|
dashArray: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('dash array'),
|
label: translate('dash array'),
|
||||||
helpEntries: 'dashArray',
|
helpEntries: 'dashArray',
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
|
@ -67,6 +77,7 @@ export const SCHEMA = {
|
||||||
datalayersControl: {
|
datalayersControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
handler: 'DataLayersControl',
|
handler: 'DataLayersControl',
|
||||||
label: translate('Display the data layers control'),
|
label: translate('Display the data layers control'),
|
||||||
|
@ -75,6 +86,7 @@ export const SCHEMA = {
|
||||||
defaultView: {
|
defaultView: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: [], // no need to update the ui, only useful when loading the map
|
impacts: [], // no need to update the ui, only useful when loading the map
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Default view'),
|
label: translate('Default view'),
|
||||||
choices: [
|
choices: [
|
||||||
['center', translate('Saved center and zoom')],
|
['center', translate('Saved center and zoom')],
|
||||||
|
@ -87,27 +99,32 @@ export const SCHEMA = {
|
||||||
description: {
|
description: {
|
||||||
type: 'Text',
|
type: 'Text',
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('description'),
|
label: translate('description'),
|
||||||
helpEntries: 'textFormatting',
|
helpEntries: 'textFormatting',
|
||||||
},
|
},
|
||||||
displayOnLoad: {
|
displayOnLoad: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: [],
|
impacts: [],
|
||||||
|
belongsTo: ['datalayer'],
|
||||||
},
|
},
|
||||||
displayPopupFooter: {
|
displayPopupFooter: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Do you want to display popup footer?'),
|
label: translate('Do you want to display popup footer?'),
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
easing: {
|
easing: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: [],
|
impacts: [],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
editinosmControl: {
|
editinosmControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the control to open OpenStreetMap editor'),
|
label: translate('Display the control to open OpenStreetMap editor'),
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -115,6 +132,7 @@ export const SCHEMA = {
|
||||||
embedControl: {
|
embedControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the embed control'),
|
label: translate('Display the embed control'),
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -122,10 +140,12 @@ export const SCHEMA = {
|
||||||
facetKey: {
|
facetKey: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map', 'datalayer'],
|
||||||
},
|
},
|
||||||
fill: {
|
fill: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('fill'),
|
label: translate('fill'),
|
||||||
helpEntries: 'fill',
|
helpEntries: 'fill',
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
|
@ -134,6 +154,7 @@ export const SCHEMA = {
|
||||||
fillColor: {
|
fillColor: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
handler: 'ColorPicker',
|
handler: 'ColorPicker',
|
||||||
label: translate('fill color'),
|
label: translate('fill color'),
|
||||||
helpEntries: 'fillColor',
|
helpEntries: 'fillColor',
|
||||||
|
@ -142,6 +163,7 @@ export const SCHEMA = {
|
||||||
fillOpacity: {
|
fillOpacity: {
|
||||||
type: Number,
|
type: Number,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
min: 0.1,
|
min: 0.1,
|
||||||
max: 1,
|
max: 1,
|
||||||
step: 0.1,
|
step: 0.1,
|
||||||
|
@ -152,16 +174,19 @@ export const SCHEMA = {
|
||||||
filterKey: {
|
filterKey: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: [],
|
impacts: [],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
},
|
},
|
||||||
fromZoom: {
|
fromZoom: {
|
||||||
type: Number,
|
type: Number,
|
||||||
impacts: [], // not needed
|
impacts: [], // not needed
|
||||||
|
belongsTo: ['map', 'datalayer'],
|
||||||
label: translate('From zoom'),
|
label: translate('From zoom'),
|
||||||
helpText: translate('Optional.'),
|
helpText: translate('Optional.'),
|
||||||
},
|
},
|
||||||
fullscreenControl: {
|
fullscreenControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the fullscreen control'),
|
label: translate('Display the fullscreen control'),
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -169,14 +194,17 @@ export const SCHEMA = {
|
||||||
geometry: {
|
geometry: {
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['feature'],
|
||||||
},
|
},
|
||||||
heat: {
|
heat: {
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['datalayer'],
|
||||||
},
|
},
|
||||||
iconClass: {
|
iconClass: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('Icon shape'),
|
label: translate('Icon shape'),
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
choices: [
|
choices: [
|
||||||
|
@ -190,6 +218,7 @@ export const SCHEMA = {
|
||||||
iconOpacity: {
|
iconOpacity: {
|
||||||
type: Number,
|
type: Number,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
min: 0.1,
|
min: 0.1,
|
||||||
max: 1,
|
max: 1,
|
||||||
step: 0.1,
|
step: 0.1,
|
||||||
|
@ -200,6 +229,7 @@ export const SCHEMA = {
|
||||||
iconUrl: {
|
iconUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
handler: 'IconUrl',
|
handler: 'IconUrl',
|
||||||
label: translate('Icon symbol'),
|
label: translate('Icon symbol'),
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
|
@ -207,10 +237,12 @@ export const SCHEMA = {
|
||||||
inCaption: {
|
inCaption: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['datalayer'],
|
||||||
},
|
},
|
||||||
interactive: {
|
interactive: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('Allow interactions'),
|
label: translate('Allow interactions'),
|
||||||
helpEntries: 'interactive',
|
helpEntries: 'interactive',
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
|
@ -219,6 +251,7 @@ export const SCHEMA = {
|
||||||
labelDirection: {
|
labelDirection: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('Label direction'),
|
label: translate('Label direction'),
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
choices: [
|
choices: [
|
||||||
|
@ -233,12 +266,14 @@ export const SCHEMA = {
|
||||||
labelInteractive: {
|
labelInteractive: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('Labels are clickable'),
|
label: translate('Labels are clickable'),
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
},
|
},
|
||||||
labelKey: {
|
labelKey: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
helpEntries: 'labelKey',
|
helpEntries: 'labelKey',
|
||||||
placeholder: translate('Default: name'),
|
placeholder: translate('Default: name'),
|
||||||
label: translate('Label key'),
|
label: translate('Label key'),
|
||||||
|
@ -247,50 +282,59 @@ export const SCHEMA = {
|
||||||
licence: {
|
licence: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map', 'datalayer'],
|
||||||
label: translate('licence'),
|
label: translate('licence'),
|
||||||
},
|
},
|
||||||
limitBounds: {
|
limitBounds: {
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['limit-bounds'],
|
impacts: ['limit-bounds'],
|
||||||
|
belongsTo: ['map'],
|
||||||
},
|
},
|
||||||
locateControl: {
|
locateControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the locate control'),
|
label: translate('Display the locate control'),
|
||||||
},
|
},
|
||||||
longCredit: {
|
longCredit: {
|
||||||
type: 'Text',
|
type: 'Text',
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Long credits'),
|
label: translate('Long credits'),
|
||||||
helpEntries: ['longCredit', 'textFormatting'],
|
helpEntries: ['longCredit', 'textFormatting'],
|
||||||
},
|
},
|
||||||
measureControl: {
|
measureControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the measure control'),
|
label: translate('Display the measure control'),
|
||||||
},
|
},
|
||||||
miniMap: {
|
miniMap: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Do you want to display a minimap?'),
|
label: translate('Do you want to display a minimap?'),
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
moreControl: {
|
moreControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Do you want to display the «more» control?'),
|
label: translate('Do you want to display the «more» control?'),
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['ui', 'data'],
|
impacts: ['ui', 'data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('name'),
|
label: translate('name'),
|
||||||
},
|
},
|
||||||
onLoadPanel: {
|
onLoadPanel: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: [], // This is what happens during the map instantiation
|
impacts: [], // This is what happens during the map instantiation
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Do you want to display a panel on load?'),
|
label: translate('Do you want to display a panel on load?'),
|
||||||
choices: [
|
choices: [
|
||||||
['none', translate('None')],
|
['none', translate('None')],
|
||||||
|
@ -304,6 +348,7 @@ export const SCHEMA = {
|
||||||
opacity: {
|
opacity: {
|
||||||
type: Number,
|
type: Number,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
min: 0.1,
|
min: 0.1,
|
||||||
max: 1,
|
max: 1,
|
||||||
step: 0.1,
|
step: 0.1,
|
||||||
|
@ -314,6 +359,7 @@ export const SCHEMA = {
|
||||||
outlink: {
|
outlink: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('Link to…'),
|
label: translate('Link to…'),
|
||||||
helpEntries: 'outlink',
|
helpEntries: 'outlink',
|
||||||
placeholder: 'http://...',
|
placeholder: 'http://...',
|
||||||
|
@ -322,6 +368,7 @@ export const SCHEMA = {
|
||||||
outlinkTarget: {
|
outlinkTarget: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('Open link in…'),
|
label: translate('Open link in…'),
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
default: 'blank',
|
default: 'blank',
|
||||||
|
@ -334,22 +381,26 @@ export const SCHEMA = {
|
||||||
overlay: {
|
overlay: {
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['background'],
|
impacts: ['background'],
|
||||||
|
belongsTo: ['map'],
|
||||||
},
|
},
|
||||||
permanentCredit: {
|
permanentCredit: {
|
||||||
type: 'Text',
|
type: 'Text',
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Permanent credits'),
|
label: translate('Permanent credits'),
|
||||||
helpEntries: ['permanentCredit', 'textFormatting'],
|
helpEntries: ['permanentCredit', 'textFormatting'],
|
||||||
},
|
},
|
||||||
permanentCreditBackground: {
|
permanentCreditBackground: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Permanent credits background'),
|
label: translate('Permanent credits background'),
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
popupContentTemplate: {
|
popupContentTemplate: {
|
||||||
type: 'Text',
|
type: 'Text',
|
||||||
impacts: [], // not needed
|
impacts: [], // not needed
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('Popup content template'),
|
label: translate('Popup content template'),
|
||||||
helpEntries: ['dynamicProperties', 'textFormatting'],
|
helpEntries: ['dynamicProperties', 'textFormatting'],
|
||||||
placeholder: '# {name}',
|
placeholder: '# {name}',
|
||||||
|
@ -359,6 +410,7 @@ export const SCHEMA = {
|
||||||
popupShape: {
|
popupShape: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: [], // not needed
|
impacts: [], // not needed
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('Popup shape'),
|
label: translate('Popup shape'),
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
choices: [
|
choices: [
|
||||||
|
@ -371,6 +423,7 @@ export const SCHEMA = {
|
||||||
popupTemplate: {
|
popupTemplate: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: [], // not needed
|
impacts: [], // not needed
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('Popup content style'),
|
label: translate('Popup content style'),
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
choices: [
|
choices: [
|
||||||
|
@ -385,21 +438,25 @@ export const SCHEMA = {
|
||||||
remoteData: {
|
remoteData: {
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['remote-data'],
|
impacts: ['remote-data'],
|
||||||
|
belongsTo: ['datalayer'],
|
||||||
},
|
},
|
||||||
scaleControl: {
|
scaleControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Do you want to display the scale control?'),
|
label: translate('Do you want to display the scale control?'),
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
scrollWheelZoom: {
|
scrollWheelZoom: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Allow scroll wheel zoom?'),
|
label: translate('Allow scroll wheel zoom?'),
|
||||||
},
|
},
|
||||||
searchControl: {
|
searchControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the search control'),
|
label: translate('Display the search control'),
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -407,28 +464,33 @@ export const SCHEMA = {
|
||||||
shortCredit: {
|
shortCredit: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Short credits'),
|
label: translate('Short credits'),
|
||||||
helpEntries: ['shortCredit', 'textFormatting'],
|
helpEntries: ['shortCredit', 'textFormatting'],
|
||||||
},
|
},
|
||||||
showLabel: {
|
showLabel: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display label'),
|
label: translate('Display label'),
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
slideshow: {
|
slideshow: {
|
||||||
|
belongsTo: ['map'],
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
},
|
},
|
||||||
slugKey: {
|
slugKey: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: [],
|
impacts: [],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
},
|
},
|
||||||
smoothFactor: {
|
smoothFactor: {
|
||||||
type: Number,
|
type: Number,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 10,
|
max: 10,
|
||||||
step: 0.5,
|
step: 0.5,
|
||||||
|
@ -440,16 +502,19 @@ export const SCHEMA = {
|
||||||
sortKey: {
|
sortKey: {
|
||||||
type: String,
|
type: String,
|
||||||
impacts: ['datalayer-index', 'data'],
|
impacts: ['datalayer-index', 'data'],
|
||||||
|
belongsTo: ['map', 'datalayer'],
|
||||||
},
|
},
|
||||||
starControl: {
|
starControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the star map button'),
|
label: translate('Display the star map button'),
|
||||||
},
|
},
|
||||||
stroke: {
|
stroke: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
label: translate('stroke'),
|
label: translate('stroke'),
|
||||||
helpEntries: 'stroke',
|
helpEntries: 'stroke',
|
||||||
inheritable: true,
|
inheritable: true,
|
||||||
|
@ -458,6 +523,7 @@ export const SCHEMA = {
|
||||||
syncEnabled: {
|
syncEnabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['sync', 'ui'],
|
impacts: ['sync', 'ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
label: translate('Enable real-time collaboration'),
|
label: translate('Enable real-time collaboration'),
|
||||||
helpEntries: 'sync',
|
helpEntries: 'sync',
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -465,26 +531,31 @@ export const SCHEMA = {
|
||||||
tilelayer: {
|
tilelayer: {
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['background'],
|
impacts: ['background'],
|
||||||
|
belongsTo: ['map'],
|
||||||
},
|
},
|
||||||
tilelayersControl: {
|
tilelayersControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the tile layers control'),
|
label: translate('Display the tile layers control'),
|
||||||
},
|
},
|
||||||
toZoom: {
|
toZoom: {
|
||||||
type: Number,
|
type: Number,
|
||||||
impacts: [], // not needed
|
impacts: [], // not needed
|
||||||
|
belongsTo: ['map', 'datalayer'],
|
||||||
label: translate('To zoom'),
|
label: translate('To zoom'),
|
||||||
helpText: translate('Optional.'),
|
helpText: translate('Optional.'),
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
type: 'String',
|
type: 'String',
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['datalayer'],
|
||||||
},
|
},
|
||||||
weight: {
|
weight: {
|
||||||
type: Number,
|
type: Number,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 20,
|
max: 20,
|
||||||
step: 1,
|
step: 1,
|
||||||
|
@ -495,10 +566,12 @@ export const SCHEMA = {
|
||||||
zoom: {
|
zoom: {
|
||||||
type: Number,
|
type: Number,
|
||||||
impacts: [], // default zoom, doesn't need to be updated
|
impacts: [], // default zoom, doesn't need to be updated
|
||||||
|
belongsTo: ['map'],
|
||||||
},
|
},
|
||||||
zoomControl: {
|
zoomControl: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
impacts: ['ui'],
|
impacts: ['ui'],
|
||||||
|
belongsTo: ['map'],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
label: translate('Display the zoom control'),
|
label: translate('Display the zoom control'),
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -506,6 +579,7 @@ export const SCHEMA = {
|
||||||
zoomTo: {
|
zoomTo: {
|
||||||
type: Number,
|
type: Number,
|
||||||
impacts: [], // not need to update the view
|
impacts: [], // not need to update the view
|
||||||
|
belongsTo: ['map', 'datalayer', 'feature'],
|
||||||
placeholder: translate('Inherit'),
|
placeholder: translate('Inherit'),
|
||||||
helpEntries: 'zoomTo',
|
helpEntries: 'zoomTo',
|
||||||
label: translate('Default zoom level'),
|
label: translate('Default zoom level'),
|
||||||
|
@ -514,5 +588,6 @@ export const SCHEMA = {
|
||||||
_latlng: {
|
_latlng: {
|
||||||
type: Object,
|
type: Object,
|
||||||
impacts: ['data'],
|
impacts: ['data'],
|
||||||
|
belongsTo: ['feature'],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { propertyBelongsTo } from '../utils.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file contains the updaters: classes that are able to convert messages
|
* This file contains the updaters: classes that are able to convert messages
|
||||||
* received from another party (or the server) to changes on the map.
|
* received from another party (or the server) to changes on the map.
|
||||||
|
@ -35,7 +37,14 @@ class BaseUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
applyMessage(payload) {
|
applyMessage(payload) {
|
||||||
let { verb } = payload
|
let { verb, subject } = payload
|
||||||
|
|
||||||
|
if (verb == 'update') {
|
||||||
|
if (!propertyBelongsTo(payload.key, subject)) {
|
||||||
|
console.error('Invalid message received', payload)
|
||||||
|
return // Do not apply the message
|
||||||
|
}
|
||||||
|
}
|
||||||
return this[verb](payload)
|
return this[verb](payload)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,31 @@ export function getImpactsFromSchema(fields, schema) {
|
||||||
return Array.from(impacted)
|
return Array.from(impacted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the given property belongs to the given subject, according to the schema.
|
||||||
|
*
|
||||||
|
* @param srtring property
|
||||||
|
* @param string subject
|
||||||
|
* @param object schema object. If ommited, global U.SCHEMA will be used.
|
||||||
|
* @returns Bool
|
||||||
|
*/
|
||||||
|
export function propertyBelongsTo(property, subject, schema) {
|
||||||
|
schema = schema || U.SCHEMA
|
||||||
|
if (subject === 'feature') {
|
||||||
|
// FIXME allow properties.whatever
|
||||||
|
property = property.replace('properties.', '').replace('_umap_options.', '')
|
||||||
|
}
|
||||||
|
property = property.replace('options.', '')
|
||||||
|
const splits = property.split('.')
|
||||||
|
const nested = splits.length > 1
|
||||||
|
if (nested) property = splits[0]
|
||||||
|
if (!Object.keys(schema).includes(property)) return false
|
||||||
|
if (nested) {
|
||||||
|
if (schema[property].type !== Object) return false
|
||||||
|
}
|
||||||
|
return schema[property].belongsTo.includes(subject)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import DOM purify, and initialize it.
|
* Import DOM purify, and initialize it.
|
||||||
*
|
*
|
||||||
|
|
|
@ -597,6 +597,84 @@ describe('Utils', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('#propertyBelongsTo', () => {
|
||||||
|
it('should return false on unexisting property', function () {
|
||||||
|
let schema = {}
|
||||||
|
assert.deepEqual(Utils.propertyBelongsTo('foo', 'map', schema), false)
|
||||||
|
})
|
||||||
|
it('should return false if subject is not listed', function () {
|
||||||
|
let schema = {
|
||||||
|
foo: { belongsTo: ['feature'] },
|
||||||
|
}
|
||||||
|
assert.deepEqual(Utils.propertyBelongsTo('foo', 'map', schema), false)
|
||||||
|
})
|
||||||
|
it('should return true if subject is listed', function () {
|
||||||
|
let schema = {
|
||||||
|
foo: { belongsTo: ['map'] },
|
||||||
|
}
|
||||||
|
assert.deepEqual(Utils.propertyBelongsTo('foo', 'map', schema), true)
|
||||||
|
})
|
||||||
|
it('should remove the `options.` prefix before checking', function () {
|
||||||
|
let schema = {
|
||||||
|
foo: { belongsTo: ['map'] },
|
||||||
|
}
|
||||||
|
assert.deepEqual(Utils.propertyBelongsTo('options.foo', 'map', schema), true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Accepts setting properties on objects', function () {
|
||||||
|
let schema = {
|
||||||
|
foo: {
|
||||||
|
type: Object,
|
||||||
|
belongsTo: ['map'],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert.deepEqual(Utils.propertyBelongsTo('options.foo.name', 'map', schema), true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Rejects setting properties on non-objects', function () {
|
||||||
|
let schema = {
|
||||||
|
foo: {
|
||||||
|
type: String,
|
||||||
|
belongsTo: ['map'],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert.deepEqual(
|
||||||
|
Utils.propertyBelongsTo('options.foo.name', 'map', schema),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('when subject = feature, should filter the `properties.`', function () {
|
||||||
|
let schema = {
|
||||||
|
foo: { belongsTo: ['feature'] },
|
||||||
|
}
|
||||||
|
assert.deepEqual(
|
||||||
|
Utils.propertyBelongsTo('properties.foo', 'feature', schema),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('On features, should filter the `_umap_options.`', function () {
|
||||||
|
let schema = {
|
||||||
|
foo: { belongsTo: ['feature'] },
|
||||||
|
}
|
||||||
|
assert.deepEqual(
|
||||||
|
Utils.propertyBelongsTo('properties._umap_options.foo', 'feature', schema),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should accept options.tilelayer.url_template', function () {
|
||||||
|
let schema = {
|
||||||
|
tilelayer: { type: Object, belongsTo: ['map'] },
|
||||||
|
}
|
||||||
|
assert.deepEqual(
|
||||||
|
Utils.propertyBelongsTo('options.tilelayer.url_template', 'map', schema),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('#parseNaiveDate', () => {
|
describe('#parseNaiveDate', () => {
|
||||||
it('should parse a date', () => {
|
it('should parse a date', () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
|
|
Loading…
Reference in a new issue