+
-
+
{this.props.content.title}
{getLangText('by %s', this.props.content.artist_name)}
+ {this.props.content.date_created.split('-')[0]}
diff --git a/js/components/ascribe_accordion_list/accordion_list_item_table.js b/js/components/ascribe_accordion_list/accordion_list_item_table.js
index 1cf410df..4ead1eeb 100644
--- a/js/components/ascribe_accordion_list/accordion_list_item_table.js
+++ b/js/components/ascribe_accordion_list/accordion_list_item_table.js
@@ -1,20 +1,23 @@
+'use strict';
+
import React from 'react';
import Table from '../ascribe_table/table';
import TableItem from '../ascribe_table/table_item';
-import TableColumnContentModel from '../../models/table_column_content_model';
-
-import { getLangText } from '../../utils/lang_utils';
+import { ColumnModel } from '../ascribe_table/models/table_models';
let AccordionListItemTable = React.createClass({
propTypes: {
className: React.PropTypes.string,
parentId: React.PropTypes.number,
itemList: React.PropTypes.array,
- columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)),
+ columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(ColumnModel)),
numOfTableItems: React.PropTypes.number,
- show: React.PropTypes.bool
+ show: React.PropTypes.bool,
+ changeOrder: React.PropTypes.func,
+ orderBy: React.PropTypes.string,
+ orderAsc: React.PropTypes.bool
},
render() {
@@ -22,14 +25,17 @@ let AccordionListItemTable = React.createClass({
return (
+ className="ascribe-table"
+ columnList={this.props.columnList}
+ itemList={this.props.itemList}
+ changeOrder={this.props.changeOrder}
+ orderBy={this.props.orderBy}
+ orderAsc={this.props.orderAsc}>
{this.props.itemList.map((item, i) => {
return (
-
+ key={i} />
);
})}
diff --git a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js
index 1d8daa45..c975500e 100644
--- a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js
+++ b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js
@@ -1,22 +1,26 @@
+'use strict';
+
import React from 'react';
+import Router from 'react-router';
import EditionListStore from '../../stores/edition_list_store';
import EditionListActions from '../../actions/edition_list_actions';
-import PieceListStore from '../../stores/piece_list_store';
import PieceListActions from '../../actions/piece_list_actions';
import AccordionListItemTable from './accordion_list_item_table';
import AccordionListItemTableToggle from './accordion_list_item_table_toggle';
+import AccordionListItemTableSelectAllEditionsToggle from './accordion_list_item_table_select_all_editions_toggle';
-import TableColumnContentModel from '../../models/table_column_content_model';
+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 TableItemCheckbox from '../ascribe_table/table_item_checkbox';
import TableItemAclFiltered from '../ascribe_table/table_item_acl_filtered';
import { getLangText } from '../../utils/lang_utils';
+let Link = Router.Link;
+
let AccordionListItemTableEditions = React.createClass({
propTypes: {
@@ -30,33 +34,116 @@ let AccordionListItemTableEditions = React.createClass({
return EditionListStore.getState();
},
- onChange(state) {
- this.setState(state);
- },
-
componentDidMount() {
EditionListStore.listen(this.onChange);
},
- componentDidUnmount() {
+ componentWillUnmount() {
EditionListStore.unlisten(this.onChange);
},
+ onChange(state) {
+ this.setState(state);
+ },
+
selectItem(pieceId, editionId) {
EditionListActions.selectEdition({pieceId, editionId});
},
+ selectAllItems() {
+ this.state.editionList[this.props.parentId]
+ .forEach((edition) => {
+ this.selectItem(this.props.parentId, edition.id);
+ });
+ },
+
+ filterSelectedEditions() {
+ let selectedEditions = this.state.editionList[this.props.parentId]
+ .filter((edition) => edition.selected);
+ return selectedEditions;
+ },
+
toggleTable() {
PieceListActions.showEditionList(this.props.parentId);
EditionListActions.fetchEditionList(this.props.parentId);
},
+ changeEditionListOrder(orderBy, orderAsc) {
+ EditionListActions.fetchEditionList(this.props.parentId, orderBy, orderAsc);
+ },
+
render() {
+ let selectedEditionsCount = 0;
+ let allEditionsCount = 0;
+ let orderBy;
+ let orderAsc;
+
+ // here we need to check if all editions of a specific
+ // piece are already defined. Otherwise .length will throw an error and we'll not
+ // be notified about it.
+ if(this.state.editionList[this.props.parentId]) {
+ selectedEditionsCount = this.filterSelectedEditions().length;
+ allEditionsCount = this.state.editionList[this.props.parentId].length;
+ orderBy = this.state.editionList[this.props.parentId].orderBy;
+ orderAsc = this.state.editionList[this.props.parentId].orderAsc;
+ }
+
+ let transition = new TransitionModel('edition', 'editionId', 'bitcoin_id', PieceListActions.closeAllEditionLists);
+
let columnList = [
- new TableColumnContentModel((item) => { return { 'editionId': item.id, 'pieceId': this.props.parentId, 'selectItem': this.selectItem, 'selected': item.selected }}, '', '', TableItemCheckbox, 1, false),
- new TableColumnContentModel((item) => { return { 'content': item.edition_number }}, 'num_editions', '#', TableItemText, 1, false),
- new TableColumnContentModel((item) => { return { 'content': item.bitcoin_id }}, 'bitcoin_id', getLangText('Bitcoin Address'), TableItemText, 5, false),
- new TableColumnContentModel((item) => { return { 'content': item.acl }}, 'acl', getLangText('Actions'), TableItemAclFiltered, 4, false)
+ new ColumnModel(
+ (item) => {
+ return {
+ 'editionId': item.id,
+ 'pieceId': this.props.parentId,
+ 'selectItem': this.selectItem,
+ 'selected': item.selected
+ }; },
+ '',
+
,
+ TableItemCheckbox,
+ 1,
+ false
+ ),
+ new ColumnModel(
+ (item) => {
+ return {
+ 'content': item.edition_number
+ }; },
+ 'edition_number',
+ '#',
+ TableItemText,
+ 1,
+ true,
+ transition
+ ),
+ new ColumnModel(
+ (item) => {
+ return {
+ 'content': item.bitcoin_id
+ }; },
+ 'bitcoin_id',
+ getLangText('Bitcoin Address'),
+ TableItemText,
+ 5,
+ true,
+ transition
+ ),
+ new ColumnModel(
+ (item) => {
+ return {
+ 'content': item.acl
+ }; },
+ 'acl',
+ getLangText('Actions'),
+ TableItemAclFiltered,
+ 4,
+ false,
+ transition
+ )
];
return (
@@ -67,9 +154,12 @@ let AccordionListItemTableEditions = React.createClass({
itemList={this.state.editionList[this.props.parentId]}
columnList={columnList}
numOfTableItems={this.props.numOfEditions}
- show={this.props.show}>
+ show={this.props.show}
+ orderBy={orderBy}
+ orderAsc={orderAsc}
+ changeOrder={this.changeEditionListOrder}>
diff --git a/js/components/ascribe_accordion_list/accordion_list_item_table_select_all_editions_toggle.js b/js/components/ascribe_accordion_list/accordion_list_item_table_select_all_editions_toggle.js
new file mode 100644
index 00000000..0fe71c35
--- /dev/null
+++ b/js/components/ascribe_accordion_list/accordion_list_item_table_select_all_editions_toggle.js
@@ -0,0 +1,23 @@
+'use strict';
+
+import React from 'react';
+
+
+let AccordionListItemTableSelectAllEditionsToggle = React.createClass({
+
+ propTypes: {
+ onChange: React.PropTypes.func.isRequired,
+ numOfSelectedEditions: React.PropTypes.number.isRequired,
+ numOfAllEditions: React.PropTypes.number.isRequired
+ },
+
+ render() {
+ return (
+
+ );
+ }
+});
+
+export default AccordionListItemTableSelectAllEditionsToggle;
\ No newline at end of file
diff --git a/js/components/ascribe_accordion_list/accordion_list_item_table_toggle.js b/js/components/ascribe_accordion_list/accordion_list_item_table_toggle.js
index a3431b04..1f05de4b 100644
--- a/js/components/ascribe_accordion_list/accordion_list_item_table_toggle.js
+++ b/js/components/ascribe_accordion_list/accordion_list_item_table_toggle.js
@@ -1,3 +1,5 @@
+'use strict';
+
import React from 'react';
let AccordionListItemTableToggle = React.createClass({
@@ -10,7 +12,7 @@ let AccordionListItemTableToggle = React.createClass({
render() {
return (
-
{this.props.show ? 'Hide all ' + this.props.numOfTableItems + ' Editions' : 'Show all ' + this.props.numOfTableItems + ' Editions'}
diff --git a/js/components/ascribe_app.js b/js/components/ascribe_app.js
index bab7de97..6484976c 100644
--- a/js/components/ascribe_app.js
+++ b/js/components/ascribe_app.js
@@ -1,3 +1,5 @@
+'use strict';
+
import React from 'react';
import Router from 'react-router';
import Header from '../components/header';
@@ -12,7 +14,7 @@ let AscribeApp = React.createClass({
-
+
);
}
});
diff --git a/js/components/ascribe_buttons/acl_button.js b/js/components/ascribe_buttons/acl_button.js
index cd9d739d..518a80d6 100644
--- a/js/components/ascribe_buttons/acl_button.js
+++ b/js/components/ascribe_buttons/acl_button.js
@@ -1,3 +1,5 @@
+'use strict';
+
import React from 'react';
import ConsignForm from '../ascribe_forms/form_consign';
@@ -17,31 +19,33 @@ let AclButton = React.createClass({
},
actionProperties(){
- if (this.props.action == 'consign'){
+ if (this.props.action === 'consign'){
return {
- title: "Consign artwork",
- tooltip: "Have someone else sell the artwork",
+ title: 'Consign artwork',
+ tooltip: 'Have someone else sell the artwork',
form:
- }
+ };
}
- else if (this.props.action == 'transfer') {
+ else if (this.props.action === 'transfer') {
return {
- title: "Transfer artwork",
- tooltip: "Transfer the ownership of the artwork",
+ title: 'Transfer artwork',
+ tooltip: 'Transfer the ownership of the artwork',
form:
- }
+ };
}
- else if (this.props.action == 'loan'){
+ else if (this.props.action === 'loan'){
return {
- title: "Loan artwork",
- tooltip: "Loan your artwork for a limited period of time",
- form:
}
+ title: 'Loan artwork',
+ tooltip: 'Loan your artwork for a limited period of time',
+ form:
+ };
}
- else if (this.props.action == 'share'){
+ else if (this.props.action === 'share'){
return {
- title: "Share artwork",
- tooltip: "Share the artwork",
- form:
}
+ title: 'Share artwork',
+ tooltip: 'Share the artwork',
+ form:
+ };
}
},
render() {
diff --git a/js/components/ascribe_buttons/button_submit_close.js b/js/components/ascribe_buttons/button_submit_close.js
index 377c74c9..094e3c40 100644
--- a/js/components/ascribe_buttons/button_submit_close.js
+++ b/js/components/ascribe_buttons/button_submit_close.js
@@ -1,5 +1,13 @@
+'use strict';
+
import React from 'react';
+
+/*
+ Is this even used somewhere?
+ Deprecate? 5.6.15 - Tim
+
+ */
let ButtonSubmitOrClose = React.createClass({
render() {
if (this.props.submitted){
@@ -14,7 +22,7 @@ let ButtonSubmitOrClose = React.createClass({
{this.props.text}
CLOSE
- )
+ );
}
});
diff --git a/js/components/ascribe_forms/alert.js b/js/components/ascribe_forms/alert.js
index 482afdfe..4d5bae64 100644
--- a/js/components/ascribe_forms/alert.js
+++ b/js/components/ascribe_forms/alert.js
@@ -1,3 +1,5 @@
+'use strict';
+
import React from 'react';
import Alert from 'react-bootstrap/lib/Alert';
@@ -7,12 +9,15 @@ let AlertDismissable = React.createClass({
alertVisible: true
};
},
+
show() {
this.setState({alertVisible: true});
},
+
hide() {
this.setState({alertVisible: false});
},
+
render() {
if (this.state.alertVisible) {
let key = this.props.error;
diff --git a/js/components/ascribe_forms/form_consign.js b/js/components/ascribe_forms/form_consign.js
index e8d8e099..0137e4a0 100644
--- a/js/components/ascribe_forms/form_consign.js
+++ b/js/components/ascribe_forms/form_consign.js
@@ -1,4 +1,4 @@
-import fetch from 'isomorphic-fetch';
+'use strict';
import React from 'react';
@@ -12,19 +12,20 @@ let ConsignForm = React.createClass({
mixins: [FormMixin],
url() {
- return ApiUrls.ownership_consigns
+ return ApiUrls.ownership_consigns;
},
+
getFormData() {
return {
bitcoin_id: this.getBitcoinIds().join(),
consignee: this.refs.consignee.state.value,
consign_message: this.refs.consign_message.state.value,
password: this.refs.password.state.value
- }
+ };
},
renderForm() {
- let title = this.getTitlesString().join("");
+ let title = this.getTitlesString().join('');
let username = this.props.currentUser.username;
let message =
`Hi,
diff --git a/js/components/ascribe_forms/form_loan.js b/js/components/ascribe_forms/form_loan.js
index 12127563..c5269214 100644
--- a/js/components/ascribe_forms/form_loan.js
+++ b/js/components/ascribe_forms/form_loan.js
@@ -1,4 +1,4 @@
-import fetch from 'isomorphic-fetch';
+'use strict';
import React from 'react';
@@ -9,20 +9,26 @@ import InputHidden from './input_hidden';
import InputCheckbox from './input_checkbox';
import InputDate from './input_date';
import InputTextArea from './input_textarea';
-import OwnershipFetcher from '../../fetchers/ownership_fetcher'
-import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close';
+
+import OwnershipFetcher from '../../fetchers/ownership_fetcher';
+import ButtonSubmitOrClose from './button_submit_close';
let LoanForm = React.createClass({
+
+ getInitialState() {
+ this.setState({
+ contract_key: null,
+ contract_url: null,
+ loaneeHasContract: false
+ });
+ },
+
mixins: [FormMixin],
url() {
- return ApiUrls.ownership_loans
- },
- componentDidMount(){
- this.setState({contract_key: null,
- contract_url: null,
- loaneeHasContract: false});
+ return ApiUrls.ownership_loans;
},
+
getFormData() {
return {
bitcoin_id: this.getBitcoinIds().join(),
@@ -33,15 +39,18 @@ let LoanForm = React.createClass({
loan_message: this.refs.loan_message.state.value,
password: this.refs.password.state.value,
terms: this.refs.terms.state.value
- }
+ };
},
- handleLoanEmailBlur(e){
+
+ handleLoanEmailBlur(){
OwnershipFetcher.fetchLoanContract(this.refs.loanee.state.value)
.then((res) => {
if (res && res.length > 0) {
- this.setState({contract_key: res[0].s3Key,
- contract_url: res[0].s3Url,
- loaneeHasContract: true});
+ this.setState({
+ contract_key: res[0].s3Key,
+ contract_url: res[0].s3Url,
+ loaneeHasContract: true
+ });
}
else{
this.resetLoanContract();
@@ -52,14 +61,16 @@ let LoanForm = React.createClass({
this.resetLoanContract();
});
},
+
resetLoanContract(){
this.setState({contract_key: null,
contract_url: null,
loaneeHasContract: false
});
},
+
renderForm() {
- let title = this.getTitlesString().join("");
+ let title = this.getTitlesString().join('');
let username = this.props.currentUser.username;
let message =
`Hi,
@@ -72,18 +83,19 @@ ${username}`;
let contract =
- )
+ );
}
});
diff --git a/js/components/ascribe_modal/modal_share.js b/js/components/ascribe_modal/modal_share.js
index 4ada244c..2cce53ad 100644
--- a/js/components/ascribe_modal/modal_share.js
+++ b/js/components/ascribe_modal/modal_share.js
@@ -1,13 +1,13 @@
+'use strict';
+
import React from 'react';
import Modal from 'react-bootstrap/lib/Modal';
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
import ModalTrigger from 'react-bootstrap/lib/ModalTrigger';
import Tooltip from 'react-bootstrap/lib/Tooltip';
-import ModalMixin from '../../mixins/modal_mixin'
-
-
-import ShareForm from '../ascribe_forms/form_share_email'
+import ModalMixin from '../../mixins/modal_mixin';
+import ShareForm from '../ascribe_forms/form_share_email';
let ShareModalButton = React.createClass({
render() {
@@ -20,12 +20,12 @@ let ShareModalButton = React.createClass({