From a9e24c62021f821e859f82a3c0c0fc00080b77d9 Mon Sep 17 00:00:00 2001 From: Egor Savkin Date: Tue, 2 Jan 2024 17:13:50 +0800 Subject: [PATCH] Fix same options in different crates and drop to the backlog Signed-off-by: Egor Savkin --- package-lock.json | 26 +++++++++---------- package.json | 2 +- static/js/shop/Backlog.jsx | 2 +- static/js/shop/OptionsWrapper.jsx | 12 ++++++--- static/js/shop/Shop.jsx | 2 +- .../js/shop/options/components/components.js | 2 ++ static/js/shop/shop_store.js | 6 +++++ static/js/shop/warnings.js | 4 +-- static/js/shop_data.js | 1 - webpack.config.js | 2 ++ 10 files changed, 36 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index c412c5a..0fa1a6d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@babel/core": "^7.23.2", "@babel/preset-env": "^7.23.2", "@babel/preset-react": "^7.22.15", - "@hello-pangea/dnd": "^16.3.0", + "@hello-pangea/dnd": "^16.5.0", "@uidotdev/usehooks": "^2.4.1", "babel-loader": "^9.1.3", "babel-preset-minify": "^0.5.2", @@ -1786,12 +1786,12 @@ "dev": true }, "node_modules/@babel/runtime": { - "version": "7.22.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz", - "integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==", + "version": "7.23.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.7.tgz", + "integrity": "sha512-w06OXVOFso7LcbzMiDGt+3X7Rh7Ho8MmgPoWU3rarH+8upf+wSU/grlGbWzQyr3DkdN6ZeuMFjpdwW0Q+HxobA==", "dev": true, "dependencies": { - "regenerator-runtime": "^0.13.11" + "regenerator-runtime": "^0.14.0" }, "engines": { "node": ">=6.9.0" @@ -1856,16 +1856,16 @@ } }, "node_modules/@hello-pangea/dnd": { - "version": "16.3.0", - "resolved": "https://registry.npmjs.org/@hello-pangea/dnd/-/dnd-16.3.0.tgz", - "integrity": "sha512-RYQ/K8shtJoyNPvFWz0gfXIK7HF3P3mL9UZFGMuHB0ljRSXVgMjVFI/FxcZmakMzw6tO7NflWLriwTNBow/4vw==", + "version": "16.5.0", + "resolved": "https://registry.npmjs.org/@hello-pangea/dnd/-/dnd-16.5.0.tgz", + "integrity": "sha512-n+am6O32jo/CFXciCysz83lPM3I3F58FJw4uS44TceieymcyxQSfzK5OhzPAKrVBZktmuOI6Zim9WABTMtXv4A==", "dev": true, "dependencies": { - "@babel/runtime": "^7.22.5", + "@babel/runtime": "^7.23.2", "css-box-model": "^1.2.1", "memoize-one": "^6.0.0", "raf-schd": "^4.0.3", - "react-redux": "^8.1.1", + "react-redux": "^8.1.3", "redux": "^4.2.1", "use-memo-one": "^1.1.3" }, @@ -4182,9 +4182,9 @@ } }, "node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", "dev": true }, "node_modules/regenerator-transform": { diff --git a/package.json b/package.json index 15447e0..1584bb1 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "prop-types": "^15.8.1", "react": "^18.2.0", "react-bootstrap": "^2.9.1", - "@hello-pangea/dnd": "^16.3.0", + "@hello-pangea/dnd": "^16.5.0", "react-dom": "^18.2.0", "uuid": "^9.0.1", "webpack": "^5.89.0", diff --git a/static/js/shop/Backlog.jsx b/static/js/shop/Backlog.jsx index 50cd956..2b14ff7 100644 --- a/static/js/shop/Backlog.jsx +++ b/static/js/shop/Backlog.jsx @@ -54,7 +54,7 @@ export function Backlog() { return ( + isDropDisabled={false}> {(provided) => (
{ - // console.log("construct", outvar, value, options_data); + // #!options_log + console.log("construct", outvar, value, options_data); + options_data[outvar] = value; }), update: ((outvar, value) => { - // console.log("update", outvar, value, options_data); + // #!options_log + console.log("update", outvar, value, options_data); + if (outvar in options_data) options_data[outvar] = value; onOptionsUpdate(crate_id, card_index, {[outvar]: value}); }) diff --git a/static/js/shop/Shop.jsx b/static/js/shop/Shop.jsx index 9850a70..84eaf7c 100644 --- a/static/js/shop/Shop.jsx +++ b/static/js/shop/Shop.jsx @@ -32,7 +32,7 @@ export function Shop() { if (drop_result.source.droppableId === "backlog") addCardFromBacklog(drop_result.destination.droppableId, drop_result.source.index, drop_result.destination.index); else if (drop_result.destination.droppableId === "backlog") - deleteCard(drop_result.destination.droppableId, drop_result.destination.index); + deleteCard(drop_result.source.droppableId, drop_result.source.index); else moveCard(drop_result.source.droppableId, drop_result.source.index, drop_result.destination.droppableId, drop_result.destination.index) } diff --git a/static/js/shop/options/components/components.js b/static/js/shop/options/components/components.js index 72b5860..5561b7e 100644 --- a/static/js/shop/options/components/components.js +++ b/static/js/shop/options/components/components.js @@ -6,6 +6,8 @@ import {SwitchWrapper} from "./Switch"; import {SwitchLineWrapper} from "./SwitchLine"; import {UnimplementedComponent} from "./UnimplementedComponent"; + +// Class components are used because we cannot use hooks for updating the state export const componentsList = { "Radio": RadioWrapper, "Switch": SwitchWrapper, diff --git a/static/js/shop/shop_store.js b/static/js/shop/shop_store.js index 8c89925..2b9d48d 100644 --- a/static/js/shop/shop_store.js +++ b/static/js/shop/shop_store.js @@ -195,6 +195,8 @@ const useHighlighted = ((set, get) => ({ card: 0 }, highlightedTimer: null, + + // #!if disable_card_highlight === false highlightCard: (crate_id, index) => set(state => ({ highlighted: { crate: crate_id, @@ -211,6 +213,10 @@ const useHighlighted = ((set, get) => ({ }, highlightedTimer: !!state.highlightedTimer ? clearTimeout(state.highlightedTimer) : null })), + // #!else + highlightCard: () => {return null;}, + highlightReset: () => {return null;}, + // #!endif })); diff --git a/static/js/shop/warnings.js b/static/js/shop/warnings.js index 6e5a91e..4c71424 100644 --- a/static/js/shop/warnings.js +++ b/static/js/shop/warnings.js @@ -31,8 +31,8 @@ const find_next_source_index = (data, index, source) => { const not_enough_resource_trigger = (name) => { return (_data, _index, counters) => { - const eem = find_in_counters(counters, name); - return eem.occupied > eem.max; + const resource = find_in_counters(counters, name); + return resource.occupied > resource.max; } } diff --git a/static/js/shop_data.js b/static/js/shop_data.js index e4c2046..e1a96ae 100644 --- a/static/js/shop_data.js +++ b/static/js/shop_data.js @@ -183,7 +183,6 @@ const shop_data = { ], warnings: [ "eem_resource", - "clk_resource", "eem_wiring_constraint" ], consumes: { diff --git a/webpack.config.js b/webpack.config.js index 992043e..662f46e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -21,9 +21,11 @@ module.exports = { debug: false, directives: { render_count: false, + options_log: true }, params: { ENV: process.env.NODE_ENV, + disable_card_highlight: true }, verbose: false, }