Merge branch 'forge' of http://bdgit.educoder.net/Hjqreturn/educoder into forge
commit
c0eb363fe3
@ -0,0 +1,33 @@
|
||||
import React , { Component } from 'react';
|
||||
|
||||
import {Route,Switch} from 'react-router-dom';
|
||||
|
||||
|
||||
import { SnackbarHOC } from 'educoder';
|
||||
import { CNotificationHOC } from '../modules/courses/common/CNotificationHOC';
|
||||
|
||||
|
||||
import './css/index.css';
|
||||
|
||||
import Loadable from 'react-loadable';
|
||||
import Loading from '../Loading';
|
||||
|
||||
const ProjectNew = Loadable({
|
||||
loader: () => import('./New/Index'),
|
||||
loading: Loading,
|
||||
})
|
||||
|
||||
class Index extends Component{
|
||||
render(){
|
||||
return(
|
||||
<Switch {...this.props}>
|
||||
<Route exact path="/forge/projects/new"
|
||||
render={
|
||||
(props) => (<ProjectNew {...this.props} {...props} {...this.state} />)
|
||||
}
|
||||
></Route>
|
||||
</Switch>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default CNotificationHOC() ( SnackbarHOC() ( Index ));
|
@ -0,0 +1,270 @@
|
||||
import React , { Component } from 'react';
|
||||
|
||||
import { Input , Form , Select , Checkbox , Button } from 'antd';
|
||||
|
||||
import '../css/index.css';
|
||||
import './new.css'
|
||||
|
||||
import axios from 'axios' ;
|
||||
const Option = Select.Option
|
||||
class Index extends Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
// authorValue:"0",
|
||||
preType:"0",
|
||||
// subType:"0",
|
||||
languageValue:"0",
|
||||
gitignoreType:"0",
|
||||
LicensesType:"0",
|
||||
|
||||
CategoryList:undefined,
|
||||
LanguageList:undefined,
|
||||
GitignoreList:undefined,
|
||||
LicensesList:undefined,
|
||||
}
|
||||
}
|
||||
componentDidMount=()=>{
|
||||
// 获取项目类别
|
||||
this.getCategory();
|
||||
// 获取项目语言
|
||||
this.getLanguage();
|
||||
// 获取Gitignore
|
||||
this.getGitignore();
|
||||
// 获取开源许可证
|
||||
this.getLicenses();
|
||||
}
|
||||
getCategory=()=>{
|
||||
const url = `/project_categories.json`
|
||||
axios.get(url).then((result)=>{
|
||||
if(result){
|
||||
let CategoryList = this.setOptionsList(result.data.project_categories)
|
||||
this.setState({
|
||||
CategoryList
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{})
|
||||
}
|
||||
|
||||
getLanguage=()=>{
|
||||
const url = `/project_languages.json`
|
||||
axios.get(url).then((result)=>{
|
||||
if(result){
|
||||
let LanguageList = this.setOptionsList(result.data.project_languages)
|
||||
this.setState({
|
||||
LanguageList
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{})
|
||||
}
|
||||
|
||||
getGitignore=()=>{
|
||||
const url = `/ignores.json`
|
||||
axios.get(url).then((result)=>{
|
||||
if(result){
|
||||
let GitignoreList = this.setOptionsList(result.data.ignores)
|
||||
this.setState({
|
||||
GitignoreList
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{})
|
||||
}
|
||||
|
||||
getLicenses=()=>{
|
||||
const url = `/licenses.json`
|
||||
axios.get(url).then((result)=>{
|
||||
if(result){
|
||||
let LicensesList = this.setOptionsList(result.data.licenses)
|
||||
this.setState({
|
||||
LicensesList
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{})
|
||||
}
|
||||
|
||||
setOptionsList = (data) =>{
|
||||
let list = undefined;
|
||||
if(data && data.length > 0){
|
||||
list = data.map((item,key)=>{
|
||||
return(
|
||||
<Option key={item.id}>{item.name}</Option>
|
||||
)
|
||||
})
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
subMitFrom = () =>{
|
||||
this.props.form.validateFieldsAndScroll((err, values) => {
|
||||
if(!err){
|
||||
console.log(values)
|
||||
const url = `/projects.json`;
|
||||
axios.post(url,{
|
||||
...values,
|
||||
user_id:50207
|
||||
}).then((result)=>{
|
||||
if(result){
|
||||
|
||||
}
|
||||
}).catch((error)=>{
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
render(){
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
|
||||
const {
|
||||
// authorValue,
|
||||
preType,
|
||||
// subType,
|
||||
languageValue,
|
||||
gitignoreType,
|
||||
LicensesType,
|
||||
|
||||
CategoryList,
|
||||
LanguageList,
|
||||
GitignoreList,
|
||||
LicensesList
|
||||
}=this.state;
|
||||
return(
|
||||
<div className="main">
|
||||
<div className="newPanel">
|
||||
<div className="newPanel_title">创建托管项目</div>
|
||||
<Form>
|
||||
<div className="newPanel_content">
|
||||
{/* <Form.Item
|
||||
label="拥有者"
|
||||
>
|
||||
{getFieldDecorator('user_id', {
|
||||
rules: [{
|
||||
required: true, message: '请选择拥有者'
|
||||
}],
|
||||
})(
|
||||
<Select value={authorValue}>
|
||||
<Option key="0">kosasa</Option>
|
||||
</Select>
|
||||
)}
|
||||
</Form.Item> */}
|
||||
<Form.Item
|
||||
label="项目名称"
|
||||
>
|
||||
{getFieldDecorator('name', {
|
||||
rules: [{
|
||||
required: true, message: '请填写项目名称'
|
||||
}],
|
||||
})(
|
||||
<Input placeholder="例如:团队协作方法与研究"/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="项目简介"
|
||||
>
|
||||
{getFieldDecorator('description', {
|
||||
rules: [{
|
||||
required: true, message: '请填写项目简介'
|
||||
}],
|
||||
})(
|
||||
<Input.TextArea autoSize={{ minRows: 2, maxRows: 6 }}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="仓库名称"
|
||||
style={{marginBottom:"0px"}}
|
||||
>
|
||||
{getFieldDecorator('repository_name', {
|
||||
rules: [{
|
||||
required: true, message: '请填写仓库名称'
|
||||
}],
|
||||
})(
|
||||
<Input placeholder="请输入仓库名称"/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<p className="formTip">好的存储库名称使用简单、深刻和独特的关键字</p>
|
||||
{/* <div className="newContent_inline"> */}
|
||||
<Form.Item
|
||||
label="项目类别"
|
||||
>
|
||||
{getFieldDecorator('project_category_id', {
|
||||
rules: [{
|
||||
required: true, message: '请选择大类别'
|
||||
}],
|
||||
})(
|
||||
<Select value={preType}>
|
||||
{CategoryList}
|
||||
</Select>
|
||||
)}
|
||||
</Form.Item>
|
||||
{/* <Form.Item>
|
||||
{getFieldDecorator('project_language_id', {
|
||||
rules: [{
|
||||
required: true, message: '请选择子类别'
|
||||
}],
|
||||
})(
|
||||
<Select value={subType} className="inline_Tag">
|
||||
<Option key="0">HTMl</Option>
|
||||
<Option key="1">HTMl111</Option>
|
||||
</Select>
|
||||
)}
|
||||
</Form.Item> */}
|
||||
{/* </div> */}
|
||||
<Form.Item
|
||||
label="项目语言"
|
||||
>
|
||||
{getFieldDecorator('project_language_id', {
|
||||
rules: [{
|
||||
required: true, message: '请选择项目语言'
|
||||
}],
|
||||
})(
|
||||
<Select value={languageValue}>
|
||||
{LanguageList}
|
||||
</Select>
|
||||
)}
|
||||
</Form.Item>
|
||||
</div>
|
||||
<div className="newPanel_content">
|
||||
<Form.Item
|
||||
label=".gitignore"
|
||||
>
|
||||
{getFieldDecorator('ignore_id')(
|
||||
<Select value={gitignoreType} className="inline_Tag">
|
||||
{GitignoreList}
|
||||
</Select>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="开源许可证"
|
||||
>
|
||||
{getFieldDecorator('license_id')(
|
||||
<Select value={LicensesType} className="inline_Tag">
|
||||
{LicensesList}
|
||||
</Select>
|
||||
)}
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="可见性"
|
||||
style={{marginBottom:"0px"}}
|
||||
>
|
||||
{getFieldDecorator('private')(
|
||||
<Checkbox value="limit">将项目设为私有</Checkbox>
|
||||
)}
|
||||
</Form.Item >
|
||||
<p className="formTip">只有企业所有人或拥有权限的企业成员才能看到</p>
|
||||
<Form.Item className="formTip">
|
||||
<Button type="primary" onClick={this.subMitFrom} className="mr20">创建项目</Button>
|
||||
<a className="btn_32" onClick={() => this.props.onCancel()}>取消</ a>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
</Form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
const WrappedIndexForm = Form.create({ name: 'NewWorkForm' })(Index);
|
||||
export default WrappedIndexForm;
|
@ -0,0 +1,77 @@
|
||||
.newPanel{
|
||||
border:1px solid #eaeaea;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.newPanel_title{
|
||||
height: 3rem;
|
||||
line-height: 3rem;
|
||||
background: #f0f0f0;
|
||||
text-align: center;
|
||||
border-radius: 4px 4px 0px 0px;
|
||||
font-size: 1.6em;
|
||||
border-bottom: 1px solid #f0f0f0
|
||||
}
|
||||
.newPanel_content{
|
||||
width: 600px;
|
||||
margin:1rem auto;
|
||||
}
|
||||
.newPanel_content .ant-row.ant-form-item{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.newPanel_content .ant-form-item-label{
|
||||
width: 100px;
|
||||
display: block;
|
||||
text-align: right;
|
||||
margin-right: 10px;
|
||||
height: 37px;
|
||||
line-height: 40px;
|
||||
}
|
||||
.newPanel_content .ant-form-item-control-wrapper{
|
||||
flex: 1;
|
||||
min-width: 280px;
|
||||
}
|
||||
.newPanel_content .ant-select-selection{
|
||||
height: 37px;
|
||||
}
|
||||
.newPanel_content .ant-select-selection__rendered,.newPanel_content input{
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
}
|
||||
|
||||
.newContent_inline{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
align-items:flex-end
|
||||
}
|
||||
.newContent_inline .ant-form-item-control-wrapper{
|
||||
min-width: 235px;
|
||||
}
|
||||
.newContent_inline .inline_Tag{
|
||||
width: 235px;
|
||||
}
|
||||
.newContent_inline > .ant-form-item:nth-child(2){
|
||||
margin-left: 20px;
|
||||
}
|
||||
.formTip{
|
||||
margin:0px 0px 20px 110px;
|
||||
}
|
||||
@media screen and (max-width: 750px){
|
||||
.newPanel_content{
|
||||
width:95%;
|
||||
}
|
||||
.newPanel_content .ant-row.ant-form-item{
|
||||
display: grid
|
||||
}
|
||||
.newPanel_content .ant-form-item-label{
|
||||
text-align: left;
|
||||
}
|
||||
.newContent_inline > .ant-form-item:nth-child(2){
|
||||
margin-left:0px
|
||||
}
|
||||
.formTip{
|
||||
margin:0px 0px 20px 0px;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
body{
|
||||
font-size:62.5%;
|
||||
}
|
||||
.main{
|
||||
width: 1200px;
|
||||
margin:2rem auto;
|
||||
background: #fff;
|
||||
}
|
||||
.btn_32{
|
||||
border-radius: 4px;
|
||||
padding:0px 12px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
background-color: #f4f4f4;
|
||||
color: #666;
|
||||
display: inline-block;
|
||||
}
|
||||
@media screen and (max-width: 1200px){
|
||||
.main{
|
||||
width:1000px;
|
||||
margin:1rem auto;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 1000px){
|
||||
.main{
|
||||
width: 750px;
|
||||
margin:1rem auto;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 750px){
|
||||
.main{
|
||||
width: 95%;
|
||||
margin:1rem auto;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue