From e2b789e5751800f5af7fb011be741e79995e9df1 Mon Sep 17 00:00:00 2001 From: Brian DeRocher Date: Wed, 20 Sep 2023 10:51:01 -0400 Subject: [PATCH] Do not use the form for the owner property. Only add the owner property to defaultProperties, if there is a user. In other words the user can use the map without logging in. --- umap/static/umap/js/umap.controls.js | 6 +++++- umap/static/umap/js/umap.features.js | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index c77746a8..b0c01c2a 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1565,7 +1565,11 @@ L.U.Editable = L.Editable.extend({ }, _getDefaultProperties: function() { - return { geojson: { properties: { owner: this.map.options.user.id } } } + const result = {} + if (this.map.options.hasOwnProperty('user')) { + result.geojson = { properties: { owner: this.map.options.user.id } } + } + return result }, connectCreatedToMap: function (layer) { diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index 77e7e648..997218ff 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -105,15 +105,14 @@ L.U.FeatureMixin = { let property for (let i = 0; i < this.datalayer._propertiesIndex.length; i++) { property = this.datalayer._propertiesIndex[i] - if (L.Util.indexOf(['name', 'description', 'owner'], property) !== -1) { + if (L.Util.indexOf(['name', 'description'], property) !== -1) { continue } properties.push([`properties.${property}`, { label: property }]) } - // We always want name, description, owner for now (properties management to come) + // We always want name and description for now (properties management to come) properties.unshift('properties.description') properties.unshift('properties.name') - properties.unshift('properties.owner') builder = new L.U.FormBuilder(this, properties, { id: 'umap-feature-properties', callback: this._redraw, // In case we have dynamic options…