Fix remove all operations

This commit is contained in:
Michael Shamoon 2020-12-22 02:18:05 -08:00
parent 2f26d07480
commit 1fb3316436
2 changed files with 18 additions and 6 deletions

View File

@ -35,7 +35,7 @@
[showCounts]="!this.selectionSpansPages"
[showRemoveAll]="this.selectionSpansPages"
(open)="tagsDropdownOpen()"
(removeAll)="applyTags([], true)"
(removeAll)="removeAllTags()"
(editingComplete)="applyTags($event)">
</app-filterable-dropdown>
<app-filterable-dropdown class="mr-2 mr-md-3" title="Correspondent" icon="person-fill" singular="true"
@ -44,7 +44,7 @@
[showCounts]="!this.selectionSpansPages"
[showRemoveAll]="this.selectionSpansPages"
(open)="correspondentsDropdownOpen()"
(removeAll)="applyCorrespondent([], true)"
(removeAll)="removeAllCorrespondents()"
(editingComplete)="applyCorrespondent($event)">
</app-filterable-dropdown>
<app-filterable-dropdown class="mr-2 mr-md-3" title="Document Type" icon="file-earmark-fill" singular="true"
@ -53,7 +53,7 @@
[showCounts]="!this.selectionSpansPages"
[showRemoveAll]="this.selectionSpansPages"
(open)="documentTypesDropdownOpen()"
(removeAll)="applyDocumentType([], true)"
(removeAll)="removeAllDocumentTypes()"
(editingComplete)="applyDocumentType($event)">
</app-filterable-dropdown>
</div>

View File

@ -149,24 +149,36 @@ export class BulkEditorComponent {
this.initialDocumentTypesToggleableItems = this._documentTypesToggleableItems
}
applyTags(newTagsToggleableItems: ToggleableItem[], forceApply:boolean = false) {
applyTags(newTagsToggleableItems: ToggleableItem[]) {
let changedTags = this.checkForChangedItems(this.initialTagsToggleableItems, newTagsToggleableItems)
if (changedTags.itemsToAdd.length > 0) this.setTags.emit(changedTags.itemsToAdd)
if (changedTags.itemsToRemove.length > 0) this.removeTags.emit(changedTags.itemsToRemove)
}
applyCorrespondent(newCorrespondentsToggleableItems: ToggleableItem[], forceApply:boolean = false) {
removeAllTags() {
this.setTags.emit(null)
}
applyCorrespondent(newCorrespondentsToggleableItems: ToggleableItem[]) {
let changedCorrespondents = this.checkForChangedItems(this.initialCorrespondentsToggleableItems, newCorrespondentsToggleableItems)
if (changedCorrespondents.itemsToAdd.length > 0) this.setCorrespondent.emit(changedCorrespondents.itemsToAdd[0])
else if (changedCorrespondents.itemsToRemove.length > 0) this.removeCorrespondents.emit(changedCorrespondents.itemsToRemove)
}
applyDocumentType(newDocumentTypesToggleableItems: ToggleableItem[], forceApply:boolean = false) {
removeAllCorrespondents() {
this.setDocumentType.emit(null)
}
applyDocumentType(newDocumentTypesToggleableItems: ToggleableItem[]) {
let changedDocumentTypes = this.checkForChangedItems(this.initialDocumentTypesToggleableItems, newDocumentTypesToggleableItems)
if (changedDocumentTypes.itemsToAdd.length > 0) this.setDocumentType.emit(changedDocumentTypes.itemsToAdd[0])
else if (changedDocumentTypes.itemsToRemove.length > 0) this.removeDocumentTypes.emit(changedDocumentTypes.itemsToRemove)
}
removeAllDocumentTypes() {
this.setDocumentType.emit(null)
}
checkForChangedItems(toggleableItemsA: ToggleableItem[], toggleableItemsB: ToggleableItem[]): ChangedItems {
let itemsToAdd: any[] = []
let itemsToRemove: any[] = []