diff --git a/class/Controller/Show/Admin.php b/class/Controller/Show/Admin.php index 5fdf3fd..cf6c4d8 100644 --- a/class/Controller/Show/Admin.php +++ b/class/Controller/Show/Admin.php @@ -46,6 +46,8 @@ public function postCommand(Request $request) protected function listHtmlCommand(Request $request) { + $script = $this->factory->scriptView('shows'); + \Layout::addJSHeader($script); $this->createShowButton(); return $this->factory->scriptView('shows'); } diff --git a/javascript/Show/ShowCard.jsx b/javascript/Show/ShowCard.jsx index 671699a..b956d59 100644 --- a/javascript/Show/ShowCard.jsx +++ b/javascript/Show/ShowCard.jsx @@ -1,38 +1,69 @@ import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Card, CardBody, CardTitle, CardImg, Button } from 'reactstrap' export default class ShowCard extends Component { constructor() { + super() this.state = { show: { - id: 0, title: null, img: null, } } - this.loadShow = this.loadShow.bind(this) + this.view = this.view.bind(this) + this.edit = this.edit.bind(this) + } + + componentDidMount() { + this.loadShow(this.props.id) } /** * Loads the details fome the back end - see Show.php */ loadShow(id) { - $.getJSON('./slideshow/show/admin/getDetails', {show_id: id}).done(function (data) { - this.setState({show: data}) - }.bind(this)) + if (id != -1) { + $.getJSON('./slideshow/show/admin/getDetails', {show_id: id}).done(function (data) { + this.setState({show: data}) + }.bind(this)) + } + else { + this.setState({ + show: { + title: "Test Show", + img: "https://placeholdit.imgix.net/~text?txtsize=33&txt=318%C3%97180&w=318&h=180" + } + }) + } + } + + view() { + + } + + edit() { + } render() { - const id = this.props.id return ( -
- -
-
{this.state.show.title}
- View - Edit -
+
+ + + + {this.state.show.title} + + + +
) } + +} + +ShowCard.propTypes = { + id: PropTypes.number } diff --git a/javascript/Show/ShowList.jsx b/javascript/Show/ShowList.jsx index b66df44..257d2d1 100644 --- a/javascript/Show/ShowList.jsx +++ b/javascript/Show/ShowList.jsx @@ -1,24 +1,29 @@ import React, {Component} from 'react' -export default class ShowList extends Component{ +export default class ShowList extends Component { constructor() { super() this.state = { - showsList: getShows() } this.getShows = this.getShows.bind(this) + this.pullShows = this.pullShows.bind(this) } - getShows() { + /** + * Pulls all the shows from the back-end + */ + pullShows() { let shows + $.get() + return new array() + } - if (this.props.shows === null || this.props.shows.length === 0) { - cards = (
-
Add a Show:
- New Show -
) + getShows() { + let shows = pullShows() + if (shows === null) { + // Add a way to handle this or not. } else { - cards = this.props.shows.map(function (id) { + cards = shows.map(function (id) { return }.bind(this)) } @@ -33,7 +38,7 @@ export default class ShowList extends Component{ render() { return (
- {this.state.showsList} + {this.getShows}
) } diff --git a/javascript/Show/ShowView.jsx b/javascript/Show/ShowView.jsx index 5fc7bcb..80df664 100644 --- a/javascript/Show/ShowView.jsx +++ b/javascript/Show/ShowView.jsx @@ -1,22 +1,88 @@ 'use strict' import React, {Component} from 'react' import ShowList from './ShowList.jsx' +import ShowCard from './ShowCard.jsx' +import { Card, CardBody, CardTitle, Row, Col, Button } from 'reactstrap' +import { Modal, ModalHeader, ModalBody, Input, InputGroup, InputGroupAddon } from 'reactstrap' export default class ShowView extends Component { constructor() { super() - this.state = {} + this.state = { + modalOpen: false, + title: "" + } + this.saveNewShow = this.saveNewShow.bind(this) + this.switchModal = this.switchModal.bind(this) + this.updateTitle = this.updateTitle.bind(this) } + saveNewShow(title) { + if (this.state.title != null) { + $.post('./slideshow/show/', title).done(function () { + window.location.href = './slideshow/show/edit' + }.bind(this)).fail(function () { + console.log("Fatal Error On Save Has Occured") + }) + } + } + + switchModal() { + this.setState({ + modalOpen: !this.state.modalOpen + }) + } + + updateTitle(event) { + this.setState({ + title: event.target.value + }) + } render() { + + const modal = ( + + Enter a Title: + + + + + + + + + + ) + + const newShow = ( + + + Create New Show + + + + ) + return (

Shows:

- // TODO: ALl the current shows that are associtaed with the admin user - // will be rendered here somehow... maybe json of slides - +
+
+ + + + +
+
+ {newShow} +
+ {modal}
) } diff --git a/javascript/Show/index.jsx b/javascript/Show/index.jsx index 33f5330..02953af 100644 --- a/javascript/Show/index.jsx +++ b/javascript/Show/index.jsx @@ -4,4 +4,4 @@ import ReactDOM from 'react-dom' import ShowView from './ShowView.jsx' ReactDOM.render( - , document.getElementById('ShowView')) + , document.getElementById('shows')) diff --git a/package.json b/package.json index 653c464..e032ff0 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,10 @@ "description": "Slideshow module using reveal.js", "main": "index.js", "dependencies": { + "popper.js": "^1.14.3", + "react": "^16.4.0", + "react-dom": "^16.4.0", + "reactstrap": "^6.1.0", "reveal": "0.0.4" }, "devDependencies": { @@ -12,17 +16,16 @@ "babel-loader": "^7.1.2", "babel-preset-env": "^1.6.1", "babel-preset-react": "^6.24.1", - "bootstrap": "^4.0.0", + "bootstrap": "^4.1.1", "browser-sync": "^2.23.6", "browser-sync-webpack-plugin": "^2.0.1", "css-loader": "^0.28.9", "es6-promise": "^4.2.4", "file-loader": "^1.1.9", + "imports-loader": "^0.8.0", "jquery": "^3.3.1", "node-sass": "^4.7.2", "prop-types": "^15.6.0", - "react": "^16.2.0", - "react-dom": "^16.2.0", "react-dropzone": "^4.2.8", "react-medium-editor": "^1.8.1", "react-modal": "^3.3.1", @@ -46,5 +49,6 @@ "license": "ISC", "bugs": { "url": "https://github.com/AppStateESS/slideshow/issues" - } + }, + "homepage": "https://github.com/AppStateESS/slideshow#readme" } diff --git a/templates/Show/view.html b/templates/Show/view.html index 8b4775a..7a64132 100644 --- a/templates/Show/view.html +++ b/templates/Show/view.html @@ -1,10 +1,3 @@
-

Show:

- - -

- - -
No sections found
- -
\ No newline at end of file +
+