CC-84: Smart Playlists

- fixed dragging tracks into playlists (smart and dumb)
- display alert when dragging into dynamic block
- display alert when dragging playlist into block
This commit is contained in:
denise 2012-08-02 11:52:11 -04:00
parent 3b5a3e6713
commit 997b5c31c3
3 changed files with 35 additions and 13 deletions

View File

@ -127,7 +127,7 @@ class PlaylistController extends Zend_Controller_Action
private function blockDynamic($obj)
{
$this->view->error = "You cannot add tracks to dynamic block.";
$this->view->error = "You cannot add tracks to dynamic blocks.";
$this->createFullResponse($obj);
}
@ -152,6 +152,11 @@ class PlaylistController extends Zend_Controller_Action
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
}
private function playlistDenied($obj) {
$this->view->error = "You cannot add playlists to smart playlists.";
$this->createFullResponse($obj);
}
public function indexAction()
{
@ -307,9 +312,15 @@ class PlaylistController extends Zend_Controller_Action
$obj->addAudioClips($ids, $afterItem, $addType);
} else if ($obj->isStatic()) {
// if the dest is a block object
//check if any items are playlists
foreach($ids as $id) {
if (is_array($id) && isset($id[1]) && $id[1] == 'playlist') {
throw new Exception('playlist to block');
}
}
$obj->addAudioClips($ids, $afterItem, $addType);
} else {
throw new BlockDynamicException;
throw new Exception('track to dynamic');
}
$this->createUpdateResponse($obj);
}
@ -319,11 +330,14 @@ class PlaylistController extends Zend_Controller_Action
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($obj_type);
}
catch (BlockDynamicException $e) {
$this->blockDynamic($obj);
}
catch (Exception $e) {
$this->playlistUnknownError($e);
if ($e->getMessage() == 'playlist to block') {
$this->playlistDenied($obj);
} else if ($e->getMessage() == 'track to dynamic') {
$this->blockDynamic($obj);
} else {
$this->playlistUnknownError($e);
}
}
}

View File

@ -266,7 +266,7 @@ EOT;
if ($modifier == "minutes") {
$timestamp = "00:".$value.":00";
} else if ($modifier == "hours") {
$timestamp = $value."00:00";
$timestamp = $value.":00:00.0";
}
$formatter = new LengthFormatter($timestamp);
$length = "~".$formatter->format();
@ -388,9 +388,14 @@ EOT;
foreach ($p_items as $ac) {
Logging::log("Adding audio file {$ac}");
$res = $this->insertBlockElement($this->buildEntry($ac, $pos));
$pos = $pos + 1;
if (is_array($ac) && $ac[1] == 'audioclip') {
$res = $this->insertBlockElement($this->buildEntry($ac[0], $pos));
$pos = $pos + 1;
} elseif (!is_array($ac)) {
$res = $this->insertBlockElement($this->buildEntry($ac, $pos));
$pos = $pos + 1;
}
}
//reset the positions of the remaining items.

View File

@ -128,11 +128,14 @@ var AIRTIME = (function(AIRTIME){
for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i];
if (temp.ftype === "audioclip" || temp.ftype === "block") {
aMediaIds.push(temp.id);
aMediaIds.push(new Array (temp.id, temp.ftype));
}
}
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
if (aMediaIds.length > 0) {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
} else {
alert('You cannot add playlists to smart playlists');
}
});
//delete from library.