TableEditor: prevent adding properties with "."

fix #426
This commit is contained in:
Yohan Boniface 2020-03-22 15:57:05 +01:00
parent 24baed0c1a
commit f7972b47a4

View file

@ -34,7 +34,7 @@ L.U.TableEditor = L.Class.extend({
};
var doRename = function () {
var newName = prompt(L._('Please enter the new name of this property'), property);
if (!newName) return;
if (!newName || !this.validateName(newName)) return;
this.datalayer.eachLayer(function (feature) {
feature.renameProperty(property, newName);
});
@ -73,6 +73,14 @@ L.U.TableEditor = L.Class.extend({
this.properties = this.datalayer._propertiesIndex;
},
validateName: function (name) {
if (name.indexOf(".") !== -1) {
this.datalayer.map.ui.alert({content: L._('Invalide property name: {name}', {name: name}), level: 'error'});
return false;
}
return true;
},
edit: function () {
var id = 'tableeditor:edit';
this.datalayer.map.fire('dataloading', {id: id});
@ -86,7 +94,7 @@ L.U.TableEditor = L.Class.extend({
label.textContent = label.title = L._('Add a new property');
var addProperty = function () {
var newName = prompt(L._('Please enter the name of the property'));
if (!newName) return;
if (!newName || !this.validateName(newName)) return;
this.datalayer.indexProperty(newName);
this.edit();
};