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

@ -96,10 +96,14 @@ class PlaylistController extends Zend_Controller_Action
$this->view->html = $this->view->render($viewPath); $this->view->html = $this->view->render($viewPath);
unset($this->view->obj); unset($this->view->obj);
} }
} else {
if ($isJson) {
return $this->view->render($viewPath);
} else { } else {
$this->view->html = $this->view->render($viewPath); $this->view->html = $this->view->render($viewPath);
} }
} }
}
private function playlistOutdated($e) private function playlistOutdated($e)
{ {
@ -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);
if ($p_type == 'Playlist') {
$this->createFullResponse(null); $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,18 +488,16 @@ class PlaylistController extends Zend_Controller_Action
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
//make sure block exists
try {
$bl = new Application_Model_Block($params['obj_id']);
$form = new Application_Form_SmartBlockCriteria(); $form = new Application_Form_SmartBlockCriteria();
$form->startForm($params['obj_id']); $form->startForm($params['obj_id']);
$bl = new Application_Model_Block($params['obj_id']);
if ($form->isValid($params)) { if ($form->isValid($params)) {
$result = $bl->generateSmartBlock($params['data']); $result = $bl->generateSmartBlock($params['data']);
try {
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) {
$this->playlistNotFound('block');
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
} else { } else {
$this->view->obj = $bl; $this->view->obj = $bl;
$this->view->id = $bl->getId(); $this->view->id = $bl->getId();
@ -499,24 +507,35 @@ class PlaylistController extends Zend_Controller_Action
$result['result'] = 1; $result['result'] = 1;
die(json_encode($result)); die(json_encode($result));
} }
} catch (BlockNotFoundException $e) {
$this->playlistNotFound('block', true);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound('block');
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
} }
public function smartBlockShuffleAction() public function smartBlockShuffleAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
try {
$bl = new Application_Model_Block($params['obj_id']); $bl = new Application_Model_Block($params['obj_id']);
$result = $bl->shuffleSmartBlock(); $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) {
$this->playlistNotFound('block');
}
} else { } else {
die(json_encode($result)); die(json_encode($result));
} }
} catch (BlockNotFoundException $e) {
$this->playlistNotFound('block', true);
} catch (PlaylistNotFoundException $e) {
$this->playlistNotFound('block');
} catch (Exception $e) {
$this->playlistUnknownError($e);
}
} }
public function getBlockInfoAction() public function getBlockInfoAction()

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") {