changing to context menu single edit/delete.

This commit is contained in:
Naomi Aro 2013-08-19 23:19:13 -04:00
parent 9b45b9dc72
commit 09693ef174
11 changed files with 609 additions and 311 deletions

View File

@ -180,8 +180,6 @@ class LibraryController extends Zend_Controller_Action
//playlist||timeline
$screen = $this->_getParam('screen');
$baseUrl = Application_Common_OsPath::getBaseDir();
$menu = array();
$userInfo = Zend_Auth::getInstance()->getStorage()->read();

View File

@ -8,6 +8,7 @@ class PlayouthistoryController extends Zend_Controller_Action
$ajaxContext
->addActionContext('file-history-feed', 'json')
->addActionContext('item-history-feed', 'json')
->addActionContext('context-menu', 'json')
->addActionContext('edit-file-item', 'json')
->addActionContext('create-list-item', 'json')
->addActionContext('edit-list-item', 'json')
@ -67,7 +68,9 @@ class PlayouthistoryController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'js/datatables/plugin/TableTools-2.1.5/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/history_styles.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery-ui-timepicker-addon.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
//set datatables columns for display of data.
@ -80,6 +83,28 @@ class PlayouthistoryController extends Zend_Controller_Action
$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()
{
try {
@ -228,6 +253,7 @@ class PlayouthistoryController extends Zend_Controller_Action
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/history_styles.css?'.$CC_CONFIG['airtime_version']);
$historyService = new Application_Service_HistoryService();
$this->view->template_list = $historyService->getListItemTemplates();
@ -241,6 +267,7 @@ class PlayouthistoryController extends Zend_Controller_Action
$baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/configuretemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/history_styles.css?'.$CC_CONFIG['airtime_version']);
try {

View File

@ -209,11 +209,11 @@ class Application_Service_HistoryService
$orderBys[] = "{$key}_filter.{$key} {$sortDir}";
}
else {
throw new Exception("Error: $key is not part of the template.");
//throw new Exception("Error: $key is not part of the template.");
}
}
if ($numOrderColumns > 0) {
if (count($orderBys) > 0) {
$orders = join(", ", $orderBys);
@ -230,7 +230,7 @@ class Application_Service_HistoryService
$mainSqlQuery.=
" OFFSET :offset LIMIT :limit";
$paramMap["offset"] = $opts["iDisplayStart"];
$paramMap["offset"] = intval($opts["iDisplayStart"]);
$paramMap["limit"] = $displayLength;
}
@ -282,6 +282,9 @@ class Application_Service_HistoryService
$result[MDATA_KEY_DURATION] = $formatter->format();
}
//need to add a checkbox..
$result["checkbox"] = "";
//$unicodeChar = '\u2612';
//$result["new"] = json_decode('"'.$unicodeChar.'"');
//$result["new"] = "U+2612";
@ -827,9 +830,9 @@ class Application_Service_HistoryService
public function getFieldTypes() {
$fields = array(
TEMPLATE_DATE,
TEMPLATE_TIME,
TEMPLATE_DATETIME,
//TEMPLATE_DATE,
//TEMPLATE_TIME,
//TEMPLATE_DATETIME,
TEMPLATE_STRING,
TEMPLATE_BOOLEAN,
TEMPLATE_INT,
@ -1019,11 +1022,11 @@ class Application_Service_HistoryService
return $this->getTemplates(self::TEMPLATE_TYPE_FILE);
}
private function datatablesColumns($template) {
private function datatablesColumns($fields) {
$columns = array();
foreach ($template["fields"] as $index=>$field) {
foreach ($fields as $field) {
$label = $field["label"];
$key = $field["name"];
@ -1041,9 +1044,22 @@ class Application_Service_HistoryService
public function getDatatablesLogSheetColumns() {
//need to prepend a checkbox column.
$checkbox = array(
"sTitle"=> "",
"mDataProp"=> "checkbox",
"sClass"=> "his_checkbox",
"bSortable"=> false
);
try {
$template = $this->getConfiguredItemTemplate();
return $this->datatablesColumns($template);
$fields = $template["fields"];
$columns = $this->datatablesColumns($fields);
array_unshift($columns, $checkbox);
return $columns;
}
catch (Exception $e) {
throw $e;
@ -1054,7 +1070,7 @@ class Application_Service_HistoryService
try {
$template = $this->getConfiguredFileTemplate();
return $this->datatablesColumns($template);
return $this->datatablesColumns($template["fields"]);
}
catch (Exception $e) {
throw $e;

View File

@ -1,3 +1,3 @@
<div id="configure_item_template" class="ui-widget ui-widget-content block-shadow alpha-block padded">
<div id="configure_item_template" class="ui-widget ui-widget-content block-shadow alpha-block padded-strong">
<?php echo $this->render('playouthistory/template-contents.phtml'); ?>
</div>

View File

@ -7,7 +7,6 @@
<li><a href="#his-tabs-2"><?php echo _("File Summary"); ?></a></li>
</ul>
<div id="his-tabs-1">
<div id="his_create"><?php echo _("Create Entry"); ?></div>
<table id="history_table_list" cellpadding="0" cellspacing="0" class="datatable"></table>
</div>
<div id="his-tabs-2">

View File

@ -1,11 +1,15 @@
<div>
<?php if (!in_array($this->template_id, $this->configured)): ?>
<button id="template_set_default" data-template="<?php echo $this->template_id; ?>">Set Default Template</button>
<?php endif; ?>
<button id="template_item_save" data-template="<?php echo $this->template_id; ?>">Save</button>
</div>
<?php if ($this->template_type == Application_Service_HistoryService::TEMPLATE_TYPE_FILE): ?>
<h4>Creating File Summary Template</h4>
<?php else: ?>
<h4>Creating Log Sheet Template</h4>
<?php endif; ?>
<div><label>Name<input id="template_name" type="text" value="<?php echo $this->template_name; ?>"></label></div>
<div class="template_name_wrap">
<label>
Name
<input id="template_name" type="text" value="<?php echo $this->template_name; ?>">
</label>
</div>
<?php $i = 0; ?>
@ -21,7 +25,9 @@
<span><?php echo $field["label"]?></span>
<span><?php echo $field["type"]?></span>
<?php if(!in_array($field["name"], $this->required_fields)): ?>
<span class="template_item_remove">Remove</span>
<span class="template_item_remove">
<i class="icon icon-trash"></i>
</span>
<?php endif; ?>
</li>
<?php $i++; ?>
@ -29,6 +35,8 @@
<?php endforeach; ?>
</ul>
<p>Add more elements:</p>
<ul class="template_file_md">
<?php foreach ($this->fileMD as $md): ?>
@ -37,21 +45,26 @@
data-type="<?php echo $md["type"]?>"
data-label="<?php echo $md["label"]?>">
<?php echo $md["label"] ?>
<a class="field_add" href="#"><i class="icon icon-plus"></i></a>
</li>
<?php endforeach; ?>
</ul>
<?php if ($this->template_type !== Application_Service_HistoryService::TEMPLATE_TYPE_FILE): ?>
<div class="template_item_add">
<div>Add New Field</div>
<div>
<input type="text">
<input type="text" placeholder="Add New Field">
<select>
<?php foreach ($this->fields as $field): ?>
<option value="<?php echo $field; ?>"><?php echo $field; ?></option>
<?php endforeach; ?>
</select>
<button>Add</button>
<button class="btn"><i class="icon-white icon-plus"></i> Add</button>
</div>
<?php endif; ?>
<div>
<?php if (!in_array($this->template_id, $this->configured)): ?>
<button id="template_set_default" data-template="<?php echo $this->template_id; ?>" class="btn">Set Default Template</button>
<?php endif; ?>
<button id="template_item_save" data-template="<?php echo $this->template_id; ?>" class="btn">Save</button>
</div>

View File

@ -1,7 +1,7 @@
<div id="history_template" class="ui-widget ui-widget-content block-shadow alpha-block padded">
<div id="history_template" class="ui-widget ui-widget-content block-shadow alpha-block padded-strong">
<div>
<div>Edit Log Sheet Template</div>
<div><h4>Log Sheet Templates</h4></div>
<ul id="template_list">
<?php if (count($this->template_list) == 0): ?>
<li>No Log Sheet Templates</li>
@ -12,19 +12,30 @@
<?php endif; ?>
<?php if (in_array($id, $this->configured)): ?>
<li data-template="<?php echo $id; ?>" data-name="<?php echo $name; ?>" class="template_configured">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>"><?php echo $name; ?></a>
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>">
<?php echo $name; ?>
</a>
<i class="icon icon-ok"></i>
<?php else: ?>
<li data-template="<?php echo $id; ?>" data-name="<?php echo $name; ?>">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>"><?php echo $name; ?></a>
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistory/set-template-default/id/{$id}"); ?>">Set Default</a>
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistory/delete-template/id/{$id}"); ?>">Remove</a>
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>">
<?php echo $name; ?>
</a>
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistory/delete-template/id/{$id}"); ?>">
<i class="icon icon-trash"></i>
</a>
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistory/set-template-default/id/{$id}"); ?>">
Set Default
</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<button id="new_item_template" class="btn">New Log Sheet Template</button>
</div>
<br><br>
<div>
<div>Edit File Summary Template</div>
<div><h4>File Summary Templates</h4></div>
<ul id="template_file">
<?php if (count($this->template_file) == 0): ?>
<li>No File Summary Templates</li>
@ -32,17 +43,25 @@
<?php foreach ($this->template_file as $id=>$name): ?>
<?php if (in_array($id, $this->configured)): ?>
<li data-template="<?php echo $id; ?>" data-name="<?php echo $name; ?>" class="template_configured">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>"><?php echo $name; ?></a>
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>">
<?php echo $name; ?>
</a>
<i class="icon icon-ok"></i>
<?php else: ?>
<li data-template="<?php echo $id; ?>" data-name="<?php echo $name; ?>">
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>"><?php echo $name; ?></a>
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistory/set-template-default/id/{$id}"); ?>">Set Default</a>
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistory/delete-template/id/{$id}"); ?>">Remove</a>
<a class="template_name" href="<?php echo $this->baseUrl("Playouthistory/configure-template/id/{$id}"); ?>">
<?php echo $name; ?>
</a>
<a class="template_remove" href="<?php echo $this->baseUrl("Playouthistory/delete-template/id/{$id}"); ?>">
<i class="icon icon-trash"></i>
</a>
<a class="template_default" href="<?php echo $this->baseUrl("Playouthistory/set-template-default/id/{$id}"); ?>">
Set Default
</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<button id="new_item_template" class="btn">New Log Sheet Template</button>
<button id="new_file_template" class="btn">New File Summary Template</button>
</div>
</div>

View File

@ -0,0 +1,120 @@
#history_template h4, #configure_item_template h4 { font-size: 14px; margin-top: 0px; }
#history_template ul, #configure_item_template ul { list-style: none; padding-left: 0px; }
#history_template li, #configure_item_template li {
clear: both;
background: #AAAAAA;
margin: 2px 0 4px 0;
padding: 4px 8px 4px 8px;
position: relative;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border: 1px solid #9F9F9F;
min-height: 15px;
}
#history_template li a, #configure_item_template li a {
text-decoration: none;
}
#history_template li a:hover, #configure_item_template li a:hover {
text-decoration: underline;
}
#history_template li .template_name {
float: left;
}
#history_template li.template_configured {
background: #9A9A9A;
border: 1px solid #858585;
}
#history_template .template_remove, #history_template .template_default {
float: right;
margin-left: 10px;
}
#history_template .template_default {
margin-left: 20px;
}
#history_template .icon-ok {
right: 10px;
margin-left: 10px;
position: absolute;
}
#configure_item_template li span {
cursor: move;
padding-left: 6px;
}
#configure_item_template li .template_item_remove, #configure_item_template li .field_add {
cursor: pointer;
float: right;
margin-left: 20px;
}
#configure_item_template li .template_item_remove:hover, #configure_item_template li .field_add:hover {
opacity:0.7;
filter:alpha(opacity=70);
}
#configure_item_template #template_name {
min-width: 230px;
float: right;
}
#configure_item_template .template_name_wrap {
display: inline-block;
}
#configure_item_template label {
vertical-align: middle;
}
#configure_item_template .template_item_add {
margin-bottom: 10px;
}
#configure_item_template .template_item_add .btn {
padding: 2px 14px 1px;
}
#configure_item_template .template_item_list li {
background-image: url('../css/images/drag.png');
background-repeat: no-repeat;
background-position: 4px 5px;
}
/* Bootstrap calendar
.bootstrap-datetimepicker-widget ul {
padding-left: 0px !important;
}
.bootstrap-datetimepicker-widget td, .bootstrap-datetimepicker-widget th {
-webkit-border-radius: 2px !important;
-moz-border-radius: 2px !important;
border-radius: 2px !important;
}
*/
/* Edit History Record */
.ui-dialog form.ui-widget-content dd {
margin-left: 0px;
margin-bottom: 10px;
}
.ui-dialog form.ui-widget-content dt {
margin-bottom: 2px;
}
.ui-dialog form.ui-widget-content dd input {
width: 190px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

View File

@ -32,7 +32,7 @@ var AIRTIME = (function(AIRTIME) {
">" +
"<span><%= label %></span>" +
"<span><%= type %></span>" +
"<span class='template_item_remove'>Remove</span>" +
"<span class='template_item_remove'><i class='icon icon-trash'></i></span>" +
"</li>";
var template = (config.required) === true ? templateRequired : templateOptional;
@ -65,9 +65,9 @@ var AIRTIME = (function(AIRTIME) {
$templateList = $(".template_item_list");
$fileMDList = $(".template_file_md");
$fileMDList.on("dblclick", "li", function(){
$fileMDList.on("click", "i.icon-plus", function(){
var $li = $(this);
var $li = $(this).parents("li");
var config = {
name: $li.data("name"),
type: $li.data("type"),

View File

@ -93,6 +93,36 @@ var AIRTIME = (function(AIRTIME) {
} );
}
function createToolbarButtons ($el) {
var $menu = $("<div class='btn-toolbar' />");
$menu.append("<div class='btn-group'>" +
"<button class='btn btn-small dropdown-toggle' data-toggle='dropdown'>" +
$.i18n._("Select")+" <span class='caret'></span>" +
"</button>" +
"<ul class='dropdown-menu'>" +
"<li id='sb-select-page'><a href='#'>"+$.i18n._("Select this page")+"</a></li>" +
"<li id='sb-dselect-page'><a href='#'>"+$.i18n._("Deselect this page")+"</a></li>" +
"<li id='sb-dselect-all'><a href='#'>"+$.i18n._("Deselect all")+"</a></li>" +
"</ul>" +
"</div>");
$menu.append("<div class='btn-group'>" +
"<button class='btn btn-small' id='his_create'>" +
"<i class='icon-white icon-plus'></i>" +
$.i18n._("Create Entry") +
"</button>" +
"</div>");
$menu.append("<div class='btn-group'>" +
"<button class='btn btn-small' id='his_trash'>" +
"<i class='icon-white icon-trash'></i>" +
"</button>" +
"</div>");
$el.append($menu);
}
function aggregateHistoryTable() {
var oTable,
$historyTableDiv = $historyContentDiv.find("#history_table_aggregate"),
@ -134,6 +164,7 @@ var AIRTIME = (function(AIRTIME) {
function itemHistoryTable() {
var oTable,
$historyTableDiv = $historyContentDiv.find("#history_table_list"),
$toolbar,
columns,
fnRowCallback,
booleans = {},
@ -158,8 +189,12 @@ var AIRTIME = (function(AIRTIME) {
text,
$nRow = $(nRow);
nRow.setAttribute('url-edit', editUrl);
nRow.setAttribute('url-delete', deleteUrl);
// add checkbox
$nRow.find('td.his_checkbox').html("<input type='checkbox' name='cb_"+aData.history_id+"'>");
nRow.setAttribute('his-id', aData.history_id);
//nRow.setAttribute('url-edit', editUrl);
//nRow.setAttribute('url-delete', deleteUrl);
for (b in booleans) {
@ -190,6 +225,9 @@ var AIRTIME = (function(AIRTIME) {
});
oTable.fnSetFilteringDelay(350);
$toolbar = $historyTableDiv.parents(".dataTables_wrapper").find(".fg-toolbar:first");
createToolbarButtons($toolbar);
return oTable;
}
@ -313,6 +351,7 @@ var AIRTIME = (function(AIRTIME) {
}
}
/*
$historyContentDiv.on("click", "#history_table_list tr", function(ev) {
openRow(oTableItem, this);
});
@ -320,6 +359,7 @@ var AIRTIME = (function(AIRTIME) {
$historyContentDiv.on("click", "#history_table_aggregate tr", function(ev) {
openRow(oTableAgg, this);
});
*/
$("#his_create").click(function(e) {
var url = baseUrl+"playouthistory/edit-list-item/format/json" ;
@ -434,6 +474,72 @@ var AIRTIME = (function(AIRTIME) {
$historyContentDiv.find("#his-tabs").tabs();
// begin context menu initialization.
$.contextMenu({
selector: '#history_table_list td:not(.library_checkbox)',
trigger: "left",
ignoreRightClick: true,
build: function($el, e) {
var items,
callback,
$tr,
id;
$tr = $el.parents("tr");
id = $tr.get(0).getAttribute("his-id");
function processMenuItems(oItems) {
// define an edit callback.
if (oItems.edit !== undefined) {
callback = function() {
$.post(oItems.edit.url, {format: "json"}, function(json) {
makeHistoryDialog(json.dialog);
}, "json");
};
oItems.edit.callback = callback;
}
// define a delete callback.
if (oItems.del !== undefined) {
callback = function() {
var c = confirm("Delete this entry?");
if (c) {
$.post(oItems.del.url, {format: "json"}, function(json) {
oTableItem.fnDraw();
});
}
};
oItems.del.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 {
items: items
};
}
});
};
return AIRTIME;