From d902e14f78913626d3f8ac758a3b98776d1589b5 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Fri, 3 Mar 2023 19:10:31 -0300 Subject: [PATCH] fix(basic.gblib): WA page bug removal. --- .../basic.gblib/services/DialogKeywords.ts | 26 +++++++++---------- .../services/KeywordsExpressions.ts | 6 ++--- .../basic.gblib/services/SystemKeywords.ts | 11 ++++---- .../services/WebAutomationServices.ts | 2 +- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index d1e677b4..83e1514c 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -228,7 +228,7 @@ export class DialogKeywords { * * @example x = TODAY */ - public async getToday({}) { + public async getToday({ }) { let d = new Date(), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), @@ -264,28 +264,28 @@ export class DialogKeywords { * * @example EXIT */ - public async exit({}) {} + public async exit({ }) { } /** * Get active tasks. * * @example list = ACTIVE TASKS */ - public async getActiveTasks({ pid }) {} + public async getActiveTasks({ pid }) { } /** * Creates a new deal. * * @example CREATE DEAL dealname,contato,empresa,amount */ - public async createDeal({ pid, dealName, contact, company, amount }) {} + public async createDeal({ pid, dealName, contact, company, amount }) { } /** * Finds contacts in XRM. * * @example list = FIND CONTACT "Sandra" */ - public async fndContact({ pid, name }) {} + public async fndContact({ pid, name }) { } public getContentLocaleWithCulture(contentLocale) { switch (contentLocale) { @@ -488,7 +488,7 @@ export class DialogKeywords { * @example SAVE "contacts.xlsx", name, email, NOW * */ - public async getNow({}) { + public async getNow({ }) { const contentLocale = this.min.core.getParam( this.min.instance, 'Default Content Language', @@ -724,7 +724,7 @@ export class DialogKeywords { * @example MENU * */ - public async showMenu({}) { + public async showMenu({ }) { // https://github.com/GeneralBots/BotServer/issues/237 // return await beginDialog('/menu'); } @@ -828,7 +828,7 @@ export class DialogKeywords { const answer = min.cbMap[userId].promise; if (kind === 'sheet') { - + // Retrieves the .xlsx file associated with the HEAR var AS file.xlsx. let { baseUrl, client } = await GBDeployer.internalGetDriveClient(this.min); @@ -864,12 +864,11 @@ export class DialogKeywords { let list = []; for (; index < results.text.length; index++) { if (results.text[index][0] !== '') { - list.push( results.text[index][0]); + list.push(results.text[index][0]); } - else - { + else { break; - } + } } // Search the answer in one of valid list items loaded from sheeet. @@ -1121,7 +1120,7 @@ export class DialogKeywords { /** * Talks to the user by using the specified text. */ - public async getTalk({ pid, text }) { + public async getTalk({ pid, text }): Promise<{ status: number }> { GBLog.info(`BASIC: TALK '${text}'.`); const { min, user } = await DialogKeywords.getProcessInfo(pid); @@ -1130,6 +1129,7 @@ export class DialogKeywords { await min.conversationalService['sendOnConversation'](min, user, text); } + return { status: 0 }; } private static getChannel(): string { diff --git a/packages/basic.gblib/services/KeywordsExpressions.ts b/packages/basic.gblib/services/KeywordsExpressions.ts index 1d4098fd..c62aed52 100644 --- a/packages/basic.gblib/services/KeywordsExpressions.ts +++ b/packages/basic.gblib/services/KeywordsExpressions.ts @@ -139,7 +139,7 @@ export class KeywordsExpressions { /^\s*open\s*(.*)/gim, ($0, $1, $2) => { let sessionName; - let kind = ''; + let kind = null; let pos; if (pos = $1.match(/\s*AS\s*\#/)) { @@ -655,7 +655,7 @@ export class KeywordsExpressions { // page is not string. // https://github.com/GeneralBots/BotServer/issues/310 const params = this.getParams('page,' + $3, ['handle', 'frameOrSelector', 'selector']); - return `await wa.click ({pid: pid, ${params}})`; + return `await wa.getClick ({pid: pid, ${params}})`; } ]; @@ -764,7 +764,7 @@ export class KeywordsExpressions { /^\s*set\s*(.*)/gim, ($0, $1, $2) => { const params = this.getParams($1, ['file', 'address', 'value']); - return `await sys.set ({pid: pid, ${params}})`; + return `await sys.getSet ({pid: pid, handle:page, ${params}})`; } ]; keywords[i++] = [ diff --git a/packages/basic.gblib/services/SystemKeywords.ts b/packages/basic.gblib/services/SystemKeywords.ts index b7692562..3e4792ea 100644 --- a/packages/basic.gblib/services/SystemKeywords.ts +++ b/packages/basic.gblib/services/SystemKeywords.ts @@ -488,14 +488,15 @@ export class SystemKeywords { * @example SET page, "elementHTMLSelector", "text" * */ - public async set({ pid, file, address, value }): Promise { + public async getSet({ pid, page, file, address, value }): Promise { const { min, user } = await DialogKeywords.getProcessInfo(pid); // Handles calls for HTML stuff - if (file._javascriptEnabled) { - const page = file; - GBLog.info(`BASIC: Web automation setting ${page}' to '${value}' (SET). `); + if (file.indexOf("#") != -1 || + file.indexOf("[") != -1 ) { + value = address; + GBLog.info(`BASIC: Web automation setting ${file}' to '${value}' (SET). `); await this.wa.setElementText({ page, selector: address, text: value }); return; @@ -1694,7 +1695,7 @@ export class SystemKeywords { const address = `${cell}:${cell}`; if (value !== found[columnName]) { - await this.set({ pid, file, address, value }); + await this.getSet({ pid, file, page:null, address, value }); merges++; } } diff --git a/packages/basic.gblib/services/WebAutomationServices.ts b/packages/basic.gblib/services/WebAutomationServices.ts index c9aa7b66..18da7ea0 100644 --- a/packages/basic.gblib/services/WebAutomationServices.ts +++ b/packages/basic.gblib/services/WebAutomationServices.ts @@ -277,7 +277,7 @@ export class WebAutomationServices { * * @example CLICK page,"#idElement" */ - public async click({ pid, handle, frameOrSelector, selector }) { + public async getClick({ pid, handle, frameOrSelector, selector }) { const page = this.getPageByHandle(handle); GBLog.info(`BASIC: Web Automation CLICK element: ${frameOrSelector}.`); if (selector) {