Skip to content

Commit

Permalink
feature(402683): made changes to get customer block details from API
Browse files Browse the repository at this point in the history
  • Loading branch information
VijayalakshmirSF4471 committed Dec 27, 2024
1 parent 7a7e478 commit 646d833
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</ng-template>

<ng-template #nodeTemplate let-data>
@if(data.data.chatWorkflowBlockId !== chatWorkflowBlockTypeEnum.SendTextMessage){
@if(data.data.chatWorkflowBlockId !== chatWorkflowBlockTypeEnum.SendTextMessage && data.data.chatWorkflowBlockId !== chatWorkflowBlockTypeEnum.GetCustomerDetails) {
<div><label style="padding: 5px;">{{ data.data.fieldDetails.label }}</label></div>
}
@switch (data.data.chatWorkflowBlockId){
Expand All @@ -51,6 +51,17 @@
</div>
</ng-container>
}
@case(chatWorkflowBlockTypeEnum.GetCustomerDetails){
<ng-container>
<div><label>Get Email details</label></div>
@if (data.data.customerBlockFieldInfo.isNameEditorEnabled){
<div><label>Get Name details</label></div>
}
@if (data.data.customerBlockFieldInfo.isPhoneEditorEnabled){
<div><label>Get Phone number details</label></div>
}
</ng-container>
}
@case(chatWorkflowBlockTypeEnum.GetPickerInput){
@switch (data.data.chatWorkflowEditorTypeId){
@case (chatWorkflowEditorTypeEnum.Boolean){
Expand Down Expand Up @@ -125,13 +136,6 @@
}
}
}
@case(chatWorkflowBlockTypeEnum.GetCustomerDetails){
<ng-container>
<div><label>Get Email details</label></div>
<div><label *ngIf="data.data.fieldDetails.hasNameDetails">Get Name details</label></div>
<div><label *ngIf="data.data.fieldDetails.hasPhoneNumberDetails">Get Phone number details</label></div>
</ng-container>
}
}
</ng-template>
</ejs-diagram>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,5 +347,4 @@ export class WorkflowDiagramComponent implements AfterViewInit {
this.diagram.loadDiagram(jsonString);
this.fileInput.nativeElement.value = '';
}

}
49 changes: 23 additions & 26 deletions src/app/components/workflow-sidebar/workflow-sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SidebarComponent, SidebarModule } from '@syncfusion/ej2-angular-navigat
import { TextFormatEnum, ChatWorkflowEditorTypeEnum, ChatWorkflowBlockTypeEnum } from '../../models/enum';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { FieldDetails, FieldOptionDetail, FieldValidation, MessageDetails, RuleData2 } from '../../models/appModel';
import { CustomerBlockFieldDetails, FieldDetails, FieldOptionDetail, FieldValidation, MessageDetails, RuleData2 } from '../../models/appModel';
import { NodeModel } from '@syncfusion/ej2-angular-diagrams';
import { DropDownListComponent, DropDownListModule } from '@syncfusion/ej2-angular-dropdowns';
import { DatePickerModule, DateTimePickerModule } from '@syncfusion/ej2-angular-calendars';
Expand Down Expand Up @@ -212,42 +212,42 @@ export class WorkflowSidebarComponent {
isPrivate: this.checkedIsPrivate,
textFormat: this.ddlTextFormat.value as TextFormatEnum
}
this.newNodeInfo = this.createNodeInfo(null, this.nodeBlockType, this.selectedWorkFlowId, null, null, messageInfo);
this.newNodeInfo = this.createNodeInfo(null, this.nodeBlockType, this.selectedWorkFlowId, null, null, messageInfo, null);
break;
}
case (this.chatWorkflowBlockTypeEnum.GetPickerInput): {
switch (this.nodeEditType) {
case (this.chatWorkflowEditorTypeEnum.Boolean): {
let fieldInfo = this.createFieldInfo(null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null, null);
break;
}
case (this.chatWorkflowEditorTypeEnum.Buttons): {
let fieldOptionInfo = this.mapOptionsToFieldOptions();
let fieldInfo = this.createFieldInfo(null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, fieldOptionInfo, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, fieldOptionInfo, null, null);
this.newNodeHeight += (this.options.length * 25);
break;
}
case this.chatWorkflowEditorTypeEnum.DropDown: {
let fieldOptionInfo = this.mapOptionsToFieldOptions();
let fieldInfo = this.createFieldInfo(null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, fieldOptionInfo, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, fieldOptionInfo, null, null);
this.newNodeHeight += (this.options.length * 25);
break;
}
case (this.chatWorkflowEditorTypeEnum.MultiSelect): {
let fieldValidationInfo = this.createFieldValidationInfo(this.fieldOptionMinValue.toString(), this.fieldOptionMaxValue.toString(), null);
let fieldOptionInfo = this.mapOptionsToFieldOptions();
let fieldInfo = this.createFieldInfo(fieldValidationInfo);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, fieldOptionInfo, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, fieldOptionInfo, null, null);
this.newNodeHeight += (this.options.length * 25);
break;
}
case (this.chatWorkflowEditorTypeEnum.List): {
let fieldOptionInfo = this.mapOptionsToFieldOptions();
let fieldInfo = this.createFieldInfo(null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, fieldOptionInfo, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, fieldOptionInfo, null, null);
this.newNodeHeight += (this.options.length * 25);
break;
}
Expand All @@ -259,13 +259,13 @@ export class WorkflowSidebarComponent {
case (this.chatWorkflowEditorTypeEnum.Text): {
let fieldValidationInfo = this.createFieldValidationInfo(null, this.fieldOptionMaxValue.toString(), null);
let fieldInfo = this.createFieldInfo(fieldValidationInfo);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null, null);
break;
}
case (this.chatWorkflowEditorTypeEnum.TextArea): {
let fieldValidationInfo = this.createFieldValidationInfo(null, this.fieldOptionMaxValue.toString(), null);
let fieldInfo = this.createFieldInfo(fieldValidationInfo);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null, null);
break;
}
case (this.chatWorkflowEditorTypeEnum.Date): {
Expand All @@ -276,7 +276,7 @@ export class WorkflowSidebarComponent {

let fieldValidationInfo = this.createFieldValidationInfo(minDate, maxDate, null);
let fieldInfo = this.createFieldInfo(fieldValidationInfo);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null, null);
break;
}
case (this.chatWorkflowEditorTypeEnum.DateTime): {
Expand All @@ -286,33 +286,37 @@ export class WorkflowSidebarComponent {

let fieldValidationInfo = this.createFieldValidationInfo(minDateTime, maxDateTime, null);
let fieldInfo = this.createFieldInfo(fieldValidationInfo);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null, null);
break;
}
case (this.chatWorkflowEditorTypeEnum.Number): {
let fieldValidationInfo = this.createFieldValidationInfo(this.fieldOptionMinValue.toString(), this.fieldOptionMaxValue.toString(), null);
let fieldInfo = this.createFieldInfo(fieldValidationInfo);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null, null);
break;
}
case (this.chatWorkflowEditorTypeEnum.Decimal): {
let fieldValidationInfo = this.createFieldValidationInfo(this.fieldOptionMinValue.toString(), this.fieldOptionMaxValue.toString(), null);
let fieldInfo = this.createFieldInfo(fieldValidationInfo);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null, null);
break;
}
case (this.chatWorkflowEditorTypeEnum.Regex): {
let fieldValidationInfo = this.createFieldValidationInfo(null, null, this.fieldOptionRegexValue);
let fieldInfo = this.createFieldInfo(fieldValidationInfo);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null);
this.newNodeInfo = this.createNodeInfo(this.nodeEditType, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null, null);
break;
}
}
break;
}
case (this.chatWorkflowBlockTypeEnum.GetCustomerDetails): {
let fieldInfo = this.createCustomerBlockFieldInfo();
this.newNodeInfo = this.createNodeInfo(null, this.nodeBlockType, this.selectedWorkFlowId, fieldInfo, null, null);
let customerBlockFieldInfo : CustomerBlockFieldDetails = {
isEmailEditorEnabled: this.getEmailInfo,
isNameEditorEnabled: this.getNameInfo,
isPhoneEditorEnabled: this.getPhoneNumberInfo,
}
this.newNodeInfo = this.createNodeInfo(null, this.nodeBlockType, this.selectedWorkFlowId, null, null, null, customerBlockFieldInfo);
break;
}
}
Expand All @@ -325,7 +329,7 @@ export class WorkflowSidebarComponent {
}
}

