1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

add es6lint to build process and fix most (not really) errors and warnings

This commit is contained in:
Tim Daubenschütz 2015-06-05 11:06:36 +02:00
parent ae4428795d
commit f987bce7cc
86 changed files with 525 additions and 318 deletions

View File

@ -9,17 +9,21 @@
"eol-last": [0], "eol-last": [0],
"no-mixed-requires": [0], "no-mixed-requires": [0],
"no-underscore-dangle": [0], "no-underscore-dangle": [0],
"react/display-name": 1, "global-strict": [2, "always"],
"no-trailing-spaces": [2, { skipBlankLines: true }],
"no-console": 0,
"camelcase": [2, {"properties": "never"}],
"react/display-name": 0,
"react/jsx-boolean-value": 1, "react/jsx-boolean-value": 1,
"react/jsx-no-undef": 1, "react/jsx-no-undef": 1,
"react/jsx-quotes": 1, "react/jsx-quotes": 1,
"react/jsx-sort-prop-types": 1, "react/jsx-sort-prop-types": 0,
"react/jsx-sort-props": 1, "react/jsx-sort-props": 0,
"react/jsx-uses-react": 1, "react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1, "react/jsx-uses-vars": 1,
"react/no-did-mount-set-state": 1, "react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1, "react/no-did-update-set-state": 1,
"react/no-multi-comp": 1, "react/no-multi-comp": 0,
"react/no-unknown-property": 1, "react/no-unknown-property": 1,
"react/prop-types": 1, "react/prop-types": 1,
"react/react-in-jsx-scope": 1, "react/react-in-jsx-scope": 1,
@ -31,7 +35,20 @@
"react" "react"
], ],
"ecmaFeatures": { "ecmaFeatures": {
"jsx": true, "jsx": 1,
"modules": true "modules": 1,
"arrowFunctions",
"classes": 1,
"blockBindings": 1,
"defaultParams": 1,
"destructuring": 1,
"objectLiteralComputedProperties": 1,
"objectLiteralDuplicateProperties": 0,
"objectLiteralShorthandMethods": 1,
"objectLiteralShorthandProperties": 1,
"restParams": 1,
"spread": 1,
"superInFunctions": 1,
"templateStrings": 1
} }
} }

View File

@ -1,3 +1,5 @@
'use strict';
var gulp = require('gulp'); var gulp = require('gulp');
var gulpif = require('gulp-if'); var gulpif = require('gulp-if');
var sourcemaps = require('gulp-sourcemaps'); var sourcemaps = require('gulp-sourcemaps');
@ -22,7 +24,7 @@ gulp.task('build', function() {
bundle(false); bundle(false);
}); });
gulp.task('serve', ['browser-sync', 'sass', 'sass:watch', 'copy', 'lint'], function() { gulp.task('serve', ['browser-sync', 'lint:watch', 'sass', 'sass:watch', 'copy'], function() {
bundle(true); bundle(true);
}); });
@ -78,6 +80,10 @@ gulp.task('lint', function () {
.pipe(eslint.failOnError()); .pipe(eslint.failOnError());
}); });
gulp.task('lint:watch', function () {
gulp.watch('js/**/*.js', ['lint']);
});
function bundle(watch) { function bundle(watch) {
var bro; var bro;

View File

@ -1,3 +1,5 @@
'use strict';
import alt from '../alt'; import alt from '../alt';
import EditionFetcher from '../fetchers/edition_fetcher'; import EditionFetcher from '../fetchers/edition_fetcher';

View File

@ -1,3 +1,5 @@
'use strict';
import alt from '../alt'; import alt from '../alt';
import EditionListFetcher from '../fetchers/edition_list_fetcher.js'; import EditionListFetcher from '../fetchers/edition_list_fetcher.js';
@ -12,7 +14,7 @@ class EditionListActions {
} }
fetchEditionList(pieceId, orderBy, orderAsc) { fetchEditionList(pieceId, orderBy, orderAsc) {
if(!orderBy && typeof orderAsc == "undefined") { if(!orderBy && typeof orderAsc == 'undefined') {
orderBy = 'edition_number'; orderBy = 'edition_number';
orderAsc = true; orderAsc = true;
} }

View File

@ -1,3 +1,5 @@
'use strict';
import alt from '../alt'; import alt from '../alt';
import PieceFetcher from '../fetchers/piece_fetcher'; import PieceFetcher from '../fetchers/piece_fetcher';

View File

@ -1,3 +1,5 @@
'use strict';
import alt from '../alt'; import alt from '../alt';
import PieceListFetcher from '../fetchers/piece_list_fetcher'; import PieceListFetcher from '../fetchers/piece_list_fetcher';
@ -28,6 +30,6 @@ class PieceListActions {
}); });
} }
}; }
export default alt.createActions(PieceListActions); export default alt.createActions(PieceListActions);

View File

@ -1,3 +1,5 @@
'use strict';
import alt from '../alt'; import alt from '../alt';
import UserFetcher from '../fetchers/user_fetcher'; import UserFetcher from '../fetchers/user_fetcher';
@ -12,12 +14,12 @@ class UserActions {
fetchCurrentUser() { fetchCurrentUser() {
UserFetcher.fetchOne() UserFetcher.fetchOne()
.then((res) => { .then((res) => {
this.actions.updateCurrentUser(res['users'][0]); this.actions.updateCurrentUser(res.users[0]);
}) })
.catch((err) => { .catch((err) => {
console.log(err); console.log(err);
}); });
} }
}; }
export default alt.createActions(UserActions); export default alt.createActions(UserActions);

View File

@ -1,3 +1,5 @@
'use strict';
import Alt from 'alt'; import Alt from 'alt';
export default new Alt(); export default new Alt();

View File

