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

View File

@ -848,7 +848,16 @@ export class FilterEditorComponent
}) })
} }
if (this.documentTypeSelectionModel.isNoneSelected()) { if (this.documentTypeSelectionModel.isNoneSelected()) {
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 }) filterRules.push({ rule_type: FILTER_DOCUMENT_TYPE, value: null })
}
} else { } else {
this.documentTypeSelectionModel this.documentTypeSelectionModel
.getSelectedItems() .getSelectedItems()
@ -868,7 +877,14 @@ export class FilterEditorComponent
}) })
} }
if (this.storagePathSelectionModel.isNoneSelected()) { if (this.storagePathSelectionModel.isNoneSelected()) {
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 }) filterRules.push({ rule_type: FILTER_STORAGE_PATH, value: null })
}
} else { } else {
this.storagePathSelectionModel this.storagePathSelectionModel
.getSelectedItems() .getSelectedItems()