forked from OpenWF/SpaceNinjaServer
		
	chore(webui): exclude always available items from datalist (#2783)
Reviewed-on: OpenWF/SpaceNinjaServer#2783 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									6a6683fb25
								
							
						
					
					
						commit
						6c2b7a61e2
					
				
							
								
								
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -17,7 +17,7 @@
 | 
			
		||||
        "morgan": "^1.10.0",
 | 
			
		||||
        "ncp": "^2.0.0",
 | 
			
		||||
        "undici": "^7.10.0",
 | 
			
		||||
        "warframe-public-export-plus": "^0.5.88",
 | 
			
		||||
        "warframe-public-export-plus": "^0.5.89",
 | 
			
		||||
        "warframe-riven-info": "^0.1.2",
 | 
			
		||||
        "winston": "^3.17.0",
 | 
			
		||||
        "winston-daily-rotate-file": "^5.0.0",
 | 
			
		||||
@ -5532,9 +5532,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-public-export-plus": {
 | 
			
		||||
      "version": "0.5.88",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.88.tgz",
 | 
			
		||||
      "integrity": "sha512-uX766+MYDY3pMncu/23Dp9VZvrUe8pdWRWMcxfUbXg29aYO2GqipimHaFtw+vfrY06YAE8nbFkCWhFL3oPDPGw=="
 | 
			
		||||
      "version": "0.5.89",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.89.tgz",
 | 
			
		||||
      "integrity": "sha512-a6dM1MirzofSsuv3LlRQHFLSSIGKPVSN93dcXSDmA3njsWqOGjJJdWyXqcyxxYw8rEB8CNowSHst/MUmKvKlRg=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-riven-info": {
 | 
			
		||||
      "version": "0.1.2",
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@
 | 
			
		||||
    "morgan": "^1.10.0",
 | 
			
		||||
    "ncp": "^2.0.0",
 | 
			
		||||
    "undici": "^7.10.0",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.88",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.89",
 | 
			
		||||
    "warframe-riven-info": "^0.1.2",
 | 
			
		||||
    "winston": "^3.17.0",
 | 
			
		||||
    "winston-daily-rotate-file": "^5.0.0",
 | 
			
		||||
 | 
			
		||||
@ -36,6 +36,7 @@ interface ListedItem {
 | 
			
		||||
    partType?: string;
 | 
			
		||||
    chainLength?: number;
 | 
			
		||||
    parazon?: boolean;
 | 
			
		||||
    alwaysAvailable?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface ItemLists {
 | 
			
		||||
@ -455,8 +456,9 @@ const getItemListsController: RequestHandler = (req, response) => {
 | 
			
		||||
 | 
			
		||||
    for (const [uniqueName, item] of Object.entries(ExportFlavour)) {
 | 
			
		||||
        res.FlavourItems.push({
 | 
			
		||||
            uniqueName: uniqueName,
 | 
			
		||||
            name: getString(item.name, lang)
 | 
			
		||||
            uniqueName,
 | 
			
		||||
            name: getString(item.name, lang),
 | 
			
		||||
            alwaysAvailable: item.alwaysAvailable
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -594,10 +594,12 @@ function fetchItemList() {
 | 
			
		||||
                        } else if (item.uniqueName.includes("ColourPicker")) {
 | 
			
		||||
                            item.name = loc("code_itemColorPalette").split("|ITEM|").join(item.name);
 | 
			
		||||
                        }
 | 
			
		||||
                        const option = document.createElement("option");
 | 
			
		||||
                        option.setAttribute("data-key", item.uniqueName);
 | 
			
		||||
                        option.value = item.name;
 | 
			
		||||
                        document.getElementById("datalist-" + type).appendChild(option);
 | 
			
		||||
                        if (!item.alwaysAvailable) {
 | 
			
		||||
                            const option = document.createElement("option");
 | 
			
		||||
                            option.setAttribute("data-key", item.uniqueName);
 | 
			
		||||
                            option.value = item.name;
 | 
			
		||||
                            document.getElementById("datalist-" + type).appendChild(option);
 | 
			
		||||
                        }
 | 
			
		||||
                        itemMap[item.uniqueName] = { ...item, type };
 | 
			
		||||
                    });
 | 
			
		||||
                } else {
 | 
			
		||||
@ -993,12 +995,12 @@ function updateInventory() {
 | 
			
		||||
            document.getElementById("FlavourItems-list").innerHTML = "";
 | 
			
		||||
            data.FlavourItems.forEach(item => {
 | 
			
		||||
                const datalist = document.getElementById("datalist-FlavourItems");
 | 
			
		||||
                if (!data.FlavourItems.some(x => x.ItemType == item.uniqueName)) {
 | 
			
		||||
                    if (!datalist.querySelector(`option[value="${item.uniqueName}"]`)) {
 | 
			
		||||
                if (!data.FlavourItems.some(x => x.ItemType == item.ItemType)) {
 | 
			
		||||
                    if (!datalist.querySelector(`option[data-key="${item.ItemType}"]`)) {
 | 
			
		||||
                        reAddToItemList(itemMap, "FlavourItems", item.ItemType);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                const optionToRemove = datalist.querySelector(`option[value="${item.ItemType}"]`);
 | 
			
		||||
                const optionToRemove = datalist.querySelector(`option[data-key="${item.ItemType}"]`);
 | 
			
		||||
                optionToRemove?.remove();
 | 
			
		||||
 | 
			
		||||
                const tr = document.createElement("tr");
 | 
			
		||||
@ -3408,10 +3410,13 @@ function doAddCurrency(currency) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function reAddToItemList(itemMap, datalist, itemType) {
 | 
			
		||||
    const option = document.createElement("option");
 | 
			
		||||
    option.setAttribute("data-key", itemType);
 | 
			
		||||
    option.value = itemMap[itemType]?.name ?? itemType;
 | 
			
		||||
    document.getElementById("datalist-" + datalist).appendChild(option);
 | 
			
		||||
    const item = itemMap[itemType];
 | 
			
		||||
    if (!item?.alwaysAvailable) {
 | 
			
		||||
        const option = document.createElement("option");
 | 
			
		||||
        option.setAttribute("data-key", itemType);
 | 
			
		||||
        option.value = item?.name ?? itemType;
 | 
			
		||||
        document.getElementById("datalist-" + datalist).appendChild(option);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function doQuestUpdate(operation, itemType) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user