Compare commits

...

1 Commits

Author SHA1 Message Date
Egor Savkin c9faa50578 Allow duplicating cards in the backlog
Signed-off-by: Egor Savkin <es@m-labs.hk>
2023-08-10 16:00:04 +08:00
3 changed files with 14 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,7 @@ import { v4 as uuidv4 } from 'uuid';
const data = window.shop_data; const data = window.shop_data;
const itemsUnfoldedList = Array.from(data.columns.backlog.categories.map(groupId => groupId.itemIds).flat());
const productStyle = (style, snapshot, removeAnim, hovered, selected, cart=false) => { const productStyle = (style, snapshot, removeAnim, hovered, selected, cart=false) => {
const custom = { const custom = {
@ -486,7 +487,7 @@ class ProductItem extends React.PureComponent {
<div className="content"> <div className="content">
<button onClick={this.handleOnClickAddItem.bind(this, id, true)}> <button onClick={this.handleOnClickAddItem.bind(this, index, true)}>
<img src="/images/shop/icon-add.svg" alt="add" /> <img src="/images/shop/icon-add.svg" alt="add" />
</button> </button>
@ -1537,7 +1538,7 @@ class Backlog extends React.PureComponent {
return ( return (
<ProductItem <ProductItem
key={item.id} key={item.id}
id={item.id} id={uuidv4()}
index={item_index} index={item_index}
name={`${item.name_number} ${item.name}`} name={`${item.name_number} ${item.name}`}
name_codename={item.name_codename} name_codename={item.name_codename}
@ -1632,10 +1633,9 @@ class Shop extends React.PureComponent {
componentDidMount() { componentDidMount() {
// index 0 is a Kasli, we place it as a default conf on the crate. // index 0 is a Kasli, we place it as a default conf on the crate.
const sourceIds = Array.from(this.state.columns.backlog.categories.map(groupId => groupId.itemIds).flat())
const source = { const source = {
droppableId: 'backlog', droppableId: 'backlog',
index: null, index: 0,
}; };
const destination = { const destination = {
droppableId: 'cart', droppableId: 'cart',
@ -1644,8 +1644,7 @@ class Shop extends React.PureComponent {
this.handleOnDragEnd({ this.handleOnDragEnd({
source, source,
destination, destination
draggableId: sourceIds[0],
}); });
} }
@ -1728,10 +1727,10 @@ class Shop extends React.PureComponent {
}); });
} }
handleClickAddItem(id, tap) { handleClickAddItem(index, tap) {
const source = { const source = {
droppableId: 'backlog', droppableId: 'backlog',
index: null, index: index,
}; };
const destination = { const destination = {
droppableId: 'cart', droppableId: 'cart',
@ -1740,8 +1739,7 @@ class Shop extends React.PureComponent {
this.handleOnDragEnd({ this.handleOnDragEnd({
source, source,
destination, destination
draggableId: id
}, tap); }, tap);
} }
@ -1945,8 +1943,9 @@ class Shop extends React.PureComponent {
const { const {
source, source,
destination, destination,
draggableId,
} = result; } = result;
let dragged_item = itemsUnfoldedList[source.index];
if (!destination) { if (!destination) {
if (source.droppableId === 'cart') { if (source.droppableId === 'cart') {
@ -1984,7 +1983,7 @@ class Shop extends React.PureComponent {
this.state.items, this.state.items,
this.state.columns[source.droppableId], this.state.columns[source.droppableId],
this.state.columns[destination.droppableId], this.state.columns[destination.droppableId],
draggableId, dragged_item,
destination, destination,
), ),
}, },

View File

@ -917,7 +917,8 @@ const shop_data = {
'urukul', 'urukul',
'phaser', 'phaser',
'mirny', 'mirny',
'almazny']}, 'almazny',
'pounder']},
{ name: 'DAC/ADC', { name: 'DAC/ADC',
itemIds: [ itemIds: [
'zotino', 'zotino',