fix(sync): Initialize tilelayerand remoteData earlier.

It makes it possible to set these values on a remote peer.
This commit is contained in:
Alexis Métaireau 2024-05-09 17:30:04 +02:00
parent 059103b66c
commit b99c242648
4 changed files with 19 additions and 9 deletions

View file

@ -68,7 +68,6 @@ export function propertyBelongsTo(property, subject, schema) {
property = property.replace('properties.', '').replace('_umap_options.', '') property = property.replace('properties.', '').replace('_umap_options.', '')
} }
property = property.replace('options.', '') property = property.replace('options.', '')
console.log(property)
const splits = property.split('.') const splits = property.split('.')
const nested = splits.length > 1 const nested = splits.length > 1
if (nested) property = splits[0] if (nested) property = splits[0]

View file

@ -210,6 +210,9 @@ U.Map = L.Map.extend({
if (!U.Utils.isObject(this.options.overlay)) { if (!U.Utils.isObject(this.options.overlay)) {
this.options.overlay = {} this.options.overlay = {}
} }
if (!U.Utils.isObject(this.options.tilelayer)) {
this.options.tilelayer = {}
}
this.initShortcuts() this.initShortcuts()
this.onceDataLoaded(function () { this.onceDataLoaded(function () {
@ -1317,9 +1320,6 @@ U.Map = L.Map.extend({
}, },
_editTilelayer: function (container) { _editTilelayer: function (container) {
if (!U.Utils.isObject(this.options.tilelayer)) {
this.options.tilelayer = {}
}
const tilelayerFields = [ const tilelayerFields = [
[ [
'options.tilelayer.name', 'options.tilelayer.name',

View file

@ -469,8 +469,8 @@ U.Layer.Heat = L.HeatLayer.extend({
this._latlngs[i].alt !== undefined this._latlngs[i].alt !== undefined
? this._latlngs[i].alt ? this._latlngs[i].alt
: this._latlngs[i][2] !== undefined : this._latlngs[i][2] !== undefined
? +this._latlngs[i][2] ? +this._latlngs[i][2]
: 1 : 1
grid[y] = grid[y] || [] grid[y] = grid[y] || []
cell = grid[y][x] cell = grid[y][x]
@ -576,6 +576,10 @@ U.DataLayer = L.Evented.extend({
} }
this.setUmapId(data.id) this.setUmapId(data.id)
this.setOptions(data) this.setOptions(data)
if (!U.Utils.isObject(this.options.remoteData)) {
this.options.remoteData = {}
}
// Retrocompat // Retrocompat
if (this.options.remoteData && this.options.remoteData.from) { if (this.options.remoteData && this.options.remoteData.from) {
this.options.fromZoom = this.options.remoteData.from this.options.fromZoom = this.options.remoteData.from
@ -1367,9 +1371,6 @@ U.DataLayer = L.Evented.extend({
) )
popupFieldset.appendChild(builder.build()) popupFieldset.appendChild(builder.build())
if (!U.Utils.isObject(this.options.remoteData)) {
this.options.remoteData = {}
}
const remoteDataFields = [ const remoteDataFields = [
[ [
'options.remoteData.url', 'options.remoteData.url',

View file

@ -690,6 +690,16 @@ describe('Utils', function () {
true 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', () => {