kitten-cloud-function
Version:
用于编程猫源码云功能(云变量、云列表等)的客户端工具
59 lines (58 loc) • 1.83 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.KittenCloudListEmptyCommand = void 0;
const other_1 = require("../../../../utils/other");
const kitten_cloud_data_update_source_1 = require("../kitten-cloud-data-update-source");
const kitten_cloud_list_update_command_1 = require("./kitten-cloud-list-update-command");
class KittenCloudListEmptyCommand extends kitten_cloud_list_update_command_1.KittenCloudListUpdateCommand {
constructor(source, list) {
super(source, list);
this.list = list;
this.backup = other_1.None;
}
execute() {
if (this.backup != other_1.None) {
throw new Error("无法执行命令:命令已被执行,不能重复执行");
}
this.backup = this.list.value;
this.list.value = [];
this.list.emptied.emit({
source: this.source,
list: this.backup.slice()
});
}
revoke() {
if (this.backup == other_1.None) {
throw new Error("无法撤销命令:命令尚未执行");
}
this.list.value = this.backup;
this.list.replacedAll.emit({
source: kitten_cloud_data_update_source_1.KittenCloudDataUpdateSource.REVOKE,
originalList: [],
newList: this.backup.slice()
});
this.backup = other_1.None;
}
isEffective() {
return true;
}
isLegal() {
return true;
}
toJSON() {
return {
method: "empty"
};
}
toCloudJSON() {
return {
action: "delete",
cvid: this.list.cvid,
nth: "all"
};
}
toString() {
return `清空云列表 ${this.data.name} `;
}
}
exports.KittenCloudListEmptyCommand = KittenCloudListEmptyCommand;
;