Skip to content

Commit

Permalink
bug fix create connector
Browse files Browse the repository at this point in the history
  • Loading branch information
dariodepa75 committed Oct 31, 2023
1 parent edfbcd1 commit b299a78
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export class CdsCanvasComponent implements OnInit {
@ViewChild('drawer_of_items_to_zoom_and_drag', { static: false }) drawerOfItemsToZoomAndDrag: ElementRef;

@Output() testItOut = new EventEmitter();
// @Output() closePanelWidget = new EventEmitter();

@Input() onHeaderTestItOut: Observable<Intent | boolean>

id_faq_kb: string;
Expand Down Expand Up @@ -117,9 +115,6 @@ export class CdsCanvasComponent implements OnInit {
this.stageService.setDrawer();
this.connectorService.initializeConnectors();
this.addEventListener();
// setTimeout(()=> {
// let newPos = scaleAndcenterStageOnCenterPosition(this.listOfIntents)
// }, 1000)
}

private async setStartIntent(){
Expand All @@ -135,8 +130,6 @@ export class CdsCanvasComponent implements OnInit {
if(startElement){
this.stageService.centerStageOnHorizontalPosition(startElement);
}
// let startElement = document.getElementById(intentSelected.intent_id);
// }
}
}

Expand Down Expand Up @@ -235,12 +228,9 @@ export class CdsCanvasComponent implements OnInit {
private initListOfIntents() {
this.listOfIntents.forEach(intent => {
if (intent.actions) {
intent.actions = intent.actions.filter(obj => obj !== null); //patch if action is null
intent.actions = intent.actions.filter(obj => obj !== null);
}
});
// this.updatePanelIntentList = !this.updatePanelIntentList;
/* variabile booleana aggiunta per far scattare l'onchange nei componenti importati dalla dashboard
* ngOnChanges funziona bene solo sugli @import degli elementi primitivi!!! */
this.refreshIntents();
}

Expand Down
76 changes: 41 additions & 35 deletions src/app/chatbot-design-studio/services/connector.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,39 +77,13 @@ export class ConnectorService {
*
*/
public createConnectors(intents){
this.logger.log('[CONNECTOR-SERV] -----> createConnectors::: ', intents);
// this.logger.log('[CONNECTOR-SERV] -----> createConnectors::: ', intents);
intents.forEach(intent => {
this.createConnectorsOfIntent(intent);
});
}

// /**
// * createConnectorFromId
// * @param fromId
// * @param toId
// * @returns
// */
// public async createConnectorFromId_old(fromId, toId, save=false, undo=false) {
// this.logger.log('[CONNECTOR-SERV] createConnectorFromId fromId ', fromId, ' toId ', toId);
// const connectorID = fromId+'/'+toId;
// // let connector = await isElementOnTheStage(connectorID); // sync
// const isConnector = document.getElementById(connectorID);
// if (isConnector) {
// this.logger.log('[CONNECTOR-SERV] il connettore esiste già', connectorID);
// // this.deleteConnector(connectorID);
// // return true;
// }
// let isOnTheStageFrom = await isElementOnTheStage(fromId); // sync
// this.logger.log('[CONNECTOR-SERV] isOnTheStageFrom', isOnTheStageFrom);
// let isOnTheStageTo = await isElementOnTheStage(toId); // sync
// this.logger.log('[CONNECTOR-SERV] isOnTheStageFrom', isOnTheStageFrom);
// if(isOnTheStageFrom && isOnTheStageTo){
// const result = await this.tiledeskConnectors.createConnectorFromId(fromId, toId, save, undo);
// return result;
// } else {
// return false;
// }
// }


/**
* createConnectorFromId
Expand All @@ -127,13 +101,22 @@ export class ConnectorService {
this.tiledeskConnectors.updateConnectorsOutOfItent(connectorID);
return true;
}
let isOnTheStageFrom = await isElementOnTheStage(fromId); // sync
this.logger.log('[CONNECTOR-SERV] isOnTheStageFrom', isOnTheStageFrom);
let isOnTheStageTo = await isElementOnTheStage(toId); // sync
this.logger.log('[CONNECTOR-SERV] isOnTheStageFrom', isOnTheStageFrom);
if(isOnTheStageFrom && isOnTheStageTo){
const fromEle = document.getElementById(fromId);
const toEle = document.getElementById(toId);

let fromEle = document.getElementById(fromId);
if(!fromEle) {
fromEle = await isElementOnTheStage(fromId); // sync
this.logger.log('[CONNECTOR-SERV] isOnTheStageFrom', fromEle);
}

let toEle = document.getElementById(toId);
if(!toEle) {
toEle = await isElementOnTheStage(toId); // sync
this.logger.log('[CONNECTOR-SERV] isOnTheStageFrom', toEle);
}

if(fromEle && toEle){
// const fromEle = document.getElementById(fromId);
// const toEle = document.getElementById(toId);
const fromPoint = this.tiledeskConnectors.elementLogicCenter(fromEle);
const toPoint = this.tiledeskConnectors.elementLogicTopLeft(toEle);
this.tiledeskConnectors.createConnector(fromId, toId, fromPoint, toPoint, save, undo);
Expand All @@ -144,6 +127,29 @@ export class ConnectorService {
}

























/**
* refreshConnectorsOfIntent
* @param intent
Expand Down
2 changes: 1 addition & 1 deletion src/app/chatbot-design-studio/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export function convertJsonToArray(jsonData:any){
}

export async function isElementOnTheStage(elementId:string): Promise<any>{
// if(document.getElementById(elementId)) return true;

return new Promise((resolve) => {
let intervalId = setInterval(async () => {
const result = document.getElementById(elementId);
Expand Down

0 comments on commit b299a78

Please sign in to comment.