Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sortItems = (sectionIndex, oldIndex, newIndex) => {
const currentSection = this.props.sections[sectionIndex];
const oldElements = this.getElementsForSection(currentSection);
const dataElements = arrayMove(oldElements, oldIndex, newIndex);
const sections = this.props.sections;
sections[sectionIndex][this.props.elementPath] = dataElements;
this.props.onSectionOrderChanged(sections);
};
const onSortEnd = ({ oldIndex, newIndex }) => {
if (oldIndex === newIndex) { return; };
let copy = [...attributes];
let newArr = arrayMove(copy, oldIndex, newIndex);
reorderAttributes(newArr, oldIndex, newIndex);
}
return (
private onSortEnd = ({ oldIndex, newIndex }) => {
let { headers } = this.state;
headers = arrayMove(headers, oldIndex, newIndex);
this.onChanged(headers);
}
onSortEnd({oldIndex, newIndex}) {
const newItemsOrder = arrayMove(this.state.items, oldIndex, newIndex);
this.setState({items: newItemsOrder});
document.body.style.cursor = this.cursor;
if (this.props.onSortChange) {
this.props.onSortChange(newItemsOrder);
}
}
const onSortEnd = ({oldIndex, newIndex}) => {
const sortedChain = arrayMove(chain, oldIndex, newIndex)
actions.sortPolicyChain(sortedChain)
}
onSortEnd({oldIndex, newIndex}) {
let {onSortEnd} = this.props;
let {items} = this.state;
this.setState({items: arrayMove(items, oldIndex, newIndex), isSorting: false});
if (onSortEnd) {
onSortEnd(this.state.items);
}
this.sortingIndex = null;
};
export function dragWallet({ oldIndex, newIndex, wallets }) {
return {
type: DRAG_WALLET,
newWallets: arrayMove(wallets.toJS(), oldIndex, newIndex),
};
}
down = (event) => {
const { body, setPage } = this.props;
const index = parseInt(event.target.dataset.index);
const item = body[index];
let _body = arrayMove(body, index, index + 1);
setPage({
options: {
type: item.type,
index: index + 1
},
body: _body
});
};
onImageReorder={({ newIndex, oldIndex }) => {
if (product) {
let ids = product.images.map(image => image.id);
ids = arrayMove(ids, oldIndex, newIndex);
reorderProductImages.mutate({
imagesIds: ids,
productId: product.id
});
}
}}
onSubmit={handleSubmit}
onSortEnd = children => ({ oldIndex, newIndex }) => {
const { client } = this.props;
const newChildren = arrayMove(children, oldIndex, newIndex);
client.mutate({
mutation: gql`
mutation reorderPages($ids: [String]) {
reorderPages(ids: $ids) {
id, order
}
}
`,
variables: {
ids: newChildren.map(x => x.id),
},
optimisticResponse: {
__typename: 'Mutation',
reorderPages: newChildren.map(({ id }, order) => ({ id, order })),
},