public createNodeInfo(editorTypeId: number | null, blockId: number, workflowId: number, fieldInfo: FieldDetails | null, fieldOptionInfo: FieldOptionDetail[] | null, messageInfo: MessageDetails | null): RuleData2 {
public createNodeInfo(editorTypeId: number | null, blockId: number, workflowId: number, fieldInfo: FieldDetails | null, fieldOptionInfo: FieldOptionDetail[] | null, messageInfo: MessageDetails | null, customerBlockFieldInfo: CustomerBlockFieldDetails | null): RuleData2 {
let ruleDataId = this.isEdit ? 0 : WorkflowSidebarComponent.nodeLength++; // Need to set value dynamically from db
return {
id: ruleDataId,
Expand All @@ -338,7 +342,8 @@ export class WorkflowSidebarComponent {
fieldDetails: fieldInfo,
branchDetails: null,
messageDetails: messageInfo,
fieldOptionDetails: fieldOptionInfo
fieldOptionDetails: fieldOptionInfo,
customerBlockFieldInfo: customerBlockFieldInfo
};
}

Expand Down Expand Up @@ -367,14 +372,6 @@ export class WorkflowSidebarComponent {
}
}

public createCustomerBlockFieldInfo(): FieldDetails {
return {
hasEmailDetails: this.getEmailInfo,
hasNameDetails: this.getNameInfo,
hasPhoneNumberDetails: this.getPhoneNumberInfo,
}
}

public createNode(width: number, height: number, nodeInfo: RuleData2): NodeModel {
return {
id: `node${nodeInfo.id}`,
Expand Down
12 changes: 9 additions & 3 deletions src/app/models/appModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ export interface FieldDetails {
value?: string;
groupId?: number;
ruleType?: number;
hasEmailDetails?: boolean; // Indicates if the customer block has email details
hasNameDetails?: boolean;
hasPhoneNumberDetails?: boolean;
}

// Define MessageDetails interface
Expand All @@ -49,6 +46,12 @@ export interface BranchDetail {
value?: string | null;
}

export interface CustomerBlockFieldDetails {
isEmailEditorEnabled?: boolean;
isNameEditorEnabled?: boolean;
isPhoneEditorEnabled?: boolean;
}

// Define the main Workflow interface
export interface RuleData2 {
id: number;
Expand All @@ -62,6 +65,8 @@ export interface RuleData2 {
branchDetails?: BranchDetail[] | null;
messageDetails?: MessageDetails | null;
fieldOptionDetails?: FieldOptionDetail[] | null;
customerBlockFieldInfo?: CustomerBlockFieldDetails | null;
parentId?: number | null;
}

// Define the main Workflow interface
Expand All @@ -75,5 +80,6 @@ export interface ChatWorkflowRulesData {
branchDetails?: BranchDetail[] | null;
messageDetails?: MessageDetails | null;
fieldOptionDetails?: FieldOptionDetail[] | null;
customerBlockFieldInfo?: CustomerBlockFieldDetails | null;
parentId?: number | null;
}

0 comments on commit 646d833

Please sign in to comment.