mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Merge pull request #1370 from paperless-ngx/fix/date-pasting
Fix: correct date pasting with some non-US formats
This commit is contained in:
commit
a81dc00ccf
@ -1,8 +1,10 @@
|
|||||||
import { Component, forwardRef, OnInit } from '@angular/core'
|
import { Component, forwardRef, OnInit } from '@angular/core'
|
||||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||||
import { NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap'
|
import {
|
||||||
|
NgbDateAdapter,
|
||||||
|
NgbDateParserFormatter,
|
||||||
|
} from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { SettingsService } from 'src/app/services/settings.service'
|
import { SettingsService } from 'src/app/services/settings.service'
|
||||||
import { LocalizedDateParserFormatter } from 'src/app/utils/ngb-date-parser-formatter'
|
|
||||||
import { AbstractInputComponent } from '../abstract-input'
|
import { AbstractInputComponent } from '../abstract-input'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -23,7 +25,8 @@ export class DateComponent
|
|||||||
{
|
{
|
||||||
constructor(
|
constructor(
|
||||||
private settings: SettingsService,
|
private settings: SettingsService,
|
||||||
private ngbDateParserFormatter: NgbDateParserFormatter
|
private ngbDateParserFormatter: NgbDateParserFormatter,
|
||||||
|
private isoDateAdapter: NgbDateAdapter<string>
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
@ -43,9 +46,10 @@ export class DateComponent
|
|||||||
let pastedText = clipboardData.getData('text')
|
let pastedText = clipboardData.getData('text')
|
||||||
pastedText = pastedText.replace(/[\sa-z#!$%\^&\*;:{}=\-_`~()]+/g, '')
|
pastedText = pastedText.replace(/[\sa-z#!$%\^&\*;:{}=\-_`~()]+/g, '')
|
||||||
const parsedDate = this.ngbDateParserFormatter.parse(pastedText)
|
const parsedDate = this.ngbDateParserFormatter.parse(pastedText)
|
||||||
const formattedDate = this.ngbDateParserFormatter.format(parsedDate)
|
if (parsedDate) {
|
||||||
this.writeValue(formattedDate)
|
this.writeValue(this.isoDateAdapter.toModel(parsedDate))
|
||||||
this.onChange(formattedDate)
|
this.onChange(this.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user