parent
24baed0c1a
commit
f7972b47a4
1 changed files with 10 additions and 2 deletions
|
@ -34,7 +34,7 @@ L.U.TableEditor = L.Class.extend({
|
||||||
};
|
};
|
||||||
var doRename = function () {
|
var doRename = function () {
|
||||||
var newName = prompt(L._('Please enter the new name of this property'), property);
|
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) {
|
this.datalayer.eachLayer(function (feature) {
|
||||||
feature.renameProperty(property, newName);
|
feature.renameProperty(property, newName);
|
||||||
});
|
});
|
||||||
|
@ -73,6 +73,14 @@ L.U.TableEditor = L.Class.extend({
|
||||||
this.properties = this.datalayer._propertiesIndex;
|
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 () {
|
edit: function () {
|
||||||
var id = 'tableeditor:edit';
|
var id = 'tableeditor:edit';
|
||||||
this.datalayer.map.fire('dataloading', {id: id});
|
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');
|
label.textContent = label.title = L._('Add a new property');
|
||||||
var addProperty = function () {
|
var addProperty = function () {
|
||||||
var newName = prompt(L._('Please enter the name of the property'));
|
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.datalayer.indexProperty(newName);
|
||||||
this.edit();
|
this.edit();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue