mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-19 02:52:42 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eeb63ee03f | ||
|
|
14252054a1 |
No files matched your search
@@ -0,0 +1,90 @@
|
||||
import { provideHttpClient } from '@angular/common/http'
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing'
|
||||
import { Component } from '@angular/core'
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms'
|
||||
import { NumberComponent } from './number/number.component'
|
||||
import { TextComponent } from './text/text.component'
|
||||
import { TextAreaComponent } from './textarea/textarea.component'
|
||||
import { UrlComponent } from './url/url.component'
|
||||
|
||||
@Component({
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
TextComponent,
|
||||
NumberComponent,
|
||||
TextAreaComponent,
|
||||
UrlComponent,
|
||||
],
|
||||
template: `
|
||||
<pngx-input-text [formControl]="control" />
|
||||
<pngx-input-number [formControl]="control" [showAdd]="false" />
|
||||
<pngx-input-textarea [formControl]="control" />
|
||||
<pngx-input-url [formControl]="control" />
|
||||
`,
|
||||
})
|
||||
class InputEventsHostComponent {
|
||||
control = new FormControl<string | number | null>(null)
|
||||
}
|
||||
|
||||
describe.each([
|
||||
['text', 'pngx-input-text input', 'Edited text', 'Edited text'],
|
||||
['number', 'pngx-input-number input', '42', 42],
|
||||
['textarea', 'pngx-input-textarea textarea', 'Edited\ntext', 'Edited\ntext'],
|
||||
['url', 'pngx-input-url input', 'https://example.com', 'https://example.com'],
|
||||
])(
|
||||
'%s input events',
|
||||
(_type, selector: string, text: string, value: string | number) => {
|
||||
let fixture: ComponentFixture<InputEventsHostComponent>
|
||||
let control: FormControl<string | number | null>
|
||||
let input: HTMLInputElement | HTMLTextAreaElement
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [InputEventsHostComponent],
|
||||
providers: [provideHttpClient(), provideHttpClientTesting()],
|
||||
})
|
||||
fixture = TestBed.createComponent(InputEventsHostComponent)
|
||||
control = fixture.componentInstance.control
|
||||
})
|
||||
|
||||
async function render() {
|
||||
fixture.detectChanges()
|
||||
await fixture.whenStable()
|
||||
input = fixture.nativeElement.querySelector(selector)
|
||||
}
|
||||
|
||||
it('updates the form while typing and marks it touched only on blur', async () => {
|
||||
await render()
|
||||
const changed = jest.fn()
|
||||
control.valueChanges.subscribe(changed)
|
||||
input.value = text
|
||||
input.dispatchEvent(new Event('input'))
|
||||
expect(control.value).toBe(value)
|
||||
expect(control.dirty).toBe(true)
|
||||
expect(control.touched).toBe(false)
|
||||
|
||||
input.dispatchEvent(new Event('change'))
|
||||
input.dispatchEvent(new Event('blur'))
|
||||
expect(control.touched).toBe(true)
|
||||
expect(changed).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('honors an explicit updateOn blur strategy', async () => {
|
||||
control = new FormControl<string | number | null>(null, {
|
||||
updateOn: 'blur',
|
||||
})
|
||||
fixture.componentInstance.control = control
|
||||
await render()
|
||||
input.value = text
|
||||
input.dispatchEvent(new Event('input'))
|
||||
expect(control.value).toBeNull()
|
||||
expect(control.pristine).toBe(true)
|
||||
|
||||
input.dispatchEvent(new Event('blur'))
|
||||
expect(control.value).toBe(value)
|
||||
expect(control.dirty).toBe(true)
|
||||
expect(control.touched).toBe(true)
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<div class="position-relative" [class.col-md-9]="horizontal">
|
||||
<div class="input-group" [class.is-invalid]="error">
|
||||
<input #inputField type="number" class="form-control" [step]="step" [id]="inputId" [(ngModel)]="value" [ngModelOptions]="{standalone: true}" (change)="onChange(value)" [class.is-invalid]="error" [disabled]="disabled">
|
||||
<input #inputField type="number" class="form-control" [step]="step" [id]="inputId" [(ngModel)]="value" [ngModelOptions]="{standalone: true}" (ngModelChange)="onChange($event)" (blur)="onTouched()" [class.is-invalid]="error" [disabled]="disabled">
|
||||
@if (showAdd) {
|
||||
<button class="btn btn-outline-secondary" type="button" id="button-addon1" (click)="nextAsn()" [disabled]="disabled">+1</button>
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
}
|
||||
</div>
|
||||
<div class="position-relative" [class.col-md-9]="horizontal">
|
||||
<input #inputField type="text" class="form-control" [class.is-invalid]="error" [id]="inputId" [(ngModel)]="value" [ngModelOptions]="{standalone: true}" (change)="onChange(value)" [disabled]="disabled" [autocomplete]="autocomplete" [placeholder]="placeholder">
|
||||
<input #inputField type="text" class="form-control" [class.is-invalid]="error" [id]="inputId" [(ngModel)]="value" [ngModelOptions]="{standalone: true}" (ngModelChange)="onChange($event)" (blur)="onTouched()" [disabled]="disabled" [autocomplete]="autocomplete" [placeholder]="placeholder">
|
||||
@if (hint) {
|
||||
<small class="form-text text-muted" [innerHTML]="hint"></small>
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
[class.font-monospace]="monospace"
|
||||
[(ngModel)]="value"
|
||||
[ngModelOptions]="{standalone: true}"
|
||||
(change)="onChange(value)"
|
||||
(ngModelChange)="onChange($event)"
|
||||
(blur)="onTouched()"
|
||||
[disabled]="disabled"
|
||||
[placeholder]="placeholder"
|
||||
rows="4">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
<div [class.col-md-9]="horizontal">
|
||||
<div class="input-group" [class.is-invalid]="error">
|
||||
<input #inputField type="url" class="form-control" [class.is-invalid]="error" placeholder="https://" [id]="inputId" [(ngModel)]="value" [ngModelOptions]="{standalone: true}" (change)="onChange(value)" [disabled]="disabled">
|
||||
<input #inputField type="url" class="form-control" [class.is-invalid]="error" placeholder="https://" [id]="inputId" [(ngModel)]="value" [ngModelOptions]="{standalone: true}" (ngModelChange)="onChange($event)" (blur)="onTouched()" [disabled]="disabled">
|
||||
<a class="btn btn-outline-secondary rounded-end" title="Open link" i18n-title [href]="value" target="_blank">
|
||||
<pngx-bs-icon width="1.2em" height="1.2em" name="box-arrow-up-right"></pngx-bs-icon>
|
||||
</a>
|
||||
|
||||
@@ -390,14 +390,12 @@ describe('DocumentDetailComponent', () => {
|
||||
expect(component.documentForm.get('title').value).toEqual('Foo Bar')
|
||||
})
|
||||
|
||||
it('should update title before doc change if was not updated via debounce', () => {
|
||||
it('should update the title form value without waiting for debounce or blur', () => {
|
||||
jest.useFakeTimers()
|
||||
initNormally()
|
||||
component.titleInput.value = 'Foo Bar'
|
||||
component.titleInput.inputField.nativeElement.dispatchEvent(
|
||||
new Event('change')
|
||||
)
|
||||
jest.advanceTimersByTime(1000)
|
||||
const input = component.titleInput.inputField.nativeElement
|
||||
input.value = 'Foo Bar'
|
||||
input.dispatchEvent(new Event('input'))
|
||||
expect(component.documentForm.get('title').value).toEqual('Foo Bar')
|
||||
})
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ msgstr ""
|
||||
"Project-Id-Version: paperless-ngx\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-11-17 20:48+0000\n"
|
||||
"PO-Revision-Date: 2026-11-17 20:49\n"
|
||||
"PO-Revision-Date: 2026-11-18 04:15\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: Italian\n"
|
||||
"Language: it_IT\n"
|
||||
@@ -1002,7 +1002,7 @@ msgstr ""
|
||||
|
||||
#: documents/models.py:1011
|
||||
msgid "Markdown"
|
||||
msgstr ""
|
||||
msgstr "Annotare"
|
||||
|
||||
#: documents/models.py:1016
|
||||
msgid "Note for the document"
|
||||
|
||||
Reference in new issue
Block a user