CC-2203: Search results: "Delete" should be at the bottom of the list and should have a confirmation

-Fixed
This commit is contained in:
martin 2011-04-18 12:43:04 -04:00
parent d7bb00dc20
commit fab68dfad1
3 changed files with 106 additions and 80 deletions

View File

@ -10,13 +10,13 @@ class LibraryController extends Zend_Controller_Action
{ {
$ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('contents', 'json') $ajaxContext->addActionContext('contents', 'json')
->addActionContext('delete', 'json') ->addActionContext('delete', 'json')
->addActionContext('context-menu', 'json') ->addActionContext('context-menu', 'json')
->addActionContext('get-file-meta-data', 'html') ->addActionContext('get-file-meta-data', 'html')
->initContext(); ->initContext();
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
$this->search_sess = new Zend_Session_Namespace("search"); $this->search_sess = new Zend_Session_Namespace("search");
} }
public function indexAction() public function indexAction()
@ -30,108 +30,115 @@ class LibraryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/advancedsearch.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/advancedsearch.js','text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css');
$this->_helper->layout->setLayout('library'); $this->_helper->layout->setLayout('library');
$this->_helper->viewRenderer->setResponseSegment('library'); $this->_helper->viewRenderer->setResponseSegment('library');
$form = new Application_Form_AdvancedSearch(); $form = new Application_Form_AdvancedSearch();
$form->addGroup(1, 1); $form->addGroup(1, 1);
$this->search_sess->next_group = 2; $this->search_sess->next_group = 2;
$this->search_sess->next_row[1] = 2; $this->search_sess->next_row[1] = 2;
$this->view->form = $form; $this->view->form = $form;
$this->view->md = $this->search_sess->md; $this->view->md = $this->search_sess->md;
$this->_helper->actionStack('index', 'playlist'); $this->_helper->actionStack('index', 'playlist');
} }
public function contextMenuAction() public function contextMenuAction()
{ {
$id = $this->_getParam('id'); $id = $this->_getParam('id');
$type = $this->_getParam('type'); $type = $this->_getParam('type');
$params = '/format/json/id/#id#/type/#type#'; $params = '/format/json/id/#id#/type/#type#';
$paramsPop = str_replace('#id#', $id, $params);
$paramsPop = str_replace('#type#', $type, $paramsPop);
$pl_sess = $this->pl_sess; $pl_sess = $this->pl_sess;
if($type === "au") { if($type === "au") {
if(isset($pl_sess->id)) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/add-item'.$params, 'callback' => 'window["setSPLContent"]'),
'title' => 'Add to Playlist');
}
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Library/delete'.$params, 'callback' => 'window["deleteAudioClip"]'), $menu[] = array('action' => array('type' => 'gourl', 'url' => '/Library/edit-file-md/id/#id#'),
'title' => 'Delete'); 'title' => 'Edit Metadata');
if(isset($pl_sess->id)) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/add-item'.$params, 'callback' => 'window["setSPLContent"]'),
'title' => 'Add to Playlist');
}
$menu[] = array('action' => array('type' => 'gourl', 'url' => '/Library/edit-file-md/id/#id#'), $menu[] = array('action' => array('type' => 'fn',
'title' => 'Edit Metadata'); 'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"),
'title' => 'Delete');
}
else if($type === "pl") {
} if(!isset($pl_sess->id) || $pl_sess->id !== $id) {
else if($type === "pl") { $menu[] = array('action' =>
array('type' => 'ajax',
if(!isset($pl_sess->id) || $pl_sess->id !== $id) { 'url' => '/Playlist/edit'.$params,
$menu[] = array('action' => 'callback' => 'window["openDiffSPL"]'),
array('type' => 'ajax', 'title' => 'Edit');
'url' => '/Playlist/edit'.$params, }
'callback' => 'window["openDiffSPL"]'), else if(isset($pl_sess->id) && $pl_sess->id === $id) {
'title' => 'Edit'); $menu[] = array('action' =>
} array('type' => 'ajax',
else if(isset($pl_sess->id) && $pl_sess->id === $id) { 'url' => '/Playlist/close'.$params,
$menu[] = array('action' => 'callback' => 'window["noOpenPL"]'),
array('type' => 'ajax', 'title' => 'Close');
'url' => '/Playlist/close'.$params, }
'callback' => 'window["noOpenPL"]'),
'title' => 'Close');
}
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/metadata/format/json/id/#id#', 'callback' => 'window["createPlaylistMetaForm"]'), $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/metadata/format/json/id/#id#', 'callback' => 'window["createPlaylistMetaForm"]'),
'title' => 'Edit Metadata'); 'title' => 'Edit Metadata');
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/delete'.$params, 'callback' => 'window["deletePlaylist"]'), //$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/delete'.$params, 'callback' => 'window["deletePlaylist"]'),
'title' => 'Delete'); // 'title' => 'Delete');
} $menu[] = array('action' => array('type' => 'fn',
'callback' => "window['confirmDeletePlaylist']('$paramsPop')"),
'title' => 'Delete');
//returns format jjmenu is looking for. }
die(json_encode($menu));
//returns format jjmenu is looking for.
die(json_encode($menu));
} }
public function deleteAction() public function deleteAction()
{ {
$id = $this->_getParam('id'); $id = $this->_getParam('id');
if (!is_null($id)) { if (!is_null($id)) {
$file = StoredFile::Recall($id); $file = StoredFile::Recall($id);
if (PEAR::isError($file)) { if (PEAR::isError($file)) {
$this->view->message = $file->getMessage(); $this->view->message = $file->getMessage();
return; return;
} }
else if(is_null($file)) { else if(is_null($file)) {
$this->view->message = "file doesn't exist"; $this->view->message = "file doesn't exist";
return; return;
} }
$res = $file->delete(); $res = $file->delete();
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
$this->view->message = $res->getMessage(); $this->view->message = $res->getMessage();
return; return;
} }
} }
$this->view->id = $id; $this->view->id = $id;
} }
public function contentsAction() public function contentsAction()
{ {
$post = $this->getRequest()->getPost(); $post = $this->getRequest()->getPost();
$datatables = StoredFile::searchFilesForPlaylistBuilder($post); $datatables = StoredFile::searchFilesForPlaylistBuilder($post);
die(json_encode($datatables)); die(json_encode($datatables));
} }
public function editFileMdAction() public function editFileMdAction()
@ -140,19 +147,19 @@ class LibraryController extends Zend_Controller_Action
$form = new Application_Form_EditAudioMD(); $form = new Application_Form_EditAudioMD();
$file_id = $this->_getParam('id', null); $file_id = $this->_getParam('id', null);
$file = StoredFile::Recall($file_id); $file = StoredFile::Recall($file_id);
if ($request->isPost()) { if ($request->isPost()) {
if ($form->isValid($request->getPost())) { if ($form->isValid($request->getPost())) {
$formdata = $form->getValues(); $formdata = $form->getValues();
$file->replaceDbMetadata($formdata); $file->replaceDbMetadata($formdata);
$this->_helper->redirector('index'); $this->_helper->redirector('index');
} }
} }
$form->populate($file->md); $form->populate($file->md);
$this->view->form = $form; $this->view->form = $form;
} }

