mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Closer
[ci skip]
This commit is contained in:
parent
b93fc7ef32
commit
87a4a96377
@ -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({
|
|
||||||
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.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) {
|
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) => {
|
||||||
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)
|
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)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,7 +848,16 @@ export class FilterEditorComponent
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (this.documentTypeSelectionModel.isNoneSelected()) {
|
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 {
|
} else {
|
||||||
this.documentTypeSelectionModel
|
this.documentTypeSelectionModel
|
||||||
.getSelectedItems()
|
.getSelectedItems()
|
||||||
@ -868,7 +877,14 @@ export class FilterEditorComponent
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (this.storagePathSelectionModel.isNoneSelected()) {
|
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 {
|
} else {
|
||||||
this.storagePathSelectionModel
|
this.storagePathSelectionModel
|
||||||
.getSelectedItems()
|
.getSelectedItems()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user