|
|
|
@ -17,16 +17,24 @@
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
|
|
import {Badge, Button, FormGroup, Input, Label, Row} from 'reactstrap';
|
|
|
|
|
import {Button, FormGroup, Input, Label, Row} from 'reactstrap';
|
|
|
|
|
import Dropzone from 'react-dropzone';
|
|
|
|
|
import {FormattedMessage} from 'react-intl';
|
|
|
|
|
import Chip from "../../../UIComponents/Chip/Chip";
|
|
|
|
|
|
|
|
|
|
class GeneralInfo extends Component {
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
this.onTextFieldChange = this.onTextFieldChange.bind(this);
|
|
|
|
|
this.addTags = this.addTags.bind(this);
|
|
|
|
|
this.handleRequestDelete = this.handleRequestDelete.bind(this);
|
|
|
|
|
this.handleTagChange = this.handleTagChange.bind(this);
|
|
|
|
|
this.state = {
|
|
|
|
|
defValue: "",
|
|
|
|
|
title: "",
|
|
|
|
|
description: "",
|
|
|
|
|
shortDescription: "",
|
|
|
|
|
tags: [],
|
|
|
|
|
screenshots: [],
|
|
|
|
|
icon: [],
|
|
|
|
@ -34,6 +42,62 @@ class GeneralInfo extends Component {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set text field values to state.
|
|
|
|
|
* */
|
|
|
|
|
onTextFieldChange(event) {
|
|
|
|
|
let field = event.target.name;
|
|
|
|
|
console.log(event.target.value);
|
|
|
|
|
switch (field) {
|
|
|
|
|
case "appName": {
|
|
|
|
|
this.setState({name: event.target.value});
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "appDescription": {
|
|
|
|
|
this.setState({description: event.target.value});
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "appShortDescription": {
|
|
|
|
|
this.setState({shortDescription: event.target.value});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a tag on Enter key press and set it to the state.
|
|
|
|
|
* Clears the tags text field.
|
|
|
|
|
* Chip gets two parameters: Key and value.
|
|
|
|
|
* */
|
|
|
|
|
addTags(event) {
|
|
|
|
|
let tags = this.state.tags;
|
|
|
|
|
if (event.charCode === 13) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
tags.push({key: Math.floor(Math.random() * 1000), value: event.target.value});
|
|
|
|
|
this.setState({tags, defValue: ""}, console.log(tags));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the value for tag.
|
|
|
|
|
* */
|
|
|
|
|
handleTagChange(event) {
|
|
|
|
|
let defaultValue = this.state.defValue;
|
|
|
|
|
defaultValue = event.target.value;
|
|
|
|
|
this.setState({defValue: defaultValue})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles Chip delete function.
|
|
|
|
|
* Removes the tag from state.tags
|
|
|
|
|
* */
|
|
|
|
|
handleRequestDelete(key) {
|
|
|
|
|
let chipData = this.state.tags;
|
|
|
|
|
const chipToDelete = chipData.map((chip) => chip.key).indexOf(key);
|
|
|
|
|
chipData.splice(chipToDelete, 1);
|
|
|
|
|
this.setState({tags: chipData});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Remove Console logs.
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
|
|
|
@ -44,13 +108,31 @@ class GeneralInfo extends Component {
|
|
|
|
|
<Label for="app-title">
|
|
|
|
|
<FormattedMessage id="Title" defaultMessage="Title"/>*
|
|
|
|
|
</Label>
|
|
|
|
|
<Input required type="text" name="appName" id="app-title"/>
|
|
|
|
|
<Input required type="text" name="appName" id="app-title"
|
|
|
|
|
onChange={this.onTextFieldChange}/>
|
|
|
|
|
</FormGroup>
|
|
|
|
|
<FormGroup>
|
|
|
|
|
<Label for="app-short-description">
|
|
|
|
|
<FormattedMessage id="shortDescription" defaultMessage="shortDescription"/>*
|
|
|
|
|
</Label>
|
|
|
|
|
<Input
|
|
|
|
|
required
|
|
|
|
|
type="textarea"
|
|
|
|
|
name="appShortDescription"
|
|
|
|
|
id="app-short-description"
|
|
|
|
|
onChange={this.onTextFieldChange}
|
|
|
|
|
/>
|
|
|
|
|
</FormGroup>
|
|
|
|
|
<FormGroup>
|
|
|
|
|
<Label for="app-title">
|
|
|
|
|
<FormattedMessage id="Description" defaultMessage="Description"/>*
|
|
|
|
|
</Label>
|
|
|
|
|
<Input required type="textarea" multiline name="appName" id="app-title"/>
|
|
|
|
|
<Input
|
|
|
|
|
required
|
|
|
|
|
type="textarea"
|
|
|
|
|
name="appDescription"
|
|
|
|
|
id="app-description"
|
|
|
|
|
onChange={this.onTextFieldChange}/>
|
|
|
|
|
</FormGroup>
|
|
|
|
|
<FormGroup>
|
|
|
|
|
<Label for="app-category">
|
|
|
|
@ -74,16 +156,23 @@ class GeneralInfo extends Component {
|
|
|
|
|
<Label for="app-tags">
|
|
|
|
|
<FormattedMessage id="Tags" defaultMessage="Tags"/>*
|
|
|
|
|
</Label>
|
|
|
|
|
<Input required type="text" value={this.state.defValue} name="app-tags" id="app-tags"/>
|
|
|
|
|
<Input
|
|
|
|
|
required
|
|
|
|
|
type="text"
|
|
|
|
|
value={this.state.defValue}
|
|
|
|
|
name="app-tags"
|
|
|
|
|
id="app-tags"
|
|
|
|
|
onChange={this.handleTagChange.bind(this)}
|
|
|
|
|
onKeyPress={this.addTags.bind(this)}
|
|
|
|
|
/>
|
|
|
|
|
<div id="batch-content">
|
|
|
|
|
{this.state.tags.map(tag => {
|
|
|
|
|
return (
|
|
|
|
|
<Badge
|
|
|
|
|
style={{margin: '0 2px 0 2px'}}
|
|
|
|
|
value={tag.value}
|
|
|
|
|
>
|
|
|
|
|
{tag.value}
|
|
|
|
|
</Badge>
|
|
|
|
|
<Chip
|
|
|
|
|
key={tag.key}
|
|
|
|
|
content={tag}
|
|
|
|
|
onDelete={this.handleRequestDelete}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
)}
|
|
|
|
@ -185,7 +274,8 @@ class GeneralInfo extends Component {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="save-info">
|
|
|
|
|
<Button>Save</Button>
|
|
|
|
|
<Button className="custom-flat danger-flat">Cancel</Button>
|
|
|
|
|
<Button className="custom-raised primary">Save</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Row>
|
|
|
|
|