Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele Panico committed Nov 7, 2023
1 parent b5cabce commit c234c88
Show file tree
Hide file tree
Showing 18 changed files with 315 additions and 47 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<div *ngIf="previewMode" class="cds-action-preview" [class.isStart]="isStart">

<div *ngIf="!isStart" class="previewContent">
<div *ngIf="!isStart" class="previewContent"
[class.isLast]="isLast">

<div class="icon-action">
<div *ngIf="isLast" class="icon-action">
<img class="active-icon" [src]="element?.src" [title]="element?.name">
</div>
<!-- <label class="title-label">

<label *ngIf="!isLast" class="title-label">
go to
</label>
-->

<cds-connector class="connector"
[idConnector] = "idConnector"
[isConnected] = "isConnected">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,31 @@
flex-direction: row;
align-items: flex-end;
justify-content: flex-end;
gap: 5px;
padding: 0px;

gap: 5px;
padding: 5px 10px;
.connector {
position: absolute;
right: -12px;
top: calc(50% - 10px);
}
&.isLast{
padding: 0px;
.connector {
right: -22px;
top: calc(50% - 10px);
}
}

.title-label{
color: #6c6859;
font-size: 12px;
}
}





/** NG-SELECT **/
.ng-select.ng-select-focused>.ng-select-container {
border-color: $color-red-hex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -18,6 +18,7 @@ export class CdsActionIntentComponent implements OnInit {
@Input() isStart: boolean;
@Input() action: ActionIntentConnected;
@Input() previewMode: boolean = true;
@Input() isLast: boolean = false;

@Output() updateIntentFromConnectorModification = new EventEmitter();
@Output() updateAndSaveAction = new EventEmitter();
Expand All @@ -40,7 +41,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;
Expand Down Expand Up @@ -85,6 +86,8 @@ export class CdsActionIntentComponent implements OnInit {
private updateConnector(){
this.isConnected = this.action.intentName?true:false;
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);
Expand All @@ -93,6 +96,7 @@ export class CdsActionIntentComponent implements OnInit {
this.action.intentName = null;
this.isConnected = false;
} else {
// console.log('[CDS-ACTION-INTENT] connettore creato - PALLINO PIENO :: ', this.connector);
this.isConnected = true;
this.action.intentName = "#"+this.connector.toId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
[style.left.px]="getIntentPosition(intent.intent_id).x"
[intent]="intent">
</cds-event>

<cds-panel-connector-menu *ngIf="IS_OPEN_PANEL_CONNECTOR_MENU"
class="panel--connector--menu"
[style.top.px]="mousePosition.y"
[style.left.px]="mousePosition.x"
(addActionFromConnectorMenu)="onAddActionFromConnectorMenu($event)">
</cds-panel-connector-menu>

</div>

<cds-options class="cds-panel-elements"
Expand All @@ -66,6 +74,8 @@
(onOptionClicked)="onOptionClicked($event)">
</cds-options>



</div>

<cds-add-action-menu class="menu--context--add"
Expand Down Expand Up @@ -100,3 +110,6 @@
id="widget-preview"
class="cds-generic-panel">
</cds-panel-widget>



Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,21 @@ cds-fulfillment {

}

.panel--connector--menu{
top: 0;
left: 0;
width: 30px;
height: 30px;
border-radius: 50%;
padding: 0;
margin: 0;
// background-color: brown;
display: block;
position: absolute;
// overflow: hidden;
z-index: 1;
}


.panel-action-backdrop {
display: flex;
Expand Down Expand Up @@ -287,6 +302,8 @@ cds-fulfillment {
}




/*********** START Draggable *************/
.tds-drag-container {
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { isElementOnTheStage, TYPE_INTENT_ELEMENT, TYPE_OF_MENU, INTENT_TEMP_ID,
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';

const swal = require('sweetalert');
// const swal = require('sweetalert');

@Component({
selector: 'cds-canvas',
Expand Down Expand Up @@ -75,6 +75,11 @@ export class CdsCanvasComponent implements OnInit {
/** panel options */
private subscriptionUndoRedo: Subscription;
stateUndoRedo: any = {undo:false, redo: false};

/** panel connector */
IS_OPEN_PANEL_CONNECTOR_MENU: boolean = false;
mousePosition: any;
connectorSelected: any;

private logger: LoggerService = LoggerInstance.getInstance()
constructor(
Expand Down Expand Up @@ -230,6 +235,7 @@ export class CdsCanvasComponent implements OnInit {
this.IS_OPEN_PANEL_WIDGET = false;
this.IS_OPEN_PANEL_ACTION_DETAIL = false;
this.IS_OPEN_PANEL_BUTTON_CONFIG = false;
this.IS_OPEN_PANEL_CONNECTOR_MENU = false;
// this.closePanelWidget.next();
}

Expand Down Expand Up @@ -420,7 +426,14 @@ export class CdsCanvasComponent implements OnInit {
*/
document.addEventListener(
"connector-selected", (e: CustomEvent) => {
this.logger.log("[CDS-CANVAS] connector-selected:", e);
// console.log("[CDS-CANVAS] connector-selected:", e, e.detail.mouse_pos);
this.IS_OPEN_PANEL_CONNECTOR_MENU = true;
this.mousePosition = e.detail.mouse_pos;
this.mousePosition.x -= 15;
this.mousePosition.y -= 15;
this.connectorSelected = e.detail.connector;
// this.IS_OPEN_ADD_ACTIONS_MENU = true;
// this.positionFloatMenu = e.detail.mouse_pos;
this.intentService.unselectAction();
},
true
Expand Down Expand Up @@ -507,7 +520,7 @@ export class CdsCanvasComponent implements OnInit {
*/
@HostListener('document:mouseup', ['$event'])
onMouseUpHandler(event: KeyboardEvent) {
this.logger.log('[CDS-CANVAS] MOUSE UP CLOSE FLOAT MENU', this.hasClickedAddAction)
this.logger.log('[CDS-CANVAS] MOUSE UP CLOSE FLOAT MENU', this.hasClickedAddAction);
}


Expand Down Expand Up @@ -617,6 +630,7 @@ export class CdsCanvasComponent implements OnInit {
onToogleSidebarIntentsList() {
this.logger.log('[CDS-CANVAS] onToogleSidebarIntentsList ')
this.IS_OPEN_INTENTS_LIST = !this.IS_OPEN_INTENTS_LIST;
this.removeConnectorDraftAndCloseFloatMenu();
this.logger.log('[CDS-CANVAS] onToogleSidebarIntentsList this.IS_OPEN_INTENTS_LIST ', this.IS_OPEN_INTENTS_LIST)
}

Expand Down Expand Up @@ -806,18 +820,20 @@ export class CdsCanvasComponent implements OnInit {
if (!this.hasClickedAddAction) {
this.removeConnectorDraftAndCloseFloatMenu();
}
swal({
title: this.translate.instant('AreYouSure'),
text: "The block " + intent.intent_display_name + " will be deleted",
icon: "warning",
buttons: ["Cancel", "Delete"],
dangerMode: true,
}).then((WillDelete) => {
if (WillDelete) {
this.closeAllPanels();
this.deleteIntent(intent);
}
})
this.closeAllPanels();
this.deleteIntent(intent);
// swal({
// title: this.translate.instant('AreYouSure'),
// text: "The block " + intent.intent_display_name + " will be deleted",
// icon: "warning",
// buttons: ["Cancel", "Delete"],
// dangerMode: true,
// }).then((WillDelete) => {
// if (WillDelete) {
// this.closeAllPanels();
// this.deleteIntent(intent);
// }
// })
}
// --------------------------------------------------------- //

Expand Down Expand Up @@ -891,6 +907,8 @@ export class CdsCanvasComponent implements OnInit {
const pos = { 'x': event.x, 'y': event.y }
this.intentSelected = event.intent;
this.positionFloatMenu = pos;


this.logger.log('[CDS-CANVAS] showPanelActions intentSelected ', this.intentSelected);
this.logger.log('[CDS-CANVAS] showPanelActions positionFloatMenu ', this.positionFloatMenu)
}
Expand Down Expand Up @@ -1025,4 +1043,18 @@ export class CdsCanvasComponent implements OnInit {
// --------------------------------------------------------- //



/**
* onAddActionFromConnectorMenu
* @param event
*/
async onAddActionFromConnectorMenu(event) {
const connector = this.connectorSelected;
// console.log('[CDS-CANVAS] onAddActionFromConnectorMenu:: ', event, connector.id);
if(event.type === "delete"){
this.connectorService.deleteConnector(connector.id, true, true);
this.IS_OPEN_PANEL_CONNECTOR_MENU = false;
}
}
// --------------------------------------------------------- //
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<cds-action-intent class="panel-response"
[isStart]="isStart"
[intentSelected]="intent"
[action]="listOfActions[0]"
[action]="startAction"
(updateAndSaveAction)="onUpdateAndSaveAction($event)">
</cds-action-intent>
</div>
Expand Down Expand Up @@ -265,6 +265,7 @@
class="panel-response action-intent"
[intentSelected]="intent"
[action]="actionIntent"
[isLast]="true"
(updateAndSaveAction)="onUpdateAndSaveAction($event)">
</cds-action-intent>

Expand Down
Loading

0 comments on commit c234c88

Please sign in to comment.