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

View File

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