BugFix: #88
This commit is contained in:
parent
8157dcc376
commit
0f301fb534
|
|
@ -19,6 +19,7 @@ export abstract class BaseInputComponent implements ControlValueAccessor {
|
||||||
@Input() label: string = '';
|
@Input() label: string = '';
|
||||||
// @Input() id: string = '';
|
// @Input() id: string = '';
|
||||||
@Input() name: string = '';
|
@Input() name: string = '';
|
||||||
|
isTooltipVisible = false;
|
||||||
constructor(protected validationMessagesService: ValidationMessagesService) {}
|
constructor(protected validationMessagesService: ValidationMessagesService) {}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.subscription = this.validationMessagesService.messages$.subscribe(() => {
|
this.subscription = this.validationMessagesService.messages$.subscribe(() => {
|
||||||
|
|
@ -51,4 +52,9 @@ export abstract class BaseInputComponent implements ControlValueAccessor {
|
||||||
this.validationMessage = this.validationMessagesService.getMessage(this.name);
|
this.validationMessage = this.validationMessagesService.getMessage(this.name);
|
||||||
}
|
}
|
||||||
setDisabledState?(isDisabled: boolean): void {}
|
setDisabledState?(isDisabled: boolean): void {}
|
||||||
|
toggleTooltip(event: Event) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
this.isTooltipVisible = !this.isTooltipVisible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input, SimpleChanges } from '@angular/core';
|
||||||
import { initFlowbite } from 'flowbite';
|
import { initFlowbite } from 'flowbite';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
@ -9,11 +9,36 @@ import { initFlowbite } from 'flowbite';
|
||||||
templateUrl: './tooltip.component.html',
|
templateUrl: './tooltip.component.html',
|
||||||
})
|
})
|
||||||
export class TooltipComponent {
|
export class TooltipComponent {
|
||||||
@Input() id;
|
@Input() id: string;
|
||||||
@Input() text;
|
@Input() text: string;
|
||||||
|
@Input() isVisible: boolean = false;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.initializeTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if (changes['isVisible']) {
|
||||||
|
this.updateTooltipVisibility();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private initializeTooltip() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
initFlowbite();
|
initFlowbite();
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updateTooltipVisibility() {
|
||||||
|
const tooltipElement = document.getElementById(this.id);
|
||||||
|
if (tooltipElement) {
|
||||||
|
if (this.isVisible) {
|
||||||
|
tooltipElement.classList.remove('invisible', 'opacity-0');
|
||||||
|
tooltipElement.classList.add('visible', 'opacity-100');
|
||||||
|
} else {
|
||||||
|
tooltipElement.classList.remove('visible', 'opacity-100');
|
||||||
|
tooltipElement.classList.add('invisible', 'opacity-0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,12 @@
|
||||||
<div
|
<div
|
||||||
attr.data-tooltip-target="tooltip-{{ name }}"
|
attr.data-tooltip-target="tooltip-{{ name }}"
|
||||||
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
||||||
|
(click)="toggleTooltip($event)"
|
||||||
|
(touchstart)="toggleTooltip($event)"
|
||||||
>
|
>
|
||||||
!
|
!
|
||||||
</div>
|
</div>
|
||||||
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage"></app-tooltip>
|
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage" [isVisible]="isTooltipVisible"></app-tooltip>
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
<ng-select
|
<ng-select
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,12 @@
|
||||||
<div
|
<div
|
||||||
attr.data-tooltip-target="tooltip-{{ name }}"
|
attr.data-tooltip-target="tooltip-{{ name }}"
|
||||||
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
||||||
|
(click)="toggleTooltip($event)"
|
||||||
|
(touchstart)="toggleTooltip($event)"
|
||||||
>
|
>
|
||||||
!
|
!
|
||||||
</div>
|
</div>
|
||||||
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage"></app-tooltip>
|
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage" [isVisible]="isTooltipVisible"></app-tooltip>
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,12 @@
|
||||||
<div
|
<div
|
||||||
attr.data-tooltip-target="tooltip-{{ name }}"
|
attr.data-tooltip-target="tooltip-{{ name }}"
|
||||||
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
||||||
|
(click)="toggleTooltip($event)"
|
||||||
|
(touchstart)="toggleTooltip($event)"
|
||||||
>
|
>
|
||||||
!
|
!
|
||||||
</div>
|
</div>
|
||||||
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage"></app-tooltip>
|
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage" [isVisible]="isTooltipVisible"></app-tooltip>
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,12 @@
|
||||||
<div
|
<div
|
||||||
attr.data-tooltip-target="tooltip-{{ name }}"
|
attr.data-tooltip-target="tooltip-{{ name }}"
|
||||||
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
||||||
|
(click)="toggleTooltip($event)"
|
||||||
|
(touchstart)="toggleTooltip($event)"
|
||||||
>
|
>
|
||||||
!
|
!
|
||||||
</div>
|
</div>
|
||||||
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage"></app-tooltip>
|
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage" [isVisible]="isTooltipVisible"></app-tooltip>
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
<ng-select [items]="items" bindLabel="name" bindValue="value" [(ngModel)]="value" (ngModelChange)="onInputChange($event)" name="type"> </ng-select>
|
<ng-select [items]="items" bindLabel="name" bindValue="value" [(ngModel)]="value" (ngModelChange)="onInputChange($event)" name="type"> </ng-select>
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,12 @@
|
||||||
<div
|
<div
|
||||||
attr.data-tooltip-target="tooltip-{{ name }}"
|
attr.data-tooltip-target="tooltip-{{ name }}"
|
||||||
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
||||||
|
(click)="toggleTooltip($event)"
|
||||||
|
(touchstart)="toggleTooltip($event)"
|
||||||
>
|
>
|
||||||
!
|
!
|
||||||
</div>
|
</div>
|
||||||
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage"></app-tooltip>
|
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage" [isVisible]="isTooltipVisible"></app-tooltip>
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,12 @@
|
||||||
<div
|
<div
|
||||||
attr.data-tooltip-target="tooltip-{{ name }}"
|
attr.data-tooltip-target="tooltip-{{ name }}"
|
||||||
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
||||||
|
(click)="toggleTooltip($event)"
|
||||||
|
(touchstart)="toggleTooltip($event)"
|
||||||
>
|
>
|
||||||
!
|
!
|
||||||
</div>
|
</div>
|
||||||
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage"></app-tooltip>
|
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage" [isVisible]="isTooltipVisible"></app-tooltip>
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
<quill-editor [(ngModel)]="value" (ngModelChange)="onInputChange($event)" (onBlur)="onTouched()" [id]="name" [attr.name]="name" [modules]="quillModules"></quill-editor>
|
<quill-editor [(ngModel)]="value" (ngModelChange)="onInputChange($event)" (onBlur)="onTouched()" [id]="name" [attr.name]="name" [modules]="quillModules"></quill-editor>
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,12 @@
|
||||||
<div
|
<div
|
||||||
attr.data-tooltip-target="tooltip-{{ name }}"
|
attr.data-tooltip-target="tooltip-{{ name }}"
|
||||||
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
||||||
|
(click)="toggleTooltip($event)"
|
||||||
|
(touchstart)="toggleTooltip($event)"
|
||||||
>
|
>
|
||||||
!
|
!
|
||||||
</div>
|
</div>
|
||||||
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage"></app-tooltip>
|
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage" [isVisible]="isTooltipVisible"></app-tooltip>
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
<select
|
<select
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,12 @@
|
||||||
<div
|
<div
|
||||||
attr.data-tooltip-target="tooltip-{{ name }}"
|
attr.data-tooltip-target="tooltip-{{ name }}"
|
||||||
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
class="absolute inline-flex items-center justify-center w-6 h-6 text-xs font-bold text-white bg-red-500 border-2 border-white rounded-full -top-2 dark:border-gray-900 hover:cursor-pointer"
|
||||||
|
(click)="toggleTooltip($event)"
|
||||||
|
(touchstart)="toggleTooltip($event)"
|
||||||
>
|
>
|
||||||
!
|
!
|
||||||
</div>
|
</div>
|
||||||
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage"></app-tooltip>
|
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage" [isVisible]="isTooltipVisible"></app-tooltip>
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
<textarea [id]="name" [ngModel]="value" (ngModelChange)="onInputChange($event)" [attr.name]="name" class="w-full p-2 border border-gray-300 rounded-md" rows="3"></textarea>
|
<textarea [id]="name" [ngModel]="value" (ngModelChange)="onInputChange($event)" [attr.name]="name" class="w-full p-2 border border-gray-300 rounded-md" rows="3"></textarea>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue