[ci skip]
This commit is contained in:
shamoon 2025-03-17 02:02:25 -07:00
parent b93fc7ef32
commit 87a4a96377
No known key found for this signature in database
2 changed files with 53 additions and 36 deletions

View File

@ -64,14 +64,27 @@ export class FilterableDropdownSelectionModel {
set items(items: MatchingModel[]) {
if (items) {
this._items = Array.from(items)
this._items.unshift({
name: $localize`:Filter drop down element to filter for documents with no correspondent/type/tag assigned:Not assigned`,
id:
this.intersection === Intersection.Include
? null
: NEGATIVE_NULL_FILTER_VALUE,
})
this.sortItems()
this.setNullItem()
}
}
private setNullItem() {
const item = {
name: $localize`:Filter drop down element to filter for documents with no correspondent/type/tag assigned:Not assigned`,
id:
this.intersection === Intersection.Include
? null
: NEGATIVE_NULL_FILTER_VALUE,
}
if (
this._items[0]?.id === null ||
this._items[0]?.id === NEGATIVE_NULL_FILTER_VALUE
) {
this._items[0] = item
} else if (this._items) {
this._items.unshift(item)
}
}
@ -144,8 +157,6 @@ export class FilterableDropdownSelectionModel {
}
toggle(id: number, fireEvent = true) {
console.log('toggling', id)
let state = this.temporarySelectionStates.get(id)
if (
state == undefined ||
@ -258,31 +269,30 @@ export class FilterableDropdownSelectionModel {
}
set intersection(intersection: Intersection) {
console.log('setting intersection', intersection)
this.temporaryIntersection = intersection
}
private checkForNullItem() {
console.log('checkForNullItem', this.items)
if (this.temporaryIntersection === Intersection.Exclude) {
this.temporarySelectionStates.delete(null)
this.items.shift()
}
this.setNullItem()
}
toggleIntersection() {
console.log('toggleIntersection')
if (this.temporarySelectionStates.size === 0) return
let newState =
this.intersection == Intersection.Include
? ToggleableItemState.Selected
: ToggleableItemState.Excluded
this.temporarySelectionStates.forEach((state, key) => {
this.temporarySelectionStates.set(key, newState)
if (key === null && this.intersection === Intersection.Exclude) {
this.temporarySelectionStates.set(NEGATIVE_NULL_FILTER_VALUE, newState)
} else if (
key === NEGATIVE_NULL_FILTER_VALUE &&
this.intersection === Intersection.Include
) {
this.temporarySelectionStates.set(null, newState)
} else {
this.temporarySelectionStates.set(key, newState)
}
})
this.changed.next(this)
}
@ -334,20 +344,11 @@ export class FilterableDropdownSelectionModel {
}
isNoneSelected() {
console.log(this.intersection)
console.log(
this.selectionSize(),
this.get(null),
this.get(NEGATIVE_NULL_FILTER_VALUE)
)
return (
(this.selectionSize() == 1 &&
this.get(null) == ToggleableItemState.Selected) ||
(this.selectionSize() > 1 &&
this.get(NEGATIVE_NULL_FILTER_VALUE) == ToggleableItemState.Selected &&
this.intersection == Intersection.Exclude)
(this.intersection == Intersection.Exclude &&
this.get(NEGATIVE_NULL_FILTER_VALUE) == ToggleableItemState.Excluded)
)
}

View File

@ -848,7 +848,16 @@ export class FilterEditorComponent
})
}
if (this.documentTypeSelectionModel.isNoneSelected()) {
filterRules.push({ rule_type: FILTER_DOCUMENT_TYPE, value: null })
if (
this.documentTypeSelectionModel.intersection == Intersection.Exclude
) {
filterRules.push({
rule_type: FILTER_DOCUMENT_TYPE,
value: NEGATIVE_NULL_FILTER_VALUE.toString(),
})
} else {
filterRules.push({ rule_type: FILTER_DOCUMENT_TYPE, value: null })
}
} else {
this.documentTypeSelectionModel
.getSelectedItems()
@ -868,7 +877,14 @@ export class FilterEditorComponent
})
}
if (this.storagePathSelectionModel.isNoneSelected()) {
filterRules.push({ rule_type: FILTER_STORAGE_PATH, value: null })
if (this.storagePathSelectionModel.intersection == Intersection.Exclude) {
filterRules.push({
rule_type: FILTER_STORAGE_PATH,
value: NEGATIVE_NULL_FILTER_VALUE.toString(),
})
} else {
filterRules.push({ rule_type: FILTER_STORAGE_PATH, value: null })
}
} else {
this.storagePathSelectionModel
.getSelectedItems()