Skip to content

Commit

Permalink
Removed the 'setName' parameter of the 'StandardResource.standardMove…
Browse files Browse the repository at this point in the history
…To(...)' static method to use instead the 'IResource.rename(...)' method
  • Loading branch information
AdrienCastex committed Jun 15, 2017
1 parent 695a93a commit c3f8b6a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
3 changes: 1 addition & 2 deletions lib/resource/physical/PhysicalResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ var PhysicalResource = (function (_super) {
return _this;
}
PhysicalResource.prototype.moveTo = function (parent, newName, overwrite, callback) {
var _this = this;
StandardResource_1.StandardResource.standardMoveTo(this, parent, newName, overwrite, function (name) { return _this.name = name; }, callback);
StandardResource_1.StandardResource.standardMoveTo(this, parent, newName, overwrite, callback);
};
PhysicalResource.prototype.rename = function (newName, callback) {
var _this = this;
Expand Down
2 changes: 1 addition & 1 deletion lib/resource/std/StandardResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export declare abstract class StandardResource implements IResource {
protected updateLastModified(): void;
protected removeFromParent(callback: SimpleCallback): void;
static standardRemoveFromParent(resource: IResource, callback: SimpleCallback): void;
static standardMoveTo(resource: IResource, parent: IResource, newName: string, overwrite: boolean, setName: (name: string) => void, callback: SimpleCallback): void;
static standardMoveTo(resource: IResource, parent: IResource, newName: string, overwrite: boolean, callback: SimpleCallback): void;
static standardMimeType(resource: IResource, targetSource: boolean, callback: ReturnCallback<string>): void;
}
12 changes: 8 additions & 4 deletions lib/resource/std/StandardResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var StandardResource = (function () {
else
callback(null);
};
StandardResource.standardMoveTo = function (resource, parent, newName, overwrite, setName, callback) {
StandardResource.standardMoveTo = function (resource, parent, newName, overwrite, callback) {
parent.getChildren(function (e, children) {
new Workflow_1.Workflow()
.each(children, function (child, cb) { return child.webName(function (e, name) {
Expand Down Expand Up @@ -130,9 +130,13 @@ var StandardResource = (function () {
callback(e);
}
else {
setName(newName);
parent.addChild(resource, function (e) {
callback(e);
resource.rename(newName, function (e, oldName, newName) {
if (e)
callback(e);
else
parent.addChild(resource, function (e) {
callback(e);
});
});
}
});
Expand Down
3 changes: 1 addition & 2 deletions lib/resource/virtual/VirtualResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ var VirtualResource = (function (_super) {
this.removeFromParent(callback);
};
VirtualResource.prototype.moveTo = function (parent, newName, overwrite, callback) {
var _this = this;
StandardResource_1.StandardResource.standardMoveTo(this, parent, newName, overwrite, function (name) { return _this.name = name; }, callback);
StandardResource_1.StandardResource.standardMoveTo(this, parent, newName, overwrite, callback);
};
VirtualResource.prototype.rename = function (newName, callback) {
var oldName = this.name;
Expand Down
2 changes: 1 addition & 1 deletion src/resource/physical/PhysicalResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export abstract class PhysicalResource extends StandardResource
abstract delete(callback : SimpleCallback)
moveTo(parent : IResource, newName : string, overwrite : boolean, callback : SimpleCallback)
{
StandardResource.standardMoveTo(this, parent, newName, overwrite, (name) => this.name = name, callback);
StandardResource.standardMoveTo(this, parent, newName, overwrite, callback);
}
rename(newName : string, callback : Return2Callback<string, string>)
{
Expand Down
12 changes: 8 additions & 4 deletions src/resource/std/StandardResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export abstract class StandardResource implements IResource
else
callback(null);
}
public static standardMoveTo(resource : IResource, parent : IResource, newName : string, overwrite : boolean, setName : (name : string) => void, callback : SimpleCallback)
public static standardMoveTo(resource : IResource, parent : IResource, newName : string, overwrite : boolean, callback : SimpleCallback)
{
parent.getChildren((e, children) => {
new Workflow()
Expand Down Expand Up @@ -196,9 +196,13 @@ export abstract class StandardResource implements IResource
}
else
{
setName(newName);
parent.addChild(resource, (e) => {
callback(e);
resource.rename(newName, (e, oldName, newName) => {
if(e)
callback(e);
else
parent.addChild(resource, (e) => {
callback(e);
})
})
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/resource/virtual/VirtualResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export abstract class VirtualResource extends StandardResource
}
moveTo(parent : IResource, newName : string, overwrite : boolean, callback : SimpleCallback)
{
StandardResource.standardMoveTo(this, parent, newName, overwrite, (name) => this.name = name, callback);
StandardResource.standardMoveTo(this, parent, newName, overwrite, callback);
}
rename(newName : string, callback : Return2Callback<string, string>)
{
Expand Down

0 comments on commit c3f8b6a

Please sign in to comment.