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:
parent
0a83c42724
commit
9c89c50560
3 changed files with 14 additions and 6 deletions
|
@ -1553,16 +1553,19 @@ L.U.Editable = L.Editable.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
createPolyline: function (latlngs) {
|
createPolyline: function (latlngs) {
|
||||||
return new L.U.Polyline(this.map, latlngs)
|
return new L.U.Polyline(this.map, latlngs, this._getDefaultProperties())
|
||||||
},
|
},
|
||||||
|
|
||||||
createPolygon: function (latlngs) {
|
createPolygon: function (latlngs) {
|
||||||
const polygon = new L.U.Polygon(this.map, latlngs)
|
return new L.U.Polygon(this.map, latlngs, this._getDefaultProperties())
|
||||||
return polygon
|
|
||||||
},
|
},
|
||||||
|
|
||||||
createMarker: function (latlng) {
|
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) {
|
connectCreatedToMap: function (layer) {
|
||||||
|
|
|
@ -105,14 +105,15 @@ L.U.FeatureMixin = {
|
||||||
let property
|
let property
|
||||||
for (let i = 0; i < this.datalayer._propertiesIndex.length; i++) {
|
for (let i = 0; i < this.datalayer._propertiesIndex.length; i++) {
|
||||||
property = this.datalayer._propertiesIndex[i]
|
property = this.datalayer._propertiesIndex[i]
|
||||||
if (L.Util.indexOf(['name', 'description'], property) !== -1) {
|
if (L.Util.indexOf(['name', 'description', 'owner'], property) !== -1) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
properties.push([`properties.${property}`, { label: property }])
|
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.description')
|
||||||
properties.unshift('properties.name')
|
properties.unshift('properties.name')
|
||||||
|
properties.unshift('properties.owner')
|
||||||
builder = new L.U.FormBuilder(this, properties, {
|
builder = new L.U.FormBuilder(this, properties, {
|
||||||
id: 'umap-feature-properties',
|
id: 'umap-feature-properties',
|
||||||
callback: this._redraw, // In case we have dynamic options…
|
callback: this._redraw, // In case we have dynamic options…
|
||||||
|
|
|
@ -939,6 +939,10 @@ L.U.FormBuilder = L.FormBuilder.extend({
|
||||||
|
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
name: { label: L._('name') },
|
name: { label: L._('name') },
|
||||||
|
owner: {
|
||||||
|
label: 'owner',
|
||||||
|
// handler: 'BlurInput', // this field should be hidden, not sure if blur does it.
|
||||||
|
},
|
||||||
description: {
|
description: {
|
||||||
label: L._('description'),
|
label: L._('description'),
|
||||||
handler: 'Textarea',
|
handler: 'Textarea',
|
||||||
|
|
Loading…
Reference in a new issue