CC-3174 : showbuilder
check into issue that propel doesn't return DateTime object in UTC. using table tools to keep track of selected rows.
This commit is contained in:
parent
3f3117cf0e
commit
fbda0e733b
16 changed files with 3999 additions and 437 deletions
|
@ -1,189 +1,10 @@
|
|||
/*
|
||||
function tpStartOnHourShowCallback(hour) {
|
||||
var tpEndHour = $('#show_builder_timepicker_end').timepicker('getHour');
|
||||
|
||||
// Check if proposed hour is prior or equal to selected end time hour
|
||||
if (hour <= tpEndHour) { return true; }
|
||||
// if hour did not match, it can not be selected
|
||||
return false;
|
||||
}
|
||||
|
||||
function tpStartOnMinuteShowCallback(hour, minute) {
|
||||
var tpEndHour = $('#show_builder_timepicker_end').timepicker('getHour'),
|
||||
tpEndMinute = $('#show_builder_timepicker_end').timepicker('getMinute');
|
||||
|
||||
// Check if proposed hour is prior to selected end time hour
|
||||
if (hour < tpEndHour) { return true; }
|
||||
// Check if proposed hour is equal to selected end time hour and minutes is prior
|
||||
if ( (hour == tpEndHour) && (minute < tpEndMinute) ) { return true; }
|
||||
// if minute did not match, it can not be selected
|
||||
return false;
|
||||
}
|
||||
|
||||
function tpEndOnHourShowCallback(hour) {
|
||||
var tpStartHour = $('#show_builder_timepicker_start').timepicker('getHour');
|
||||
|
||||
// Check if proposed hour is after or equal to selected start time hour
|
||||
if (hour >= tpStartHour) { return true; }
|
||||
// if hour did not match, it can not be selected
|
||||
return false;
|
||||
}
|
||||
|
||||
function tpEndOnMinuteShowCallback(hour, minute) {
|
||||
var tpStartHour = $('#show_builder_timepicker_start').timepicker('getHour'),
|
||||
tpStartMinute = $('#show_builder_timepicker_start').timepicker('getMinute');
|
||||
|
||||
// Check if proposed hour is after selected start time hour
|
||||
if (hour > tpStartHour) { return true; }
|
||||
// Check if proposed hour is equal to selected start time hour and minutes is after
|
||||
if ( (hour == tpStartHour) && (minute > tpStartMinute) ) { return true; }
|
||||
// if minute did not match, it can not be selected
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Get the schedule range start in unix timestamp form (in seconds).
|
||||
* defaults to NOW if nothing is selected.
|
||||
*
|
||||
* @param String sDatePickerId
|
||||
*
|
||||
* @param String sTimePickerId
|
||||
*
|
||||
* @return Number iTime
|
||||
*/
|
||||
function fnGetUIPickerUnixTimestamp(sDatePickerId, sTimePickerId) {
|
||||
var oDate,
|
||||
oTimePicker = $( sTimePickerId ),
|
||||
iTime,
|
||||
iHour,
|
||||
iMin,
|
||||
iServerOffset,
|
||||
iClientOffset;
|
||||
|
||||
oDate = $( sDatePickerId ).datepicker( "getDate" );
|
||||
|
||||
//nothing has been selected from this datepicker.
|
||||
if (oDate === null) {
|
||||
oDate = new Date();
|
||||
}
|
||||
else {
|
||||
iHour = oTimePicker.timepicker('getHour');
|
||||
iMin = oTimePicker.timepicker('getMinute');
|
||||
|
||||
oDate.setHours(iHour, iMin);
|
||||
}
|
||||
|
||||
iTime = oDate.getTime(); //value is in millisec.
|
||||
iTime = Math.round(iTime / 1000);
|
||||
iServerOffset = serverTimezoneOffset;
|
||||
iClientOffset = oDate.getTimezoneOffset() * 60;//function returns minutes
|
||||
|
||||
//adjust for the fact the the Date object is
|
||||
iTime = iTime + iServerOffset + iClientOffset;
|
||||
|
||||
return iTime;
|
||||
}
|
||||
/*
|
||||
* Returns an object containing a unix timestamp in seconds for the start/end range
|
||||
*
|
||||
* @return Object {"start", "end", "range"}
|
||||
*/
|
||||
function fnGetScheduleRange() {
|
||||
var iStart,
|
||||
iEnd,
|
||||
iRange,
|
||||
MIN_RANGE = 60*60*24;
|
||||
|
||||
iStart = fnGetUIPickerUnixTimestamp("#show_builder_datepicker_start", "#show_builder_timepicker_start");
|
||||
iEnd = fnGetUIPickerUnixTimestamp("#show_builder_datepicker_end", "#show_builder_timepicker_end");
|
||||
|
||||
iRange = iEnd - iStart;
|
||||
|
||||
//return min range
|
||||
if (iRange < MIN_RANGE){
|
||||
iEnd = iStart + MIN_RANGE;
|
||||
iRange = MIN_RANGE;
|
||||
}
|
||||
|
||||
return {
|
||||
start: iStart,
|
||||
end: iEnd,
|
||||
range: iRange
|
||||
};
|
||||
}
|
||||
|
||||
var fnServerData = function fnServerData( sSource, aoData, fnCallback ) {
|
||||
aoData.push( { name: "format", value: "json"} );
|
||||
|
||||
if (fnServerData.hasOwnProperty("start")) {
|
||||
aoData.push( { name: "start", value: fnServerData.start} );
|
||||
}
|
||||
if (fnServerData.hasOwnProperty("end")) {
|
||||
aoData.push( { name: "end", value: fnServerData.end} );
|
||||
}
|
||||
|
||||
$.ajax( {
|
||||
"dataType": "json",
|
||||
"type": "GET",
|
||||
"url": sSource,
|
||||
"data": aoData,
|
||||
"success": fnCallback
|
||||
} );
|
||||
};
|
||||
|
||||
var fnShowBuilderRowCallback = function ( nRow, aData, iDisplayIndex, iDisplayIndexFull ){
|
||||
var i,
|
||||
sSeparatorHTML,
|
||||
fnPrepareSeparatorRow,
|
||||
node;
|
||||
|
||||
//save some info for reordering purposes.
|
||||
$(nRow).data({aData: aData});
|
||||
|
||||
fnPrepareSeparatorRow = function(sRowContent, sClass) {
|
||||
|
||||
node = nRow.children[1];
|
||||
node.innerHTML = sRowContent;
|
||||
node.setAttribute('colspan',100);
|
||||
for (i = 2; i < nRow.children.length; i = i+1) {
|
||||
node = nRow.children[i];
|
||||
node.innerHTML = "";
|
||||
node.setAttribute("style", "display : none");
|
||||
}
|
||||
|
||||
nRow.className = sClass;
|
||||
};
|
||||
|
||||
if (aData.header === true) {
|
||||
node = nRow.children[0];
|
||||
node.innerHTML = '<span class="ui-icon ui-icon-play"></span>';
|
||||
|
||||
sSeparatorHTML = '<span>'+aData.title+'</span><span>'+aData.starts+'</span><span>'+aData.ends+'</span>';
|
||||
fnPrepareSeparatorRow(sSeparatorHTML, "show-builder-header");
|
||||
}
|
||||
else if (aData.footer === true) {
|
||||
|
||||
node = nRow.children[0];
|
||||
node.innerHTML = '<span class="ui-icon ui-icon-check"></span>';
|
||||
|
||||
sSeparatorHTML = '<span>Show Footer</span>';
|
||||
fnPrepareSeparatorRow(sSeparatorHTML, "show-builder-footer");
|
||||
}
|
||||
else if (aData.empty === true) {
|
||||
|
||||
}
|
||||
else {
|
||||
$(nRow).attr("id", "sched_"+aData.id);
|
||||
}
|
||||
|
||||
return nRow;
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
var oTable,
|
||||
var tableDiv = $('#show_builder_table'),
|
||||
oTable,
|
||||
oBaseDatePickerSettings,
|
||||
oBaseTimePickerSettings;
|
||||
oBaseTimePickerSettings,
|
||||
fnAddSelectedItems,
|
||||
fnRemoveSelectedItems;
|
||||
|
||||
oBaseDatePickerSettings = {
|
||||
dateFormat: 'yy-mm-dd',
|
||||
|
@ -203,9 +24,178 @@ $(document).ready(function() {
|
|||
defaultTime: '0:00'
|
||||
};
|
||||
|
||||
oTable = $('#show_builder_table').dataTable( {
|
||||
/*
|
||||
* Get the schedule range start in unix timestamp form (in seconds).
|
||||
* defaults to NOW if nothing is selected.
|
||||
*
|
||||
* @param String sDatePickerId
|
||||
*
|
||||
* @param String sTimePickerId
|
||||
*
|
||||
* @return Number iTime
|
||||
*/
|
||||
function fnGetUIPickerUnixTimestamp(sDatePickerId, sTimePickerId) {
|
||||
var oDate,
|
||||
oTimePicker = $( sTimePickerId ),
|
||||
iTime,
|
||||
iHour,
|
||||
iMin,
|
||||
iServerOffset,
|
||||
iClientOffset;
|
||||
|
||||
oDate = $( sDatePickerId ).datepicker( "getDate" );
|
||||
|
||||
//nothing has been selected from this datepicker.
|
||||
if (oDate === null) {
|
||||
oDate = new Date();
|
||||
}
|
||||
else {
|
||||
iHour = oTimePicker.timepicker('getHour');
|
||||
iMin = oTimePicker.timepicker('getMinute');
|
||||
|
||||
oDate.setHours(iHour, iMin);
|
||||
}
|
||||
|
||||
iTime = oDate.getTime(); //value is in millisec.
|
||||
iTime = Math.round(iTime / 1000);
|
||||
iServerOffset = serverTimezoneOffset;
|
||||
iClientOffset = oDate.getTimezoneOffset() * 60;//function returns minutes
|
||||
|
||||
//adjust for the fact the the Date object is
|
||||
iTime = iTime + iServerOffset + iClientOffset;
|
||||
|
||||
return iTime;
|
||||
}
|
||||
/*
|
||||
* Returns an object containing a unix timestamp in seconds for the start/end range
|
||||
*
|
||||
* @return Object {"start", "end", "range"}
|
||||
*/
|
||||
function fnGetScheduleRange() {
|
||||
var iStart,
|
||||
iEnd,
|
||||
iRange,
|
||||
MIN_RANGE = 60*60*24;
|
||||
|
||||
iStart = fnGetUIPickerUnixTimestamp("#show_builder_datepicker_start", "#show_builder_timepicker_start");
|
||||
iEnd = fnGetUIPickerUnixTimestamp("#show_builder_datepicker_end", "#show_builder_timepicker_end");
|
||||
|
||||
iRange = iEnd - iStart;
|
||||
|
||||
//return min range
|
||||
if (iRange < MIN_RANGE){
|
||||
iEnd = iStart + MIN_RANGE;
|
||||
iRange = MIN_RANGE;
|
||||
}
|
||||
|
||||
return {
|
||||
start: iStart,
|
||||
end: iEnd,
|
||||
range: iRange
|
||||
};
|
||||
}
|
||||
|
||||
var fnServerData = function ( sSource, aoData, fnCallback ) {
|
||||
aoData.push( { name: "format", value: "json"} );
|
||||
|
||||
if (fnServerData.hasOwnProperty("start")) {
|
||||
aoData.push( { name: "start", value: fnServerData.start} );
|
||||
}
|
||||
if (fnServerData.hasOwnProperty("end")) {
|
||||
aoData.push( { name: "end", value: fnServerData.end} );
|
||||
}
|
||||
|
||||
$.ajax( {
|
||||
"dataType": "json",
|
||||
"type": "GET",
|
||||
"url": sSource,
|
||||
"data": aoData,
|
||||
"success": fnCallback
|
||||
} );
|
||||
};
|
||||
|
||||
var fnShowBuilderRowCallback = function ( nRow, aData, iDisplayIndex, iDisplayIndexFull ){
|
||||
var i,
|
||||
sSeparatorHTML,
|
||||
fnPrepareSeparatorRow,
|
||||
node;
|
||||
|
||||
//save some info for reordering purposes.
|
||||
$(nRow).data({aData: aData});
|
||||
|
||||
fnPrepareSeparatorRow = function(sRowContent, sClass) {
|
||||
|
||||
node = nRow.children[1];
|
||||
node.innerHTML = sRowContent;
|
||||
node.setAttribute('colspan',100);
|
||||
for (i = 2; i < nRow.children.length; i = i+1) {
|
||||
node = nRow.children[i];
|
||||
node.innerHTML = "";
|
||||
node.setAttribute("style", "display : none");
|
||||
}
|
||||
|
||||
nRow.className = sClass;
|
||||
};
|
||||
|
||||
if (aData.header === true) {
|
||||
node = nRow.children[0];
|
||||
node.innerHTML = '<span class="ui-icon ui-icon-play"></span>';
|
||||
|
||||
sSeparatorHTML = '<span>'+aData.title+'</span><span>'+aData.starts+'</span><span>'+aData.ends+'</span>';
|
||||
fnPrepareSeparatorRow(sSeparatorHTML, "show-builder-header");
|
||||
}
|
||||
else if (aData.footer === true) {
|
||||
|
||||
node = nRow.children[0];
|
||||
node.innerHTML = '<span class="ui-icon ui-icon-check"></span>';
|
||||
|
||||
sSeparatorHTML = '<span>Show Footer</span>';
|
||||
fnPrepareSeparatorRow(sSeparatorHTML, "show-builder-footer");
|
||||
}
|
||||
else if (aData.empty === true) {
|
||||
|
||||
}
|
||||
else {
|
||||
$(nRow).attr("id", "sched_"+aData.id);
|
||||
|
||||
node = nRow.children[0];
|
||||
if (aData.checkbox === true) {
|
||||
node.innerHTML = '<input type="checkbox" name="'+aData.id+'"></input>';
|
||||
}
|
||||
else {
|
||||
node.innerHTML = '';
|
||||
|
||||
$(nRow).addClass("show-builder-not-allowed");
|
||||
}
|
||||
}
|
||||
|
||||
return nRow;
|
||||
};
|
||||
|
||||
fnRemoveSelectedItems = function() {
|
||||
var oTT = TableTools.fnGetInstance('show_builder_table'),
|
||||
aData = oTT.fnGetSelectedData(),
|
||||
item,
|
||||
temp,
|
||||
ids = [];
|
||||
|
||||
for (item in aData) {
|
||||
temp = aData[item];
|
||||
if (temp !== null && temp.hasOwnProperty('id')) {
|
||||
ids.push(temp.id);
|
||||
}
|
||||
}
|
||||
|
||||
$.post( "/showbuilder/schedule-remove",
|
||||
{"ids": ids, "format": "json"},
|
||||
function(data) {
|
||||
var x;
|
||||
});
|
||||
};
|
||||
|
||||
oTable = tableDiv.dataTable( {
|
||||
"aoColumns": [
|
||||
/* checkbox */ {"mDataProp": "checkbox", "sTitle": "<input type='checkbox' name='sb_all'>", "sWidth": "25px"},
|
||||
/* checkbox */ {"mDataProp": "checkbox", "sTitle": "<input type='checkbox' name='sb_cb_all'>", "sWidth": "15px"},
|
||||
// /* scheduled id */{"mDataProp": "id", "sTitle": "id"},
|
||||
// /* instance */{"mDataProp": "instance", "sTitle": "si_id"},
|
||||
/* starts */{"mDataProp": "starts", "sTitle": "Airtime"},
|
||||
|
@ -233,8 +223,35 @@ $(document).ready(function() {
|
|||
"aiExclude": [ 0, 1 ]
|
||||
},
|
||||
|
||||
"oTableTools": {
|
||||
"sRowSelect": "multi",
|
||||
"aButtons": [],
|
||||
"fnRowSelected": function ( node ) {
|
||||
var x;
|
||||
|
||||
//seems to happen if everything is selected
|
||||
if ( node === null) {
|
||||
oTable.find("input[type=checkbox]").attr("checked", true);
|
||||
}
|
||||
else {
|
||||
$(node).find("input[type=checkbox]").attr("checked", true);
|
||||
}
|
||||
},
|
||||
"fnRowDeselected": function ( node ) {
|
||||
var x;
|
||||
|
||||
//seems to happen if everything is deselected
|
||||
if ( node === null) {
|
||||
oTable.find("input[type=checkbox]").attr("checked", false);
|
||||
}
|
||||
else {
|
||||
$(node).find("input[type=checkbox]").attr("checked", false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// R = ColReorder, C = ColVis, see datatables doc for others
|
||||
"sDom": 'Rr<"H"C>t<"F">',
|
||||
"sDom": 'Rr<"H"CT<"#show_builder_toolbar">>t<"F">',
|
||||
|
||||
//options for infinite scrolling
|
||||
//"bScrollInfinite": true,
|
||||
|
@ -246,6 +263,17 @@ $(document).ready(function() {
|
|||
|
||||
});
|
||||
|
||||
$('[name="sb_cb_all"]').click(function(){
|
||||
var oTT = TableTools.fnGetInstance('show_builder_table');
|
||||
|
||||
if ($(this).is(":checked")) {
|
||||
oTT.fnSelectAll();
|
||||
}
|
||||
else {
|
||||
oTT.fnSelectNone();
|
||||
}
|
||||
});
|
||||
|
||||
$( "#show_builder_datepicker_start" ).datepicker(oBaseDatePickerSettings);
|
||||
|
||||
$( "#show_builder_timepicker_start" ).timepicker(oBaseTimePickerSettings);
|
||||
|
@ -255,13 +283,11 @@ $(document).ready(function() {
|
|||
$( "#show_builder_timepicker_end" ).timepicker(oBaseTimePickerSettings);
|
||||
|
||||
$( "#show_builder_timerange_button" ).click(function(ev){
|
||||
var oTable,
|
||||
oSettings,
|
||||
var oSettings,
|
||||
oRange;
|
||||
|
||||
oRange = fnGetScheduleRange();
|
||||
|
||||
oTable = $('#show_builder_table').dataTable({"bRetrieve": true});
|
||||
oSettings = oTable.fnSettings();
|
||||
oSettings.fnServerData.start = oRange.start;
|
||||
oSettings.fnServerData.end = oRange.end;
|
||||
|
@ -269,7 +295,7 @@ $(document).ready(function() {
|
|||
oTable.fnDraw();
|
||||
});
|
||||
|
||||
$( "#show_builder_table" ).sortable({
|
||||
tableDiv.sortable({
|
||||
placeholder: "placeholder show-builder-placeholder",
|
||||
forceHelperSize: true,
|
||||
forcePlaceholderSize: true,
|
||||
|
@ -307,4 +333,9 @@ $(document).ready(function() {
|
|||
}
|
||||
});
|
||||
|
||||
$("#show_builder_toolbar")
|
||||
.append('<span class="ui-icon ui-icon-trash"></span>')
|
||||
.find(".ui-icon-trash")
|
||||
.click(fnRemoveSelectedItems);
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue