mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-17 10:13:56 -05:00
document list service: selection model
This commit is contained in:
parent
a8f27f79dd
commit
56dfc71bb9
@ -118,6 +118,7 @@ export class DocumentListViewService {
|
|||||||
//want changes in the filter editor to propagate into here right away.
|
//want changes in the filter editor to propagate into here right away.
|
||||||
this.view.filterRules = cloneFilterRules(filterRules)
|
this.view.filterRules = cloneFilterRules(filterRules)
|
||||||
this.reload()
|
this.reload()
|
||||||
|
this.reduceSelectionToFilter()
|
||||||
this.saveDocumentListView()
|
this.saveDocumentListView()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,6 +193,49 @@ export class DocumentListViewService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selected = new Set<number>()
|
||||||
|
|
||||||
|
selectNone() {
|
||||||
|
this.selected.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
private reduceSelectionToFilter() {
|
||||||
|
if (this.selected.size > 0) {
|
||||||
|
this.documentService.listAllFilteredIds(this.filterRules).subscribe(ids => {
|
||||||
|
let subset = new Set<number>()
|
||||||
|
for (let id of ids) {
|
||||||
|
if (this.selected.has(id)) {
|
||||||
|
subset.add(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.selected = subset
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
selectAll() {
|
||||||
|
this.documentService.listAllFilteredIds(this.filterRules).subscribe(ids => ids.forEach(id => this.selected.add(id)))
|
||||||
|
}
|
||||||
|
|
||||||
|
selectPage() {
|
||||||
|
this.selected.clear()
|
||||||
|
this.documents.forEach(doc => {
|
||||||
|
this.selected.add(doc.id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
isSelected(d: PaperlessDocument) {
|
||||||
|
return this.selected.has(d.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelected(d: PaperlessDocument, value: boolean) {
|
||||||
|
if (value) {
|
||||||
|
this.selected.add(d.id)
|
||||||
|
} else if (!value) {
|
||||||
|
this.selected.delete(d.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
constructor(private documentService: DocumentService) {
|
constructor(private documentService: DocumentService) {
|
||||||
let documentListViewConfigJson = sessionStorage.getItem(DOCUMENT_LIST_SERVICE.CURRENT_VIEW_CONFIG)
|
let documentListViewConfigJson = sessionStorage.getItem(DOCUMENT_LIST_SERVICE.CURRENT_VIEW_CONFIG)
|
||||||
if (documentListViewConfigJson) {
|
if (documentListViewConfigJson) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user