From 6ca28e5fe2547d115fd54ac980a9466869deaade Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 11 Mar 2021 23:23:51 +0100 Subject: footnote editor working --- .../app/views/dashboard/dashboard.container.js | 4 +- .../editor/footnotes/components/footnote.form.js | 78 +++++++++++++++++++++- .../app/views/editor/footnotes/footnotes.css | 37 ++++++++-- 3 files changed, 112 insertions(+), 7 deletions(-) (limited to 'animism-align/frontend') diff --git a/animism-align/frontend/app/views/dashboard/dashboard.container.js b/animism-align/frontend/app/views/dashboard/dashboard.container.js index 0d4da43..2f270b3 100644 --- a/animism-align/frontend/app/views/dashboard/dashboard.container.js +++ b/animism-align/frontend/app/views/dashboard/dashboard.container.js @@ -89,10 +89,12 @@ class DashboardContainer extends Component { {episode.is_live && {"(published)"}}
- Viewer + Overview Timeline Transcript + Footnotes Settings + Watch
diff --git a/animism-align/frontend/app/views/editor/footnotes/components/footnote.form.js b/animism-align/frontend/app/views/editor/footnotes/components/footnote.form.js index 3cd909d..525eb46 100644 --- a/animism-align/frontend/app/views/editor/footnotes/components/footnote.form.js +++ b/animism-align/frontend/app/views/editor/footnotes/components/footnote.form.js @@ -1,14 +1,88 @@ import React, { Component } from 'react' +import { TextArea, Button } from 'app/common' +import actions from 'app/actions' + export default class FootnoteForm extends Component { state = { editing: false, + footnote: {}, + } + + constructor(props) { + super(props) + this.edit = this.edit.bind(this) + this.handleChange = this.handleChange.bind(this) + this.handleSubmit = this.handleSubmit.bind(this) + this.handleCancel = this.handleCancel.bind(this) + } + + componentDidMount() { + this.setState({ footnote: { ...this.props.footnote } }) + } + + edit() { + this.setState({ editing: true }) + } + + handleChange(e){ + e.preventDefault() + this.setState({ + footnote: { + ...this.state.footnote, + text: e.target.value, + } + }) + } + + handleSubmit(e) { + e.preventDefault() + actions.annotation.update(this.state.footnote) + this.setState({ editing: false }) + } + + handleCancel(e) { + e.preventDefault() + this.setState({ + editing: false, + footnote: { ...this.props.footnote } + }) } render() { - const { footnote, index } = this.props + return this.state.editing + ? this.renderForm() + : this.renderEntry() + } + + renderForm() { + const { index } = this.props + const { footnote } = this.state + return ( +
+