mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-04-20 06:49:27 +00:00
Compare commits
3 Commits
feature-ta
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8edbc70dbc | ||
|
|
862e8e2292 | ||
|
|
ae2b780509 |
@@ -86,7 +86,7 @@
|
|||||||
<div class="selected-icon">
|
<div class="selected-icon">
|
||||||
@if (addedRelativeDate) {
|
@if (addedRelativeDate) {
|
||||||
<a class="text-light focus-variants" href="javascript:void(0)" (click)="clearAddedRelativeDate()">
|
<a class="text-light focus-variants" href="javascript:void(0)" (click)="clearAddedRelativeDate()">
|
||||||
<i-bs width="1em" height="1em" name="check" class="variant-unfocused"></i-bs>
|
<i-bs width="1em" height="1em" name="check" class="variant-unfocused text-dark"></i-bs>
|
||||||
<i-bs width="1em" height="1em" name="x" class="variant-focused text-primary"></i-bs>
|
<i-bs width="1em" height="1em" name="x" class="variant-focused text-primary"></i-bs>
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,21 @@ describe('CustomFieldQueryAtom', () => {
|
|||||||
atom.value = [1, 3]
|
atom.value = [1, 3]
|
||||||
expect(changeSpy).toHaveBeenCalledTimes(1)
|
expect(changeSpy).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should emit one changed event when operator change coerces value', () => {
|
||||||
|
const atom = new CustomFieldQueryAtom([
|
||||||
|
1,
|
||||||
|
CustomFieldQueryOperator.In,
|
||||||
|
[1, 2],
|
||||||
|
])
|
||||||
|
const changeSpy = jest.fn()
|
||||||
|
atom.changed.subscribe(changeSpy)
|
||||||
|
|
||||||
|
atom.operator = CustomFieldQueryOperator.Exact
|
||||||
|
|
||||||
|
expect(changeSpy).toHaveBeenCalledTimes(1)
|
||||||
|
expect(atom.serialize()).toEqual([1, CustomFieldQueryOperator.Exact, ''])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('CustomFieldQueryExpression', () => {
|
describe('CustomFieldQueryExpression', () => {
|
||||||
|
|||||||
@@ -70,29 +70,29 @@ export class CustomFieldQueryAtom extends CustomFieldQueryElement {
|
|||||||
const newTypes: string[] =
|
const newTypes: string[] =
|
||||||
CUSTOM_FIELD_QUERY_VALUE_TYPES_BY_OPERATOR[operator]?.split('|')
|
CUSTOM_FIELD_QUERY_VALUE_TYPES_BY_OPERATOR[operator]?.split('|')
|
||||||
if (!newTypes) {
|
if (!newTypes) {
|
||||||
this.value = null
|
this._value = null
|
||||||
} else {
|
} else {
|
||||||
if (!newTypes.includes(typeof this.value)) {
|
if (!newTypes.includes(typeof this.value)) {
|
||||||
switch (newTypes[0]) {
|
switch (newTypes[0]) {
|
||||||
case 'string':
|
case 'string':
|
||||||
this.value = ''
|
this._value = ''
|
||||||
break
|
break
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
this.value = 'true'
|
this._value = 'true'
|
||||||
break
|
break
|
||||||
case 'array':
|
case 'array':
|
||||||
this.value = []
|
this._value = []
|
||||||
break
|
break
|
||||||
case 'number':
|
case 'number':
|
||||||
const num = parseFloat(this.value as string)
|
const num = parseFloat(this.value as string)
|
||||||
this.value = isNaN(num) ? null : num.toString()
|
this._value = isNaN(num) ? null : num.toString()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
['true', 'false'].includes(this.value as string) &&
|
['true', 'false'].includes(this.value as string) &&
|
||||||
newTypes.includes('string')
|
newTypes.includes('string')
|
||||||
) {
|
) {
|
||||||
this.value = ''
|
this._value = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.operator = operator
|
super.operator = operator
|
||||||
|
|||||||
Reference in New Issue
Block a user