From 9eb28db680deabc435ad0dfeffc24f89af0ad057 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Tue, 25 Jun 2019 16:32:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/boards/AddDirModal.js | 78 +++++++++++++++++++ .../src/modules/courses/boards/BoardsNew.js | 45 ++++++++--- .../modules/courses/members/teacherList.js | 8 +- 3 files changed, 119 insertions(+), 12 deletions(-) create mode 100644 public/react/src/modules/courses/boards/AddDirModal.js diff --git a/public/react/src/modules/courses/boards/AddDirModal.js b/public/react/src/modules/courses/boards/AddDirModal.js new file mode 100644 index 000000000..89ff6dfeb --- /dev/null +++ b/public/react/src/modules/courses/boards/AddDirModal.js @@ -0,0 +1,78 @@ +import React,{ Component } from "react"; +import {Tooltip, Modal, Input } from 'antd' +import moment from 'moment' +import { getUrl, WordsBtn } from 'educoder' +import axios from 'axios' +class AddDirModal extends Component{ + constructor(props){ + super(props); + this.state = { + + } + } + onInput = (e) => { + this.setState({ + inputValue: e.target.value + }) + } + open = () => { + this.setState({ visible: true, inputValue: '' }) + } + onSave = () => { + let coursesId = this.props.match.params.coursesId; + const url = `/courses/${coursesId}/boards.json` + let { inputValue } = this.state; + + axios.post(url,{ + name: inputValue + }).then((response)=>{ + if (response.data.status == 0) { + this.onCancel() + this.props.showNotification('添加成功') + this.props.addSuccess && this.props.addSuccess() + } + }).catch((error)=>{ + console.log(error) + }) + } + onCancel = () => { + this.setState({ visible: false, inputValue: '' }) + } + render(){ + let { inputValue, visible } = this.state; + const { title } = this.props; + return( + +
+
{this.props.label}:
+ +
+ + {/* {this.state.NavmodalValuetype===true? + {this.state.NavmodalValues} + :""} */} + + {/* this.state.NavmodalValuetype===true?"clearfix mt20 edu-txt-center": */} +
+ 取消 + 确定 +
+
+ ) + } +} +export default AddDirModal; \ No newline at end of file diff --git a/public/react/src/modules/courses/boards/BoardsNew.js b/public/react/src/modules/courses/boards/BoardsNew.js index cf530aba5..97d9436a6 100644 --- a/public/react/src/modules/courses/boards/BoardsNew.js +++ b/public/react/src/modules/courses/boards/BoardsNew.js @@ -3,13 +3,13 @@ import React,{ Component } from "react"; import { Form, Input, InputNumber, Switch, Radio, Slider, Button, Upload, Icon, Rate, Checkbox, message, - Row, Col, Select, Modal + Row, Col, Select, Modal, Divider } from 'antd'; import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; import axios from 'axios' import './board.css' import "../common/formCommon.css" - +import AddDirModal from './AddDirModal' import { RouteHOC } from './common.js' import CBreadcrumb from '../common/CBreadcrumb' import {getUploadActionUrl, bytesToSize, uploadNameSizeSeperator, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll} from 'educoder'; @@ -29,14 +29,14 @@ class BoardsNew extends Component{ boards: [] } } - componentDidMount = () => { - - const topicId = this.props.match.params.topicId - + addSuccess = () => { + this.fetchBoards() + } + fetchBoards = () => { + const isEdit = this.isEdit const boardId = this.props.match.params.boardId - const boardsUrl = `/courses/board_list.json?board_id=${boardId}` - const isEdit = !!topicId + const boardsUrl = `/courses/board_list.json?board_id=${boardId}` axios.get(boardsUrl, { }) .then((response) => { if (response.data.status == 0) { @@ -57,8 +57,17 @@ class BoardsNew extends Component{ .catch(function (error) { console.log(error); }); - + } + componentDidMount = () => { + + const topicId = this.props.match.params.topicId + const isEdit = !!topicId this.isEdit = isEdit + + const boardId = this.props.match.params.boardId + + this.fetchBoards() + if (isEdit) { const url = `/messages/${topicId}.json` axios.get(url, { @@ -260,6 +269,12 @@ class BoardsNew extends Component{ return(
+