|
@@ -1,6 +1,8 @@
|
|
import styled from 'styled-components'
|
|
import styled from 'styled-components'
|
|
import gql from 'graphql-tag'
|
|
import gql from 'graphql-tag'
|
|
import { Mutation, Query } from 'react-apollo'
|
|
import { Mutation, Query } from 'react-apollo'
|
|
|
|
+import File from './File'
|
|
|
|
+import ProjectVersion from './ProjectVersion'
|
|
|
|
|
|
const CREATE_PROJECT = gql`
|
|
const CREATE_PROJECT = gql`
|
|
mutation CREATE_PROJECT($name: String!, $abbreviation: String!, $description: String) {
|
|
mutation CREATE_PROJECT($name: String!, $abbreviation: String!, $description: String) {
|
|
@@ -55,12 +57,27 @@ const ProjectSelector = props => (
|
|
</Query >
|
|
</Query >
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+const ProjectFields = props => (
|
|
|
|
+ <fieldset>
|
|
|
|
+ {props.title && <legend>{props.title}</legend>}
|
|
|
|
+ <label htmlFor='name'>Project name</label>
|
|
|
|
+ <input type='text' name='name' id='name' placeholder='Project name' value={props.state.name} onChange={props.onChange} />
|
|
|
|
+ <label htmlFor='abbreviation'>Project abbreviation</label>
|
|
|
|
+ <input type='text' name='abbreviation' id='abbreviation' placeholder='Project abbreviation' value={props.state.abbreviation} onChange={props.onChange} />
|
|
|
|
+ <label htmlFor='description'>Project description</label>
|
|
|
|
+ <textarea name='description' id='description' placeholder='Project description' value={props.state.description} onChange={props.onChange} />
|
|
|
|
+ </fieldset>
|
|
|
|
+)
|
|
|
|
+
|
|
class Project extends React.Component {
|
|
class Project extends React.Component {
|
|
state = {
|
|
state = {
|
|
id: null,
|
|
id: null,
|
|
name: '',
|
|
name: '',
|
|
abbreviation: '',
|
|
abbreviation: '',
|
|
description: '',
|
|
description: '',
|
|
|
|
+ files: [],
|
|
|
|
+ versions: [],
|
|
|
|
+ ...this.props.project
|
|
}
|
|
}
|
|
|
|
|
|
toState = event => {
|
|
toState = event => {
|
|
@@ -76,16 +93,8 @@ class Project extends React.Component {
|
|
const { data } = await createProject()
|
|
const { data } = await createProject()
|
|
this.state.id = data.createProject.id
|
|
this.state.id = data.createProject.id
|
|
}}>
|
|
}}>
|
|
- <h1>Project Setup</h1>
|
|
|
|
- <fieldset id='project-generic'>
|
|
|
|
- <label htmlFor='name'>Project name</label>
|
|
|
|
- <input type='text' name='name' id='name' placeholder='Project name' value={this.state.name} onChange={this.toState} />
|
|
|
|
- <label htmlFor='abbreviation'>Project abbreviation</label>
|
|
|
|
- <input type='text' name='abbreviation' id='abbreviation' placeholder='Project abbreviation' value={this.state.abbreviation} onChange={this.toState} />
|
|
|
|
- <label htmlFor='description'>Project description</label>
|
|
|
|
- <textarea name='description' id='description' placeholder='Project description' value={this.state.description} onChange={this.toState} />
|
|
|
|
- </fieldset>
|
|
|
|
- <button type='submit'>Save</button>
|
|
|
|
|
|
+ <ProjectFields title="Project" state={this.state} onChange={this.toState} />
|
|
|
|
+ <button type='submit'>{this.state.id && this.state.id !== "__NEW__" ? "Save" : "Add"}</button>
|
|
</form>
|
|
</form>
|
|
)}
|
|
)}
|
|
</Mutation>
|
|
</Mutation>
|
|
@@ -94,4 +103,4 @@ class Project extends React.Component {
|
|
}
|
|
}
|
|
|
|
|
|
export default Project
|
|
export default Project
|
|
-export { ProjectSelector }
|
|
|
|
|
|
+export { ProjectSelector, QUERY_PROJECTS, ProjectFields }
|