@ -6,16 +6,13 @@ import promise from 'es6-promise';
promise.polyfill(); promise.polyfill();
import AscribeApp from './components/ascribe_app';
import AppConstants from './constants/application_constants'; import AppConstants from './constants/application_constants';
import ApiUrls from './constants/api_urls'; import ApiUrls from './constants/api_urls';
import routes from './routes'; import routes from './routes';
import alt from './alt';
import fetch from './utils/fetch'; import fetch from './utils/fetch';
import AlertDismissable from './components/ascribe_forms/alert';
/* /*
Taken from Taken from
http://stackoverflow.com/questions/30613447/how-to-debug-reactjss-setstate?noredirect=1#comment49301874_30613447 http://stackoverflow.com/questions/30613447/how-to-debug-reactjss-setstate?noredirect=1#comment49301874_30613447
<remove this in production> <remove this in production>

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import ConsignForm from './ascribe_forms/form_consign'; import ConsignForm from './ascribe_forms/form_consign';
@ -17,31 +19,33 @@ let AclButton = React.createClass({
}, },
actionProperties(){ actionProperties(){
if (this.props.action == 'consign'){ if (this.props.action === 'consign'){
return { return {
title: "Consign artwork", title: 'Consign artwork',
tooltip: "Have someone else sell the artwork", tooltip: 'Have someone else sell the artwork',
form: <ConsignForm /> form: <ConsignForm />
} };
} }
else if (this.props.action == 'transfer') { else if (this.props.action === 'transfer') {
return { return {
title: "Transfer artwork", title: 'Transfer artwork',
tooltip: "Transfer the ownership of the artwork", tooltip: 'Transfer the ownership of the artwork',
form: <TransferForm /> form: <TransferForm />
} };
} }
else if (this.props.action == 'loan'){ else if (this.props.action === 'loan'){
return { return {
title: "Loan artwork", title: 'Loan artwork',
tooltip: "Loan your artwork for a limited period of time", tooltip: 'Loan your artwork for a limited period of time',
form: <LoanForm />} form: <LoanForm />
};
} }
else if (this.props.action == 'share'){ else if (this.props.action === 'share'){
return { return {
title: "Share artwork", title: 'Share artwork',
tooltip: "Share the artwork", tooltip: 'Share the artwork',
form: <ShareForm />} form: <ShareForm />
};
} }
}, },
render() { render() {

View File

@ -1,5 +1,6 @@
'use strict';
import React from 'react'; import React from 'react';
import ReactAddons from 'react/addons';
let AccordionList = React.createClass({ let AccordionList = React.createClass({

View File

@ -1,8 +1,8 @@
'use strict';
import React from 'react'; import React from 'react';
import Router from 'react-router'; import Router from 'react-router';
import AccordionListItemTable from './accordion_list_item_table';
import { getLangText } from '../../utils/lang_utils'; import { getLangText } from '../../utils/lang_utils';
let Link = Router.Link; let Link = Router.Link;
@ -10,7 +10,8 @@ let Link = Router.Link;
let AccordionListItem = React.createClass({ let AccordionListItem = React.createClass({
propTypes: { propTypes: {
className: React.PropTypes.string, className: React.PropTypes.string,
content: React.PropTypes.object content: React.PropTypes.object,
children: React.PropTypes.object
}, },
render() { render() {

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import Table from '../ascribe_table/table'; import Table from '../ascribe_table/table';
@ -5,8 +7,6 @@ import TableItem from '../ascribe_table/table_item';
import { ColumnModel } from '../ascribe_table/models/table_models'; import { ColumnModel } from '../ascribe_table/models/table_models';
import { getLangText } from '../../utils/lang_utils';
let AccordionListItemTable = React.createClass({ let AccordionListItemTable = React.createClass({
propTypes: { propTypes: {
className: React.PropTypes.string, className: React.PropTypes.string,
@ -26,7 +26,7 @@ let AccordionListItemTable = React.createClass({
<div className={this.props.className}> <div className={this.props.className}>
<Table <Table
className="ascribe-table" className="ascribe-table"
columnList={this.props.columnList} columnList={this.props.columnList}
itemList={this.props.itemList} itemList={this.props.itemList}
changeOrder={this.props.changeOrder} changeOrder={this.props.changeOrder}
orderBy={this.props.orderBy} orderBy={this.props.orderBy}
@ -35,8 +35,7 @@ let AccordionListItemTable = React.createClass({
return ( return (
<TableItem <TableItem
className="ascribe-table-item-selectable" className="ascribe-table-item-selectable"
key={i}> key={i} />
</TableItem>
); );
})} })}
</Table> </Table>

View File

@ -1,9 +1,10 @@
'use strict';
import React from 'react'; import React from 'react';
import Router from 'react-router'; import Router from 'react-router';
import EditionListStore from '../../stores/edition_list_store'; import EditionListStore from '../../stores/edition_list_store';
import EditionListActions from '../../actions/edition_list_actions'; import EditionListActions from '../../actions/edition_list_actions';
import PieceListStore from '../../stores/piece_list_store';
import PieceListActions from '../../actions/piece_list_actions'; import PieceListActions from '../../actions/piece_list_actions';
import AccordionListItemTable from './accordion_list_item_table'; import AccordionListItemTable from './accordion_list_item_table';
@ -12,7 +13,6 @@ import AccordionListItemTableSelectAllEditionsToggle from './accordion_list_item
import { ColumnModel, TransitionModel } from '../ascribe_table/models/table_models'; import { ColumnModel, TransitionModel } from '../ascribe_table/models/table_models';
import TableItemImg from '../ascribe_table/table_item_img';
import TableItemText from '../ascribe_table/table_item_text'; import TableItemText from '../ascribe_table/table_item_text';
import TableItemCheckbox from '../ascribe_table/table_item_checkbox'; import TableItemCheckbox from '../ascribe_table/table_item_checkbox';
import TableItemAclFiltered from '../ascribe_table/table_item_acl_filtered'; import TableItemAclFiltered from '../ascribe_table/table_item_acl_filtered';
@ -34,10 +34,6 @@ let AccordionListItemTableEditions = React.createClass({
return EditionListStore.getState(); return EditionListStore.getState();
}, },
onChange(state) {
this.setState(state);
},
componentDidMount() { componentDidMount() {
EditionListStore.listen(this.onChange); EditionListStore.listen(this.onChange);
}, },
@ -46,6 +42,10 @@ let AccordionListItemTableEditions = React.createClass({
EditionListStore.unlisten(this.onChange); EditionListStore.unlisten(this.onChange);
}, },
onChange(state) {
this.setState(state);
},
selectItem(pieceId, editionId) { selectItem(pieceId, editionId) {
EditionListActions.selectEdition({pieceId, editionId}); EditionListActions.selectEdition({pieceId, editionId});
}, },
@ -84,7 +84,7 @@ let AccordionListItemTableEditions = React.createClass({
if(this.state.editionList[this.props.parentId]) { if(this.state.editionList[this.props.parentId]) {
selectedEditionsCount = this.filterSelectedEditions().length; selectedEditionsCount = this.filterSelectedEditions().length;
allEditionsCount = this.state.editionList[this.props.parentId].length; allEditionsCount = this.state.editionList[this.props.parentId].length;
orderBy = this.state.editionList[this.props.parentId].orderBy orderBy = this.state.editionList[this.props.parentId].orderBy;
orderAsc = this.state.editionList[this.props.parentId].orderAsc; orderAsc = this.state.editionList[this.props.parentId].orderAsc;
} }
@ -98,7 +98,7 @@ let AccordionListItemTableEditions = React.createClass({
'pieceId': this.props.parentId, 'pieceId': this.props.parentId,
'selectItem': this.selectItem, 'selectItem': this.selectItem,
'selected': item.selected 'selected': item.selected
}}, }; },
'', '',
<AccordionListItemTableSelectAllEditionsToggle <AccordionListItemTableSelectAllEditionsToggle
onChange={this.selectAllItems} onChange={this.selectAllItems}
@ -109,10 +109,10 @@ let AccordionListItemTableEditions = React.createClass({
false false
), ),
new ColumnModel( new ColumnModel(
(item) => { (item) => {
return { return {
'content': item.edition_number 'content': item.edition_number
}}, }; },
'edition_number', 'edition_number',
'#', '#',
TableItemText, TableItemText,
@ -124,7 +124,7 @@ let AccordionListItemTableEditions = React.createClass({
(item) => { (item) => {
return { return {
'content': item.bitcoin_id 'content': item.bitcoin_id
}}, }; },
'bitcoin_id', 'bitcoin_id',
getLangText('Bitcoin Address'), getLangText('Bitcoin Address'),
TableItemText, TableItemText,
@ -133,10 +133,10 @@ let AccordionListItemTableEditions = React.createClass({
transition transition
), ),
new ColumnModel( new ColumnModel(
(item) => { (item) => {
return { return {
'content': item.acl 'content': item.acl
}}, }; },
'acl', 'acl',
getLangText('Actions'), getLangText('Actions'),
TableItemAclFiltered, TableItemAclFiltered,
@ -159,7 +159,7 @@ let AccordionListItemTableEditions = React.createClass({
orderAsc={orderAsc} orderAsc={orderAsc}
changeOrder={this.changeEditionListOrder}> changeOrder={this.changeEditionListOrder}>
<AccordionListItemTableToggle <AccordionListItemTableToggle
className="ascribe-accordion-list-table-toggle" className="ascribe-accordion-list-table-toggle"
onClick={this.toggleTable} onClick={this.toggleTable}
show={this.props.show} show={this.props.show}
numOfTableItems={this.props.numOfEditions} /> numOfTableItems={this.props.numOfEditions} />

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
@ -11,8 +13,8 @@ let AccordionListItemTableSelectAllEditionsToggle = React.createClass({
render() { render() {
return ( return (
<input type="checkbox" <input type="checkbox"
onChange={this.props.onChange} onChange={this.props.onChange}
checked={this.props.numOfAllEditions === this.props.numOfSelectedEditions} /> checked={this.props.numOfAllEditions === this.props.numOfSelectedEditions} />
); );
} }

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
let AccordionListItemTableToggle = React.createClass({ let AccordionListItemTableToggle = React.createClass({
@ -10,7 +12,7 @@ let AccordionListItemTableToggle = React.createClass({
render() { render() {
return ( return (
<span <span
className={this.props.className} className={this.props.className}
onClick={this.props.onClick}> onClick={this.props.onClick}>
{this.props.show ? 'Hide all ' + this.props.numOfTableItems + ' Editions' : 'Show all ' + this.props.numOfTableItems + ' Editions'} {this.props.show ? 'Hide all ' + this.props.numOfTableItems + ' Editions' : 'Show all ' + this.props.numOfTableItems + ' Editions'}

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import Router from 'react-router'; import Router from 'react-router';
import Header from '../components/header'; import Header from '../components/header';
@ -12,7 +14,7 @@ let AscribeApp = React.createClass({
<div> <div>
<Header /> <Header />
<RouteHandler /> <RouteHandler />
</div> </div>
); );
} }
}); });

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import Alert from 'react-bootstrap/lib/Alert'; import Alert from 'react-bootstrap/lib/Alert';
@ -7,12 +9,15 @@ let AlertDismissable = React.createClass({
alertVisible: true alertVisible: true
}; };
}, },
show() { show() {
this.setState({alertVisible: true}); this.setState({alertVisible: true});
}, },
hide() { hide() {
this.setState({alertVisible: false}); this.setState({alertVisible: false});
}, },
render() { render() {
if (this.state.alertVisible) { if (this.state.alertVisible) {
let key = this.props.error; let key = this.props.error;

View File

@ -1,5 +1,13 @@
'use strict';
import React from 'react'; import React from 'react';
/*
Is this even used somewhere?
Deprecate? 5.6.15 - Tim
*/
let ButtonSubmitOrClose = React.createClass({ let ButtonSubmitOrClose = React.createClass({
render() { render() {
if (this.props.submitted){ if (this.props.submitted){
@ -14,7 +22,7 @@ let ButtonSubmitOrClose = React.createClass({
<button type="submit" className="btn btn-ascribe-inv">{this.props.text}</button> <button type="submit" className="btn btn-ascribe-inv">{this.props.text}</button>
<button className="btn btn-ascribe-inv" onClick={this.props.onClose}>CLOSE</button> <button className="btn btn-ascribe-inv" onClick={this.props.onClose}>CLOSE</button>
</div> </div>
) );
} }
}); });

View File

@ -1,4 +1,4 @@
import fetch from 'isomorphic-fetch'; 'use strict';
import React from 'react'; import React from 'react';
@ -12,19 +12,20 @@ let ConsignForm = React.createClass({
mixins: [FormMixin], mixins: [FormMixin],
url() { url() {
return ApiUrls.ownership_consigns return ApiUrls.ownership_consigns;
}, },
getFormData() { getFormData() {
return { return {
bitcoin_id: this.getBitcoinIds().join(), bitcoin_id: this.getBitcoinIds().join(),
consignee: this.refs.consignee.state.value, consignee: this.refs.consignee.state.value,
consign_message: this.refs.consign_message.state.value, consign_message: this.refs.consign_message.state.value,
password: this.refs.password.state.value password: this.refs.password.state.value
} };
}, },
renderForm() { renderForm() {
let title = this.getTitlesString().join(""); let title = this.getTitlesString().join('');
let username = this.props.currentUser.username; let username = this.props.currentUser.username;
let message = let message =
`Hi, `Hi,

View File

@ -1,4 +1,4 @@
import fetch from 'isomorphic-fetch'; 'use strict';
import React from 'react'; import React from 'react';
@ -9,39 +9,47 @@ import InputHidden from './input_hidden';
import InputCheckbox from './input_checkbox'; import InputCheckbox from './input_checkbox';
import InputDate from './input_date'; import InputDate from './input_date';
import InputTextArea from './input_textarea'; import InputTextArea from './input_textarea';
import OwnershipFetcher from '../../fetchers/ownership_fetcher' import OwnershipFetcher from '../../fetchers/ownership_fetcher';
import ButtonSubmitOrClose from './button_submit_close'; import ButtonSubmitOrClose from './button_submit_close';
let LoanForm = React.createClass({ let LoanForm = React.createClass({
getInitialState() {
this.setState({
contract_key: null,
contract_url: null,
loaneeHasContract: false
});
},
mixins: [FormMixin], mixins: [FormMixin],
url() { url() {
return ApiUrls.ownership_loans return ApiUrls.ownership_loans;
},
componentDidMount(){
this.setState({contract_key: null,
contract_url: null,
loaneeHasContract: false});
}, },
getFormData() { getFormData() {
return { return {
bitcoin_id: this.getBitcoinIds().join(), bitcoin_id: this.getBitcoinIds().join(),
loanee: this.refs.loanee.state.value, loanee: this.refs.loanee.state.value,
gallery_name: this.refs.gallery_name.state.value, gallery_name: this.refs.gallery_name.state.value,
startdate: this.refs.startdate.state.value.format("YYYY-MM-DD"), startdate: this.refs.startdate.state.value.format('YYYY-MM-DD'),
enddate: this.refs.enddate.state.value.format("YYYY-MM-DD"), enddate: this.refs.enddate.state.value.format('YYYY-MM-DD'),
loan_message: this.refs.loan_message.state.value, loan_message: this.refs.loan_message.state.value,
password: this.refs.password.state.value, password: this.refs.password.state.value,
terms: this.refs.terms.state.value terms: this.refs.terms.state.value
} };
}, },
handleLoanEmailBlur(e){
handleLoanEmailBlur(){
OwnershipFetcher.fetchLoanContract(this.refs.loanee.state.value) OwnershipFetcher.fetchLoanContract(this.refs.loanee.state.value)
.then((res) => { .then((res) => {
if (res && res.length > 0) { if (res && res.length > 0) {
this.setState({contract_key: res[0].s3Key, this.setState({
contract_url: res[0].s3Url, contract_key: res[0].s3Key,
loaneeHasContract: true}); contract_url: res[0].s3Url,
loaneeHasContract: true
});
} }
else{ else{
this.resetLoanContract(); this.resetLoanContract();
@ -52,14 +60,16 @@ let LoanForm = React.createClass({
this.resetLoanContract(); this.resetLoanContract();
}); });
}, },
resetLoanContract(){ resetLoanContract(){
this.setState({contract_key: null, this.setState({contract_key: null,
contract_url: null, contract_url: null,
loaneeHasContract: false loaneeHasContract: false
}); });
}, },
renderForm() { renderForm() {
let title = this.getTitlesString().join(""); let title = this.getTitlesString().join('');
let username = this.props.currentUser.username; let username = this.props.currentUser.username;
let message = let message =
`Hi, `Hi,
@ -72,18 +82,19 @@ ${username}`;
let contract = <InputHidden ref="terms" value="True"/>; let contract = <InputHidden ref="terms" value="True"/>;
if (this.state.loaneeHasContract){ if (this.state.loaneeHasContract){
let label = <div> let label = (<div>
I agree to the&nbsp; I agree to the&nbsp;
<a href={this.state.contract_url} target="_blank"> <a href={this.state.contract_url} target="_blank">
terms of {this.refs.loanee.state.value} terms of {this.refs.loanee.state.value}
</a> </a>
</div>; </div>);
contract = <InputCheckbox contract = (<InputCheckbox
ref="terms" ref="terms"
required="required" required="required"
label={label} label={label}
/> />);
} }
return ( return (
<form id="loan_modal_content" role="form" onSubmit={this.submit}> <form id="loan_modal_content" role="form" onSubmit={this.submit}>
<input className="invisible" type="email" name="fake_loanee"/> <input className="invisible" type="email" name="fake_loanee"/>

View File

@ -1,4 +1,4 @@
import fetch from 'isomorphic-fetch'; 'use strict';
import React from 'react'; import React from 'react';
@ -12,17 +12,19 @@ let ShareForm = React.createClass({
mixins: [FormMixin], mixins: [FormMixin],
url() { url() {
return ApiUrls.ownership_shares_mail return ApiUrls.ownership_shares_mail;
}, },
getFormData() { getFormData() {
return { return {
bitcoin_id: this.getBitcoinIds().join(), bitcoin_id: this.getBitcoinIds().join(),
share_emails: this.refs.share_emails.state.value, share_emails: this.refs.share_emails.state.value,
share_message: this.refs.share_message.state.value share_message: this.refs.share_message.state.value
} };
}, },
renderForm() { renderForm() {
let title = this.getTitlesString().join(""); let title = this.getTitlesString().join('');
let username = this.props.currentUser.username; let username = this.props.currentUser.username;
let message = let message =
`Hi, `Hi,

View File

@ -1,4 +1,4 @@
import fetch from 'isomorphic-fetch'; 'use strict';
import React from 'react'; import React from 'react';
@ -9,23 +9,24 @@ import InputTextArea from './input_textarea';
import ButtonSubmitOrClose from './button_submit_close'; import ButtonSubmitOrClose from './button_submit_close';
let TransferForm = React.createClass({ let TransferForm = React.createClass({
mixins: [FormMixin], mixins: [FormMixin],
url() { url() {
return ApiUrls.ownership_transfers return ApiUrls.ownership_transfers;
}, },
getFormData() { getFormData() {
return { return {
bitcoin_id: this.getBitcoinIds().join(), bitcoin_id: this.getBitcoinIds().join(),
transferee: this.refs.transferee.state.value, transferee: this.refs.transferee.state.value,
transfer_message: this.refs.transfer_message.state.value, transfer_message: this.refs.transfer_message.state.value,
password: this.refs.password.state.value password: this.refs.password.state.value
} };
}, },
renderForm() { renderForm() {
let title = this.getTitlesString().join(""); let title = this.getTitlesString().join('');
let username = this.props.currentUser.username; let username = this.props.currentUser.username;
let message = let message =
`Hi, `Hi,

View File

@ -1,4 +1,4 @@
import fetch from 'isomorphic-fetch'; 'use strict';
import React from 'react'; import React from 'react';
@ -12,15 +12,17 @@ let UnConsignForm = React.createClass({
mixins: [FormMixin], mixins: [FormMixin],
url() { url() {
return ApiUrls.ownership_unconsigns return ApiUrls.ownership_unconsigns;
}, },
getFormData() { getFormData() {
return { return {
bitcoin_id: this.props.edition.bitcoin_id, bitcoin_id: this.props.edition.bitcoin_id,
unconsign_message: this.refs.unconsign_message.state.value, unconsign_message: this.refs.unconsign_message.state.value,
password: this.refs.password.state.value password: this.refs.password.state.value
} };
}, },
renderForm() { renderForm() {
let title = this.props.edition.title; let title = this.props.edition.title;
let username = this.props.currentUser.username; let username = this.props.currentUser.username;

View File

@ -1,10 +1,9 @@
import fetch from 'isomorphic-fetch'; 'use strict';
import React from 'react'; import React from 'react';
import ApiUrls from '../../constants/api_urls'; import ApiUrls from '../../constants/api_urls';
import FormMixin from '../../mixins/form_mixin'; import FormMixin from '../../mixins/form_mixin';
import InputText from './input_text';
import InputTextArea from './input_textarea'; import InputTextArea from './input_textarea';
import ButtonSubmitOrClose from './button_submit_close'; import ButtonSubmitOrClose from './button_submit_close';
@ -12,14 +11,16 @@ let UnConsignRequestForm = React.createClass({
mixins: [FormMixin], mixins: [FormMixin],
url() { url() {
return ApiUrls.ownership_unconsigns_request return ApiUrls.ownership_unconsigns_request;
}, },
getFormData() { getFormData() {
return { return {
bitcoin_id: this.props.edition.bitcoin_id, bitcoin_id: this.props.edition.bitcoin_id,
unconsign_request_message: this.refs.unconsign_request_message.state.value unconsign_request_message: this.refs.unconsign_request_message.state.value
} };
}, },
renderForm() { renderForm() {
let title = this.props.edition.title; let title = this.props.edition.title;
let username = this.props.currentUser.username; let username = this.props.currentUser.username;

View File

@ -1,19 +1,24 @@
'use strict';
import React from 'react'; import React from 'react';
import AlertMixin from '../../mixins/alert_mixin' import AlertMixin from '../../mixins/alert_mixin';
let InputCheckbox = React.createClass({ let InputCheckbox = React.createClass({
mixins : [AlertMixin], mixins: [AlertMixin],
getInitialState() { getInitialState() {
return {value: null, return {
alerts: null // needed in AlertMixin value: null,
alerts: null // needed in AlertMixin
}; };
}, },
handleChange(event) { handleChange(event) {
this.setState({value: event.target.value}); this.setState({value: event.target.value});
}, },
render() { render() {
let alerts = (this.props.submitted) ? null : this.state.alerts; let alerts = (this.props.submitted) ? null : this.state.alerts;
return ( return (

View File

@ -1,15 +1,18 @@
'use strict';
import React from 'react'; import React from 'react';
import AlertMixin from '../../mixins/alert_mixin' import AlertMixin from '../../mixins/alert_mixin';
import DatePicker from 'react-datepicker/dist/react-datepicker' import DatePicker from 'react-datepicker/dist/react-datepicker';
let InputDate = React.createClass({ let InputDate = React.createClass({
mixins : [AlertMixin], mixins: [AlertMixin],
getInitialState() { getInitialState() {
return {value: null, return {
alerts: null // needed in AlertMixin value: null,
alerts: null // needed in AlertMixin
}; };
}, },
@ -18,7 +21,7 @@ let InputDate = React.createClass({
}, },
render: function () { render: function () {
let className = "form-control input-text-ascribe"; let className = 'form-control input-text-ascribe';
let alerts = (this.props.submitted) ? null : this.state.alerts; let alerts = (this.props.submitted) ? null : this.state.alerts;
return ( return (
<DatePicker <DatePicker
@ -29,6 +32,10 @@ let InputDate = React.createClass({
placeholderText={this.props.placeholderText} placeholderText={this.props.placeholderText}
/> />
); );
// CAN THIS BE REMOVED???
//
// - Tim?
//
//return ( //return (
// <div className="input-group date" // <div className="input-group date"
// ref={this.props.name + "_picker"} // ref={this.props.name + "_picker"}

View File

@ -1,10 +1,12 @@
'use strict';
import React from 'react'; import React from 'react';
import AlertMixin from '../../mixins/alert_mixin' import AlertMixin from '../../mixins/alert_mixin';
let InputHidden = React.createClass({ let InputHidden = React.createClass({
mixins : [AlertMixin], mixins: [AlertMixin],
getInitialState() { getInitialState() {
return {value: this.props.value, return {value: this.props.value,

View File

@ -1,21 +1,25 @@
'use strict';
import React from 'react'; import React from 'react';
import AlertMixin from '../../mixins/alert_mixin' import AlertMixin from '../../mixins/alert_mixin';
let InputText = React.createClass({ let InputText = React.createClass({
mixins : [AlertMixin], mixins: [AlertMixin],
getInitialState() { getInitialState() {
return {value: null, return {value: null,
alerts: null // needed in AlertMixin alerts: null // needed in AlertMixin
}; };
}, },
handleChange(event) { handleChange(event) {
this.setState({value: event.target.value}); this.setState({value: event.target.value});
}, },
render() { render() {
let className = "form-control input-text-ascribe"; let className = 'form-control input-text-ascribe';
let alerts = (this.props.submitted) ? null : this.state.alerts; let alerts = (this.props.submitted) ? null : this.state.alerts;
return ( return (
<div className="form-group"> <div className="form-group">

View File

@ -1,21 +1,24 @@
'use strict';
import React from 'react'; import React from 'react';
import AlertMixin from '../../mixins/alert_mixin' import AlertMixin from '../../mixins/alert_mixin';
let InputTextArea = React.createClass({ let InputTextArea = React.createClass({
mixins : [AlertMixin], mixins: [AlertMixin],
getInitialState() { getInitialState() {
return {value: this.props.defaultValue, return {
alerts: null // needed in AlertMixin value: this.props.defaultValue,
alerts: null // needed in AlertMixin
}; };
}, },
handleChange(event) { handleChange(event) {
this.setState({value: event.target.value}); this.setState({value: event.target.value});
}, },
render() { render() {
let className = "form-control input-text-ascribe textarea-ascribe-message"; let className = 'form-control input-text-ascribe textarea-ascribe-message';
let alerts = (this.props.submitted) ? null : this.state.alerts; let alerts = (this.props.submitted) ? null : this.state.alerts;
return ( return (

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import InjectInHeadMixin from '../../mixins/inject_in_head_mixin'; import InjectInHeadMixin from '../../mixins/inject_in_head_mixin';
@ -14,7 +16,7 @@ import InjectInHeadMixin from '../../mixins/inject_in_head_mixin';
let resourceMap = { let resourceMap = {
'image': 1 'image': 1
} };
let ResourceViewer = React.createClass({ let ResourceViewer = React.createClass({
propTypes: { propTypes: {

View File

@ -1,11 +1,13 @@
'use strict';
import React from 'react'; import React from 'react';
import Modal from 'react-bootstrap/lib/Modal'; import Modal from 'react-bootstrap/lib/Modal';
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import ModalTrigger from 'react-bootstrap/lib/ModalTrigger'; import ModalTrigger from 'react-bootstrap/lib/ModalTrigger';
import Tooltip from 'react-bootstrap/lib/Tooltip'; import Tooltip from 'react-bootstrap/lib/Tooltip';
import LoanForm from '../ascribe_forms/form_loan' import LoanForm from '../ascribe_forms/form_loan';
import ModalMixin from '../../mixins/modal_mixin' import ModalMixin from '../../mixins/modal_mixin';
let LoanModalButton = React.createClass({ let LoanModalButton = React.createClass({
render() { render() {
@ -19,12 +21,12 @@ let LoanModalButton = React.createClass({
</div> </div>
</ModalTrigger> </ModalTrigger>
</OverlayTrigger> </OverlayTrigger>
) );
} }
}); });
let LoanModal = React.createClass({ let LoanModal = React.createClass({
mixins : [ModalMixin], mixins: [ModalMixin],
render() { render() {
return ( return (
@ -35,7 +37,7 @@ let LoanModal = React.createClass({
onRequestHide={this.onRequestHide}/> onRequestHide={this.onRequestHide}/>
</div> </div>
</Modal> </Modal>
) );
} }
}); });

View File

@ -1,13 +1,13 @@
'use strict';
import React from 'react'; import React from 'react';
import Modal from 'react-bootstrap/lib/Modal'; import Modal from 'react-bootstrap/lib/Modal';
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import ModalTrigger from 'react-bootstrap/lib/ModalTrigger'; import ModalTrigger from 'react-bootstrap/lib/ModalTrigger';
import Tooltip from 'react-bootstrap/lib/Tooltip'; import Tooltip from 'react-bootstrap/lib/Tooltip';
import ModalMixin from '../../mixins/modal_mixin' import ModalMixin from '../../mixins/modal_mixin';
import ShareForm from '../ascribe_forms/form_share_email';
import ShareForm from '../ascribe_forms/form_share_email'
let ShareModalButton = React.createClass({ let ShareModalButton = React.createClass({
render() { render() {
@ -20,12 +20,12 @@ let ShareModalButton = React.createClass({
</div> </div>
</ModalTrigger> </ModalTrigger>
</OverlayTrigger> </OverlayTrigger>
) );
} }
}); });
let ShareModal = React.createClass({ let ShareModal = React.createClass({
mixins : [ModalMixin], mixins: [ModalMixin],
render() { render() {
return ( return (
@ -36,7 +36,7 @@ let ShareModal = React.createClass({
onRequestHide={this.onRequestHide}/> onRequestHide={this.onRequestHide}/>
</div> </div>
</Modal> </Modal>
) );
} }
}); });

View File

@ -1,11 +1,13 @@
'use strict';
import React from 'react'; import React from 'react';
import Modal from 'react-bootstrap/lib/Modal'; import Modal from 'react-bootstrap/lib/Modal';
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import ModalTrigger from 'react-bootstrap/lib/ModalTrigger'; import ModalTrigger from 'react-bootstrap/lib/ModalTrigger';
import Tooltip from 'react-bootstrap/lib/Tooltip'; import Tooltip from 'react-bootstrap/lib/Tooltip';
import UnConsignForm from '../ascribe_forms/form_unconsign' import UnConsignForm from '../ascribe_forms/form_unconsign';
import ModalMixin from '../../mixins/modal_mixin' import ModalMixin from '../../mixins/modal_mixin';
let UnConsignModalButton = React.createClass({ let UnConsignModalButton = React.createClass({
render() { render() {
@ -19,12 +21,12 @@ let UnConsignModalButton = React.createClass({
</div> </div>
</ModalTrigger> </ModalTrigger>
</OverlayTrigger> </OverlayTrigger>
) );
} }
}); });
let UnConsignModal = React.createClass({ let UnConsignModal = React.createClass({
mixins : [ModalMixin], mixins: [ModalMixin],
render() { render() {
return ( return (
@ -35,7 +37,7 @@ let UnConsignModal = React.createClass({
onRequestHide={this.onRequestHide}/> onRequestHide={this.onRequestHide}/>
</div> </div>
</Modal> </Modal>
) );
} }
}); });

View File

@ -1,11 +1,13 @@
'use strict';
import React from 'react'; import React from 'react';
import Modal from 'react-bootstrap/lib/Modal'; import Modal from 'react-bootstrap/lib/Modal';
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import ModalTrigger from 'react-bootstrap/lib/ModalTrigger'; import ModalTrigger from 'react-bootstrap/lib/ModalTrigger';
import Tooltip from 'react-bootstrap/lib/Tooltip'; import Tooltip from 'react-bootstrap/lib/Tooltip';
import UnConsignRequestForm from '../ascribe_forms/form_unconsign_request' import UnConsignRequestForm from '../ascribe_forms/form_unconsign_request';
import ModalMixin from '../../mixins/modal_mixin' import ModalMixin from '../../mixins/modal_mixin';
let UnConsignRequestModalButton = React.createClass({ let UnConsignRequestModalButton = React.createClass({
render() { render() {
@ -19,12 +21,12 @@ let UnConsignRequestModalButton = React.createClass({
</div> </div>
</ModalTrigger> </ModalTrigger>
</OverlayTrigger> </OverlayTrigger>
) );
} }
}); });
let UnConsignRequestModal = React.createClass({ let UnConsignRequestModal = React.createClass({
mixins : [ModalMixin], mixins: [ModalMixin],
render() { render() {
return ( return (
@ -35,7 +37,7 @@ let UnConsignRequestModal = React.createClass({
onRequestHide={this.onRequestHide}/> onRequestHide={this.onRequestHide}/>
</div> </div>
</Modal> </Modal>
) );
} }
}); });

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import ReactAddons from 'react/addons'; import ReactAddons from 'react/addons';
@ -6,7 +8,7 @@ import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import ModalTrigger from 'react-bootstrap/lib/ModalTrigger'; import ModalTrigger from 'react-bootstrap/lib/ModalTrigger';
import Tooltip from 'react-bootstrap/lib/Tooltip'; import Tooltip from 'react-bootstrap/lib/Tooltip';
import ModalMixin from '../../mixins/modal_mixin' import ModalMixin from '../../mixins/modal_mixin';
let ModalWrapper = React.createClass({ let ModalWrapper = React.createClass({
@ -27,20 +29,22 @@ let ModalWrapper = React.createClass({
{this.props.button} {this.props.button}
</ModalTrigger> </ModalTrigger>
</OverlayTrigger> </OverlayTrigger>
) );
} }
}); });
// //
let ModalBody = React.createClass({ let ModalBody = React.createClass({
mixins : [ModalMixin],
mixins: [ModalMixin],
handleSuccess(){ handleSuccess(){
this.props.handleSuccess(); this.props.handleSuccess();
this.props.onRequestHide(); this.props.onRequestHide();
}, },
renderChildren() { renderChildren() {
return ReactAddons.Children.map(this.props.children, (child, i) => { return ReactAddons.Children.map(this.props.children, (child) => {
return ReactAddons.addons.cloneWithProps(child, { return ReactAddons.addons.cloneWithProps(child, {
editions: this.props.editions, editions: this.props.editions,
currentUser: this.props.currentUser, currentUser: this.props.currentUser,
@ -49,6 +53,7 @@ let ModalBody = React.createClass({
}); });
}); });
}, },
render() { render() {
return ( return (
<Modal {...this.props} title={this.props.title}> <Modal {...this.props} title={this.props.title}>
@ -56,7 +61,7 @@ let ModalBody = React.createClass({
{this.renderChildren()} {this.renderChildren()}
</div> </div>
</Modal> </Modal>
) );
} }
}); });

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import PaginationButton from './pagination_button'; import PaginationButton from './pagination_button';
@ -7,25 +9,23 @@ let Pagination = React.createClass({
goToPage: React.PropTypes.func.isRequired, goToPage: React.PropTypes.func.isRequired,
currentPage: React.PropTypes.number.isRequired, currentPage: React.PropTypes.number.isRequired,
totalPages: React.PropTypes.number.isRequired totalPages: React.PropTypes.number.isRequired
//itemListCount: React.PropTypes.number.isRequired //itemListCount: React.PropTypes.number.isRequired
}, },
render() { render() {
return( return (
<nav> <nav>
<ul className="pager"> <ul className="pager">
<PaginationButton <PaginationButton
direction='previous' direction='previous'
goToPage={this.props.goToPage} goToPage={this.props.goToPage}
currentPage={this.props.currentPage} currentPage={this.props.currentPage}
totalPages={this.props.totalPages}> totalPages={this.props.totalPages} />
</PaginationButton> <PaginationButton
<PaginationButton
direction='next' direction='next'
goToPage={this.props.goToPage} goToPage={this.props.goToPage}
currentPage={this.props.currentPage} currentPage={this.props.currentPage}
totalPages={this.props.totalPages}> totalPages={this.props.totalPages} />
</PaginationButton>
</ul> </ul>
</nav> </nav>
); );

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import Router from 'react-router'; import Router from 'react-router';

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import { mergeOptions } from '../../utils/general_utils'; import { mergeOptions } from '../../utils/general_utils';
@ -108,7 +110,7 @@ let PieceListBulkModal = React.createClass({
<PieceListBulkModalSelectedEditionsWidget <PieceListBulkModalSelectedEditionsWidget
numberOfSelectedEditions={this.fetchSelectedEditionList().length} /> numberOfSelectedEditions={this.fetchSelectedEditionList().length} />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span <span
className="piece-list-bulk-modal-clear-all" className="piece-list-bulk-modal-clear-all"
onClick={this.clearAllSelections}>clear all</span> onClick={this.clearAllSelections}>clear all</span>
</div> </div>
@ -148,7 +150,7 @@ let PieceListBulkModal = React.createClass({
); );
} else { } else {
return null; return null;
} }
} }
}); });

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
let PieceListBulkModalSelectedEditionsWidget = React.createClass({ let PieceListBulkModalSelectedEditionsWidget = React.createClass({

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import PieceListStore from '../../stores/piece_list_store'; import PieceListStore from '../../stores/piece_list_store';
@ -6,18 +8,16 @@ import PieceListActions from '../../actions/piece_list_actions';
import Input from 'react-bootstrap/lib/Input'; import Input from 'react-bootstrap/lib/Input';
import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import PieceListToolbarFilterWidgetFilter from './piece_list_toolbar_filter_widget';
let PieceListToolbar = React.createClass({ let PieceListToolbar = React.createClass({
propTypes: {
className: React.PropTypes.string
},
getInitialState() { getInitialState() {
return PieceListStore.getState(); return PieceListStore.getState();
}, },
onChange(state) {
this.setState(state);
},
componentDidMount() { componentDidMount() {
PieceListStore.listen(this.onChange); PieceListStore.listen(this.onChange);
}, },
@ -26,6 +26,10 @@ let PieceListToolbar = React.createClass({
PieceListStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange);
}, },
onChange(state) {
this.setState(state);
},
searchFor() { searchFor() {
let searchTerm = this.refs.search.getInputDOMNode().value; let searchTerm = this.refs.search.getInputDOMNode().value;
PieceListActions.fetchPieceList(this.state.page, this.pageSize, searchTerm, this.state.orderBy, this.state.orderAsc); PieceListActions.fetchPieceList(this.state.page, this.pageSize, searchTerm, this.state.orderBy, this.state.orderAsc);

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import Glyphicon from 'react-bootstrap/lib/Glyphicon';

View File

@ -1,3 +1,5 @@
'use strict';
export class ColumnModel { export class ColumnModel {
// ToDo: Add validation for all passed-in parameters // ToDo: Add validation for all passed-in parameters
constructor(transformFn, columnName, displayName, displayType, rowWidth, canBeOrdered, transition) { constructor(transformFn, columnName, displayName, displayType, rowWidth, canBeOrdered, transition) {
@ -12,7 +14,7 @@ export class ColumnModel {
} }
/** /**
* If a user opens an editionList of a piece and clicks on a specific edition to go to the * If a user opens an editionList of a piece and clicks on a specific edition to go to the
* piece detail page, all previously opened editionLists are still saved as show = true in the * piece detail page, all previously opened editionLists are still saved as show = true in the
* pieceList store. * pieceList store.
* *

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import ReactAddons from 'react/addons'; import ReactAddons from 'react/addons';
@ -12,7 +14,9 @@ let Table = React.createClass({
changeOrder: React.PropTypes.func, changeOrder: React.PropTypes.func,
orderBy: React.PropTypes.string, orderBy: React.PropTypes.string,
orderAsc: React.PropTypes.bool, orderAsc: React.PropTypes.bool,
className: React.PropTypes.string className: React.PropTypes.string,
children: React.PropTypes.object,
itemList: React.PropTypes.array
}, },
renderChildren() { renderChildren() {
@ -29,7 +33,7 @@ let Table = React.createClass({
render() { render() {
return ( return (
<table className={'table ' + this.props.className}> <table className={'table ' + this.props.className}>
<TableHeader <TableHeader
columnList={this.props.columnList} columnList={this.props.columnList}
itemList={this.props.itemList} itemList={this.props.itemList}
changeOrder={this.props.changeOrder} changeOrder={this.props.changeOrder}

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import TableColumnMixin from '../../mixins/table_column_mixin'; import TableColumnMixin from '../../mixins/table_column_mixin';
@ -7,7 +9,6 @@ import { ColumnModel } from './models/table_models';
let TableHeader = React.createClass({ let TableHeader = React.createClass({
mixins: [TableColumnMixin],
propTypes: { propTypes: {
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(ColumnModel)), columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(ColumnModel)),
itemList: React.PropTypes.array.isRequired, itemList: React.PropTypes.array.isRequired,
@ -16,6 +17,8 @@ let TableHeader = React.createClass({
orderBy: React.PropTypes.string orderBy: React.PropTypes.string
}, },
mixins: [TableColumnMixin],
render() { render() {
return ( return (
<thead> <thead>
@ -29,20 +32,18 @@ let TableHeader = React.createClass({
return ( return (
<TableHeaderItem <TableHeaderItem
key={i} key={i}
columnClasses={columnClasses} columnClasses={columnClasses}
displayName={val.displayName} displayName={val.displayName}
columnName={columnName} columnName={columnName}
canBeOrdered={canBeOrdered} canBeOrdered={canBeOrdered}
orderAsc={this.props.orderAsc} orderAsc={this.props.orderAsc}
orderBy={this.props.orderBy} orderBy={this.props.orderBy}
changeOrder={this.props.changeOrder}> changeOrder={this.props.changeOrder} />
</TableHeaderItem>
); );
})} })}
</tr> </tr>
</thead> </thead>
); );
} }
}); });

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import TableHeaderItemCarret from './table_header_item_carret'; import TableHeaderItemCarret from './table_header_item_carret';
@ -25,7 +27,7 @@ let TableHeaderItem = React.createClass({
if(this.props.canBeOrdered && this.props.changeOrder && this.props.orderAsc != null && this.props.orderBy) { if(this.props.canBeOrdered && this.props.changeOrder && this.props.orderAsc != null && this.props.orderBy) {
if(this.props.columnName === this.props.orderBy) { if(this.props.columnName === this.props.orderBy) {
return ( return (
<th <th
className={'ascribe-table-header-column'} className={'ascribe-table-header-column'}
onClick={this.changeOrder}> onClick={this.changeOrder}>
<span>{this.props.displayName} <TableHeaderItemCarret orderAsc={this.props.orderAsc} /></span> <span>{this.props.displayName} <TableHeaderItemCarret orderAsc={this.props.orderAsc} /></span>
@ -33,7 +35,7 @@ let TableHeaderItem = React.createClass({
); );
} else { } else {
return ( return (
<th <th
className={'ascribe-table-header-column'} className={'ascribe-table-header-column'}
onClick={this.changeOrder}> onClick={this.changeOrder}>
<span>{this.props.displayName}</span> <span>{this.props.displayName}</span>

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
let TableHeaderItemCarret = React.createClass({ let TableHeaderItemCarret = React.createClass({

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import { ColumnModel } from './models/table_models'; import { ColumnModel } from './models/table_models';
@ -18,8 +20,7 @@ let TableItem = React.createClass({
<TableItemWrapper <TableItemWrapper
columnList={this.props.columnList} columnList={this.props.columnList}
columnContent={this.props.columnContent} columnContent={this.props.columnContent}
columnWidth={12}> columnWidth={12} />
</TableItemWrapper>
); );
} }
}); });

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
/** /**
@ -5,7 +7,7 @@ import React from 'react';
*/ */
let TableItemImg = React.createClass({ let TableItemImg = React.createClass({
propTypes: { propTypes: {
content: React.PropTypes.string.isRequired, content: React.PropTypes.string.isRequired
}, },
render() { render() {

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
@ -12,7 +14,8 @@ let TableItemSelectable = React.createClass({
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(ColumnModel)), columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(ColumnModel)),
columnContent: React.PropTypes.object, columnContent: React.PropTypes.object,
parentId: React.PropTypes.number, parentId: React.PropTypes.number,
className: React.PropTypes.string className: React.PropTypes.string,
selectItem: React.PropTypes.func
}, },
selectItem() { selectItem() {
@ -25,12 +28,11 @@ let TableItemSelectable = React.createClass({
}); });
return ( return (
<TableItem <TableItem
className={tableItemClasses + ' ' + this.props.className} className={tableItemClasses + ' ' + this.props.className}
columnList={this.props.columnList} columnList={this.props.columnList}
columnContent={this.props.columnContent} columnContent={this.props.columnContent}
onClick={this.selectItem}> onClick={this.selectItem} />
</TableItem>
); );
} }

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import { ColumnModel } from './models/table_models'; import { ColumnModel } from './models/table_models';
@ -26,14 +28,18 @@ let TableItemSubtable = React.createClass({
}; };
}, },
onChange(state) {
this.setState(state);
},
componentDidMount() { componentDidMount() {
EditionListStore.listen(this.onChange); EditionListStore.listen(this.onChange);
}, },
componentWillUnmount() {
EditionListStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
loadEditionList() { loadEditionList() {
if(this.state.open) { if(this.state.open) {
this.setState({ this.setState({
@ -77,10 +83,9 @@ let TableItemSubtable = React.createClass({
className="ascribe-table-item-selectable" className="ascribe-table-item-selectable"
selectItem={this.selectItem} selectItem={this.selectItem}
parentId={this.props.columnContent.id} parentId={this.props.columnContent.id}
key={i}> key={i} />
</TableItemSelectable>
); );
})} })}
</Table> </Table>
</div> </div>
</div> </div>
@ -94,15 +99,13 @@ let TableItemSubtable = React.createClass({
<TableItemWrapper <TableItemWrapper
columnList={this.props.columnList} columnList={this.props.columnList}
columnContent={this.props.columnContent} columnContent={this.props.columnContent}
columnWidth={12}> columnWidth={12} />
</TableItemWrapper>
<div className="col-xs-1 col-sm-1 col-md-1 col-lg-1 ascribe-table-item-column"> <div className="col-xs-1 col-sm-1 col-md-1 col-lg-1 ascribe-table-item-column">
<TableItemSubtableButton content="+" onClick={this.loadEditionList}> <TableItemSubtableButton content="+" onClick={this.loadEditionList} />
</TableItemSubtableButton>
</div> </div>
</div> </div>
{renderEditionListTable()} {renderEditionListTable()}
</div> </div>
); );
} }
}); });

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
let TableItemSubtableButton = React.createClass({ let TableItemSubtableButton = React.createClass({

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import Router from 'react-router'; import Router from 'react-router';
@ -7,13 +9,14 @@ import TableColumnMixin from '../../mixins/table_column_mixin';
let Link = Router.Link; let Link = Router.Link;
let TableItemWrapper = React.createClass({ let TableItemWrapper = React.createClass({
mixins: [TableColumnMixin, Router.Navigation],
propTypes: { propTypes: {
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(ColumnModel)), columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(ColumnModel)),
columnContent: React.PropTypes.object, columnContent: React.PropTypes.object,
columnWidth: React.PropTypes.number.isRequired columnWidth: React.PropTypes.number.isRequired
}, },
mixins: [TableColumnMixin, Router.Navigation],
render() { render() {
return ( return (
<tr> <tr>
@ -27,7 +30,7 @@ let TableItemWrapper = React.createClass({
if(!column.transition) { if(!column.transition) {
return ( return (
<td <td
className={'ascribe-table-item-column'} className={'ascribe-table-item-column'}
key={i}> key={i}>
<TypeElement {...typeElementProps} /> <TypeElement {...typeElementProps} />
</td> </td>
@ -42,8 +45,8 @@ let TableItemWrapper = React.createClass({
*/ */
return ( return (
<td key={i}> <td key={i}>
<Link <Link
className={'ascribe-table-item-column'} className={'ascribe-table-item-column'}
onClick={column.transition.callback} onClick={column.transition.callback}
{...linkProps}> {...linkProps}>
<TypeElement {...typeElementProps} /> <TypeElement {...typeElementProps} />

View File

@ -1,14 +1,21 @@
'use strict';
import React from 'react'; import React from 'react';
import ResourceViewer from './ascribe_media/resource_viewer'; import ResourceViewer from './ascribe_media/resource_viewer';
import EditionActions from '../actions/edition_actions' import EditionActions from '../actions/edition_actions';
import AclButton from './acl_button' import AclButton from './acl_button';
/** /**
* This is the component that implements display-specific functionality * This is the component that implements display-specific functionality
*/ */
let Edition = React.createClass({ let Edition = React.createClass({
propTypes: {
edition: React.PropTypes.object,
currentUser: React.PropTypes.object
},
render() { render() {
let thumbnail = this.props.edition.thumbnail; let thumbnail = this.props.edition.thumbnail;
let mimetype = this.props.edition.digital_work.mime; let mimetype = this.props.edition.digital_work.mime;
@ -31,13 +38,17 @@ let Edition = React.createClass({
}); });
let EditionHeader = React.createClass({ let EditionHeader = React.createClass({
propTypes: {
edition: React.PropTypes.object
},
render() { render() {
var title_html = <div className="ascribe-detail-title">{this.props.edition.title}</div>; var titleHtml = <div className="ascribe-detail-title">{this.props.edition.title}</div>;
return ( return (
<div className="ascribe-detail-header"> <div className="ascribe-detail-header">
<EditionDetailProperty label="title" value={title_html} /> <EditionDetailProperty label="title" value={titleHtml} />
<EditionDetailProperty label="by" value={this.props.edition.artist_name} /> <EditionDetailProperty label="by" value={this.props.edition.artist_name} />
<EditionDetailProperty label="date" value={ this.props.edition.date_created.slice(0,4) } /> <EditionDetailProperty label="date" value={ this.props.edition.date_created.slice(0, 4) } />
<hr/> <hr/>
</div> </div>
); );
@ -45,26 +56,32 @@ let EditionHeader = React.createClass({
}); });
let EditionDetails = React.createClass({ let EditionDetails = React.createClass({
propTypes: {
edition: React.PropTypes.object,
currentUser: React.PropTypes.object
},
handleSuccess(){ handleSuccess(){
EditionActions.fetchOne(this.props.edition.id); EditionActions.fetchOne(this.props.edition.id);
}, },
render() { render() {
return ( return (
<div className="ascribe-detail-header"> <div className="ascribe-detail-header">
<EditionDetailProperty label="edition" <EditionDetailProperty label="edition"
value={this.props.edition.edition_number + " of " + this.props.edition.num_editions} /> value={this.props.edition.edition_number + ' of ' + this.props.edition.num_editions} />
<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/>
<AclButton <AclButton
availableAcls={["transfer"]} availableAcls={['transfer']}
action="transfer" action="transfer"
editions={[this.props.edition]} editions={[this.props.edition]}
currentUser={this.props.currentUser} currentUser={this.props.currentUser}
handleSuccess={this.handleSuccess} handleSuccess={this.handleSuccess}
/> />
<AclButton <AclButton
availableAcls={["consign"]} availableAcls={['consign']}
action="consign" action="consign"
editions={[this.props.edition]} editions={[this.props.edition]}
currentUser={this.props.currentUser} currentUser={this.props.currentUser}
@ -78,6 +95,11 @@ let EditionDetails = React.createClass({
}); });
let EditionDetailProperty = React.createClass({ let EditionDetailProperty = React.createClass({
propTypes: {
label: React.PropTypes.string,
value: React.PropTypes.string
},
render() { render() {
return ( return (
<div className="row ascribe-detail-property"> <div className="row ascribe-detail-property">

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import { mergeOptions } from '../utils/general_utils'; import { mergeOptions } from '../utils/general_utils';
@ -28,6 +30,7 @@ let EditionContainer = React.createClass({
UserActions.fetchCurrentUser(); UserActions.fetchCurrentUser();
EditionActions.fetchOne(this.props.params.editionId); EditionActions.fetchOne(this.props.params.editionId);
}, },
componentWillUnmount() { componentWillUnmount() {
EditionStore.unlisten(this.onChange); EditionStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange); UserStore.unlisten(this.onChange);
@ -36,10 +39,9 @@ let EditionContainer = React.createClass({
render() { render() {
if('title' in this.state.edition) { if('title' in this.state.edition) {
return ( return (
<Edition <Edition
edition={this.state.edition} edition={this.state.edition}
currentUser={this.state.currentUser}> currentUser={this.state.currentUser} />
</Edition>
); );
} else { } else {
return ( return (

View File

@ -1,13 +1,13 @@
'use strict';
import React from 'react'; import React from 'react';
import Router from 'react-router'; import Router from 'react-router';
import AltContainer from 'alt/AltContainer';
import UserActions from '../actions/user_actions'; import UserActions from '../actions/user_actions';
import UserStore from '../stores/user_store'; import UserStore from '../stores/user_store';
import Nav from 'react-bootstrap/lib/Nav'; import Nav from 'react-bootstrap/lib/Nav';
import Navbar from 'react-bootstrap/lib/Navbar'; import Navbar from 'react-bootstrap/lib/Navbar';
import NavItem from 'react-bootstrap/lib/NavItem';
import DropdownButton from 'react-bootstrap/lib/DropdownButton'; import DropdownButton from 'react-bootstrap/lib/DropdownButton';
import MenuItem from 'react-bootstrap/lib/MenuItem'; import MenuItem from 'react-bootstrap/lib/MenuItem';
@ -22,7 +22,7 @@ let Header = React.createClass({
}, },
componentDidMount() { componentDidMount() {
UserStore.listen(this.onChange) UserStore.listen(this.onChange);
UserActions.fetchCurrentUser(); UserActions.fetchCurrentUser();
}, },

View File

@ -1,5 +1,6 @@
'use strict';
import React from 'react'; import React from 'react';
import AltContainer from 'alt/AltContainer';
import PieceListStore from '../stores/piece_list_store'; import PieceListStore from '../stores/piece_list_store';
import PieceListActions from '../actions/piece_list_actions'; import PieceListActions from '../actions/piece_list_actions';
@ -15,7 +16,10 @@ import PieceListToolbar from './ascribe_piece_list_toolbar/piece_list_toolbar';
let PieceList = React.createClass({ let PieceList = React.createClass({
propTypes: {
query: React.PropTypes.object
},
getInitialState() { getInitialState() {
return PieceListStore.getState(); return PieceListStore.getState();
}, },
@ -35,7 +39,7 @@ let PieceList = React.createClass({
}, },
paginationGoToPage(page) { paginationGoToPage(page) {
return (e) => PieceListActions.fetchPieceList(page, this.state.pageSize, return () => PieceListActions.fetchPieceList(page, this.state.pageSize,
this.state.search, this.state.orderBy, this.state.search, this.state.orderBy,
this.state.orderAsc); this.state.orderAsc);
}, },
@ -47,8 +51,8 @@ let PieceList = React.createClass({
render() { render() {
let currentPage = parseInt(this.props.query.page, 10) || 1; let currentPage = parseInt(this.props.query.page, 10) || 1;
let totalPages = Math.ceil(this.state.pieceListCount / this.state.pageSize) let totalPages = Math.ceil(this.state.pieceListCount / this.state.pageSize);
return ( return (
<div> <div>
<PieceListToolbar className="ascribe-piece-list-toolbar" /> <PieceListToolbar className="ascribe-piece-list-toolbar" />
@ -64,11 +68,11 @@ let PieceList = React.createClass({
pageSize={this.state.pageSize}> pageSize={this.state.pageSize}>
{this.state.pieceList.map((item, i) => { {this.state.pieceList.map((item, i) => {
return ( return (
<AccordionListItem <AccordionListItem
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 ascribe-accordion-list-item" 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 ascribe-accordion-list-item"
content={item} content={item}
key={i}> key={i}>
<AccordionListItemTableEditions <AccordionListItemTableEditions
className="ascribe-accordion-list-item-table col-xs-12 col-sm-8 col-md-6 col-lg-6 col-sm-offset-2 col-md-offset-3 col-lg-offset-3" className="ascribe-accordion-list-item-table col-xs-12 col-sm-8 col-md-6 col-lg-6 col-sm-offset-2 col-md-offset-3 col-lg-offset-3"
parentId={item.id} parentId={item.id}
show={item.show} show={item.show}
@ -80,8 +84,7 @@ let PieceList = React.createClass({
<Pagination <Pagination
currentPage={currentPage} currentPage={currentPage}
totalPages={totalPages} totalPages={totalPages}
goToPage={this.paginationGoToPage}> goToPage={this.paginationGoToPage} />
</Pagination>
</div> </div>
); );
} }

View File

@ -1,17 +1,19 @@
'use strict';
import AppConstants from './application_constants'; import AppConstants from './application_constants';
let apiUrls = { let apiUrls = {
'ownership_shares_mail' : AppConstants.baseUrl + 'ownership/shares/mail/', 'ownership_shares_mail': AppConstants.baseUrl + 'ownership/shares/mail/',
'ownership_transfers' : AppConstants.baseUrl + 'ownership/transfers/', 'ownership_transfers': AppConstants.baseUrl + 'ownership/transfers/',
'user': AppConstants.baseUrl + 'users/', 'user': AppConstants.baseUrl + 'users/',
'pieces_list': AppConstants.baseUrl + 'pieces/', 'pieces_list': AppConstants.baseUrl + 'pieces/',
'piece': AppConstants.baseUrl + 'pieces/${piece_id}', 'piece': AppConstants.baseUrl + 'pieces/${piece_id}',
'edition': AppConstants.baseUrl + 'editions/${bitcoin_id}/', 'edition': AppConstants.baseUrl + 'editions/${bitcoin_id}/',
'editions_list': AppConstants.baseUrl + 'pieces/${piece_id}/editions/', 'editions_list': AppConstants.baseUrl + 'pieces/${piece_id}/editions/',
'ownership_loans' : AppConstants.baseUrl + 'ownership/loans/', 'ownership_loans': AppConstants.baseUrl + 'ownership/loans/',
'ownership_consigns' : AppConstants.baseUrl + 'ownership/consigns/', 'ownership_consigns': AppConstants.baseUrl + 'ownership/consigns/',
'ownership_unconsigns' : AppConstants.baseUrl + 'ownership/unconsigns/', 'ownership_unconsigns': AppConstants.baseUrl + 'ownership/unconsigns/',
'ownership_unconsigns_request' : AppConstants.baseUrl + 'ownership/unconsigns/request/' 'ownership_unconsigns_request': AppConstants.baseUrl + 'ownership/unconsigns/request/'
}; };
export default apiUrls; export default apiUrls;

View File

@ -1,3 +1,5 @@
'use strict';
let constants = { let constants = {
//'baseUrl': 'http://localhost:8000/api/', //'baseUrl': 'http://localhost:8000/api/',
'baseUrl': 'http://staging.ascribe.io/api/', 'baseUrl': 'http://staging.ascribe.io/api/',

View File

@ -1,3 +1,5 @@
'use strict';
const languages = { const languages = {
'en-US': { 'en-US': {
'Bitcoin Address': 'Bitcoin Address', 'Bitcoin Address': 'Bitcoin Address',

View File

@ -1,13 +1,11 @@
'use strict';
import fetch from '../utils/fetch'; import fetch from '../utils/fetch';
import AppConstants from '../constants/application_constants';
let EditionFetcher = { let EditionFetcher = {
/** /**
* Fetch one user from the API. * Fetch one user from the API.
* If no arg is supplied, load the current user * If no arg is supplied, load the current user
*
*/ */
fetchOne(editionId) { fetchOne(editionId) {
return fetch.get('edition', {'bitcoin_id': editionId}); return fetch.get('edition', {'bitcoin_id': editionId});

View File

@ -1,9 +1,9 @@
'use strict';
import fetch from '../utils/fetch'; import fetch from '../utils/fetch';
import { generateOrderingQueryParams } from '../utils/fetch_api_utils'; import { generateOrderingQueryParams } from '../utils/fetch_api_utils';
import AppConstants from '../constants/application_constants';
let EditionListFetcher = { let EditionListFetcher = {
/** /**

View File

@ -1,14 +1,14 @@
'use strict';
import fetch from 'isomorphic-fetch'; import fetch from 'isomorphic-fetch';
import AppConstants from '../constants/application_constants'; import AppConstants from '../constants/application_constants';
import FetchApiUtils from '../utils/fetch_api_utils';
let OwnershipFetcher = { let OwnershipFetcher = {
/** /**
* Fetch one user from the API. * Fetch one user from the API.
* If no arg is supplied, load the current user * If no arg is supplied, load the current user
*
*/ */
fetchLoanContract(email) { fetchLoanContract(email) {
return fetch(AppConstants.baseUrl + 'ownership/loans/contract/?loanee=' + email, { return fetch(AppConstants.baseUrl + 'ownership/loans/contract/?loanee=' + email, {

View File

@ -1,15 +1,14 @@
import fetch from '../utils/fetch'; 'use strict';
import AppConstants from '../constants/application_constants'; import fetch from '../utils/fetch';
let PieceFetcher = { let PieceFetcher = {
/** /**
* Fetch one user from the API. * Fetch one user from the API.
* If no arg is supplied, load the current user * If no arg is supplied, load the current user
*
*/ */
fetchOne(pieceId) { fetchOne() {
return fetch.get('piece'); return fetch.get('piece');
} }
}; };

View File

@ -1,4 +1,5 @@
import AppConstants from '../constants/application_constants'; 'use strict';
import { generateOrderingQueryParams } from '../utils/fetch_api_utils'; import { generateOrderingQueryParams } from '../utils/fetch_api_utils';
import fetch from '../utils/fetch'; import fetch from '../utils/fetch';

View File

@ -1,13 +1,12 @@
import fetch from '../utils/fetch'; 'use strict';
import AppConstants from '../constants/application_constants'; import fetch from '../utils/fetch';
let UserFetcher = { let UserFetcher = {
/** /**
* Fetch one user from the API. * Fetch one user from the API.
* If no arg is supplied, load the current user * If no arg is supplied, load the current user
*
*/ */
fetchOne() { fetchOne() {
return fetch.get('user'); return fetch.get('user');

View File

@ -1,15 +1,17 @@
'use strict';
import React from 'react'; import React from 'react';
import AlertDismissable from '../components/ascribe_forms/alert'; import AlertDismissable from '../components/ascribe_forms/alert';
let AlertMixin = { let AlertMixin = {
setAlerts(errors){ setAlerts(errors){
let alerts = errors.map( let alerts = errors.map((error) => {
function(error) { return <AlertDismissable error={error} key={error}/>;
return <AlertDismissable error={error} key={error}/>; });
}.bind(this)
);
this.setState({alerts: alerts}); this.setState({alerts: alerts});
}, },
clearAlerts(){ clearAlerts(){
this.setState({alerts: null}); this.setState({alerts: null});
} }

View File

@ -1,8 +1,9 @@
'use strict';
import fetch from '../utils/fetch'; import fetch from '../utils/fetch';
import React from 'react'; import React from 'react';
import AppConstants from '../constants/application_constants' import AlertDismissable from '../components/ascribe_forms/alert';
import AlertDismissable from '../components/ascribe_forms/alert'
export const FormMixin = { export const FormMixin = {
getInitialState() { getInitialState() {
@ -10,7 +11,7 @@ export const FormMixin = {
submitted: false submitted: false
, status: null , status: null
, errors: [] , errors: []
} };
}, },
submit(e) { submit(e) {
@ -18,7 +19,7 @@ export const FormMixin = {
this.setState({submitted: true}); this.setState({submitted: true});
fetch fetch
.post(this.url(), { body: this.getFormData() }) .post(this.url(), { body: this.getFormData() })
.then(response => { this.props.handleSuccess(); }) .then(() => { this.props.handleSuccess(); })
.catch(this.handleError); .catch(this.handleError);
}, },
@ -40,31 +41,29 @@ export const FormMixin = {
getBitcoinIds(){ getBitcoinIds(){
return this.props.editions.map(function(edition){ return this.props.editions.map(function(edition){
return edition.bitcoin_id return edition.bitcoin_id;
}) });
}, },
getTitlesString(){ getTitlesString(){
return this.props.editions.map(function(edition){ return this.props.editions.map(function(edition){
return '- \"' + edition.title + ', edition ' + edition.edition_number + '\"\n' return '- \"' + edition.title + ', edition ' + edition.edition_number + '\"\n';
}) });
}, },
render(){ render(){
let alert = null; let alert = null;
if (this.state.errors.length > 0){ if (this.state.errors.length > 0){
alert = this.state.errors.map( alert = this.state.errors.map((error) => {
function(error) { return <AlertDismissable error={error} key={error}/>;
return <AlertDismissable error={error} key={error}/>; });
}.bind(this)
);
} }
return ( return (
<div> <div>
{alert} {alert}
{this.renderForm()} {this.renderForm()}
</div> </div>
) );
} }
}; };

View File

@ -1,12 +1,14 @@
'use strict';
let mapAttr = { let mapAttr = {
link: 'href', link: 'href',
source: 'src' source: 'src'
} };
let mapExt = { let mapExt = {
js: 'source', js: 'source',
css: 'link' css: 'link'
} };
let InjectInHeadMixin = { let InjectInHeadMixin = {
@ -23,9 +25,9 @@ let InjectInHeadMixin = {
}, },
injectTag(tag, src){ injectTag(tag, src){
console.log(this.foobar); if (InjectInHeadMixin.isPresent(tag, src)) {
if (InjectInHeadMixin.isPresent(tag, src))
return; return;
}
let attr = mapAttr[tag]; let attr = mapAttr[tag];
let element = document.createElement(tag); let element = document.createElement(tag);
@ -49,6 +51,8 @@ let InjectInHeadMixin = {
} catch (e) { } catch (e) {
throw new Error(`Cannot inject ${src} in the DOM, cannot guess the tag name from extension ${ext}. Valid extensions are "js" and "css".`); throw new Error(`Cannot inject ${src} in the DOM, cannot guess the tag name from extension ${ext}. Valid extensions are "js" and "css".`);
} }
// ES6Lint says tag is not defined, pls fix
// - Tim
InjectInHeadMixin.injectTag(tag, src); InjectInHeadMixin.injectTag(tag, src);
} }

View File

@ -1,9 +1,10 @@
import React from 'react'; 'use strict';
let ModalMixin = { let ModalMixin = {
onRequestHide(e){ onRequestHide(e){
if (e) if (e) {
e.preventDefault(); e.preventDefault();
}
this.props.onRequestHide(); this.props.onRequestHide();
} }
}; };

View File

@ -1,4 +1,4 @@
import React from 'react'; 'use strict';
import { sumNumList } from '../utils/general_utils'; import { sumNumList } from '../utils/general_utils';
@ -14,7 +14,7 @@ let TableColumnMixin = {
let numOfUsedColumns = sumNumList(listOfRowValues); let numOfUsedColumns = sumNumList(listOfRowValues);
if(numOfUsedColumns > numOfColumns) { if(numOfUsedColumns > numOfColumns) {
throw new Error('This table has only ' + numOfColumns + ' columns to assign. You defined ' + numOfUsedColumns + '. Change this in the columnMap you\'re passing to the table.') throw new Error('This table has only ' + numOfColumns + ' columns to assign. You defined ' + numOfUsedColumns + '. Change this in the columnMap you\'re passing to the table.');
} else { } else {
return bootstrapClasses.join( listOfRowValues[i] + ' ') + listOfRowValues[i]; return bootstrapClasses.join( listOfRowValues[i] + ' ') + listOfRowValues[i];
} }

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import Router from 'react-router'; import Router from 'react-router';
@ -10,11 +12,8 @@ let Route = Router.Route;
let routes = ( let routes = (
<Route name="app" handler={AscribeApp}> <Route name="app" handler={AscribeApp}>
<Route name="pieces" path="/" handler={PieceList}> <Route name="pieces" path="/" handler={PieceList} />
<Route name="edition" path="/editions/:editionId" handler={EditionContainer} />
</Route>
<Route name="edition" path="/editions/:editionId" handler={EditionContainer}>
</Route>
</Route> </Route>
); );

View File

@ -1,3 +1,5 @@
'use strict';
import React from 'react'; import React from 'react';
import alt from '../alt'; import alt from '../alt';
@ -15,7 +17,7 @@ class EditionListStore {
// This uses the index of the new editionList for determining the edition. // This uses the index of the new editionList for determining the edition.
// If the list of editions can be sorted in the future, this needs to be changed! // If the list of editions can be sorted in the future, this needs to be changed!
editionListOfPiece[i] = React.addons.update(edition, {$merge: editionListOfPiece[i]}); editionListOfPiece[i] = React.addons.update(edition, {$merge: editionListOfPiece[i]});
}) });
} }
this.editionList[pieceId] = editionListOfPiece; this.editionList[pieceId] = editionListOfPiece;
@ -26,7 +28,7 @@ class EditionListStore {
* Default values for both are set in the editon_list-actions. * Default values for both are set in the editon_list-actions.
*/ */
this.editionList[pieceId].orderBy = orderBy; this.editionList[pieceId].orderBy = orderBy;
this.editionList[pieceId].orderAsc = orderAsc this.editionList[pieceId].orderAsc = orderAsc;
} }
onSelectEdition({pieceId, editionId}) { onSelectEdition({pieceId, editionId}) {
@ -55,6 +57,6 @@ class EditionListStore {
}); });
}); });
} }
}; }
export default alt.createStore(EditionListStore); export default alt.createStore(EditionListStore);

View File

@ -1,3 +1,5 @@
'use strict';
import alt from '../alt'; import alt from '../alt';
import EditionActions from '../actions/edition_actions'; import EditionActions from '../actions/edition_actions';

View File

@ -1,4 +1,5 @@
import React from 'react'; 'use strict';
import alt from '../alt'; import alt from '../alt';
import PieceListActions from '../actions/piece_list_actions'; import PieceListActions from '../actions/piece_list_actions';
@ -7,7 +8,7 @@ import PieceListActions from '../actions/piece_list_actions';
class PieceListStore { class PieceListStore {
constructor() { constructor() {
/** /**
* The store manages the state that is introduced by fetching * The store manages the state that is introduced by fetching
* the resource with certain parameters. * the resource with certain parameters.
* *
* This means that pieceList for example only contains pageSize-many items. * This means that pieceList for example only contains pageSize-many items.
@ -20,8 +21,8 @@ class PieceListStore {
this.pieceListCount = 0; this.pieceListCount = 0;
this.page = 1; this.page = 1;
this.pageSize = 10; this.pageSize = 10;
this.search = ""; this.search = '';
this.orderBy = "artist_name"; this.orderBy = 'artist_name';
this.orderAsc = true; this.orderAsc = true;
this.bindActions(PieceListActions); this.bindActions(PieceListActions);
} }
@ -58,13 +59,13 @@ class PieceListStore {
* Pagination - Known Issue: * Pagination - Known Issue:
* ######################### * #########################
* *
* *
* The piece list store currently stores the open/close state of a piece list item. * The piece list store currently stores the open/close state of a piece list item.
* *
* Once a new page is requested, this.pieceList will be overwritten, which means that the * Once a new page is requested, this.pieceList will be overwritten, which means that the
* open/close state of a specific list item will be thrown away. * open/close state of a specific list item will be thrown away.
* *
* This means that when opening an editionListTable on a piece, and continuing * This means that when opening an editionListTable on a piece, and continuing
* clicking next or back in the pagination, the editionListTable will return to its * clicking next or back in the pagination, the editionListTable will return to its
* default value, which is "close". * default value, which is "close".
* *
@ -73,6 +74,6 @@ class PieceListStore {
*/ */
this.pieceList = pieceList; this.pieceList = pieceList;
} }
}; }
export default alt.createStore(PieceListStore); export default alt.createStore(PieceListStore);

View File

@ -1,3 +1,5 @@
'use strict';
import alt from '../alt'; import alt from '../alt';
import PieceAction from '../actions/piece_actions'; import PieceAction from '../actions/piece_actions';

View File

@ -1,3 +1,5 @@
'use strict';
import alt from '../alt'; import alt from '../alt';
import UserAction from '../actions/user_actions'; import UserAction from '../actions/user_actions';

View File

@ -1,11 +1,13 @@
'use strict';
import { default as _fetch } from 'isomorphic-fetch'; import { default as _fetch } from 'isomorphic-fetch';
import { argsToQueryParams } from '../utils/fetch_api_utils'; import { argsToQueryParams } from '../utils/fetch_api_utils';
class UrlMapError extends Error {}; class UrlMapError extends Error {}
class ServerError extends Error {}; class ServerError extends Error {}
class APIError extends Error {}; class APIError extends Error {}
class Fetch { class Fetch {
@ -33,7 +35,7 @@ class Fetch {
} }
handleAPIError(json) { handleAPIError(json) {
if (!json['success']) { if (!json.success) {
let error = new APIError(); let error = new APIError();
error.json = json; error.json = json;
throw error; throw error;
@ -58,7 +60,7 @@ class Fetch {
let re = /\${(\w+)}/g; let re = /\${(\w+)}/g;
newUrl = newUrl.replace(re, (match, key) => { newUrl = newUrl.replace(re, (match, key) => {
let val = params[key] let val = params[key];
if (!val) { if (!val) {
throw new Error(`Cannot find param ${key}`); throw new Error(`Cannot find param ${key}`);
} }
@ -76,7 +78,7 @@ class Fetch {
request(verb, url, options) { request(verb, url, options) {
options = options || {}; options = options || {};
let merged = this._merge(this.httpOptions, options); let merged = this._merge(this.httpOptions, options);
merged['method'] = verb; merged.method = verb;
return _fetch(url, merged) return _fetch(url, merged)
.then(this.unpackResponse) .then(this.unpackResponse)
.then(JSON.parse) .then(JSON.parse)
@ -95,8 +97,8 @@ class Fetch {
let newUrl = this.prepareUrl(url, params); let newUrl = this.prepareUrl(url, params);
let body = null; let body = null;
if (params['body']) { if (params.body) {
body = JSON.stringify(params['body']) body = JSON.stringify(params.body);
} }
return this.request('post', url, { body }); return this.request('post', url, { body });
} }

View File

@ -1,3 +1,5 @@
'use strict';
import { sanitize } from './general_utils'; import { sanitize } from './general_utils';
// TODO: Create Unittests that test all functions // TODO: Create Unittests that test all functions
@ -16,7 +18,7 @@ import { sanitize } from './general_utils';
* ?page=1&page_size=10 * ?page=1&page_size=10
* *
* CamelCase gets converted to snake_case! * CamelCase gets converted to snake_case!
* *
*/ */
export function argsToQueryParams(obj) { export function argsToQueryParams(obj) {
@ -38,10 +40,10 @@ export function argsToQueryParams(obj) {
return s + snakeCaseKey + '=' + encodeURIComponent(obj[key]); return s + snakeCaseKey + '=' + encodeURIComponent(obj[key]);
}) })
.join(''); .join('');
}; }
/** /**
* Takes a string and a boolean and generates a string query parameter for * Takes a string and a boolean and generates a string query parameter for
* an API call. * an API call.
*/ */
export function generateOrderingQueryParams(orderBy, orderAsc) { export function generateOrderingQueryParams(orderBy, orderAsc) {
@ -52,11 +54,11 @@ export function generateOrderingQueryParams(orderBy, orderAsc) {
} }
return interpolation + orderBy; return interpolation + orderBy;
}; }
export function status(response) { export function status(response) {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
return response return response;
} }
throw new Error(response.json()) throw new Error(response.json());
}; }

View File

@ -1,3 +1,5 @@
'use strict';
// TODO: Create Unittests that test all functions // TODO: Create Unittests that test all functions
export function sanitize(obj) { export function sanitize(obj) {
@ -12,7 +14,7 @@ export function sanitize(obj) {
}); });
return obj; return obj;
}; }
/** /**
* Returns the values of an object. * Returns the values of an object.
@ -21,7 +23,7 @@ export function valuesOfObject(obj) {
return Object return Object
.keys(obj) .keys(obj)
.map(key => obj[key]); .map(key => obj[key]);
}; }
/** /**
* Sums up a list of numbers. Like a Epsilon-math-kinda-sum... * Sums up a list of numbers. Like a Epsilon-math-kinda-sum...
@ -30,11 +32,14 @@ export function sumNumList(l) {
let sum = 0; let sum = 0;
l.forEach((num) => sum += parseFloat(num) || 0); l.forEach((num) => sum += parseFloat(num) || 0);
return sum; return sum;
}; }
/* /*
Taken from http://stackoverflow.com/a/4795914/1263876 Taken from http://stackoverflow.com/a/4795914/1263876
Behaves like C's format string function Behaves like C's format string function
REFACTOR TO ES6 (let instead of var)
*/ */
export function formatText() { export function formatText() {
var args = arguments, var args = arguments,
@ -60,7 +65,7 @@ export function formatText() {
} }
return val; return val;
}); });
}; }
/** /**
* Takes a list of object and merges their keys to one object. * Takes a list of object and merges their keys to one object.
@ -72,11 +77,11 @@ export function mergeOptions(...l) {
let newObj = {}; let newObj = {};
for(let i = 1; i < l.length; i++) { for(let i = 1; i < l.length; i++) {
newObj = _mergeOptions(newObj, _mergeOptions(l[i-1], l[i])); newObj = _mergeOptions(newObj, _mergeOptions(l[i - 1], l[i]));
} }
return newObj; return newObj;
}; }
/** /**
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1 * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
@ -85,9 +90,9 @@ export function mergeOptions(...l) {
* @returns obj3 a new object based on obj1 and obj2 * @returns obj3 a new object based on obj1 and obj2
* Taken from: http://stackoverflow.com/a/171256/1263876 * Taken from: http://stackoverflow.com/a/171256/1263876
*/ */
function _mergeOptions(obj1,obj2){ function _mergeOptions(obj1, obj2){
var obj3 = {}; let obj3 = {};
for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; } for (let attrname in obj1) { obj3[attrname] = obj1[attrname]; }
for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; } for (let attrname in obj2) { obj3[attrname] = obj2[attrname]; }
return obj3; return obj3;
}; }

View File

@ -1,3 +1,5 @@
'use strict';
import languages from '../constants/languages'; import languages from '../constants/languages';
import { formatText } from './general_utils'; import { formatText } from './general_utils';
@ -27,4 +29,4 @@ export function getLangText(s, ...args) {
} }
} }
}; }