mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-13 10:07:15 +01:00
36 lines
958 B
TypeScript
36 lines
958 B
TypeScript
import { Component, forwardRef, OnInit } from '@angular/core';
|
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
import { SettingsService } from 'src/app/services/settings.service';
|
|
import { AbstractInputComponent } from '../abstract-input';
|
|
|
|
|
|
@Component({
|
|
providers: [{
|
|
provide: NG_VALUE_ACCESSOR,
|
|
useExisting: forwardRef(() => DateComponent),
|
|
multi: true
|
|
}],
|
|
selector: 'app-input-date',
|
|
templateUrl: './date.component.html',
|
|
styleUrls: ['./date.component.scss']
|
|
})
|
|
export class DateComponent extends AbstractInputComponent<string> implements OnInit {
|
|
|
|
constructor(private settings: SettingsService) {
|
|
super()
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
super.ngOnInit()
|
|
this.placeholder = this.settings.getLocalizedDateInputFormat()
|
|
}
|
|
|
|
placeholder: string
|
|
|
|
// prevent chars other than numbers and separators
|
|
onKeyPress(event: KeyboardEvent) {
|
|
if (!/[0-9,\.\/-]+/.test(event.key)) {
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
}
|