diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 36f14edbf..d53d4b5da 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -328,7 +328,7 @@ class ApplicationController < ActionController::Base def current_user # User.current - User.find_by_id 36401 + User.find_by_id 50207 # nil end diff --git a/public/react/src/forge/Main/Detail.js b/public/react/src/forge/Main/Detail.js index 700e10972..b019a8e56 100644 --- a/public/react/src/forge/Main/Detail.js +++ b/public/react/src/forge/Main/Detail.js @@ -35,6 +35,7 @@ class Detail extends Component{ isManager:false, isReporter:false, isDeveloper:false, + project_id:undefined, watchers_count:undefined , praises_count:undefined , forked_count:undefined @@ -45,6 +46,12 @@ class Detail extends Component{ this.getDetail(); } + componentDidUpdate=(provState)=>{ + if(provState.match.params.projectsId !== this.props.match.params.projectsId){ + this.getDetail(); + } + } + getDetail=()=>{ const { login } = this.props.current_user; const { projectsId } = this.props.match.params; @@ -53,6 +60,7 @@ class Detail extends Component{ if(result){ this.setState({ projectDetail:result.data, + project_id:result.data.project_id, isManager:result.data.permission && result.data.permission === "Manager", isReporter:result.data.permission && result.data.permission === "Reporter", isDeveloper:result.data.permission && result.data.permission === "Developer", @@ -67,44 +75,71 @@ class Detail extends Component{ // 关注和取消关注 focusFunc =(flag)=>{ - const { projectsId } = this.props.match.params; - if(flag){ - const url = `/projects/${projectsId}/watchers/follow.json`; + const { project_id } = this.state; + if(!flag){ + const url = `/projects/${project_id}/watchers/follow.json`; axios.post(url).then(result=>{ if(result){ this.props.showNotification('关注成功'); + this.getDetail(); } + }).catch(error=>{ + console.log(error); }) }else{ - const url = `/projects/${projectsId}/watchers/unfollow.json`; + const url = `/projects/${project_id}/watchers/unfollow.json`; axios.delete(url).then(result=>{ if(result){ this.props.showNotification('取消关注成功'); + this.getDetail(); } + }).catch(error=>{ + console.log(error); }) } } // 点赞和取消点赞 pariseFunc=(flag)=>{ - const { projectsId } = this.props.match.params; - if(flag){ - const url = `/projects/${projectsId}/praise_tread/like.json`; + const { project_id } = this.state; + if(!flag){ + const url = `/projects/${project_id}/praise_tread/like.json`; axios.post(url).then(result=>{ if(result){ this.props.showNotification('点赞成功'); + this.getDetail(); } + }).catch(error=>{ + console.log(error); }) }else{ - const url = `/projects/${projectsId}/praise_tread/unlike.json`; + const url = `/projects/${project_id}/praise_tread/unlike.json`; axios.delete(url).then(result=>{ if(result){ this.props.showNotification('取消点赞成功'); + this.getDetail(); } + }).catch(error=>{ + console.log(error); }) } } + // fork项目 + forkFunc=()=>{ + const { project_id } = this.state; + const url = `/projects/${project_id}/forks.json`; + axios.post(url).then(result=>{ + if(result && result.data.status === 0){ + this.props.history.push(`/projects/${result.data.identifier}/coder`); + }else{ + this.props.showNotification(result.data.message); + } + }).catch(error=>{ + console.log(error); + }) + } + render(){ const { projectsId } = this.props.match.params; @@ -118,15 +153,21 @@ class Detail extends Component{ - this.focusFunc(true)}>关注 + this.focusFunc(projectDetail && projectDetail.watched)}> + + {projectDetail && projectDetail.watched ? '取消关注':'关注'} + {watchers_count} - this.pariseFunc(true)}>点赞 + this.pariseFunc(projectDetail && projectDetail.praised)}> + + {projectDetail && projectDetail.praised ? '取消点赞':'点赞'} + {praises_count} - + - Fork + Fork {forked_count} diff --git a/public/react/src/forge/Main/list.css b/public/react/src/forge/Main/list.css index 2250a50e1..dbf75010a 100644 --- a/public/react/src/forge/Main/list.css +++ b/public/react/src/forge/Main/list.css @@ -415,7 +415,7 @@ body,#root{ } @media screen and (max-width: 370px){ - .p-r-tags{ + .p-r-tags,.p-r-btn{ opacity: 0; display: none; } diff --git a/public/react/src/forge/Order/New.js b/public/react/src/forge/Order/New.js index 1eb00657f..5aeec1bf8 100644 --- a/public/react/src/forge/Order/New.js +++ b/public/react/src/forge/Order/New.js @@ -1,16 +1,209 @@ import React , { Component } from "react"; +import { Form , Input , Select } from 'antd'; +import {Link} from 'react-router-dom'; + +import {getImageUrl} from 'educoder'; import Nav from './Nav'; +import './order.css'; + +import axios from 'axios'; +const Option = Select.Option; +const TextArea = Input.TextArea; class New extends Component{ + constructor(props){ + super(props); + this.state={ + branch_name:"0", + issue_tag_ids:"0", + fixed_version_id:"0", + tracker_id:"0", + issue_type:"0", + assigned_to_id:"0", + priority_id:"0", + done_ratio:"0", + issue_chosen:undefined + } + } + + componentDidMount=()=>{ + this.InitData(); + this.getSelectList(); + } + + InitData=()=>{ + this.props.form.setFieldsValue({ + ...this.state + }); + } + + getSelectList=()=>{ + const { projectsId } = this.props.match.params; + + const url = `/projects/${projectsId}/issues/new.json`; + axios.get(url).then((result)=>{ + if(result){ + this.setState({ + issue_chosen:result.data.issue_chosen + }) + } + }).catch((error)=>{ + console.log(error); + }) + } + + // 创建 + handleSubmit=()=>{ + this.props.form.validateFieldsAndScroll((err, values) => { + console.log(values); + }) + } + render(){ + const { getFieldDecorator } = this.props.form; + const { current_user } = this.props; + const { issue_tag_ids , fixed_version_id , branch_name , tracker_id , issue_type ,assigned_to_id , priority_id , done_ratio, + issue_chosen } = this.state; + + const renderSelect =(array)=>{ + if(array && array.length > 0){ + return( + array.map((item,key)=>{ + return( + + ) + }) + ) + } + } return(