How to use the react-sortable-hoc.arrayMove function in react-sortable-hoc

To help you get started, we’ve selected a few react-sortable-hoc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dhis2 / maintenance-app / src / EditModel / event-program / create-data-entry-form / SectionForm.js View on Github external
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);
    };
github john-guerra / navio / shipyard / src / components / playground / navio-container / sidebar / Sider.jsx View on Github external
const onSortEnd = ({ oldIndex, newIndex }) => {
    if (oldIndex === newIndex) { return; };
    let copy = [...attributes];
    let newArr = arrayMove(copy, oldIndex, newIndex);
    reorderAttributes(newArr, oldIndex, newIndex);
  }
  return (
github brookshi / Hitchhiker / client / src / components / key_value / key_value_list.tsx View on Github external
private onSortEnd = ({ oldIndex, newIndex }) => {
        let { headers } = this.state;
        headers = arrayMove(headers, oldIndex, newIndex);
        this.onChanged(headers);
    }
github superdesk / superdesk-planning / client / components / SortItems / index.jsx View on Github external
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);
        }
    }
github 3scale / porta / app / javascript / src / Policies / components / PolicyChain.jsx View on Github external
const onSortEnd = ({oldIndex, newIndex}) => {
    const sortedChain = arrayMove(chain, oldIndex, newIndex)
    actions.sortPolicyChain(sortedChain)
  }
github higlass / higlass / app / scripts / PositionalTiledPlot.jsx View on Github external
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;
  };
github hubiinetwork / hubii-core / src / containers / WalletHoc / actions.js View on Github external
export function dragWallet({ oldIndex, newIndex, wallets }) {
  return {
    type: DRAG_WALLET,
    newWallets: arrayMove(wallets.toJS(), oldIndex, newIndex),
  };
}
github mojisrc / fashop-admin / src / components / shop / diy / view / index.js View on Github external
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
        });
    };
github mirumee / saleor-dashboard / src / products / views / ProductUpdate.tsx View on Github external
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}
github olymp / olymp / packages / fela / src / navbar / editable.js View on Github external
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 })),
      },