Skip to content

Commit

Permalink
Merge pull request #3058 from wowsims/batch_item_remove
Browse files Browse the repository at this point in the history
now items without enchants can be removed from batch
  • Loading branch information
lologarithm authored May 8, 2023
2 parents 547b244 + 5d17a4d commit 093af64
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
9 changes: 9 additions & 0 deletions ui/core/components/gear_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,15 @@ export class SelectorModal extends BaseModal {
this.setData();
}

// Could be 'Items' 'Enchants' or 'Gem1'-'Gem3'
openTabName(name: string) {
Array.from(this.tabsElem.getElementsByClassName("selector-modal-item-tab")).forEach(elem => {
if (elem.getAttribute("data-content-id") == name+"-tab") {
(elem as HTMLElement).click();
}
});
}

openTab(idx: number) {
const elems = this.tabsElem.getElementsByClassName("selector-modal-item-tab");
(elems[idx] as HTMLElement).click();
Expand Down
41 changes: 22 additions & 19 deletions ui/core/components/individual_sim_ui/bulk_tab.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import { ContentBlock } from "../content_block";
import { Database } from '../../proto_utils/database';
import { ContentBlock } from "../content_block";
import { Importer } from "../importers";

import { IndividualSimUI } from "../../individual_sim_ui";
import { TypedEvent } from "../../typed_event";

import { EventID } from '../../typed_event.js';

import { EquipmentSpec, GemColor, ItemSlot, ItemSpec, SimDatabase, SimEnchant, SimGem, SimItem, Spec } from "../../proto/common";
import { BulkComboResult, BulkSettings, ItemSpecWithSlot, ProgressMetrics } from "../../proto/api";
import { EquipmentSpec, GemColor, ItemSlot, ItemSpec, SimDatabase, SimEnchant, SimGem, SimItem, Spec } from "../../proto/common";

import { ItemData, ItemList, ItemRenderer, SelectorModal, SelectorModalTabs } from "../gear_picker";
import { SimTab } from "../sim_tab";

import { UIEnchant, UIGem, UIItem } from "../../proto/ui";
import { Component } from "../component";
import { EquippedItem } from "../../proto_utils/equipped_item";
import { Component } from "../component";
import { ResultsViewer } from "../results_viewer";

import { Popover, Tooltip } from 'bootstrap';
import { BooleanPicker } from "../boolean_picker";
import { gemMatchesSocket, getEmptyGemSocketIconUrl } from "../../proto_utils/gems";
import { getEligibleItemSlots } from "../../proto_utils/utils";
import { ActionId } from "../../proto_utils/action_id";
import { getEmptyGemSocketIconUrl } from "../../proto_utils/gems";
import { canEquipItem, getEligibleItemSlots } from "../../proto_utils/utils";
import { BaseModal } from "../base_modal";
import { SimUI } from "ui/core/sim_ui";
import { canEquipItem } from "../../proto_utils/utils";
import { BooleanPicker } from "../boolean_picker";

export class BulkGearJsonImporter<SpecType extends Spec> extends Importer {
private readonly simUI: IndividualSimUI<SpecType>;
Expand Down Expand Up @@ -180,16 +177,22 @@ 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 = 'Remove from Batch';
destroyItemButton.classList.add('btn', 'btn-danger');
destroyItemButton.onclick = () => {
bulkUI.setItems(bulkUI.getItems().filter((item, idx) => { return idx != this.index }));
modal.close();
};
removeButton.parentNode.appendChild(destroyItemButton);
if (eligibleEnchants.length > 0) {
modal.openTabName("Enchants");
} else if (this.item._gems.length > 0) {
modal.openTabName("Gem1");
}

const destroyItemButton = document.createElement('button');
destroyItemButton.textContent = 'Remove from Batch';
destroyItemButton.classList.add('btn', 'btn-danger');
destroyItemButton.onclick = () => {
bulkUI.setItems(bulkUI.getItems().filter((item, idx) => { return idx != this.index }));
modal.close();
};
const closeX = modal.header?.querySelector('.close-button');
if (closeX != undefined) {
modal.header?.insertBefore(destroyItemButton, closeX);
}
};

Expand Down

0 comments on commit 093af64

Please sign in to comment.