forked from M-Labs/web2019
Allow duplicating cards in the backlog
Signed-off-by: Egor Savkin <es@m-labs.hk>
This commit is contained in:
parent
4dc15f5633
commit
27c7db1df4
File diff suppressed because one or more lines are too long
@ -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>
|
||||||
|
|
||||||
@ -1538,7 +1539,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}
|
||||||
@ -1633,10 +1634,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',
|
||||||
@ -1645,8 +1645,7 @@ class Shop extends React.PureComponent {
|
|||||||
|
|
||||||
this.handleOnDragEnd({
|
this.handleOnDragEnd({
|
||||||
source,
|
source,
|
||||||
destination,
|
destination
|
||||||
draggableId: sourceIds[0],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1729,10 +1728,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',
|
||||||
@ -1741,8 +1740,7 @@ class Shop extends React.PureComponent {
|
|||||||
|
|
||||||
this.handleOnDragEnd({
|
this.handleOnDragEnd({
|
||||||
source,
|
source,
|
||||||
destination,
|
destination
|
||||||
draggableId: id
|
|
||||||
}, tap);
|
}, tap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1946,8 +1944,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') {
|
||||||
@ -1985,7 +1984,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,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -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',
|
||||||
|
Loading…
Reference in New Issue
Block a user