Commit 1ffd5d3b authored by hh1966's avatar hh1966
Browse files

Fix table resize in research plan detail

parent e4404877
......@@ -27,7 +27,8 @@ export default class ResearchPlanDetails extends Component {
const { research_plan } = props;
this.state = {
research_plan,
edit: true
edit: true,
update: false
};
}
......@@ -36,6 +37,13 @@ export default class ResearchPlanDetails extends Component {
this.setState({ research_plan });
}
toggleFullScreen() {
this.props.toggleFullScreen()
// toogle update prop to notify react data grid for view change
this.setState({ update: !this.state.update })
}
// handle functions
handleSubmit() {
......@@ -185,8 +193,9 @@ export default class ResearchPlanDetails extends Component {
}
renderPropertiesTab(research_plan) {
let { name, body, attachments } = research_plan;
let submitLabel = research_plan.isNew ? "Create" : "Save";
const { name, body, attachments } = research_plan
const { update } = this.state
const submitLabel = research_plan.isNew ? "Create" : "Save"
return (
<ListGroup fill="true">
......@@ -200,7 +209,8 @@ export default class ResearchPlanDetails extends Component {
onChange={this.handleBodyChange.bind(this)}
onDrop={this.handleBodyDrop.bind(this)}
onAdd={this.handleBodyAdd.bind(this)}
onDelete={this.handleBodyDelete.bind(this)} />
onDelete={this.handleBodyDelete.bind(this)}
update={update} />
<ResearchPlanDetailsAttachments attachments={attachments}
onDrop={this.handleAttachmentDrop.bind(this)}
......@@ -260,7 +270,7 @@ export default class ResearchPlanDetails extends Component {
overlay={<Tooltip id="fullSample">Fullresearch_plan</Tooltip>}>
<Button bsStyle="info" bsSize="xsmall" className="button-right"
onClick={() => this.props.toggleFullScreen()}>
onClick={this.toggleFullScreen.bind(this)}>
<i className="fa fa-expand"></i>
</Button>
</OverlayTrigger>
......
......@@ -9,14 +9,15 @@ import Field from './ResearchPlanDetailsField'
export default class ResearchPlanDetailsBody extends Component {
render() {
let { body, disabled, onChange, onDrop, onAdd, onDelete } = this.props
let { body, disabled, onChange, onDrop, onAdd, onDelete, update } = this.props
let fields = body.map((field, index) => {
return <Field key={field.id}
field={field} index={index} disabled={disabled}
onChange={onChange.bind(this)}
onDrop={onDrop.bind(this)}
onDelete={onDelete.bind(this)} />
onDelete={onDelete.bind(this)}
update={update} />
})
return (
......@@ -43,4 +44,5 @@ ResearchPlanDetailsBody.propTypes = {
disabled: PropTypes.bool,
onChange: PropTypes.func,
onDrop: PropTypes.func,
update: PropTypes.bool
}
......@@ -13,7 +13,7 @@ import ResearchPlanDetailsFieldTable from './ResearchPlanDetailsFieldTable'
export default class ResearchPlanDetailsField extends Component {
render() {
let { field, index, disabled, onChange, onDrop, onDelete } = this.props
let { field, index, disabled, onChange, onDrop, onDelete, update } = this.props
let label, component
switch (field.type) {
......@@ -39,7 +39,7 @@ export default class ResearchPlanDetailsField extends Component {
label = 'Table'
component = <ResearchPlanDetailsFieldTable key={field.id}
field={field} index={index} disabled={disabled}
onChange={onChange.bind(this)} />
onChange={onChange.bind(this)} update={update} />
break;
}
......@@ -71,4 +71,5 @@ ResearchPlanDetailsField.propTypes = {
disabled: PropTypes.bool,
onChange: PropTypes.func,
onDrop: PropTypes.func,
update: PropTypes.bool
}
......@@ -19,6 +19,7 @@ export default class ResearchPlanDetailsFieldTable extends Component {
constructor(props) {
super(props);
this.state = {
update: this.props.update,
showModal: '',
idx: null
}
......@@ -40,6 +41,12 @@ export default class ResearchPlanDetailsFieldTable extends Component {
}
}
componentDidUpdate() {
if (this.state.update != this.props.update) {
this.setState({ update: this.props.update })
}
}
buildRow() {
return []
}
......@@ -247,4 +254,5 @@ ResearchPlanDetailsFieldTable.propTypes = {
index: PropTypes.number,
disabled: PropTypes.bool,
onChange: PropTypes.func,
update: PropTypes.bool
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment