replacing booleans in table with checkbox + column title
This commit is contained in:
parent
c3c64e6fb1
commit
673c422015
|
@ -254,9 +254,21 @@ class Application_Service_HistoryService
|
||||||
$timezoneUTC = new DateTimeZone("UTC");
|
$timezoneUTC = new DateTimeZone("UTC");
|
||||||
$timezoneLocal = new DateTimeZone($this->timezone);
|
$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.
|
//need to display the results in the station's timezone.
|
||||||
foreach ($rows as $index => &$result) {
|
foreach ($rows as $index => &$result) {
|
||||||
|
|
||||||
|
foreach ($boolCast as $name) {
|
||||||
|
$result[$name] = (bool) $result[$name];
|
||||||
|
}
|
||||||
|
|
||||||
$dateTime = new DateTime($result["starts"], $timezoneUTC);
|
$dateTime = new DateTime($result["starts"], $timezoneUTC);
|
||||||
$dateTime->setTimezone($timezoneLocal);
|
$dateTime->setTimezone($timezoneLocal);
|
||||||
$result["starts"] = $dateTime->format("Y-m-d H:i:s");
|
$result["starts"] = $dateTime->format("Y-m-d H:i:s");
|
||||||
|
@ -1019,7 +1031,8 @@ class Application_Service_HistoryService
|
||||||
$columns[] = array(
|
$columns[] = array(
|
||||||
"sTitle"=> $label,
|
"sTitle"=> $label,
|
||||||
"mDataProp"=> $key,
|
"mDataProp"=> $key,
|
||||||
"sClass"=> "his_{$key}"
|
"sClass"=> "his_{$key}",
|
||||||
|
"sDataType"=> $field["type"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
function aggregateHistoryTable() {
|
function aggregateHistoryTable() {
|
||||||
var oTable,
|
var oTable,
|
||||||
$historyTableDiv = $historyContentDiv.find("#history_table_aggregate"),
|
$historyTableDiv = $historyContentDiv.find("#history_table_aggregate"),
|
||||||
|
columns,
|
||||||
fnRowCallback;
|
fnRowCallback;
|
||||||
|
|
||||||
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
||||||
|
@ -104,7 +105,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
nRow.setAttribute('url-edit', editUrl);
|
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( {
|
oTable = $historyTableDiv.dataTable( {
|
||||||
|
|
||||||
|
@ -133,16 +134,40 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
function itemHistoryTable() {
|
function itemHistoryTable() {
|
||||||
var oTable,
|
var oTable,
|
||||||
$historyTableDiv = $historyContentDiv.find("#history_table_list"),
|
$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 ) {
|
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/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-edit', editUrl);
|
||||||
nRow.setAttribute('url-delete', deleteUrl);
|
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( {
|
oTable = $historyTableDiv.dataTable( {
|
||||||
|
|
Loading…
Reference in New Issue