1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

made edition table row selectable

This commit is contained in:
Tim Daubenschütz 2015-07-08 17:35:30 +02:00
parent 1c470203b7
commit bfb40bb19e
6 changed files with 17 additions and 15 deletions

View File

@ -3,7 +3,7 @@
import React from 'react'; import React from 'react';
import Table from '../ascribe_table/table'; import Table from '../ascribe_table/table';
import TableItem from '../ascribe_table/table_item'; import TableItemSelectable from '../ascribe_table/table_item_selectable';
import { ColumnModel } from '../ascribe_table/models/table_models'; import { ColumnModel } from '../ascribe_table/models/table_models';
@ -16,7 +16,8 @@ let AccordionListItemTable = React.createClass({
show: React.PropTypes.bool, show: React.PropTypes.bool,
changeOrder: React.PropTypes.func, changeOrder: React.PropTypes.func,
orderBy: React.PropTypes.string, orderBy: React.PropTypes.string,
orderAsc: React.PropTypes.bool orderAsc: React.PropTypes.bool,
selectItem: React.PropTypes.func
}, },
render() { render() {
@ -32,9 +33,11 @@ let AccordionListItemTable = React.createClass({
orderAsc={this.props.orderAsc}> orderAsc={this.props.orderAsc}>
{this.props.itemList.map((item, i) => { {this.props.itemList.map((item, i) => {
return ( return (
<TableItem <TableItemSelectable
className="ascribe-table-item-selectable" className="ascribe-table-item-selectable"
key={i} /> key={i}
selectItem={this.props.selectItem}
parentId={this.props.parentId}/>
); );
})} })}
</Table> </Table>

View File

@ -202,7 +202,8 @@ let AccordionListItemTableEditions = React.createClass({
show={show} show={show}
orderBy={orderBy} orderBy={orderBy}
orderAsc={orderAsc} orderAsc={orderAsc}
changeOrder={this.changeEditionListOrder} /> changeOrder={this.changeEditionListOrder}
selectItem={this.selectItem}/>
<AccordionListItemTableToggle <AccordionListItemTableToggle
className="ascribe-accordion-list-table-toggle" className="ascribe-accordion-list-table-toggle"
onClick={this.loadFurtherEditions} onClick={this.loadFurtherEditions}

View File

@ -12,12 +12,14 @@ let TableItem = React.createClass({
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,
className: React.PropTypes.string className: React.PropTypes.string,
onClick: React.PropTypes.func
}, },
render() { render() {
return ( return (
<TableItemWrapper <TableItemWrapper
onClick={this.props.onClick}
columnList={this.props.columnList} columnList={this.props.columnList}
columnContent={this.props.columnContent} columnContent={this.props.columnContent}
columnWidth={12} /> columnWidth={12} />

View File

@ -7,18 +7,13 @@ let TableItemCheckbox = React.createClass({
propTypes: { propTypes: {
editionId: React.PropTypes.number, editionId: React.PropTypes.number,
pieceId: React.PropTypes.number, pieceId: React.PropTypes.number,
selectItem: React.PropTypes.func,
selected: React.PropTypes.bool selected: React.PropTypes.bool
}, },
selectItem() {
this.props.selectItem(this.props.pieceId, this.props.editionId);
},
render() { render() {
return ( return (
<span> <span>
<input type="checkbox" onChange={this.selectItem} checked={this.props.selected}/> <input type="checkbox" checked={this.props.selected} readOnly/>
</span> </span>
); );
} }

View File

@ -19,7 +19,7 @@ let TableItemSelectable = React.createClass({
}, },
selectItem() { selectItem() {
this.props.selectItem(this.props.parentId, this.props.columnContent.edition_number); this.props.selectItem(this.props.parentId, this.props.columnContent.id);
}, },
render() { render() {

View File

@ -11,14 +11,15 @@ let TableItemWrapper = React.createClass({
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,
onClick: React.PropTypes.func
}, },
mixins: [Router.Navigation], mixins: [Router.Navigation],
render() { render() {
return ( return (
<tr> <tr onClick={this.props.onClick}>
{this.props.columnList.map((column, i) => { {this.props.columnList.map((column, i) => {
let TypeElement = column.displayType; let TypeElement = column.displayType;