wv-gotcha
Version:
 wv-local-service-bus # Purpose To accumulate your walkthroughs to accomplish your common tasks with less effort.
55 lines • 3.13 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WTR_Notes_NewMinMap = void 0;
const decova_filesystem_1 = require("decova-filesystem");
const Dialog_1 = require("../Dialog");
const UPathMan_1 = require("../UPathMan");
const _RegisterWalkthrough_1 = require("./_Foundation/_RegisterWalkthrough");
let WTR_Notes_NewMinMap = class WTR_Notes_NewMinMap {
constructor() {
this.text = `Notes >> New mindmap (.xmmap)`;
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
let docName;
while (true) {
docName = yield Dialog_1.Dialog.askForTextAsync('Document Name?');
const isValid = /^[0-9A-z \-\._\(\)]+$/.test(docName);
if (!isValid) {
Dialog_1.Dialog.error("File name is expected to contains alphabets, numerics and {-,.,_,(,)} only");
continue;
}
break;
}
var newFile = pathMan.getMindMapFile(docName);
if (newFile.exists() === false) {
const templateFile = new decova_filesystem_1.FileInfo(pathMan.xmmapTemplateFile.fullName);
const content = templateFile.readAllText().xReplaceAll(UPathMan_1.TEMPLATE_PLACEHOLDER, docName);
pathMan.getMindMapFile(docName).writeAllText(content);
}
Dialog_1.Dialog.info(`Pleae wait for ${docName}.xmmap to open`);
Dialog_1.Dialog.exec(`\"${newFile.fullName}\"`);
});
}
};
WTR_Notes_NewMinMap = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Notes_NewMinMap);
exports.WTR_Notes_NewMinMap = WTR_Notes_NewMinMap;
//# sourceMappingURL=WTR_Notes_NewMinMap.js.map