Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor() {
super('DeleteToDo', [
new botbuilder_dialogs_adaptive_1.LogAction(`DeleteToDo: todos = {user.todos}`),
new botbuilder_dialogs_adaptive_1.IfCondition(`user.todos != null`, [
new botbuilder_dialogs_adaptive_1.SetProperty('$title', '@title'),
new botbuilder_dialogs_adaptive_1.ChoiceInput('$title', `Which todo would you like to remove?`, 'user.todos'),
new botbuilder_dialogs_adaptive_1.EditArray(botbuilder_dialogs_adaptive_1.ArrayChangeType.remove, 'user.todos', '$title'),
new botbuilder_dialogs_adaptive_1.SendActivity(`Deleted the todo named "{$title}".`),
new botbuilder_dialogs_adaptive_1.IfCondition(`user.tips.clearToDos != true`, [
new botbuilder_dialogs_adaptive_1.SendActivity(`You can delete all your todos by saying "delete all todos".`),
new botbuilder_dialogs_adaptive_1.SetProperty('user.tips.clearToDos', 'true')
])
]).else([
new botbuilder_dialogs_adaptive_1.SendActivity(`No todos to delete.`)
])
]);
// Use parents recognizer
this.recognizer = recognizer_1.getRecognizer();
// Add interruption rules
this.addRule(new botbuilder_dialogs_adaptive_1.OnIntent('#Cancel', [], [
new botbuilder_dialogs_adaptive_1.CancelAllDialogs('cancelDelete')
]));
constructor() {
super('DeleteToDo', [
new LogAction(`DeleteToDo: todos = {user.todos}`),
new IfCondition(`user.todos != null`, [
new SetProperty('$title', '@title'),
new ChoiceInput('$title', `Which todo would you like to remove?`, 'user.todos'),
new EditArray(ArrayChangeType.remove, 'user.todos', '$title'),
new SendActivity(`Deleted the todo named "{$title}".`),
new IfCondition(`user.tips.clearToDos != true`, [
new SendActivity(`You can delete all your todos by saying "delete all todos".`),
new SetProperty('user.tips.clearToDos', 'true')
])
]).else([
new SendActivity(`No todos to delete.`)
])
]);
// Use parents recognizer
this.recognizer = getRecognizer();
// Add interruption rules
this.addRule(new OnIntent('#Cancel', [], [
constructor() {
super('DeleteToDo', [
new botbuilder_dialogs_adaptive_1.LogStep(`DeleteToDo: todoList = {user.todoList}`),
new botbuilder_dialogs_adaptive_1.IfCondition(`user.todoList != null`, [
new botbuilder_dialogs_adaptive_1.SaveEntity(schema_1.variables.title, schema_1.entities.title),
new botbuilder_dialogs_adaptive_1.ChoiceInput(schema_1.variables.title, `Which todo would you like to remove?`, schema_1.user.todoList),
new botbuilder_dialogs_adaptive_1.EditArray(botbuilder_dialogs_adaptive_1.ArrayChangeType.remove, schema_1.user.todoList, schema_1.variables.title),
new botbuilder_dialogs_adaptive_1.SendActivity(`Deleted the todo named "${schema_1.variables.print.title}". You can delete all your todos by saying "delete all todos".`)
]).else([
new botbuilder_dialogs_adaptive_1.SendActivity(`No todos to delete.`)
])
]);
// Use parents recognizer
this.recognizer = recognizer_1.getRecognizer();
// Add interruption rules
this.addRule(new botbuilder_dialogs_adaptive_1.IntentRule(schema_1.intents.Cancel, [
new botbuilder_dialogs_adaptive_1.CancelDialog(schema_1.events.CancelDelete)
]));
}
}
function createChoiceInputForAllAdaptiveDialogs() {
const rootDialog = new AdaptiveDialog(AdaptiveDialog.name);
const choices = [];
const switchCases = [];
(resourceExplorer.getResources('.dialog') || []).forEach(resource => {
if (resource.resourceId !== undefined && resource.resourceId.endsWith('.main.dialog')) {
let dialogName = path.basename(resource.resourceId, '.main.dialog');
const subDialog = resourceExplorer.loadType(resource);
choices.push({value : dialogName});
switchCases.push(new Case(dialogName, [subDialog]));
}
});
rootDialog.generator = new TemplateEngineLanguageGenerator();
rootDialog.triggers.push(new OnBeginDialog([
new ChoiceInput().configure({
property: new StringExpression('turn.userChoice'),
prompt: new ActivityTemplate(`Choose a declarative sample to run..`),
style: new EnumExpression(ListStyle.list),
choices: new ArrayExpression(choices),
alwaysPrompt: new BoolExpression(true)
}),
new SendActivity("# Running ${turn.userChoice}.main.dialog"),
new SwitchCondition('turn.userChoice', switchCases),
new RepeatDialog()
]));
return rootDialog;
}