1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-14 17:15:08 +01:00

add personal note to piece detail page

This commit is contained in:
Tim Daubenschütz 2015-06-05 16:20:28 +02:00
parent 7f82d49278
commit 443829320f
7 changed files with 98 additions and 30 deletions

View File

@ -6,12 +6,15 @@ import UserStore from '../../stores/user_store';
import AclButton from '../ascribe_buttons/acl_button'; import AclButton from '../ascribe_buttons/acl_button';
let AclButtonList = React.createClass({ let AclButtonList = React.createClass({
getInitialState() { propTypes: {
return UserStore.getState(); className: React.PropTypes.string,
editions: React.PropTypes.array,
availableAcls: React.PropTypes.array,
handleSuccess: React.PropTypes.func
}, },
onChange(state) { getInitialState() {
this.setState(state); return UserStore.getState();
}, },
componentDidMount() { componentDidMount() {
@ -23,9 +26,13 @@ let AclButtonList = React.createClass({
UserStore.unlisten(this.onChange); UserStore.unlisten(this.onChange);
}, },
onChange(state) {
this.setState(state);
},
render() { render() {
return ( return (
<div className="text-center"> <div className={this.props.className}>
<AclButton <AclButton
availableAcls={this.props.availableAcls} availableAcls={this.props.availableAcls}
action="transfer" action="transfer"

View File

@ -8,6 +8,7 @@ import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col'; import Col from 'react-bootstrap/lib/Col';
import Button from 'react-bootstrap/lib/Button'; import Button from 'react-bootstrap/lib/Button';
import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import TextareaAutosize from 'react-textarea-autosize';
import EditionActions from '../actions/edition_actions'; import EditionActions from '../actions/edition_actions';
import AclButtonList from './ascribe_buttons/acl_button_list'; import AclButtonList from './ascribe_buttons/acl_button_list';
@ -21,7 +22,8 @@ let Edition = React.createClass({
propTypes: { propTypes: {
edition: React.PropTypes.object, edition: React.PropTypes.object,
currentUser: React.PropTypes.object, currentUser: React.PropTypes.object,
deleteEdition: React.PropTypes.func deleteEdition: React.PropTypes.func,
savePersonalNote: React.PropTypes.func
}, },
render() { render() {
@ -30,7 +32,7 @@ let Edition = React.createClass({
let extraData = null; let extraData = null;
if (this.props.edition.digital_work.encoding_urls) { if (this.props.edition.digital_work.encoding_urls) {
extraData = this.props.edition.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label } }); extraData = this.props.edition.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label }; });
} }
let bitcoinIdValue = ( let bitcoinIdValue = (
@ -43,7 +45,7 @@ let Edition = React.createClass({
return ( return (
<Row> <Row>
<Col md={7}> <Col md={6}>
<MediaPlayer mimetype={mimetype} <MediaPlayer mimetype={mimetype}
preview={thumbnail} preview={thumbnail}
url={this.props.edition.digital_work.url} url={this.props.edition.digital_work.url}
@ -54,11 +56,17 @@ let Edition = React.createClass({
</Button> </Button>
</p> </p>
</Col> </Col>
<Col md={5}> <Col md={6} className="ascribe-edition-details">
<EditionHeader edition={this.props.edition}/> <EditionHeader edition={this.props.edition}/>
<EditionSummary <EditionSummary
edition={this.props.edition} edition={this.props.edition}
currentUser={ this.props.currentUser }/> currentUser={ this.props.currentUser }/>
<CollapsibleEditionDetails
title="Personal Note"
iconName="pencil">
<EditionPersonalNote
savePersonalNote={this.props.savePersonalNote}/>
</CollapsibleEditionDetails>
<CollapsibleEditionDetails <CollapsibleEditionDetails
title="Provenance/Ownership History" title="Provenance/Ownership History"
@ -138,10 +146,15 @@ let EditionSummary = React.createClass({
<EditionDetailProperty label="ID" value={ this.props.edition.bitcoin_id } /> <EditionDetailProperty label="ID" value={ this.props.edition.bitcoin_id } />
<EditionDetailProperty label="OWNER" value={ this.props.edition.owner } /> <EditionDetailProperty label="OWNER" value={ this.props.edition.owner } />
<br/> <br/>
<Row>
<Col md={12}>
<AclButtonList <AclButtonList
className="pull-left"
availableAcls={this.props.edition.acl} availableAcls={this.props.edition.acl}
editions={[this.props.edition]} editions={[this.props.edition]}
handleSuccess={this.handleSuccess} /> handleSuccess={this.handleSuccess} />
</Col>
</Row>
<hr/> <hr/>
</div> </div>
); );
@ -156,7 +169,8 @@ let CollapsibleEditionDetails = React.createClass({
React.PropTypes.object, React.PropTypes.object,
React.PropTypes.array React.PropTypes.array
]), ]),
show: React.PropTypes.bool show: React.PropTypes.bool,
iconName: React.PropTypes.string
}, },
getDefaultProps() { getDefaultProps() {
@ -169,10 +183,11 @@ let CollapsibleEditionDetails = React.createClass({
if(this.props.show) { if(this.props.show) {
return ( return (
<div className="ascribe-detail-header"> <div className="ascribe-detail-header">
<CollapsibleParagraph title={this.props.title}> <CollapsibleParagraph
title={this.props.title}
iconName={this.props.iconName}>
{this.props.children} {this.props.children}
</CollapsibleParagraph> </CollapsibleParagraph>
<hr/>
</div> </div>
); );
} else { } else {
@ -188,7 +203,8 @@ const CollapsibleParagraph = React.createClass({
children: React.PropTypes.oneOfType([ children: React.PropTypes.oneOfType([
React.PropTypes.object, React.PropTypes.object,
React.PropTypes.array React.PropTypes.array
]) ]),
iconName: React.PropTypes.string
}, },
mixins: [CollapsibleMixin], mixins: [CollapsibleMixin],
@ -206,14 +222,16 @@ const CollapsibleParagraph = React.createClass({
this.setState({expanded: !this.state.expanded}); this.setState({expanded: !this.state.expanded});
}, },
render(){ render() {
let styles = this.getCollapsibleClassSet(); let styles = this.getCollapsibleClassSet();
let text = this.isExpanded() ? 'Hide' : 'Show'; let text = this.isExpanded() ? '-' : '+';
let icon = this.props.iconName ? (<Glyphicon style={{fontSize: '.75em'}} glyph={this.props.iconName} />) : null;
return ( return (
<div className="ascribe-edition-collapsible-wrapper"> <div className="ascribe-edition-collapsible-wrapper">
<div onClick={this.onHandleToggle}> <div onClick={this.onHandleToggle}>
<span>{this.props.title} </span> <span>{text} {icon} {this.props.title} </span>
<a>{text}</a>
</div> </div>
<div ref='panel' className={classNames(styles) + ' ascribe-edition-collapible-content'}> <div ref='panel' className={classNames(styles) + ' ascribe-edition-collapible-content'}>
{this.props.children} {this.props.children}
@ -284,5 +302,33 @@ let EditionDetailHistoryIterator = React.createClass({
} }
}); });
let EditionPersonalNote = React.createClass({
propTypes: {
savePersonalNote: React.PropTypes.func
},
prepareSavePersonalNote() {
let personalNote = React.findDOMNode(this.refs.personalNote).value;
this.props.savePersonalNote(personalNote);
},
render() {
return (
<Row>
<Col md={12} className="ascribe-edition-personal-note">
<TextareaAutosize
ref="personalNote"
className="form-control"
rows={3}
placeholder='Write something...' />
<Button
onClick={this.prepareSavePersonalNote}
className="pull-right">Save</Button>
</Col>
</Row>
);
}
});
export default Edition; export default Edition;

View File

@ -37,7 +37,12 @@ let EditionContainer = React.createClass({
}, },
deleteEdition() { deleteEdition() {
// Delete Edition from server
},
savePersonalNote(note) {
console.log(note);
// Save personalNote to server
}, },
render() { render() {
@ -46,7 +51,8 @@ let EditionContainer = React.createClass({
<Edition <Edition
edition={this.state.edition} edition={this.state.edition}
currentUser={this.state.currentUser} currentUser={this.state.currentUser}
deleteEdition={this.deleteEdition}/> deleteEdition={this.deleteEdition}
savePersonalNote={this.savePersonalNote}/>
); );
} else { } else {
return ( return (

View File

@ -29,6 +29,7 @@
"gulp-util": "^3.0.4", "gulp-util": "^3.0.4",
"jest-cli": "^0.4.0", "jest-cli": "^0.4.0",
"lodash": "^3.9.3", "lodash": "^3.9.3",
"react-textarea-autosize": "^2.2.3",
"reactify": "^1.1.0", "reactify": "^1.1.0",
"vinyl-buffer": "^1.0.0", "vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0", "vinyl-source-stream": "^1.1.0",
@ -45,8 +46,7 @@
"react-datepicker": "~0.8.0", "react-datepicker": "~0.8.0",
"react-router": "^0.13.3", "react-router": "^0.13.3",
"shmui": "^0.1.0", "shmui": "^0.1.0",
"uglifyjs": "^2.4.10", "uglifyjs": "^2.4.10"
"react-datepicker": "~0.8.0"
}, },
"jest": { "jest": {
"scriptPreprocessor": "node_modules/babel-jest", "scriptPreprocessor": "node_modules/babel-jest",

View File

@ -1,3 +1,11 @@
.ascribe-edition-details hr {
border-top: 1px solid #616161;
}
.ascribe-edition-personal-note > textarea {
margin-bottom: 1em;
}
.ascribe-edition-collapsible-wrapper { .ascribe-edition-collapsible-wrapper {
vertical-align: bottom; vertical-align: bottom;
width:100%; width:100%;
@ -9,7 +17,7 @@
} }
.ascribe-edition-collapsible-wrapper > div > span { .ascribe-edition-collapsible-wrapper > div > span {
font-size:1.4em; font-size:1.3em;
margin-right: .5em; margin-right: .5em;
} }

View File

@ -21,6 +21,7 @@
border-left:0; border-left:0;
border-right:0; border-right:0;
margin-bottom: 1.5em; margin-bottom: 1.5em;
border-top:0;
} }
.clear-paddings { .clear-paddings {

View File

@ -366,7 +366,7 @@ $navbar-collapse-max-height: 340px !default;
$navbar-default-color: #777 !default; $navbar-default-color: #777 !default;
$navbar-default-bg: white !default; $navbar-default-bg: white !default;
$navbar-default-border: darken($navbar-default-bg, 6.5%) !default; $navbar-default-border: #616161;
// Navbar links // Navbar links
$navbar-default-link-color: #777 !default; $navbar-default-link-color: #777 !default;