CC-4302: Library : Deletion of newly created Smart Block does not prevent you from editing it which leads to small hang up

-fixed
This commit is contained in:
denise 2012-08-29 16:00:58 -04:00
parent 46a6a5fc30
commit fe48780932
2 changed files with 52 additions and 30 deletions

View File

@ -97,7 +97,11 @@ class PlaylistController extends Zend_Controller_Action
unset($this->view->obj); unset($this->view->obj);
} }
} else { } else {
$this->view->html = $this->view->render($viewPath); if ($isJson) {
return $this->view->render($viewPath);
} else {
$this->view->html = $this->view->render($viewPath);
}
} }
} }
@ -112,13 +116,19 @@ class PlaylistController extends Zend_Controller_Action
$this->createFullResponse($obj); $this->createFullResponse($obj);
} }
private function playlistNotFound($p_type) private function playlistNotFound($p_type, $p_isJson = false)
{ {
$p_type = ucfirst($p_type);
$this->view->error = "{$p_type} not found"; $this->view->error = "{$p_type} not found";
Logging::info("{$p_type} not found"); Logging::info("{$p_type} not found");
Application_Model_Library::changePlaylist(null, $p_type); Application_Model_Library::changePlaylist(null, $p_type);
$this->createFullResponse(null);
if ($p_type == 'Playlist') {
$this->createFullResponse(null);
} else {
die(json_encode(array("error"=>$this->view->error, "result"=>1, "html"=>$this->createFullResponse(null, true))));
}
} }
private function playlistNoPermission($p_type) private function playlistNoPermission($p_type)
@ -478,26 +488,31 @@ class PlaylistController extends Zend_Controller_Action
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
$form = new Application_Form_SmartBlockCriteria();
$form->startForm($params['obj_id']); //make sure block exists
$bl = new Application_Model_Block($params['obj_id']); try {
if ($form->isValid($params)) { $bl = new Application_Model_Block($params['obj_id']);
$result = $bl->generateSmartBlock($params['data']);
try { $form = new Application_Form_SmartBlockCriteria();
$form->startForm($params['obj_id']);
if ($form->isValid($params)) {
$result = $bl->generateSmartBlock($params['data']);
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true)))); die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true))));
} catch (PlaylistNotFoundException $e) { } else {
$this->playlistNotFound('block'); $this->view->obj = $bl;
} catch (Exception $e) { $this->view->id = $bl->getId();
$this->playlistUnknownError($e); $this->view->form = $form;
$viewPath = 'playlist/smart-block.phtml';
$result['html'] = $this->view->render($viewPath);
$result['result'] = 1;
die(json_encode($result));
} }
} else { } catch (BlockNotFoundException $e) {
$this->view->obj = $bl; $this->playlistNotFound('block', true);
$this->view->id = $bl->getId(); } catch (PlaylistNotFoundException $e) {
$this->view->form = $form; $this->playlistNotFound('block');
$viewPath = 'playlist/smart-block.phtml'; } catch (Exception $e) {
$result['html'] = $this->view->render($viewPath); $this->playlistUnknownError($e);
$result['result'] = 1;
die(json_encode($result));
} }
} }
@ -505,17 +520,21 @@ class PlaylistController extends Zend_Controller_Action
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
$bl = new Application_Model_Block($params['obj_id']); try {
$result = $bl->shuffleSmartBlock(); $bl = new Application_Model_Block($params['obj_id']);
$result = $bl->shuffleSmartBlock();
if ($result['result'] == 0) { if ($result['result'] == 0) {
try {
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true))));
} catch (PlaylistNotFoundException $e) { } else {
$this->playlistNotFound('block'); die(json_encode($result));
} }
} else { } catch (BlockNotFoundException $e) {
die(json_encode($result)); $this->playlistNotFound('block', true);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound('block');
} catch (Exception $e) {
$this->playlistUnknownError($e);
} }
} }

View File

@ -437,6 +437,9 @@ function callback(data, type) {
dt = $('table[id="library_display"]').dataTable(); dt = $('table[id="library_display"]').dataTable();
if (type == 'shuffle' || type == 'generate') { if (type == 'shuffle' || type == 'generate') {
if (json.error !== undefined) {
alert(json.error);
}
AIRTIME.playlist.fnOpenPlaylist(json); AIRTIME.playlist.fnOpenPlaylist(json);
var form = $('#smart-block-form'); var form = $('#smart-block-form');
if (json.result == "0") { if (json.result == "0") {