Fix some clearing stuff
This commit is contained in:
parent
03fec3fa3e
commit
bddca47924
@ -35,6 +35,13 @@ export class CustomFieldQueriesModel {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isEmpty(): boolean {
|
||||||
|
return (
|
||||||
|
this.queries.length === 0 ||
|
||||||
|
(this.queries.length === 1 && this.queries[0].value.length === 0)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private validateAtom(atom: CustomFieldQueryAtom) {
|
private validateAtom(atom: CustomFieldQueryAtom) {
|
||||||
let valid: boolean = !!(atom.field && atom.operator && atom.value)
|
let valid: boolean = !!(atom.field && atom.operator && atom.value)
|
||||||
return valid
|
return valid
|
||||||
@ -112,6 +119,9 @@ export class CustomFieldQueriesModel {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
foundComponent.changed.complete()
|
foundComponent.changed.complete()
|
||||||
|
if (this.isEmpty()) {
|
||||||
|
this.clear()
|
||||||
|
}
|
||||||
this.changed.next(this)
|
this.changed.next(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +171,7 @@ export class CustomFieldsQueryDropdownComponent {
|
|||||||
if (this._selectionModel) {
|
if (this._selectionModel) {
|
||||||
this._selectionModel.changed.complete()
|
this._selectionModel.changed.complete()
|
||||||
}
|
}
|
||||||
model.changed.subscribe((updatedModel) => {
|
model.changed.subscribe(() => {
|
||||||
this.onModelChange()
|
this.onModelChange()
|
||||||
})
|
})
|
||||||
this._selectionModel = model
|
this._selectionModel = model
|
||||||
@ -172,7 +182,7 @@ export class CustomFieldsQueryDropdownComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onModelChange() {
|
private onModelChange() {
|
||||||
if (this.selectionModel.isValid()) {
|
if (this.selectionModel.isEmpty() || this.selectionModel.isValid()) {
|
||||||
this.selectionModelChange.next(this.selectionModel)
|
this.selectionModelChange.next(this.selectionModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ export class CustomFieldQueryExpression extends CustomFieldQueryElement {
|
|||||||
super(CustomFieldQueryElementType.Expression)
|
super(CustomFieldQueryElementType.Expression)
|
||||||
let values
|
let values
|
||||||
;[this._operator, values] = expressionArray
|
;[this._operator, values] = expressionArray
|
||||||
if (!values) {
|
if (!values || values.length === 0) {
|
||||||
this._value = []
|
this._value = []
|
||||||
} else if (values?.length > 0 && values[0] instanceof Array) {
|
} else if (values?.length > 0 && values[0] instanceof Array) {
|
||||||
this._value = values.map((value) => {
|
this._value = values.map((value) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user