From 786404a8a692448b04fd8df5dbca8013631a0abd Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 9 Mar 2021 17:50:09 +0100 Subject: adding episodes to projects --- animism-align/frontend/app/views/auth/auth.gate.js | 1 + .../app/views/dashboard/dashboard.container.js | 127 +++++++++++++++++++++ .../frontend/app/views/dashboard/dashboard.css | 52 +++++++++ .../app/views/episode/components/episode.form.js | 48 ++++++-- .../app/views/episode/components/episode.menu.js | 6 +- .../app/views/episode/containers/episode.edit.js | 20 +++- .../app/views/episode/containers/episode.new.js | 24 +++- .../app/views/episode/episode.container.js | 6 +- .../frontend/app/views/episode/episode.css | 6 + .../frontend/app/views/nav/header.component.js | 25 ++-- animism-align/frontend/app/views/nav/nav.css | 7 +- .../app/views/project/components/project.form.js | 7 +- .../app/views/project/components/project.menu.js | 6 +- .../app/views/project/containers/project.edit.js | 2 +- .../app/views/project/containers/project.new.js | 2 +- .../app/views/project/project.container.js | 2 + .../frontend/app/views/site/site.actions.js | 1 + 17 files changed, 308 insertions(+), 34 deletions(-) create mode 100644 animism-align/frontend/app/views/dashboard/dashboard.container.js create mode 100644 animism-align/frontend/app/views/dashboard/dashboard.css (limited to 'animism-align/frontend/app/views') diff --git a/animism-align/frontend/app/views/auth/auth.gate.js b/animism-align/frontend/app/views/auth/auth.gate.js index e07316e..5e759a6 100644 --- a/animism-align/frontend/app/views/auth/auth.gate.js +++ b/animism-align/frontend/app/views/auth/auth.gate.js @@ -21,6 +21,7 @@ class AuthGate extends Component { load() { if (!this.props.user.id) return + this.props.onAuthenticate() } render() { diff --git a/animism-align/frontend/app/views/dashboard/dashboard.container.js b/animism-align/frontend/app/views/dashboard/dashboard.container.js new file mode 100644 index 0000000..6befaae --- /dev/null +++ b/animism-align/frontend/app/views/dashboard/dashboard.container.js @@ -0,0 +1,127 @@ +import React, { Component } from 'react' +import { connect } from 'react-redux' +import { Link } from 'react-router-dom' + +import './dashboard.css' + +// import actions from 'app/actions' +import { Loader } from 'app/common' +import { groupResponseBy } from 'app/utils/api.utils' + +class DashboardContainer extends Component { + state = { + ready: false, + episodes: {}, + venues: {}, + } + + constructor(props) { + super(props) + } + + componentDidMount() { + this.build() + } + + componentDidUpdate(prevProps) { + if ( + !this.state.ready || + (this.props.project !== prevProps.project) || + (this.props.episode !== prevProps.episode) || + (this.props.venue !== prevProps.venue) + ) { + this.build() + } + } + + build() { + if (this.props.loading) return + const episodes = groupResponseBy(this.props.episodes, 'project_id') + const venues = groupResponseBy(this.props.venues, 'project_id') + this.setState({ ready: true, episodes, venues }) + } + + render() { + const { loading, projects } = this.props + const { episodes, venues, ready } = this.state + if (loading || !ready) { + return ( +
+ +
+ ) + } + return ( +
+
+
+
+

Projects

+
+
+ + Add Project +
+
+
+ {projects.order.map((project_id) => { + const project = projects.lookup[project_id] + console.log(project) + return ( +
+
+
+

{project.title}

+ {project.is_live && {"(published)"}} +
+
+ + Add Episode + Venues + Settings +
+
+ {(episodes[project.id] || []).map(episode => ( +
+
+
+ + {'Episode #' + episode.episode_number} + + {episode.is_live && {"(published)"}} +
+
+ Viewer + Timeline + Transcript + Settings +
+
+
+
+ {episode.title} +
+
+
+ ))} +
+ ) + })} +
+ ) + } +} + +const mapStateToProps = state => ({ + loading: ( + !state.project.index.lookup || + !state.episode.index.lookup || + !state.venue.index.lookup || + state.project.index.loading || + state.episode.index.loading || + state.venue.index.loading + ), + projects: state.project.index, + episodes: state.episode.index, + venues: state.venue.index, +}) + +export default connect(mapStateToProps)(DashboardContainer) diff --git a/animism-align/frontend/app/views/dashboard/dashboard.css b/animism-align/frontend/app/views/dashboard/dashboard.css new file mode 100644 index 0000000..34bcb66 --- /dev/null +++ b/animism-align/frontend/app/views/dashboard/dashboard.css @@ -0,0 +1,52 @@ +.dashboard { + padding: 1.5rem; +} + +.project-top { + padding: 1rem; +} +.project-top h1 { + margin: 0; +} + +.dashboard .project-entry { + padding: 1rem; + margin: 0 0 1rem 0; + background: #111; +} + +.dashboard .episode-entry { + margin-bottom: 0.5rem; +} +.dashboard .project-entry .row.project-heading { + margin-bottom: 1rem; +} +.dashboard h2 { + display: inline-block; + margin: 0; +} +.dashboard .title { + width: 25rem; + color: #fff; + text-overflow: ellipsis; + white-space: pre; + overflow: hidden; +} +.dashboard .row { + margin-bottom: 0.25rem; + align-items: center; +} +.dashboard .links a { + margin-right: 0.5rem; + text-decoration: none; +} +.dashboard .links a:hover { + text-decoration: underline; +} +.dashboard .published { + color: #888; + margin-left: 0.5rem; +} +.dashboard i { + color: #bbb; +} \ No newline at end of file diff --git a/animism-align/frontend/app/views/episode/components/episode.form.js b/animism-align/frontend/app/views/episode/components/episode.form.js index 63d55e7..c60d3b2 100644 --- a/animism-align/frontend/app/views/episode/components/episode.form.js +++ b/animism-align/frontend/app/views/episode/components/episode.form.js @@ -20,6 +20,7 @@ const newEpisode = () => ({ export default class EpisodeForm extends Component { state = { + project_id: 0, title: "", submitTitle: "", data: { ...newEpisode() }, @@ -37,8 +38,10 @@ export default class EpisodeForm extends Component { } componentDidMount() { - const { data, isNew } = this.props - const title = isNew ? 'New episode' : 'Editing ' + data.title + const { data, isNew, project } = this.props + const title = isNew + ? 'Add episode to project ' + project.title + : 'Editing Episode ' + data.episode_number + ": " + data.title const submitTitle = isNew ? "Add Episode" : "Save Changes" this.setState({ title, @@ -112,8 +115,8 @@ export default class EpisodeForm extends Component { } const { isNew, onSubmit } = this.props const { data } = this.state - const requiredKeys = "episode_number release_date".split(" ") - const validKeys = "title episode_number release_date is_live settings".split(" ") + const requiredKeys = "project_id episode_number release_date".split(" ") + const validKeys = "project_id title episode_number release_date is_live settings".split(" ") const validData = validKeys.reduce((a,b) => { a[b] = data[b]; return a }, {}) if (!data.title) { data.title = "TBD" @@ -141,10 +144,8 @@ export default class EpisodeForm extends Component {

{title}

- +

Episode information

+ +

Build configuration

+ + + +