replacing booleans in table with checkbox + column title

This commit is contained in:
Naomi 2013-08-14 16:38:59 -04:00
parent c3c64e6fb1
commit 673c422015
2 changed files with 44 additions and 6 deletions

View File

@ -254,8 +254,20 @@ class Application_Service_HistoryService
$timezoneUTC = new DateTimeZone("UTC");
$timezoneLocal = new DateTimeZone($this->timezone);
$boolCast = array();
foreach ($fields as $index=>$field) {
if ($field["type"] == TEMPLATE_BOOLEAN) {
$boolCast[] = $field["name"];
}
}
//need to display the results in the station's timezone.
foreach ($rows as $index => &$result) {
foreach ($boolCast as $name) {
$result[$name] = (bool) $result[$name];
}
$dateTime = new DateTime($result["starts"], $timezoneUTC);
$dateTime->setTimezone($timezoneLocal);
@ -1019,7 +1031,8 @@ class Application_Service_HistoryService
$columns[] = array(
"sTitle"=> $label,
"mDataProp"=> $key,
"sClass"=> "his_{$key}"
"sClass"=> "his_{$key}",
"sDataType"=> $field["type"]
);
}

View File

@ -96,6 +96,7 @@ var AIRTIME = (function(AIRTIME) {
function aggregateHistoryTable() {
var oTable,
$historyTableDiv = $historyContentDiv.find("#history_table_aggregate"),
columns,
fnRowCallback;
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
@ -104,7 +105,7 @@ var AIRTIME = (function(AIRTIME) {
nRow.setAttribute('url-edit', editUrl);
};
var columns = JSON.parse(localStorage.getItem('datatables-historyfile-aoColumns'));
columns = JSON.parse(localStorage.getItem('datatables-historyfile-aoColumns'));
oTable = $historyTableDiv.dataTable( {
@ -133,18 +134,42 @@ var AIRTIME = (function(AIRTIME) {
function itemHistoryTable() {
var oTable,
$historyTableDiv = $historyContentDiv.find("#history_table_list"),
fnRowCallback;
columns,
fnRowCallback,
booleans = {},
i, c;
var columns = JSON.parse(localStorage.getItem('datatables-historyitem-aoColumns'));
columns = JSON.parse(localStorage.getItem('datatables-historyitem-aoColumns'));
for (i in columns) {
c = columns[i];
if (c["sDataType"] === "boolean") {
booleans[c["mDataProp"]] = c["sTitle"];
}
}
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var editUrl = baseUrl+"playouthistory/edit-list-item/format/json/id/"+aData.history_id,
deleteUrl = baseUrl+"playouthistory/delete-list-item/format/json/id/"+aData.history_id;
deleteUrl = baseUrl+"playouthistory/delete-list-item/format/json/id/"+aData.history_id,
emptyCheckBox = String.fromCharCode(parseInt(2610, 16)),
checkedCheckBox = String.fromCharCode(parseInt(2612, 16)),
b,
text,
$nRow = $(nRow);
nRow.setAttribute('url-edit', editUrl);
nRow.setAttribute('url-delete', deleteUrl);
for (b in booleans) {
text = aData[b] ? checkedCheckBox : emptyCheckBox;
text = text + " " + booleans[b];
$nRow.find(".his_"+b).html(text);
}
};
oTable = $historyTableDiv.dataTable( {
"aoColumns": columns,