Skip to content

Commit

Permalink
Merge pull request #2934 from wowsims/improve_add_remove_bulk
Browse files Browse the repository at this point in the history
updated some add/remove functions to work correctly after I broke them
  • Loading branch information
lologarithm authored Apr 14, 2023
2 parents c26b555 + 7ff6967 commit 221d472
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ui/core/components/gear_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ export class ItemList<T> {

});

simUI.bt.importItems(itemSpecs);
simUI.bt.addItems(itemSpecs);
simUI.bt.setCombinations(false);
// TODO: should we open the bulk sim UI or should we run in the background showing progress, and then sort the items in the picker?
}
Expand Down
20 changes: 12 additions & 8 deletions ui/core/components/individual_sim_ui/bulk_tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class BulkGearJsonImporter<SpecType extends Spec> extends Importer {
throw new Error("cannot find item with ID " + itemSpec.id);
}
}
this.bulkUI.importItems(items);
this.bulkUI.addItems(items);
}
}
this.close();
Expand Down Expand Up @@ -161,7 +161,7 @@ export class BulkItemPicker extends Component {
const otherItems = this.bulkUI.getItems();
otherItems[this.index] = equippedItem.asSpec();
this.item = equippedItem;
this.bulkUI.importItems(otherItems);
this.bulkUI.addItems(otherItems);
changeEvent.emit(TypedEvent.nextEventID());
}
},
Expand All @@ -173,11 +173,10 @@ export class BulkItemPicker extends Component {
const removeButton = modal.body.querySelector('.selector-modal-remove-button');
if (removeButton && removeButton.parentNode) {
const destroyItemButton = document.createElement('button');
destroyItemButton.textContent = 'Destroy Item';
destroyItemButton.textContent = 'Remove from Batch';
destroyItemButton.classList.add('btn', 'btn-danger');
destroyItemButton.onclick = () => {
const needle = this.item.asSpec();
bulkUI.importItems(bulkUI.getItems().filter((spec) => { return !ItemSpec.equals(spec, needle); }));
bulkUI.setItems(bulkUI.getItems().filter((item, idx) => { return idx != this.index }));
modal.close();
};
removeButton.parentNode.appendChild(destroyItemButton);
Expand Down Expand Up @@ -311,15 +310,20 @@ export class BulkTab extends SimTab {
return itemsDb;
}

importItems(items: Array<ItemSpec>) {
addItems(items: Array<ItemSpec>) {
if (this.items.length == 0) {
this.items = items;
} else {
this.items = this.items.concat(items);
}
this.itemsChangedEmitter.emit(TypedEvent.nextEventID());
}


setItems(items: Array<ItemSpec>) {
this.items = items;
this.itemsChangedEmitter.emit(TypedEvent.nextEventID());
}

clearItems() {
this.items = new Array<ItemSpec>();
this.itemsChangedEmitter.emit(TypedEvent.nextEventID());
Expand Down Expand Up @@ -490,7 +494,7 @@ export class BulkTab extends SimTab {
const items = filters.favoriteItems.map((itemID) => {
return ItemSpec.create({id: itemID});
});
this.importItems(items);
this.addItems(items);
});
settingsBlock.bodyElement.appendChild(importFavsButton);

Expand Down

0 comments on commit 221d472

Please sign in to comment.