From 696557ca3f023f967c711699e52596d6062393d5 Mon Sep 17 00:00:00 2001 From: Ivareh Date: Sat, 16 Nov 2024 12:07:43 +0100 Subject: [PATCH 1/2] #663 Removed unused plot inputs and fixed autofocus min max --- src/backend_api/app/plotting/plotter.py | 18 ++-- .../ItemInputComp/MinMaxItemLvlInput.tsx | 89 ++++++++++--------- .../src/components/Input/MiscItemInput.tsx | 13 ++- .../ModifierInputComp/FancyModifierInput.tsx | 11 +-- .../StandardLayoutInput/MinMaxNumberInput.tsx | 5 +- 5 files changed, 71 insertions(+), 65 deletions(-) diff --git a/src/backend_api/app/plotting/plotter.py b/src/backend_api/app/plotting/plotter.py index b9456456..e526ab29 100644 --- a/src/backend_api/app/plotting/plotter.py +++ b/src/backend_api/app/plotting/plotter.py @@ -2,7 +2,6 @@ from pydantic import TypeAdapter from sqlalchemy import ( BinaryExpression, - Boolean, ColumnElement, Result, and_, @@ -238,12 +237,17 @@ def _apply_item_specs( item_spec_query_fields.pop("maxIlvl") if item_spec_query.influences is not None: - item_specifications += [ - model_Item.influences[key].cast(Boolean) - == item_spec_query.influences.__dict__[key] - for key in item_spec_query.influences.model_fields - if (item_spec_query.influences.__dict__[key] is not None) - ] + # item_specifications += [ + # ( + # model_Item.influences[key].isnot(None).cast(Boolean) + # if model_Item.influences[key].is_not(None) + # else model_Item.influences[key] + # == item_spec_query.influences.__dict__[key] + # ) + # for key in item_spec_query.influences.model_fields + # if item_spec_query.influences.__dict__[key] is not None + # ] + # TODO: Fix influences query and uncomment above item_spec_query_fields.pop("influences") item_specifications += [ diff --git a/src/frontend/src/components/Input/ItemInputComp/MinMaxItemLvlInput.tsx b/src/frontend/src/components/Input/ItemInputComp/MinMaxItemLvlInput.tsx index c158e4b0..1d4b5802 100644 --- a/src/frontend/src/components/Input/ItemInputComp/MinMaxItemLvlInput.tsx +++ b/src/frontend/src/components/Input/ItemInputComp/MinMaxItemLvlInput.tsx @@ -1,54 +1,55 @@ import { useGraphInputStore } from "../../../store/GraphInputStore"; import { - MinMaxNumberInput, - HandleNumberChangeEventFunction, - DefaultMinMaxValues, + MinMaxNumberInput, + HandleNumberChangeEventFunction, + DefaultMinMaxValues, } from "../StandardLayoutInput/MinMaxNumberInput"; interface MinMaxInputProps { - text: string; + text: string; } // Min Max Item Lvl Input Component - This component is used to input the min and max ilvl of an item. export const MinMaxIlvlInput = (props: MinMaxInputProps) => { - const { itemSpec, setItemSpecMinIlvl, setItemSpecMaxIlvl } = - useGraphInputStore(); - - const handleMinChange = (eventValue: string) => { - const eventValueInt = parseInt(eventValue); - - setItemSpecMinIlvl(eventValueInt); - }; - - const handleMaxChange = (eventValue: string) => { - const eventValueInt = parseInt(eventValue); - - setItemSpecMaxIlvl(eventValueInt); - }; - - const handleNumberChange: HandleNumberChangeEventFunction = ( - value, - numericalType - ) => { - if (numericalType === "min") { - handleMinChange(value); - } else if (numericalType === "max") { - handleMaxChange(value); - } else { - throw "'numericalType' must be 'min' or 'max'"; - } - }; - - const presetValue: DefaultMinMaxValues = { - min: itemSpec?.minIlvl != null ? itemSpec.minIlvl : undefined, - max: itemSpec?.maxIlvl != null ? itemSpec.maxIlvl : undefined, - }; - - return ( - - ); + const { itemSpec, setItemSpecMinIlvl, setItemSpecMaxIlvl } = + useGraphInputStore(); + + const handleMinChange = (eventValue: string) => { + const eventValueInt = parseInt(eventValue); + + setItemSpecMinIlvl(eventValueInt); + }; + + const handleMaxChange = (eventValue: string) => { + const eventValueInt = parseInt(eventValue); + + setItemSpecMaxIlvl(eventValueInt); + }; + + const handleNumberChange: HandleNumberChangeEventFunction = ( + value, + numericalType, + ) => { + if (numericalType === "min") { + handleMinChange(value); + } else if (numericalType === "max") { + handleMaxChange(value); + } else { + throw "'numericalType' must be 'min' or 'max'"; + } + }; + + const presetValue: DefaultMinMaxValues = { + min: itemSpec?.minIlvl != null ? itemSpec.minIlvl : undefined, + max: itemSpec?.maxIlvl != null ? itemSpec.maxIlvl : undefined, + }; + + return ( + + ); }; diff --git a/src/frontend/src/components/Input/MiscItemInput.tsx b/src/frontend/src/components/Input/MiscItemInput.tsx index a1465af5..2fd43dcc 100644 --- a/src/frontend/src/components/Input/MiscItemInput.tsx +++ b/src/frontend/src/components/Input/MiscItemInput.tsx @@ -11,7 +11,7 @@ export const MiscItemInput = () => { const clearClicked = useGraphInputStore((state) => state.clearClicked); const miscItemExpanded = useExpandedComponentStore( - (state) => state.expandedMiscItem + (state) => state.expandedMiscItem, ); const { setExpandedMiscItem } = useExpandedComponentStore(); @@ -35,22 +35,21 @@ export const MiscItemInput = () => { /> {miscItemExpanded && ( - + {/** **/} - + {/** - - + **/} + {/**< IsItemInput itemSpecKey={"searing"} text={"Exarch influence"} /> - - + **/} )} diff --git a/src/frontend/src/components/Input/ModifierInputComp/FancyModifierInput.tsx b/src/frontend/src/components/Input/ModifierInputComp/FancyModifierInput.tsx index 6ddcf965..25507989 100644 --- a/src/frontend/src/components/Input/ModifierInputComp/FancyModifierInput.tsx +++ b/src/frontend/src/components/Input/ModifierInputComp/FancyModifierInput.tsx @@ -12,7 +12,7 @@ type HandleChangeEventFunction = ( value: string | undefined, selectedModifierIndex: number, numericalType?: "min" | "max", - textRolls?: string + textRolls?: string, ) => void; export type TakingInputEventFunction = (orderIndex: number) => void; @@ -44,7 +44,7 @@ const InputChangeHandler = (props: InputChangeHandler) => { props.modifierId, value, props.selectedModifierIndex, - numericalType + numericalType, ) } flexProps={{ @@ -53,6 +53,7 @@ const InputChangeHandler = (props: InputChangeHandler) => { }} defaultValues={defaultMinMaxValues} tight={true} + autoFocus={true} /> ); } else if (textRolls == null) { @@ -73,7 +74,7 @@ const InputChangeHandler = (props: InputChangeHandler) => { value, props.selectedModifierIndex, undefined, - textRolls + textRolls, ) } defaultValue={defaultTextValue} @@ -153,7 +154,7 @@ export const FancyModifierInput = (props: FancyModifierInputProps) => { value: string | undefined, selectedModifierIndex: number, numericalType?: "min" | "max", - textRolls?: string + textRolls?: string, ): void => { if (numericalType && textRolls) { throw "'numericalType' and 'textRolls' cannot both be defined"; @@ -180,7 +181,7 @@ export const FancyModifierInput = (props: FancyModifierInputProps) => { throw `Couldnt find the current 'wantedModifierExtended' with the index ${props.selectedModifierIndex}`; } const currentWantedModifierExtended = wantedModifierExtended.filter( - (spec) => spec.index == props.selectedModifierIndex + (spec) => spec.index == props.selectedModifierIndex, ); const currentRelevantModifierSpec = diff --git a/src/frontend/src/components/Input/StandardLayoutInput/MinMaxNumberInput.tsx b/src/frontend/src/components/Input/StandardLayoutInput/MinMaxNumberInput.tsx index 6f957d15..1651c02f 100644 --- a/src/frontend/src/components/Input/StandardLayoutInput/MinMaxNumberInput.tsx +++ b/src/frontend/src/components/Input/StandardLayoutInput/MinMaxNumberInput.tsx @@ -9,7 +9,7 @@ import { export type HandleNumberChangeEventFunction = ( value: string, - numericalType: "min" | "max" + numericalType: "min" | "max", ) => void; export interface DefaultMinMaxValues { @@ -25,6 +25,7 @@ export interface MinMaxNumberProps { isDimmed?: boolean; defaultValues?: DefaultMinMaxValues; tight?: boolean; + autoFocus?: boolean; } export const MinMaxNumberInput = (props: MinMaxNumberProps) => { @@ -64,7 +65,7 @@ export const MinMaxNumberInput = (props: MinMaxNumberProps) => { Date: Sat, 16 Nov 2024 12:35:14 +0100 Subject: [PATCH 2/2] #663 Removed isRelic from project completely and migrated frontend --- .../app/core/schemas/plot/input.py | 1 - .../app/tests/utils/model_utils/plot.py | 1 - src/frontend/openapi.json | 45 +------------------ src/frontend/src/client/models/Item.ts | 2 - src/frontend/src/client/models/ItemCreate.ts | 2 - src/frontend/src/client/models/ItemSpecs.ts | 1 - src/frontend/src/client/schemas/$Item.ts | 12 ----- .../src/client/schemas/$ItemCreate.ts | 12 ----- src/frontend/src/client/schemas/$ItemSpecs.ts | 8 ---- .../Input/ItemInputComp/IsItemInput.tsx | 10 +---- src/frontend/src/store/GraphInputStore.tsx | 5 --- src/frontend/src/store/StateInterface.tsx | 2 - 12 files changed, 3 insertions(+), 98 deletions(-) diff --git a/src/backend_api/app/core/schemas/plot/input.py b/src/backend_api/app/core/schemas/plot/input.py index 5649a49f..26a8b3f1 100644 --- a/src/backend_api/app/core/schemas/plot/input.py +++ b/src/backend_api/app/core/schemas/plot/input.py @@ -17,7 +17,6 @@ class ItemSpecs(_pydantic.BaseModel): influences: Influences | None = None searing: bool | None = None tangled: bool | None = None - isRelic: bool | None = None foilVariation: int | None = None diff --git a/src/backend_api/app/tests/utils/model_utils/plot.py b/src/backend_api/app/tests/utils/model_utils/plot.py index 8729ff59..8dd992da 100644 --- a/src/backend_api/app/tests/utils/model_utils/plot.py +++ b/src/backend_api/app/tests/utils/model_utils/plot.py @@ -41,7 +41,6 @@ async def create_minimal_random_plot_query_dict(db: Session) -> dict[str, Any]: "influences": None, "searing": None, "tangled": None, - "isRelic": None, "foilVariation": None, } diff --git a/src/frontend/openapi.json b/src/frontend/openapi.json index 401c587e..cc7edba4 100644 --- a/src/frontend/openapi.json +++ b/src/frontend/openapi.json @@ -3145,10 +3145,6 @@ "type": "integer", "title": "Itembasetypeid" }, - "typeLine": { - "type": "string", - "title": "Typeline" - }, "ilvl": { "type": "integer", "title": "Ilvl" @@ -3271,17 +3267,6 @@ ], "title": "Tangled" }, - "isRelic": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ], - "title": "Isrelic" - }, "prefixes": { "anyOf": [ { @@ -3328,7 +3313,6 @@ "required": [ "league", "itemBaseTypeId", - "typeLine", "ilvl", "rarity", "createdHoursSinceLaunch", @@ -3482,10 +3466,6 @@ "type": "integer", "title": "Itembasetypeid" }, - "typeLine": { - "type": "string", - "title": "Typeline" - }, "ilvl": { "type": "integer", "title": "Ilvl" @@ -3608,17 +3588,6 @@ ], "title": "Tangled" }, - "isRelic": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ], - "title": "Isrelic" - }, "prefixes": { "anyOf": [ { @@ -3661,7 +3630,6 @@ "required": [ "league", "itemBaseTypeId", - "typeLine", "ilvl", "rarity", "createdHoursSinceLaunch" @@ -3880,17 +3848,6 @@ ], "title": "Tangled" }, - "isRelic": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ], - "title": "Isrelic" - }, "foilVariation": { "anyOf": [ { @@ -5242,4 +5199,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/frontend/src/client/models/Item.ts b/src/frontend/src/client/models/Item.ts index f051a577..04007f7a 100644 --- a/src/frontend/src/client/models/Item.ts +++ b/src/frontend/src/client/models/Item.ts @@ -7,7 +7,6 @@ export type Item = { name?: (string | null); league: string; itemBaseTypeId: number; - typeLine: string; ilvl: number; rarity: string; identified?: boolean; @@ -21,7 +20,6 @@ export type Item = { influences?: (Influences | null); searing?: (boolean | null); tangled?: (boolean | null); - isRelic?: (boolean | null); prefixes?: (number | null); suffixes?: (number | null); foilVariation?: (number | null); diff --git a/src/frontend/src/client/models/ItemCreate.ts b/src/frontend/src/client/models/ItemCreate.ts index 1cf3f1b4..00a32c35 100644 --- a/src/frontend/src/client/models/ItemCreate.ts +++ b/src/frontend/src/client/models/ItemCreate.ts @@ -7,7 +7,6 @@ export type ItemCreate = { name?: (string | null); league: string; itemBaseTypeId: number; - typeLine: string; ilvl: number; rarity: string; identified?: boolean; @@ -21,7 +20,6 @@ export type ItemCreate = { influences?: (Influences | null); searing?: (boolean | null); tangled?: (boolean | null); - isRelic?: (boolean | null); prefixes?: (number | null); suffixes?: (number | null); foilVariation?: (number | null); diff --git a/src/frontend/src/client/models/ItemSpecs.ts b/src/frontend/src/client/models/ItemSpecs.ts index affed04b..a96e61eb 100644 --- a/src/frontend/src/client/models/ItemSpecs.ts +++ b/src/frontend/src/client/models/ItemSpecs.ts @@ -17,7 +17,6 @@ export type ItemSpecs = { influences?: (Influences | null); searing?: (boolean | null); tangled?: (boolean | null); - isRelic?: (boolean | null); foilVariation?: (number | null); }; diff --git a/src/frontend/src/client/schemas/$Item.ts b/src/frontend/src/client/schemas/$Item.ts index 91dea96f..ffd5e86b 100644 --- a/src/frontend/src/client/schemas/$Item.ts +++ b/src/frontend/src/client/schemas/$Item.ts @@ -20,10 +20,6 @@ export const $Item = { type: 'number', isRequired: true, }, - typeLine: { - type: 'string', - isRequired: true, - }, ilvl: { type: 'number', isRequired: true, @@ -115,14 +111,6 @@ export const $Item = { type: 'null', }], }, - isRelic: { - type: 'any-of', - contains: [{ - type: 'boolean', - }, { - type: 'null', - }], - }, prefixes: { type: 'any-of', contains: [{ diff --git a/src/frontend/src/client/schemas/$ItemCreate.ts b/src/frontend/src/client/schemas/$ItemCreate.ts index 81605578..b8b44180 100644 --- a/src/frontend/src/client/schemas/$ItemCreate.ts +++ b/src/frontend/src/client/schemas/$ItemCreate.ts @@ -20,10 +20,6 @@ export const $ItemCreate = { type: 'number', isRequired: true, }, - typeLine: { - type: 'string', - isRequired: true, - }, ilvl: { type: 'number', isRequired: true, @@ -115,14 +111,6 @@ export const $ItemCreate = { type: 'null', }], }, - isRelic: { - type: 'any-of', - contains: [{ - type: 'boolean', - }, { - type: 'null', - }], - }, prefixes: { type: 'any-of', contains: [{ diff --git a/src/frontend/src/client/schemas/$ItemSpecs.ts b/src/frontend/src/client/schemas/$ItemSpecs.ts index ce45a048..638db668 100644 --- a/src/frontend/src/client/schemas/$ItemSpecs.ts +++ b/src/frontend/src/client/schemas/$ItemSpecs.ts @@ -108,14 +108,6 @@ export const $ItemSpecs = { type: 'null', }], }, - isRelic: { - type: 'any-of', - contains: [{ - type: 'boolean', - }, { - type: 'null', - }], - }, foilVariation: { type: 'any-of', contains: [{ diff --git a/src/frontend/src/components/Input/ItemInputComp/IsItemInput.tsx b/src/frontend/src/components/Input/ItemInputComp/IsItemInput.tsx index 71c98bb7..192ac3a1 100644 --- a/src/frontend/src/components/Input/ItemInputComp/IsItemInput.tsx +++ b/src/frontend/src/components/Input/ItemInputComp/IsItemInput.tsx @@ -22,8 +22,7 @@ interface IsItemInputProps { | "hunter" | "warlord" | "searing" - | "tangled" - | "isRelic"; + | "tangled"; text: string; } @@ -45,7 +44,6 @@ export const IsItemInput = ({ itemSpecKey, text }: IsItemInputProps) => { setItemSpecWarlordInfluence, setItemSpecSearing, setItemSpecTangled, - setItemSpecIsRelic, } = useGraphInputStore(); let presetValue: boolean | undefined | null; @@ -107,10 +105,6 @@ export const IsItemInput = ({ itemSpecKey, text }: IsItemInputProps) => { presetValue = itemSpec?.tangled; setItemSpecMisc = setItemSpecTangled; break; - case "isRelic": - presetValue = itemSpec?.isRelic; - setItemSpecMisc = setItemSpecIsRelic; - break; default: throw "Couldn't match 'itemSpecKey' with item spec set function."; } @@ -129,7 +123,7 @@ export const IsItemInput = ({ itemSpecKey, text }: IsItemInputProps) => { ]; const defaultOption = optionsList.find( - (option) => convertToBoolean(option.value) === presetValue + (option) => convertToBoolean(option.value) === presetValue, ); return ( diff --git a/src/frontend/src/store/GraphInputStore.tsx b/src/frontend/src/store/GraphInputStore.tsx index 23711290..cbc47e69 100644 --- a/src/frontend/src/store/GraphInputStore.tsx +++ b/src/frontend/src/store/GraphInputStore.tsx @@ -272,11 +272,6 @@ export const useGraphInputStore = create((set) => ({ itemSpec: { ...state.itemSpec, tangled: tangled }, })), - setItemSpecIsRelic: (isRelic: boolean | undefined) => - set((state) => ({ - itemSpec: { ...state.itemSpec, isRelic: isRelic }, - })), - setItemSpecCorrupted: (corrupted: boolean | undefined) => set((state) => ({ itemSpec: { ...state.itemSpec, corrupted: corrupted }, diff --git a/src/frontend/src/store/StateInterface.tsx b/src/frontend/src/store/StateInterface.tsx index 2f7d59c5..2eba8624 100644 --- a/src/frontend/src/store/StateInterface.tsx +++ b/src/frontend/src/store/StateInterface.tsx @@ -34,7 +34,6 @@ export interface ItemSpecState { influences?: InfluenceSpecState | null; searing?: boolean | null; tangled?: boolean | null; - isRelic?: boolean | null; foilVariation?: number | null; } @@ -138,7 +137,6 @@ export interface GraphInputState { setItemSpecReplica: SetItemSpecMisc; setItemSpecSearing: SetItemSpecMisc; setItemSpecTangled: SetItemSpecMisc; - setItemSpecIsRelic: SetItemSpecMisc; setItemSpecFoilVariation: (foilVariation: number | undefined) => void; setBaseSpec: (baseSpec: BaseSpecState) => void;