context menu just in the client now. works for both tables.

This commit is contained in:
Naomi 2013-08-20 14:58:22 -04:00
parent 3ea2b920a6
commit 10ef55b083
2 changed files with 49 additions and 79 deletions

View File

@ -8,7 +8,6 @@ class PlayouthistoryController extends Zend_Controller_Action
$ajaxContext $ajaxContext
->addActionContext('file-history-feed', 'json') ->addActionContext('file-history-feed', 'json')
->addActionContext('item-history-feed', 'json') ->addActionContext('item-history-feed', 'json')
->addActionContext('context-menu', 'json')
->addActionContext('edit-file-item', 'json') ->addActionContext('edit-file-item', 'json')
->addActionContext('create-list-item', 'json') ->addActionContext('create-list-item', 'json')
->addActionContext('edit-list-item', 'json') ->addActionContext('edit-list-item', 'json')
@ -83,28 +82,6 @@ class PlayouthistoryController extends Zend_Controller_Action
$this->view->headScript()->appendScript($script); $this->view->headScript()->appendScript($script);
} }
public function contextMenuAction()
{
$baseUrl = Application_Common_OsPath::getBaseDir();
$id = $this->_getParam('id');
$menu = array();
$menu["edit"] = array(
"name"=> _("Edit"),
"icon" => "edit",
"url" => $baseUrl."playouthistory/edit-list-item/id/{$id}"
);
$menu["del"] = array(
"name"=> _("Delete"),
"icon" => "delete",
"url" => $baseUrl."playouthistory/delete-list-item/id/{$id}"
);
$this->view->items = $menu;
}
public function fileHistoryFeedAction() public function fileHistoryFeedAction()
{ {
try { try {

View File

@ -130,9 +130,10 @@ var AIRTIME = (function(AIRTIME) {
fnRowCallback; fnRowCallback;
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var editUrl = baseUrl+"Playouthistory/edit-file-item/format/json/id/"+aData.file_id; var editUrl = baseUrl+"playouthistory/edit-file-item/id/"+aData.file_id,
$nRow = $(nRow);
nRow.setAttribute('url-edit', editUrl); $nRow.data('url-edit', editUrl);
}; };
columns = JSON.parse(localStorage.getItem('datatables-historyfile-aoColumns')); columns = JSON.parse(localStorage.getItem('datatables-historyfile-aoColumns'));
@ -181,8 +182,8 @@ var AIRTIME = (function(AIRTIME) {
} }
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var editUrl = baseUrl+"playouthistory/edit-list-item/format/json/id/"+aData.history_id, var editUrl = baseUrl+"playouthistory/edit-list-item/id/"+aData.history_id,
deleteUrl = baseUrl+"playouthistory/delete-list-item/format/json/id/"+aData.history_id, deleteUrl = baseUrl+"playouthistory/delete-list-item/id/"+aData.history_id,
emptyCheckBox = String.fromCharCode(parseInt(2610, 16)), emptyCheckBox = String.fromCharCode(parseInt(2610, 16)),
checkedCheckBox = String.fromCharCode(parseInt(2612, 16)), checkedCheckBox = String.fromCharCode(parseInt(2612, 16)),
b, b,
@ -192,9 +193,9 @@ var AIRTIME = (function(AIRTIME) {
// add checkbox // add checkbox
$nRow.find('td.his_checkbox').html("<input type='checkbox' name='cb_"+aData.history_id+"'>"); $nRow.find('td.his_checkbox').html("<input type='checkbox' name='cb_"+aData.history_id+"'>");
nRow.setAttribute('his-id', aData.history_id); $nRow.data('his-id', aData.history_id);
//nRow.setAttribute('url-edit', editUrl); $nRow.data('url-edit', editUrl);
//nRow.setAttribute('url-delete', deleteUrl); $nRow.data('url-delete', deleteUrl);
for (b in booleans) { for (b in booleans) {
@ -356,6 +357,7 @@ var AIRTIME = (function(AIRTIME) {
openRow(oTableItem, this); openRow(oTableItem, this);
}); });
$historyContentDiv.on("click", "#history_table_aggregate tr", function(ev) { $historyContentDiv.on("click", "#history_table_aggregate tr", function(ev) {
openRow(oTableAgg, this); openRow(oTableAgg, this);
}); });
@ -476,65 +478,56 @@ var AIRTIME = (function(AIRTIME) {
// begin context menu initialization. // begin context menu initialization.
$.contextMenu({ $.contextMenu({
selector: '#history_table_list td:not(.library_checkbox)', selector: '#history_content td:not(.his_checkbox)',
trigger: "left", trigger: "left",
ignoreRightClick: true, ignoreRightClick: true,
build: function($el, e) { build: function($el, e) {
var items, var items = {},
callback, callback,
$tr, $tr;
id;
$tr = $el.parents("tr"); $tr = $el.parents("tr");
id = $tr.get(0).getAttribute("his-id");
function processMenuItems(oItems) { var editUrl = $tr.data("url-edit");
var deleteUrl = $tr.data("url-delete");
// define an edit callback. if (editUrl !== undefined) {
if (oItems.edit !== undefined) {
callback = function() { callback = function() {
$.post(oItems.edit.url, {format: "json"}, function(json) { $.post(editUrl, {format: "json"}, function(json) {
makeHistoryDialog(json.dialog); makeHistoryDialog(json.dialog);
}, "json"); }, "json");
}; };
oItems.edit.callback = callback; items["edit"] = {
"name": $.i18n._("Edit"),
"icon": "edit",
"callback": callback
};
} }
// define a delete callback. if (deleteUrl !== undefined) {
if (oItems.del !== undefined) {
callback = function() { callback = function() {
var c = confirm("Delete this entry?"); var c = confirm("Delete this entry?");
if (c) { if (c) {
$.post(oItems.del.url, {format: "json"}, function(json) { $.post(deleteUrl, {format: "json"}, function(json) {
oTableItem.fnDraw(); oTableItem.fnDraw();
}); });
} }
}; };
oItems.del.callback = callback; items["del"] = {
"name": $.i18n._("Delete"),
"icon": "delete",
"callback": callback
};
} }
items = oItems;
}
request = $.ajax({
url: baseUrl+"playouthistory/context-menu",
type: "GET",
data: {id : id, format: "json"},
dataType: "json",
async: false,
success: function(json){
processMenuItems(json.items);
}
});
return { return {
items: items items: items
}; };