add show form sent via ajax request, opens sections with errors if not completed properly.
This commit is contained in:
parent
a32550d625
commit
2b5927bf33
6 changed files with 129 additions and 63 deletions
|
@ -69,6 +69,7 @@
|
||||||
<actionMethod actionName="getShowData"/>
|
<actionMethod actionName="getShowData"/>
|
||||||
<actionMethod actionName="showContentDialog"/>
|
<actionMethod actionName="showContentDialog"/>
|
||||||
<actionMethod actionName="editShow"/>
|
<actionMethod actionName="editShow"/>
|
||||||
|
<actionMethod actionName="addShow"/>
|
||||||
</controllerFile>
|
</controllerFile>
|
||||||
<controllerFile controllerName="Api">
|
<controllerFile controllerName="Api">
|
||||||
<actionMethod actionName="index"/>
|
<actionMethod actionName="index"/>
|
||||||
|
@ -300,12 +301,16 @@
|
||||||
</viewControllerScriptsDirectory>
|
</viewControllerScriptsDirectory>
|
||||||
<viewControllerScriptsDirectory forControllerName="User">
|
<viewControllerScriptsDirectory forControllerName="User">
|
||||||
<viewScriptFile forActionName="removeUser"/>
|
<viewScriptFile forActionName="removeUser"/>
|
||||||
|
</viewControllerScriptsDirectory>
|
||||||
<viewControllerScriptsDirectory forControllerName="Playlist">
|
<viewControllerScriptsDirectory forControllerName="Playlist">
|
||||||
<viewScriptFile forActionName="setPlaylistFades"/>
|
<viewScriptFile forActionName="setPlaylistFades"/>
|
||||||
</viewControllerScriptsDirectory>
|
</viewControllerScriptsDirectory>
|
||||||
<viewControllerScriptsDirectory forControllerName="Schedule">
|
<viewControllerScriptsDirectory forControllerName="Schedule">
|
||||||
<viewScriptFile forActionName="editShow"/>
|
<viewScriptFile forActionName="editShow"/>
|
||||||
</viewControllerScriptsDirectory>
|
</viewControllerScriptsDirectory>
|
||||||
|
<viewControllerScriptsDirectory forControllerName="Schedule">
|
||||||
|
<viewScriptFile forActionName="addShow"/>
|
||||||
|
</viewControllerScriptsDirectory>
|
||||||
</viewScriptsDirectory>
|
</viewScriptsDirectory>
|
||||||
<viewHelpersDirectory/>
|
<viewHelpersDirectory/>
|
||||||
<viewFiltersDirectory enabled="false"/>
|
<viewFiltersDirectory enabled="false"/>
|
||||||
|
|
|
@ -23,6 +23,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
->addActionContext('find-playlists', 'json')
|
->addActionContext('find-playlists', 'json')
|
||||||
->addActionContext('remove-group', 'json')
|
->addActionContext('remove-group', 'json')
|
||||||
->addActionContext('edit-show', 'json')
|
->addActionContext('edit-show', 'json')
|
||||||
|
->addActionContext('add-show', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
|
|
||||||
$this->sched_sess = new Zend_Session_Namespace("schedule");
|
$this->sched_sess = new Zend_Session_Namespace("schedule");
|
||||||
|
@ -57,39 +58,6 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$formStyle = new Application_Form_AddShowStyle();
|
$formStyle = new Application_Form_AddShowStyle();
|
||||||
$formStyle->removeDecorator('DtDdWrapper');
|
$formStyle->removeDecorator('DtDdWrapper');
|
||||||
|
|
||||||
if ($request->isPost()) {
|
|
||||||
|
|
||||||
$data = $request->getPost();
|
|
||||||
|
|
||||||
$what = $formWhat->isValid($data);
|
|
||||||
$when = $formWhen->isValid($data);
|
|
||||||
if($when) {
|
|
||||||
$when = $formWhen->checkReliantFields($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($data["add_show_repeats"]) {
|
|
||||||
$repeats = $formRepeats->isValid($data);
|
|
||||||
if($repeats) {
|
|
||||||
$when = $formRepeats->checkReliantFields($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$repeats = 1; //make it valid, results don't matter anyways.
|
|
||||||
}
|
|
||||||
|
|
||||||
$who = $formWho->isValid($data);
|
|
||||||
$style = $formStyle->isValid($data);
|
|
||||||
|
|
||||||
if ($what && $when && $repeats && $who && $style) {
|
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
|
||||||
|
|
||||||
$show = new Show(new User($userInfo->id, $userInfo->type));
|
|
||||||
$show->addShow($data);
|
|
||||||
$this->_redirect('Schedule');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->view->what = $formWhat;
|
$this->view->what = $formWhat;
|
||||||
$this->view->when = $formWhen;
|
$this->view->when = $formWhen;
|
||||||
$this->view->repeats = $formRepeats;
|
$this->view->repeats = $formRepeats;
|
||||||
|
@ -332,9 +300,70 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$show = new Show($showInstance->getShowId());
|
$show = new Show($showInstance->getShowId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addShowAction()
|
||||||
|
{
|
||||||
|
$js = $this->_getParam('data');
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
//need to convert from serialized jQuery array.
|
||||||
|
foreach($js as $j){
|
||||||
|
$data[$j["name"]] = $j["value"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$formWhat = new Application_Form_AddShowWhat();
|
||||||
|
$formWho = new Application_Form_AddShowWho();
|
||||||
|
$formWhen = new Application_Form_AddShowWhen();
|
||||||
|
$formRepeats = new Application_Form_AddShowRepeats();
|
||||||
|
$formStyle = new Application_Form_AddShowStyle();
|
||||||
|
|
||||||
|
$formWhat->removeDecorator('DtDdWrapper');
|
||||||
|
$formWho->removeDecorator('DtDdWrapper');
|
||||||
|
$formWhen->removeDecorator('DtDdWrapper');
|
||||||
|
$formRepeats->removeDecorator('DtDdWrapper');
|
||||||
|
$formStyle->removeDecorator('DtDdWrapper');
|
||||||
|
|
||||||
|
$what = $formWhat->isValid($data);
|
||||||
|
$when = $formWhen->isValid($data);
|
||||||
|
if($when) {
|
||||||
|
$when = $formWhen->checkReliantFields($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($data["add_show_repeats"]) {
|
||||||
|
$repeats = $formRepeats->isValid($data);
|
||||||
|
if($repeats) {
|
||||||
|
$when = $formRepeats->checkReliantFields($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$repeats = 1; //make it valid, results don't matter anyways.
|
||||||
|
}
|
||||||
|
|
||||||
|
$who = $formWho->isValid($data);
|
||||||
|
$style = $formStyle->isValid($data);
|
||||||
|
|
||||||
|
if ($what && $when && $repeats && $who && $style) {
|
||||||
|
|
||||||
|
if($user->isAdmin()) {
|
||||||
|
Show::addShow($data);
|
||||||
|
}
|
||||||
|
//$this->_redirect('Schedule');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
$this->view->what = $formWhat;
|
||||||
|
$this->view->when = $formWhen;
|
||||||
|
$this->view->repeats = $formRepeats;
|
||||||
|
$this->view->who = $formWho;
|
||||||
|
$this->view->style = $formStyle;
|
||||||
|
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<form id="add-show-form" method="post" action="" style="display:none;">
|
<div id="schedule-add-show" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded">
|
||||||
<div id="schedule-add-show" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded">
|
|
||||||
<div class="button-bar">
|
<div class="button-bar">
|
||||||
<button id="add-show-submit" class="right-floated">Add this show</button>
|
<button id="add-show-submit" class="right-floated">Add this show</button>
|
||||||
<button id="add-show-close" class="right-floated">Close</button>
|
<button id="add-show-close" class="right-floated">Close</button>
|
||||||
|
@ -21,5 +20,5 @@
|
||||||
<div id="schedule-show-style" class="collapsible-content">
|
<div id="schedule-show-style" class="collapsible-content">
|
||||||
<?php echo $this->style ?>
|
<?php echo $this->style ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
|
|
1
application/views/scripts/schedule/add-show.phtml
Normal file
1
application/views/scripts/schedule/add-show.phtml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<br /><br /><center>View script for controller <b>Schedule</b> and script/action name <b>addShow</b></center>
|
|
@ -1,5 +1,7 @@
|
||||||
<?php if($this->isAdmin) : ?>
|
<?php if($this->isAdmin) : ?>
|
||||||
|
<form id="add-show-form" method="post" action="" style="display:none;">
|
||||||
<?php echo $this->render('schedule/add-show-form.phtml') ?>
|
<?php echo $this->render('schedule/add-show-form.phtml') ?>
|
||||||
|
</form>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div id='schedule_calendar' class="ui-widget-content block-shadow padded omega-block"></div>
|
<div id='schedule_calendar' class="ui-widget-content block-shadow padded omega-block"></div>
|
||||||
|
|
|
@ -127,9 +127,39 @@ function setAddShowEvents() {
|
||||||
|
|
||||||
$("#add-show-submit")
|
$("#add-show-submit")
|
||||||
.button()
|
.button()
|
||||||
.click(function(){
|
.click(function(event){
|
||||||
$("form").submit();
|
event.preventDefault();
|
||||||
|
|
||||||
|
var data = $("form").serializeArray();
|
||||||
|
var y;
|
||||||
|
|
||||||
|
$.post("/Schedule/add-show", {format: "json", data: data}, function(json){
|
||||||
|
if(json.form) {
|
||||||
|
$("#add-show-form")
|
||||||
|
.empty()
|
||||||
|
.append(json.form);
|
||||||
|
|
||||||
|
setAddShowEvents();
|
||||||
|
showErrorSections();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scheduleRefetchEvents();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showErrorSections() {
|
||||||
|
|
||||||
|
if($("#schedule-show-when .errors").length > 0) {
|
||||||
|
$("#schedule-show-when").show();
|
||||||
|
}
|
||||||
|
if($("#schedule-show-who .errors").length > 0) {
|
||||||
|
$("#schedule-show-who").show();
|
||||||
|
}
|
||||||
|
if($("#schedule-show-style .errors").length > 0) {
|
||||||
|
$("#schedule-show-style").show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue