fix a couple issues with the bulk editor

This commit is contained in:
jonaswinkler 2020-12-29 17:20:45 +01:00
parent b2327d6fde
commit 7f4cfc0b76
2 changed files with 3 additions and 5 deletions

View File

@ -56,6 +56,7 @@ export class BulkEditorComponent {
return this.documentService.bulkEdit(Array.from(this.list.selected), method, args).pipe( return this.documentService.bulkEdit(Array.from(this.list.selected), method, args).pipe(
tap(() => { tap(() => {
this.list.reload() this.list.reload()
this.list.reduceSelectionToFilter()
this.list.selected.forEach(id => { this.list.selected.forEach(id => {
this.openDocumentService.refreshDocument(id) this.openDocumentService.refreshDocument(id)
}) })
@ -118,7 +119,7 @@ export class BulkEditorComponent {
} else if (changedTags.itemsToAdd.length > 1 && changedTags.itemsToRemove.length == 0) { } else if (changedTags.itemsToAdd.length > 1 && changedTags.itemsToRemove.length == 0) {
modal.componentInstance.message = $localize`This operation will add the tags ${this._localizeList(changedTags.itemsToAdd)} to all ${this.list.selected.size} selected document(s).` modal.componentInstance.message = $localize`This operation will add the tags ${this._localizeList(changedTags.itemsToAdd)} to all ${this.list.selected.size} selected document(s).`
} else if (changedTags.itemsToAdd.length == 0 && changedTags.itemsToRemove.length == 1) { } else if (changedTags.itemsToAdd.length == 0 && changedTags.itemsToRemove.length == 1) {
let tag = changedTags.itemsToAdd[0] let tag = changedTags.itemsToRemove[0]
modal.componentInstance.message = $localize`This operation will remove the tag ${tag.name} from all ${this.list.selected.size} selected document(s).` modal.componentInstance.message = $localize`This operation will remove the tag ${tag.name} from all ${this.list.selected.size} selected document(s).`
} else if (changedTags.itemsToAdd.length == 0 && changedTags.itemsToRemove.length > 1) { } else if (changedTags.itemsToAdd.length == 0 && changedTags.itemsToRemove.length > 1) {
modal.componentInstance.message = $localize`This operation will remove the tags ${this._localizeList(changedTags.itemsToRemove)} from all ${this.list.selected.size} selected document(s).` modal.componentInstance.message = $localize`This operation will remove the tags ${this._localizeList(changedTags.itemsToRemove)} from all ${this.list.selected.size} selected document(s).`
@ -139,7 +140,6 @@ export class BulkEditorComponent {
private performSetTags(modal, changedTags: ChangedItems) { private performSetTags(modal, changedTags: ChangedItems) {
this.executeBulkOperation('modify_tags', {"add_tags": changedTags.itemsToAdd.map(t => t.id), "remove_tags": changedTags.itemsToRemove.map(t => t.id)}).subscribe( this.executeBulkOperation('modify_tags', {"add_tags": changedTags.itemsToAdd.map(t => t.id), "remove_tags": changedTags.itemsToRemove.map(t => t.id)}).subscribe(
response => { response => {
this.tagService.clearCache()
if (modal) { if (modal) {
modal.close() modal.close()
} }
@ -173,7 +173,6 @@ export class BulkEditorComponent {
private performSetCorrespondents(modal, correspondent: MatchingModel) { private performSetCorrespondents(modal, correspondent: MatchingModel) {
this.executeBulkOperation('set_correspondent', {"correspondent": correspondent ? correspondent.id : null}).subscribe( this.executeBulkOperation('set_correspondent', {"correspondent": correspondent ? correspondent.id : null}).subscribe(
response => { response => {
this.correspondentService.clearCache()
if (modal) { if (modal) {
modal.close() modal.close()
} }
@ -207,7 +206,6 @@ export class BulkEditorComponent {
private performSetDocumentTypes(modal, documentType) { private performSetDocumentTypes(modal, documentType) {
this.executeBulkOperation('set_document_type', {"document_type": documentType ? documentType.id : null}).subscribe( this.executeBulkOperation('set_document_type', {"document_type": documentType ? documentType.id : null}).subscribe(
response => { response => {
this.documentTypeService.clearCache()
if (modal) { if (modal) {
modal.close() modal.close()
} }

View File

@ -203,7 +203,7 @@ export class DocumentListViewService {
this.selected.clear() this.selected.clear()
} }
private reduceSelectionToFilter() { reduceSelectionToFilter() {
if (this.selected.size > 0) { if (this.selected.size > 0) {
this.documentService.listAllFilteredIds(this.filterRules).subscribe(ids => { this.documentService.listAllFilteredIds(this.filterRules).subscribe(ids => {
let subset = new Set<number>() let subset = new Set<number>()