CC-2145 : Redesign & layout fixes for the Preferences screen

added javascript to page, got rid of separate index/update actions and moved everything to just index since update was not needed as a separate action.
This commit is contained in:
naomiaro 2011-04-03 18:04:14 -04:00
parent a28d8ce305
commit 9bd1aa14a9
5 changed files with 43 additions and 31 deletions

View File

@ -10,42 +10,37 @@ class PreferenceController extends Zend_Controller_Action
public function indexAction()
{
$this->view->headScript()->appendFile('/js/airtime/preferences/preferences.js','text/javascript');
$request = $this->getRequest();
$this->view->statusMsg = "";
$form = new Application_Form_Preferences();
$this->view->form = $form;
}
public function updateAction()
{
$request = $this->getRequest();
if (!$this->getRequest()->isPost()) {
return $this->_forward('Preference/index');
}
if ($request->isPost()) {
$form = new Application_Form_Preferences();
if ($form->isValid($request->getPost())) {
if ($form->isValid($request->getPost())) {
$values = $form->getValues();
Application_Model_Preference::SetHeadTitle($values["preferences_general"]["stationName"], $this->view);
Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]);
Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]);
Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]);
$values = $form->getValues();
Application_Model_Preference::SetHeadTitle($values["preferences_general"]["stationName"], $this->view);
Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]);
Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]);
Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]);
Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]);
Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]);
Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]);
Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]);
Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]);
Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]);
Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]);
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]);
Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]);
Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]);
Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]);
Application_Model_Preference::SetSoundCloudGenre($values["preferences_soundcloud"]["SoundCloudGenre"]);
Application_Model_Preference::SetSoundCloudTrackType($values["preferences_soundcloud"]["SoundCloudTrackType"]);
Application_Model_Preference::SetSoundCloudLicense($values["preferences_soundcloud"]["SoundCloudLicense"]);
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
}
}
$this->view->form = $form;
return $this->render('index'); //render the phtml file
}
}

View File

@ -5,7 +5,8 @@ class Application_Form_Preferences extends Zend_Form
public function init()
{
$this->setAction('/Preference/update')->setMethod('post');
$this->setAction('/Preference');
$this->setMethod('post');
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences.phtml'))

View File

@ -1,9 +1,9 @@
<form method="post" action="/Preference/update" enctype="application/x-www-form-urlencoded">
<form method="<?php echo $this->element->getMethod() ?>" action="<?php echo $this->element->getAction() ?>" enctype="application/x-www-form-urlencoded">
<?php echo $this->element->getSubform('preferences_general') ?>
<h3 class="collapsible-header"><span class="arrow-icon"></span>SoundCloud settings</h3>
<div class="collapsible-content" id="soundcloud-settings" style="display: block;">
<div class="collapsible-content" id="soundcloud-settings" style="display: none;">
<?php echo $this->element->getSubform('preferences_soundcloud') ?>
</div>

View File

@ -1 +0,0 @@
Left empty on purpose

View File

@ -0,0 +1,17 @@
$(document).ready(function() {
var form = $("form");
form.find("h3").click(function(){
var h3 = $(this);
h3.next().toggle();
if(h3.hasClass("close")) {
h3.removeClass("close");
}
else {
h3.addClass("close");
}
});
});