1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00

Merge remote-tracking branch 'origin/AD-419-decouple-piece-registration-from-' into AD-551-work-on-burn-down-list

This commit is contained in:
Tim Daubenschütz 2015-07-10 19:01:21 +02:00
commit cbb965c264
13 changed files with 75 additions and 52 deletions

View File

@ -37,7 +37,7 @@ let AccordionListItem = React.createClass({
},
componentDidMount() {
if(this.props.content.num_editions !== 0) {
if(this.props.content.num_editions > 0) {
PieceListActions.fetchFirstEditionForPiece(this.props.content.id);
}
},
@ -72,6 +72,7 @@ let AccordionListItem = React.createClass({
handleEditionCreationSuccess(response) {
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
PieceListActions.updatePropertyForPiece({pieceId: this.props.content.id, key: 'num_editions', value: 0});
this.setState({
creatingEditions: true
@ -116,7 +117,7 @@ let AccordionListItem = React.createClass({
render() {
let linkData;
if(this.props.content.num_editions === 0) {
if(this.props.content.num_editions < 1) {
linkData = {
to: 'piece',
params: {
@ -167,7 +168,7 @@ let AccordionListItem = React.createClass({
</div>
</div>
</div>
{this.props.content.num_editions === 0 && this.state.showCreateEditionsDialog ? <AccordionListItemCreateEditions pieceId={this.props.content.id} handleSuccess={this.handleEditionCreationSuccess}/> : null}
{this.props.content.num_editions < 1 && this.state.showCreateEditionsDialog ? <AccordionListItemCreateEditions pieceId={this.props.content.id} handleSuccess={this.handleEditionCreationSuccess}/> : null}
{/* this.props.children is AccordionListItemTableEditions */}
{this.props.children}

View File

@ -16,12 +16,9 @@ let AccordionListItemCreateEditions = React.createClass({
},
getFormData(){
let data = {};
for (let ref in this.refs.form.refs){
data[this.refs.form.refs[ref].props.name] = this.refs.form.refs[ref].state.value;
}
data.piece_id = parseInt(this.props.pieceId, 10);
return data;
return {
piece_id: parseInt(this.props.pieceId, 10)
};
},
render() {

View File

@ -75,23 +75,23 @@ let AccordionListItemEditionWidget = React.createClass({
let piece = this.props.piece;
let numEditions = piece.num_editions;
if(numEditions === 0) {
if(this.props.creatingEditions) {
return (
if(numEditions === -1) {
return (
<span
onClick={this.props.toggleCreateEditionsDialog}
className="ascribe-accordion-list-item-edition-widget">
+ Editions
</span>
);
}
else if(numEditions === 0) {
return (
<span>
Creating Editions <span className="glyph-ascribe-spool-chunked ascribe-color spin"/>
</span>
);
} else {
return (
<span
onClick={this.props.toggleCreateEditionsDialog}
className="ascribe-accordion-list-item-edition-widget">
+ Editions
</span>
);
}
} else if(numEditions === 1) {
}
else if(numEditions === 1) {
let editionMapping = piece && piece.firstEdition ? piece.firstEdition.edition_number + '/' + piece.num_editions : '';
return (

View File

@ -84,7 +84,8 @@ let Edition = React.createClass({
<CollapsibleParagraph
title="Notes"
show={(this.state.currentUser.username && true || false) ||
(this.props.edition.acl.indexOf('edit') > -1 || this.props.edition.public_note)}>
(this.props.edition.acl.indexOf('edit') > -1 || this.props.edition.public_note)}
defaultExpanded={true}>
<EditionPersonalNote
currentUser={this.state.currentUser}
handleSuccess={this.props.loadEdition}

View File

@ -56,7 +56,8 @@ let Piece = React.createClass({
title="Further Details"
show={this.props.piece.acl.indexOf('edit') > -1
|| Object.keys(this.props.piece.extra_data).length > 0
|| this.props.piece.other_data !== null}>
|| this.props.piece.other_data !== null}
defaultExpanded={true}>
<FurtherDetails
editable={this.props.piece.acl.indexOf('edit') > -1}
pieceId={this.props.piece.id}

View File

@ -7,6 +7,7 @@ import Button from 'react-bootstrap/lib/Button';
import requests from '../../utils/requests';
import { getLangText } from '../../utils/lang_utils';
import { mergeOptionsWithDuplicates } from '../../utils/general_utils';
import AlertDismissable from './alert';
@ -54,13 +55,13 @@ let Form = React.createClass({
},
getFormData(){
if ('getFormData' in this.props){
return this.props.getFormData();
}
let data = {};
for (let ref in this.refs){
data[this.refs[ref].props.name] = this.refs[ref].state.value;
}
if ('getFormData' in this.props){
data = mergeOptionsWithDuplicates(data, this.props.getFormData());
}
return data;
},

View File

@ -19,7 +19,8 @@ let InputCheckbox = React.createClass({
handleFocus() {
this.refs.checkbox.getDOMNode().checked = !this.refs.checkbox.getDOMNode().checked;
this.setState({
show: this.refs.checkbox.getDOMNode().checked
show: this.refs.checkbox.getDOMNode().checked,
value: this.refs.checkbox.getDOMNode().checked
});
},

View File

@ -66,12 +66,16 @@ let Header = React.createClass({
getPoweredBy(){
if (this.state.whitelabel.logo) {
return (
<div className="row no-margin ascribe-subheader">
<a className="pull-right" href="https://www.ascribe.io/" target="_blank">
<span id="powered">{getLangText('powered by')} </span>
<span>ascribe </span>
<span className="glyph-ascribe-spool-chunked ascribe-color"></span>
</a>
<div className="row ascribe-subheader">
<div className="col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2">
<div className="row">
<a className="pull-right" href="https://www.ascribe.io/" target="_blank">
<span id="powered">{getLangText('powered by')} </span>
<span>ascribe </span>
<span className="glyph-ascribe-spool-chunked ascribe-color"></span>
</a>
</div>
</div>
</div>);
}
return null;

View File

@ -105,13 +105,10 @@ let PasswordResetForm = React.createClass({
mixins: [Router.Navigation],
getFormData(){
let data = {};
for (let ref in this.refs.form.refs){
data[this.refs.form.refs[ref].props.name] = this.refs.form.refs[ref].state.value;
}
data.email = this.props.email;
data.token = this.props.token;
return data;
return {
email: this.props.email,
token: this.props.token
};
},
handleSuccess() {
this.transitionTo('pieces');

View File

@ -98,12 +98,9 @@ let RegisterPiece = React.createClass( {
},
getFormData(){
let data = {};
for (let ref in this.refs.form.refs){
data[this.refs.form.refs[ref].props.name] = this.refs.form.refs[ref].state.value;
}
data.digital_work_key = this.state.digitalWorkKey;
return data;
return {
digital_work_key: this.state.digitalWorkKey
};
},
submitKey(key){

View File

@ -91,6 +91,9 @@ let SignupForm = React.createClass({
', ' + getLangText('please confirm') + '.');
},
getFormData(){
return {terms: this.refs.form.refs.terms.refs.input.state.value};
},
render() {
let tooltipPassword = getLangText('Your password must be at least 10 characters') + '.\n ' +
getLangText('This password is securing your digital property like a bank account') + '.\n ' +
@ -101,6 +104,7 @@ let SignupForm = React.createClass({
ref='form'
url={apiUrls.users_signup}
handleSuccess={this.handleSuccess}
getFormData={this.getFormData}
buttons={
<button type="submit" className="btn ascribe-btn ascribe-btn-login">
{getLangText('Sign up to ascribe')}
@ -153,7 +157,7 @@ let SignupForm = React.createClass({
name="terms"
className="ascribe-settings-property-collapsible-toggle"
style={{paddingBottom: 0}}>
<InputCheckbox />
<InputCheckbox/>
</Property>
</Form>
);

View File

@ -112,6 +112,24 @@ export function mergeOptions(...l) {
return newObj;
}
/**
* Takes a list of object and merges their keys to one object.
* Uses mergeOptions for two objects.
* @param {[type]} l [description]
* @return {[type]} [description]
*/
export function mergeOptionsWithDuplicates(...l) {
// If the objects submitted in the list have duplicates,in their key names,
// abort the merge and tell the function's user to check his objects.
let newObj = {};
for(let i = 1; i < l.length; i++) {
newObj = _mergeOptions(newObj, _mergeOptions(l[i - 1], l[i]));
}
return newObj;
}
/**
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
* @param obj1

View File

@ -62,6 +62,11 @@ hr {
font-size: 0.8em;
}
.img-brand {
padding: 0;
height: 45px;
margin: 5px 0 5px 0;
}
.truncate {
white-space: nowrap;
width: 4em;
@ -101,10 +106,6 @@ hr {
color: $ascribe-color;
}
.img-brand{
height: 25px;
}
.ascribe-subheader{
padding-bottom: 10px;
margin-top: -10px;