Set a default property for features that the owner is the current user.

https://github.com/umap-project/umap/issues/430
This commit is contained in:
Brian DeRocher 2023-09-19 19:04:00 -04:00
parent 0a83c42724
commit 9c89c50560
3 changed files with 14 additions and 6 deletions

View file

@ -1553,16 +1553,19 @@ L.U.Editable = L.Editable.extend({
},
createPolyline: function (latlngs) {
return new L.U.Polyline(this.map, latlngs)
return new L.U.Polyline(this.map, latlngs, this._getDefaultProperties())
},
createPolygon: function (latlngs) {
const polygon = new L.U.Polygon(this.map, latlngs)
return polygon
return new L.U.Polygon(this.map, latlngs, this._getDefaultProperties())
},
createMarker: function (latlng) {
return new L.U.Marker(this.map, latlng)
return new L.U.Marker(this.map, latlng, this._getDefaultProperties())
},
_getDefaultProperties: function() {
return { geojson: { properties: { owner: this.map.options.user.id } } }
},
connectCreatedToMap: function (layer) {

View file

@ -105,14 +105,15 @@ 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'], property) !== -1) {
if (L.Util.indexOf(['name', 'description', 'owner'], property) !== -1) {
continue
}
properties.push([`properties.${property}`, { label: property }])
}
// We always want name and description for now (properties management to come)
// We always want name, description, owner 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…

View file

@ -939,6 +939,10 @@ L.U.FormBuilder = L.FormBuilder.extend({
defaultOptions: {
name: { label: L._('name') },
owner: {
label: 'owner',
// handler: 'BlurInput', // this field should be hidden, not sure if blur does it.
},
description: {
label: L._('description'),
handler: 'Textarea',