Test and fix current layer rename.

This commit is contained in:
Flint O'Brien
2016-05-02 18:33:45 -04:00
parent 57047b4fb1
commit 2799b4cba2
4 changed files with 61 additions and 11 deletions

View File

@@ -300,10 +300,20 @@ svgedit.draw.Drawing.prototype.getCurrentLayerName = function () {
/**
* Set the current layer's name.
* @param {string} name - The new name.
* @returns {Object} If the name was changed, returns {title:SVGGElement, previousName:string}; otherwise null.
* @param {svgedit.history.HistoryRecordingService} hrService - History recording service
* @returns {string|null} The new name if changed; otherwise, null.
*/
svgedit.draw.Drawing.prototype.setCurrentLayerName = function (name) {
return this.current_layer ? this.current_layer.setName(name) : null;
svgedit.draw.Drawing.prototype.setCurrentLayerName = function (name, hrService) {
var finalName = null;
if( this.current_layer) {
var oldName = this.current_layer.getName();
finalName = this.current_layer.setName(name, hrService);
if( finalName) {
delete this.layer_map[oldName];
this.layer_map[finalName] = this.current_layer;
}
}
return finalName;
};
/**