2018-01-06 03:26:57 +01:00
|
|
|
import React from 'react';
|
2018-01-19 21:11:38 +01:00
|
|
|
import ExpandingTextArea from 'components/ExpandingTextArea';
|
2018-01-06 03:26:57 +01:00
|
|
|
|
2018-01-17 19:49:57 +01:00
|
|
|
class PublishMetadataInputs extends React.Component {
|
2018-01-06 03:26:57 +01:00
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
|
|
|
this.toggleShowInputs = this.toggleShowInputs.bind(this);
|
2018-01-20 01:03:49 +01:00
|
|
|
this.handleInput = this.handleInput.bind(this);
|
|
|
|
this.handleSelect = this.handleSelect.bind(this);
|
2018-01-06 03:26:57 +01:00
|
|
|
}
|
|
|
|
toggleShowInputs () {
|
2018-01-20 01:03:49 +01:00
|
|
|
this.props.onToggleMetadataInputs(!this.props.showMetadataInputs);
|
2018-01-06 03:26:57 +01:00
|
|
|
}
|
2018-01-20 01:03:49 +01:00
|
|
|
handleInput (event) {
|
|
|
|
const target = event.target;
|
|
|
|
const value = target.type === 'checkbox' ? target.checked : target.value;
|
|
|
|
const name = target.name;
|
2018-01-10 22:10:08 +01:00
|
|
|
this.props.onMetadataChange(name, value);
|
2018-01-08 18:39:59 +01:00
|
|
|
}
|
2018-01-20 01:03:49 +01:00
|
|
|
handleSelect (event) {
|
2018-01-10 22:10:08 +01:00
|
|
|
const name = event.target.name;
|
2018-01-09 02:06:31 +01:00
|
|
|
const selectedOption = event.target.selectedOptions[0].value;
|
2018-01-10 22:10:08 +01:00
|
|
|
this.props.onMetadataChange(name, selectedOption);
|
2018-01-09 02:06:31 +01:00
|
|
|
}
|
2018-01-06 03:26:57 +01:00
|
|
|
render () {
|
|
|
|
return (
|
2018-01-15 18:59:23 +01:00
|
|
|
<div id="publish-details" className="row row--padded row--no-top row--wide">
|
2018-01-20 01:03:49 +01:00
|
|
|
<a className="label link--primary" id="publish-details-toggle" href="#" onClick={this.toggleShowInputs}>{this.props.showMetadataInputs ? '[less]' : '[more]'}</a>
|
|
|
|
{this.props.showMetadataInputs && (
|
2018-01-15 18:59:23 +01:00
|
|
|
<div>
|
|
|
|
<div className="row row--no-top">
|
|
|
|
<div className="column column--3 column--med-10 align-content-top">
|
|
|
|
<label htmlFor="publish-license" className="label">Description:</label>
|
|
|
|
</div><div className="column column--7 column--sml-10">
|
2018-01-19 21:11:38 +01:00
|
|
|
<ExpandingTextArea
|
2018-01-17 00:55:29 +01:00
|
|
|
id="publish-description"
|
|
|
|
className="textarea textarea--primary textarea--full-width"
|
2018-01-19 21:11:38 +01:00
|
|
|
rows={1}
|
|
|
|
maxLength={2000}
|
2018-01-20 01:03:49 +01:00
|
|
|
style={{ maxHeight: 200 }}
|
2018-01-17 00:55:29 +01:00
|
|
|
name="description"
|
|
|
|
placeholder="Optional description"
|
|
|
|
value={this.props.description}
|
2018-01-20 01:03:49 +01:00
|
|
|
onChange={this.handleInput} />
|
2018-01-08 18:39:59 +01:00
|
|
|
</div>
|
2018-01-15 18:59:23 +01:00
|
|
|
</div>
|
2018-01-08 18:39:59 +01:00
|
|
|
|
2018-01-15 18:59:23 +01:00
|
|
|
<div className="row row--no-top">
|
|
|
|
<div className="column column--3 column--med-10">
|
|
|
|
<label htmlFor="publish-license" className="label">License:</label>
|
|
|
|
</div><div className="column column--7 column--sml-10">
|
2018-01-20 01:03:49 +01:00
|
|
|
<select type="text" name="license" id="publish-license" className="select select--primary" onChange={this.handleSelect}>
|
2018-01-15 18:59:23 +01:00
|
|
|
<option value=" ">Unspecified</option>
|
|
|
|
<option value="Public Domain">Public Domain</option>
|
|
|
|
<option value="Creative Commons">Creative Commons</option>
|
|
|
|
</select>
|
2018-01-08 18:39:59 +01:00
|
|
|
</div>
|
2018-01-15 18:59:23 +01:00
|
|
|
</div>
|
2018-01-08 18:39:59 +01:00
|
|
|
|
2018-01-15 18:59:23 +01:00
|
|
|
<div className="row row--no-top">
|
|
|
|
<div className="column column--3">
|
|
|
|
<label htmlFor="publish-nsfw" className="label">Mature:</label>
|
|
|
|
</div><div className="column column--7">
|
2018-01-20 01:03:49 +01:00
|
|
|
<input className="input-checkbox" type="checkbox" id="publish-nsfw" name="nsfw" value={this.props.nsfw} onChange={this.handleInput} />
|
2018-01-08 18:39:59 +01:00
|
|
|
</div>
|
2018-01-06 03:26:57 +01:00
|
|
|
</div>
|
2018-01-15 18:59:23 +01:00
|
|
|
</div>
|
|
|
|
)}
|
2018-01-06 03:26:57 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-17 19:49:57 +01:00
|
|
|
export default PublishMetadataInputs;
|