mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
chore: fix updaters to use umap instead of map and properties instead of options
This commit is contained in:
parent
b0eb263d93
commit
e1a24b6180
6 changed files with 18 additions and 15 deletions
|
@ -252,7 +252,7 @@ const ControlsMixin = {
|
||||||
})
|
})
|
||||||
|
|
||||||
const updateConnectedPeersCount = () => {
|
const updateConnectedPeersCount = () => {
|
||||||
connectedPeersCount.innerHTML = this.sync.getNumberOfConnectedPeers()
|
connectedPeersCount.innerHTML = this.umap.sync.getNumberOfConnectedPeers()
|
||||||
}
|
}
|
||||||
updateConnectedPeersCount()
|
updateConnectedPeersCount()
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ export default class Slideshow extends WithTemplate {
|
||||||
|
|
||||||
play() {
|
play() {
|
||||||
if (this._id) return
|
if (this._id) return
|
||||||
if (this.umap.editEnabled || !this.umap.options.slideshow.active) return
|
if (this.umap.editEnabled || !this.umap.properties.slideshow.active) return
|
||||||
L.DomUtil.addClass(document.body, this.CLASSNAME)
|
L.DomUtil.addClass(document.body, this.CLASSNAME)
|
||||||
this._id = window.setInterval(L.bind(this.loop, this), this.options.delay)
|
this._id = window.setInterval(L.bind(this.loop, this), this.options.delay)
|
||||||
this.startSpinner()
|
this.startSpinner()
|
||||||
|
|
|
@ -6,8 +6,8 @@ import { fieldInSchema } from '../utils.js'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class BaseUpdater {
|
class BaseUpdater {
|
||||||
constructor(map) {
|
constructor(umap) {
|
||||||
this.map = map
|
this.umap = umap
|
||||||
}
|
}
|
||||||
|
|
||||||
updateObjectValue(obj, key, value) {
|
updateObjectValue(obj, key, value) {
|
||||||
|
@ -32,8 +32,8 @@ class BaseUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
getDataLayerFromID(layerId) {
|
getDataLayerFromID(layerId) {
|
||||||
if (layerId) return this.map.getDataLayerByUmapId(layerId)
|
if (layerId) return this.umap.getDataLayerByUmapId(layerId)
|
||||||
return this.map.defaultEditDataLayer()
|
return this.umap.defaultEditDataLayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
applyMessage(payload) {
|
applyMessage(payload) {
|
||||||
|
@ -45,18 +45,18 @@ class BaseUpdater {
|
||||||
export class MapUpdater extends BaseUpdater {
|
export class MapUpdater extends BaseUpdater {
|
||||||
update({ key, value }) {
|
update({ key, value }) {
|
||||||
if (fieldInSchema(key)) {
|
if (fieldInSchema(key)) {
|
||||||
this.updateObjectValue(this.map, key, value)
|
this.updateObjectValue(this.umap, key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.map.render([key])
|
this.umap.render([key])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DataLayerUpdater extends BaseUpdater {
|
export class DataLayerUpdater extends BaseUpdater {
|
||||||
upsert({ value }) {
|
upsert({ value }) {
|
||||||
// Inserts does not happen (we use multiple updates instead).
|
// Inserts does not happen (we use multiple updates instead).
|
||||||
this.map.createDataLayer(value, false)
|
this.umap.createDataLayer(value, false)
|
||||||
this.map.render([])
|
this.umap.render([])
|
||||||
}
|
}
|
||||||
|
|
||||||
update({ key, metadata, value }) {
|
update({ key, metadata, value }) {
|
||||||
|
|
|
@ -1245,7 +1245,7 @@ export default class Umap extends ServerStored {
|
||||||
|
|
||||||
render(fields) {
|
render(fields) {
|
||||||
if (fields.includes('numberOfConnectedPeers')) {
|
if (fields.includes('numberOfConnectedPeers')) {
|
||||||
this.renderEditToolbar()
|
this._leafletMap.renderEditToolbar()
|
||||||
this.propagate()
|
this.propagate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,10 @@ export function getImpactsFromSchema(fields, schema) {
|
||||||
export function fieldInSchema(field, schema) {
|
export function fieldInSchema(field, schema) {
|
||||||
const current_schema = schema || U.SCHEMA
|
const current_schema = schema || U.SCHEMA
|
||||||
if (typeof field !== 'string') return false
|
if (typeof field !== 'string') return false
|
||||||
const field_name = field.replace('options.', '').split('.')[0]
|
const field_name = field
|
||||||
|
.replace('options.', '')
|
||||||
|
.replace('properties.', '')
|
||||||
|
.split('.')[0]
|
||||||
return current_schema[field_name] !== undefined
|
return current_schema[field_name] !== undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ def test_websocket_connection_can_sync_polygons(
|
||||||
|
|
||||||
@pytest.mark.xdist_group(name="websockets")
|
@pytest.mark.xdist_group(name="websockets")
|
||||||
def test_websocket_connection_can_sync_map_properties(
|
def test_websocket_connection_can_sync_map_properties(
|
||||||
context, live_server, websocket_server, tilelayer
|
new_page, live_server, websocket_server, tilelayer
|
||||||
):
|
):
|
||||||
map = MapFactory(name="sync", edit_status=Map.ANONYMOUS)
|
map = MapFactory(name="sync", edit_status=Map.ANONYMOUS)
|
||||||
map.settings["properties"]["syncEnabled"] = True
|
map.settings["properties"]["syncEnabled"] = True
|
||||||
|
@ -169,9 +169,9 @@ def test_websocket_connection_can_sync_map_properties(
|
||||||
DataLayerFactory(map=map, data={})
|
DataLayerFactory(map=map, data={})
|
||||||
|
|
||||||
# Create two tabs
|
# Create two tabs
|
||||||
peerA = context.new_page()
|
peerA = new_page()
|
||||||
peerA.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
peerA.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
||||||
peerB = context.new_page()
|
peerB = new_page()
|
||||||
peerB.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
peerB.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
||||||
|
|
||||||
# Name change is synced
|
# Name change is synced
|
||||||
|
|
Loading…
Reference in a new issue