View File

@ -248,8 +248,6 @@ class ScheduleController extends Zend_Controller_Action
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/'.$id, $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/'.$id,
'callback' => 'window["beginEditShow"]'), 'title' => 'Edit Show'); 'callback' => 'window["beginEditShow"]'), 'title' => 'Edit Show');
//$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params,
// 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Edit This Instance and All Following');
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params, $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params,
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance'); 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance');
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params, $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show'.$params,

View File

@ -24,7 +24,6 @@ function deleteItem(type, id) {
dt.fnDeleteRow( tr ); dt.fnDeleteRow( tr );
} }
//callbacks called by jjmenu
function deleteAudioClip(json) { function deleteAudioClip(json) {
if(json.message) { if(json.message) {
alert(json.message); alert(json.message);
@ -34,6 +33,28 @@ function deleteAudioClip(json) {
deleteItem("au", json.id); deleteItem("au", json.id);
} }
//callbacks called by jjmenu
function confirmDeleteAudioClip(params){
if(confirm('Are you sure you want to delete?')){
var url = '/Library/delete' + params;
$.ajax({
url: url,
success: deleteAudioClip
});
}
}
//callbacks called by jjmenu
function confirmDeletePlaylist(params){
if(confirm('Are you sure you want to delete?')){
var url = '/Playlist/delete' + params;
$.ajax({
url: url,
success: deletePlaylist
});
}
}
function deletePlaylist(json) { function deletePlaylist(json) {
if(json.message) { if(json.message) {
alert(json.message); alert(json.message);