diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.ts index f3193ff7..ffdfebd0 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.ts @@ -3,7 +3,7 @@ import { Intent } from 'src/app/models/intent-model'; import { ActionIntentConnected } from 'src/app/models/action-model'; import { IntentService } from '../../../../../services/intent.service'; import { Subscription } from 'rxjs/internal/Subscription'; -import { TYPE_UPDATE_ACTION, ACTIONS_LIST } from '../../../../../utils'; +import { TYPE_UPDATE_ACTION, ACTIONS_LIST, TYPE_ACTION } from '../../../../../utils'; import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'; import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'; @@ -40,7 +40,7 @@ export class CdsActionIntentComponent implements OnInit { } ngOnInit(): void { - // console.log("[CDS-ACTION-INTENT] elementSelected: ", this.action, this.intentSelected) + console.log("[CDS-ACTION-INTENT] elementSelected: ", this.action, this.intentSelected) this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => { // console.log('[CDS-ACTION-INTENT] - subcribe to isChangedConnector$ >>', connector); this.connector = connector; @@ -83,9 +83,10 @@ export class CdsActionIntentComponent implements OnInit { private updateConnector(){ - this.logger.log('[CDS-ACTION-INTENT] 1- updateConnector :: ',this.action.intentName); - this.isConnected = this.action.intentName?true:false; + // console.log('[CDS-ACTION-INTENT] 1- updateConnector :: ',this.action); try { + if(!this.action.intentName)this.isConnected = false; + else this.isConnected = true; const array = this.connector.fromId.split("/"); const idAction= array[1]; // console.log('[CDS-ACTION-INTENT] 2 - updateConnector :: ', idAction, this.action._tdActionId, this.connector); @@ -95,7 +96,7 @@ export class CdsActionIntentComponent implements OnInit { this.action.intentName = null; this.isConnected = false; } else { - this.logger.log('[CDS-ACTION-INTENT] connettore creato - PALLINO PIENO :: ', this.connector); + console.log('[CDS-ACTION-INTENT] connettore creato - PALLINO PIENO :: ', this.connector); this.isConnected = true; this.action.intentName = "#"+this.connector.toId; } diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.html b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.html index 73e3cb63..82539dca 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.html +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.html @@ -34,7 +34,7 @@ @@ -124,12 +124,12 @@ (updateAndSaveAction)="onUpdateAndSaveAction($event)"> - - + --> 0) this.logger.log("[CDS-INTENT] aggiorno le actions dell'intent"); - this.listOfActions = this.intent.actions; - // AGGIORNO I CONNETTORI - // this.intentService.updateIntent(this.intent); /// DEVO ELIMINARE UPDATE DA QUI!!!!! + // this.listOfActions = this.intent.actions; + this.listOfActions = this.intent.actions.filter(function(obj) { + return obj._tdActionType !== TYPE_ACTION.INTENT; + }); } //UPDATE QUESTIONS @@ -175,8 +176,10 @@ export class CdsIntentComponent implements OnInit, OnDestroy, OnChanges { ngOnInit(): void { console.log('CdsPanelIntentComponent ngAfterViewInit-->', this.intent); - this.setIntentSelected(); + + if (this.intent.actions && this.intent.actions.length === 1 && this.intent.actions[0]._tdActionType === TYPE_ACTION.INTENT && this.intent.intent_display_name === 'start') { + console.log('CdsPanelIntentComponent START-->',this.intent.actions[0]); this.startAction = this.intent.actions[0]; if (!this.startAction._tdActionId) { this.startAction = patchActionId(this.intent.actions[0]); @@ -188,13 +191,31 @@ export class CdsIntentComponent implements OnInit, OnDestroy, OnChanges { // //** center stage on 'start' intent */ // let startElement = document.getElementById(this.intent.intent_id) // this.stageService.centerStageOnHorizontalPosition(startElement) + } else { + this.setIntentSelected(); } - + + this.setActionIntentInIntent(); this.isInternalIntent = checkInternalIntent(this.intent) - this.actionIntent = this.intentService.createNewAction(TYPE_ACTION.INTENT); this.addEventListener(); } + private setActionIntentInIntent(){ + let actionIntent = this.intentService.createNewAction(TYPE_ACTION.INTENT); + this.intent.actions = this.intent.actions.map(function(action) { + if(action._tdActionType === TYPE_ACTION.INTENT){ + actionIntent = action; + } + return action; + }); + this.actionIntent = actionIntent; + if(this.actionIntent.intentName){ + const fromId = this.intent.intent_id+'/'+this.actionIntent._tdActionId; + const toId = this.actionIntent.intentName.replace("#", ""); + this.connectorService.createConnectorFromId(fromId, toId, false, false); //Sync + } + } + ngOnChanges(changes: SimpleChanges): void { // Fixed bug where an empty intent's action placeholder remains visible if an action is dragged from the left action menu this.logger.log('[CDS-INTENT] hideActionPlaceholderOfActionPanel (dragged from sx panel) ', this.hideActionPlaceholderOfActionPanel) @@ -204,14 +225,12 @@ export class CdsIntentComponent implements OnInit, OnDestroy, OnChanges { if (addActionPlaceholderEl !== null) { addActionPlaceholderEl.style.opacity = '0'; } - } else if (this.hideActionPlaceholderOfActionPanel === true) { const addActionPlaceholderEl = document.querySelector('.add--action-placeholder'); this.logger.log('[CDS-INTENT] HERE 2 !!!! addActionPlaceholderEl ', addActionPlaceholderEl); if (addActionPlaceholderEl !== null) { addActionPlaceholderEl.style.opacity = '1'; } - } } @@ -645,10 +664,28 @@ export class CdsIntentComponent implements OnInit, OnDestroy, OnChanges { replaceItemInArrayForKey('_tdActionId', this.intent.actions, action); } } - console.log('[CDS-INTENT] onUpdateAndSaveAction:::: ', object, this.intent, this.intent.actions); + this.setActionIntentInListOfActions(); + // console.log('[CDS-INTENT] onUpdateAndSaveAction:::: ', object, this.intent, this.intent.actions); this.intentService.onUpdateIntentWithTimeout(this.intent, 0, true, connector); } + + + private setActionIntentInListOfActions(){ + let actionIntent = this.actionIntent; + let addIntentAction = true; + this.intent.actions = this.intent.actions.map(function(action) { + if(action._tdActionType === TYPE_ACTION.INTENT){ + addIntentAction = false; + return actionIntent; + } + return action; + }); + if (addIntentAction) { + this.intent.actions.push(this.actionIntent); + } + } + openActionMenu(intent: any, calleBy: string) { this.logger.log('[CDS-INTENT] openActionMenu > intent ', intent) this.logger.log('[CDS-INTENT] openActionMenu > calleBy ', calleBy) diff --git a/src/app/chatbot-design-studio/services/connector.service.ts b/src/app/chatbot-design-studio/services/connector.service.ts index a5dc490b..1e5d30a6 100644 --- a/src/app/chatbot-design-studio/services/connector.service.ts +++ b/src/app/chatbot-design-studio/services/connector.service.ts @@ -166,7 +166,7 @@ export class ConnectorService { // this.logger.log('[CONNECTOR-SERV] intent_display_name', intent.intent_display_name); if(action.intentName && action.intentName !== ''){ const idConnectorFrom = intent.intent_id+'/'+action._tdActionId; - const idConnectorTo = action.intentName.replace("#", ""); ; + const idConnectorTo = action.intentName.replace("#", ""); this.logger.log('[CONNECTOR-SERV] -> CREATE CONNECTOR', idConnectorFrom, idConnectorTo); this.createConnectorFromId(idConnectorFrom, idConnectorTo); } diff --git a/src/assets/js/tiledesk-stage.js b/src/assets/js/tiledesk-stage.js index f6a8b13a..20e13533 100644 --- a/src/assets/js/tiledesk-stage.js +++ b/src/assets/js/tiledesk-stage.js @@ -173,7 +173,6 @@ export class TiledeskStage { event.preventDefault(); pos_mouse_x = event.clientX; pos_mouse_y = event.clientY; - const custom_event = new CustomEvent("start-dragging", { detail: { element: element