Commit 06a97767 authored by Yannis Barlas's avatar Yannis Barlas

Merge branch '123-mutliple-tab-clicking' into 'master'

Resolve "Mutliple tab clicking"

Closes #123

See merge request !125
parents fb61ae15 a8f7e87e
Pipeline #4925 passed with stages
in 2 minutes and 11 seconds
......@@ -137,5 +137,6 @@ export default compose(
form: 'decision',
onChange: debounce(onChange, 1000, { maxWait: 5000 }),
onSubmit,
destroyOnUnmount: false,
}),
)(DecisionLayout)
......@@ -30,10 +30,8 @@ const DecisionLayout = ({
versions.forEach(version => {
// TODO: allow multiple decisions, e.g. appeals
const { decision } = version
if (decision && decision.submitted) {
const submittedMoment = moment(decision.submitted)
const key = submittedMoment.format('x')
const label = submittedMoment.format('YYYY-MM-DD')
decisionSections.push({
......@@ -44,7 +42,7 @@ const DecisionLayout = ({
<Decision decision={decision} />
</div>
),
key,
key: version.id,
label,
})
......@@ -53,12 +51,12 @@ const DecisionLayout = ({
<SimpleEditor
content={version.source}
editing="selection"
key={key}
key={version.id}
layout="bare"
readOnly
/>
),
key,
key: version.id,
label,
})
}
......@@ -68,7 +66,6 @@ const DecisionLayout = ({
if (currentVersion.submitted && (!decision || !decision.submitted)) {
const submittedMoment = moment()
const key = submittedMoment.format('x')
const label = submittedMoment.format('YYYY-MM-DD')
decisionSections.push({
content: (
......@@ -90,7 +87,7 @@ const DecisionLayout = ({
/>
</div>
),
key,
key: currentVersion.id,
label,
})
......@@ -99,12 +96,12 @@ const DecisionLayout = ({
<SimpleEditor
content={currentVersion.source}
editing="selection"
key={key}
key={currentVersion.id}
layout="bare"
readOnly
/>
),
key,
key: currentVersion.id,
label,
})
}
......@@ -118,7 +115,6 @@ const DecisionLayout = ({
title="Versions"
/>
</div>
<div className={classes.column}>
<Tabs
activeKey={decisionSections[decisionSections.length - 1].key}
......
......@@ -18,14 +18,6 @@ class Tabs extends React.Component {
this.setState({ activeKey })
}
componentWillReceiveProps(nextProps) {
const { activeKey } = nextProps
if (activeKey !== this.props.activeKey) {
this.setState({ activeKey })
}
}
setActiveKey(activeKey) {
this.setState({ activeKey })
}
......
......@@ -14,18 +14,18 @@ const parser = schema => {
}
class HtmlViewer extends React.Component {
componentWillMount() {
const { value, options } = this.props
changeContentValue(value) {
const { options } = this.props
const { schema } = options
const parse = parser(schema)
options.doc = parse(value)
return parse(value)
}
render() {
const { options, className } = this.props
const { options, className, value } = this.props
options.doc = this.changeContentValue(value)
return <Viewer className={className} options={options} />
}
}
......
......@@ -14,6 +14,11 @@ class Viewer extends React.Component {
}
}
componentDidUpdate(props) {
const newState = EditorState.create(props.options)
this.view.updateState(newState)
}
createEditorView = node => {
const { className } = this.props
const { state } = this.state
......
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