import React, { Component } from 'react'; import {getImageUrl} from 'educoder'; import '../../paths/ShixunPaths.css'; import DetailCardsEditAndAdd from './DetailCardsEditAndAdd'; import axios from 'axios'; import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"; const reorder = (list, startIndex, endIndex) => { const result = Array.from(list); const [removed] = result.splice(startIndex, 1); result.splice(endIndex, 0, removed); return result; }; const $ = window.$ class DetailCards extends Component{ constructor(props){ super(props) this.state={ pathCardsList:undefined } } getPathCardsList(){ let pathid = this.props.match.params.PathId // let pathid= 28; let url=`/stages.json?subject_id=`+pathid; axios.get(url).then((result)=>{ if(result.status===200){ this.setState({ pathCardsList:result.data.stages }) } }).catch((error)=>{ console.log(error); }) } for_paragraph = (index) =>{ $("#detail_for_paragraph_"+index).slideToggle(500); } componentDidMount(){ this.getPathCardsList(); } onDragEnd = (result, shixunIndex) => { // console.log(result) // dropped outside the list if (!result.destination) { console.log('dropped outside the list') return; } if (result.destination.index === result.source.index) { console.log('the same') return; } // TODO exchange axios request const shixuns_list = reorder( this.state.pathCardsList[shixunIndex].shixuns_list, result.source.index, result.destination.index ); const pathCardsList = this.state.pathCardsList pathCardsList[shixunIndex].shixuns_list = shixuns_list; this.setState({ pathCardsList }); } render(){ let { pathCardsList }=this.state; return(
{item.stage_description}
{/* 两个 ref={provided.innerRef} item 加 {...provided.draggableProps} handler 加 {...provided.dragHandleProps} */}