conversion inputs to components
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<div>
|
||||
<label [for]="name" class="block text-sm font-bold text-gray-700 mb-1 relative w-fit">
|
||||
{{ label }}
|
||||
@if(validationMessage){
|
||||
<div
|
||||
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"
|
||||
>
|
||||
!
|
||||
</div>
|
||||
<app-tooltip id="tooltip-{{ name }}" [text]="validationMessage"></app-tooltip>
|
||||
}
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
[id]="name"
|
||||
[ngModel]="value"
|
||||
(input)="onInputChange($event)"
|
||||
(blur)="onTouched()"
|
||||
[attr.name]="name"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
||||
[options]="{ prefix: '$', thousands: ',', decimal: '.', precision: 0, align: 'left' }"
|
||||
currencyMask
|
||||
/>
|
||||
</div>
|
||||
@@ -0,0 +1,31 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, forwardRef } from '@angular/core';
|
||||
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { NgxCurrencyDirective } from 'ngx-currency';
|
||||
import { BaseInputComponent } from '../base-input/base-input.component';
|
||||
import { TooltipComponent } from '../tooltip/tooltip.component';
|
||||
import { ValidationMessagesService } from '../validation-messages.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-validated-price',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, TooltipComponent, NgxCurrencyDirective],
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => ValidatedPriceComponent),
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
templateUrl: './validated-price.component.html',
|
||||
})
|
||||
export class ValidatedPriceComponent extends BaseInputComponent {
|
||||
constructor(validationMessagesService: ValidationMessagesService) {
|
||||
super(validationMessagesService);
|
||||
}
|
||||
|
||||
onInputChange(event: Event): void {
|
||||
this.value = event;
|
||||
this.onChange(event);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user