diff --git a/class/Factory/ShowFactory.php b/class/Factory/ShowFactory.php index 79c9864..e782171 100644 --- a/class/Factory/ShowFactory.php +++ b/class/Factory/ShowFactory.php @@ -67,7 +67,7 @@ public function post(Request $request) $show->title = $request->pullPostString('title'); $show->active = 0; $this->saveResource($show); - $this->createImageDirectory($show); + //$this->createImageDirectory($show); return $show; } @@ -92,11 +92,7 @@ public function listing($showAll = false) public function view($id) { - /* @var $resource \slideshow\Resource\ShowResource */ - $resource = $this->load($id); - $vars = $resource->getStringVars(); - - $template = new \phpws2\Template($vars); + $template = new \phpws2\Template(); $template->setModuleTemplate('slideshow', 'Show/view.html'); return $template->get(); } diff --git a/class/Resource/ShowResource.php b/class/Resource/ShowResource.php index b6607ab..0647e56 100644 --- a/class/Resource/ShowResource.php +++ b/class/Resource/ShowResource.php @@ -43,8 +43,8 @@ class ShowResource extends BaseAbstract public function __construct() { parent::__construct(); - $this->showId = new \phpws2\Variable\IntegerVar(null, 'showId'); - $this->title = new \phpws2\Variable\StringVar(null, 'title'); + $this->showId = new \phpws2\Variable\IntegerVar(0, 'showId'); + $this->title = new \phpws2\Variable\TextOnly(null, 'title'); $this->title->setLimit('255'); $this->active = new \phpws2\Variable\BooleanVar(0, 'active'); } diff --git a/javascript/Show/ShowView.jsx b/javascript/Show/ShowView.jsx index 80df664..7d05f09 100644 --- a/javascript/Show/ShowView.jsx +++ b/javascript/Show/ShowView.jsx @@ -13,17 +13,30 @@ export default class ShowView extends Component { title: "" } + //this.load = this.load.bind(this) this.saveNewShow = this.saveNewShow.bind(this) this.switchModal = this.switchModal.bind(this) + this.successMessage = this.message.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") + $.ajax({ + url: 'slideshow/Show', + data: { + title: this.state.title + }, + dataType: 'json', + type: 'post', + success: () => { + this.switchModal(), + this.message(), + this.load() + }, + error: () => { + alert('Sorry, but this slideshow cannot be created.') + }, }) } } @@ -40,6 +53,17 @@ export default class ShowView extends Component { }) } + /* This should redirect the user to the edit page. + load() { + $.get({ + + }) + }*/ + + message() { + alert("New SlideShow Created!") + } + render() { const modal = (