Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add tooltip support #8

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<div class="tree-group" [ngClass]="{'no-node': !group.children?.length}">
<workflow-tooltip-render [showsTooltip]="showsTooltip"
[tooltipText]="tooltipText"
[topPosition]="topPosition"
[leftPosition]="leftPosition"></workflow-tooltip-render>
<div class="workflow-group">
<div class="workflow-group-content">
<span *ngIf="!isFirst"> {{ group.name }} </span>
Expand Down Expand Up @@ -86,6 +90,8 @@
[popperPlacement]="'bottom-start'"
[popperApplyClass]="'workflow-popper'"
(click)="onPoperClick($event, inputPopper)"
(mouseover)="showTooltip($event, nodeWithInput, input)"
(mouseout)="hideTooltip()"
>
<span
class="value-text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
} from '../../types/base.types';
import {IDropdownSettings} from 'ng-multiselect-dropdown';
import {
ChangeColumnValue,
GatewayElement,
ReadColumnValue,
TriggerWhenColumnChanges,
Expand Down Expand Up @@ -118,6 +119,11 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {

nodeList: WorkflowNode<E>[];

showsTooltip = false;
tooltipText = 'This is default parent component text';
topPosition: any;
leftPosition: any;

public types = NodeTypes;
public prevPopperRef: NgxPopperjsContentComponent;

Expand Down Expand Up @@ -369,6 +375,37 @@ export class GroupComponent<E> implements OnInit, AfterViewInit {
popper?.popperInstance?.forceUpdate();
}

/**
* shows custom tooltip
* @param {MouseEvent} e - event object
* @param element - NodeWithInput<E>
* @param {WorkflowPrompt} input - WorkflowPrompt - this is the input object that was clicked on
*/
showTooltip(e: MouseEvent, element: NodeWithInput<E>, input: WorkflowPrompt) {
if (
['condition', 'value'].includes(input.inputKey) &&
(element.node.elements.includes(ChangeColumnValue.identifier) ||
element.node.elements.includes(ReadColumnValue.identifier) ||
element.node.elements.includes(ReadColumnValue.identifier)) &&
!element.node.state.get('column')
) {
this.tooltipText =
this.localizedStringMap.selectColumnTooltip ?? 'Select a column first';
this.showsTooltip = true;
this.topPosition = e.clientY + 10;
this.leftPosition = e.clientX;
}
}

/**
* hides custom tooltip
*/
hideTooltip() {
this.showsTooltip = false;
this.topPosition = null;
this.leftPosition = null;
}

/**
* It returns a function that hides the previous popper
* @returns A function that calls the hide method on the previous popper reference.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<ng-container *ngIf="showsTooltip">
<div class="tooltip"
[style.top]="topPosition + 'px'"
[style.left]="leftPosition + 'px'">
{{ tooltipText }}
</div>
</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import '../../../assets/styles/colors';

.tooltip {
position: absolute; // enables it to appear where we want it later
font-size: 14px;
line-height: 14px;
padding: 5px 10px;
color:$black;
display: inline-block;
box-shadow: 4px 6px 12px $grey2;
background-color: $white;
border: 1px solid $grey2;
border-radius: 5px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component, Input, OnInit } from '@angular/core';

@Component({
selector: 'workflow-tooltip-render',
templateUrl: './tooltip-render.component.html',
styleUrls: ['./tooltip-render.component.scss']
})
export class TooltipRenderComponent implements OnInit {

@Input() showsTooltip = true;
@Input() tooltipText = 'Default tooltip text';
@Input() topPosition = 215;
@Input() leftPosition = 400;

constructor() { }

ngOnInit(): void {
}

}
1 change: 1 addition & 0 deletions projects/workflows-creator/src/lib/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ export enum LocalizedStringKeys {
Else = 'elseLbl',
TypeSubject = 'typeSubjectLbl',
TypeEmail = 'typeEmailLbl',
SelectColumnTooltip = 'selectColumnTooltip'
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ import {TriggerOnInterval} from './services/bpmn/elements/tasks/trigger-on-inter
import {StartOnIntervalElement} from './services/bpmn/elements/base/start-on-interval.element';
import {TriggerOnAddItem} from './services/bpmn/elements/tasks/trigger-on-add-item.task';
import {OnAddItemEvent} from './services/statement/events/onadditem.event';
import { TooltipRenderComponent } from './builder/tooltip-render/tooltip-render.component';
@NgModule({
declarations: [BuilderComponent, GroupComponent, NodeComponent],
declarations: [BuilderComponent, GroupComponent, NodeComponent, TooltipRenderComponent],
exports: [BuilderComponent, GroupComponent, NodeComponent, NgxPopperjsModule],
imports: [
CommonModule,
Expand Down