CC-3174 : showbuilder

group add/delete is working
This commit is contained in:
Naomi Aro 2012-02-01 18:47:08 +01:00
parent 3d502b748f
commit f5b2a23eb1
9 changed files with 177 additions and 125 deletions

View file

@ -1,6 +1,6 @@
function fnLibraryTableRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$(nRow).attr("id", aData["id"]);
$(nRow).attr("id", aData["row_id"]);
return nRow;
}
@ -30,13 +30,22 @@ function addLibraryItemEvents() {
}
function setupLibraryToolbar() {
/*
* @param oTable the datatables instance for the library.
*/
function setupLibraryToolbar(oTable) {
var aButtons,
oSettings;
//[0] = button text
//[1] = id
//[2] = enabled
var aButtons = [["Reset Order", "library_order_reset", true],
aButtons = [["Reset Order", "library_order_reset", true],
["Delete", "library_group_delete", false],
["Add", "library_group_add", false]];
addToolBarButtonsLibrary(aButtons);
oSettings = oTable.fnSettings();
oSettings.fnServerData.start = oRange.start;
}

View file

@ -26,28 +26,55 @@ function addLibraryItemEvents() {
function setupLibraryToolbar() {
var aButtons,
fnTest,
fnAddSelectedItems;
fnAddSelectedItems,
oSettings,
oLibTable = $("#library_display").dataTable(),
oSchedTable = $("#show_builder_table").dataTable(),
oLibTT = TableTools.fnGetInstance('library_display'),
oSchedTT = TableTools.fnGetInstance('show_builder_table');
fnTest = function() {
alert("hi");
};
fnAddSelectedItems = function() {
var oTT = TableTools.fnGetInstance('show_builder_table'),
aData = oTT.fnGetSelectedData(),
i,
length = aData.length;
var aData = oLibTT.fnGetSelectedData(),
item,
temp,
aMediaIds = [],
aSchedIds = [];
for (i=0, i<length; i+=1;) {
var x;
//process selected files/playlists.
for (item in aData) {
temp = aData[item];
if (temp !== null && temp.hasOwnProperty('id')) {
aMediaIds.push({"id": temp.id, "type": temp.ftype});
}
}
aData = oSchedTT.fnGetSelectedData();
//process selected schedule rows to add media after.
for (item in aData) {
temp = aData[item];
if (temp !== null && temp.hasOwnProperty('id')) {
aSchedIds.push({"id": temp.id, "instance": temp.instance});
}
}
$.post("/showbuilder/schedule-add",
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
function(json){
oLibTT.fnSelectNone();
oSchedTable.fnDraw();
});
};
//[0] = button text
//[1] = id
//[2] = enabled
aButtons = [["Reset Order", "library_order_reset", true, fnTest],
["Delete", "library_group_delete", false, fnTest],
["Add", "library_group_add", false, fnTest]];
["Add", "library_group_add", false, fnAddSelectedItems]];
addToolBarButtonsLibrary(aButtons);
}

View file

@ -327,7 +327,7 @@ function createDataTable(data) {
/* Genre */ {"sTitle": "Genre", "sName": "genre", "mDataProp": "genre", "sWidth": "10%", "sClass": "library_genre"},
/* Year */ {"sTitle": "Year", "sName": "year", "mDataProp": "year", "sWidth": "8%", "sClass": "library_year"},
/* Length */ {"sTitle": "Length", "sName": "length", "mDataProp": "length", "sWidth": "10%", "sClass": "library_length"},
/* Type */ {"sTitle": "Type", "sName": "ftype", "bSearchable": false, "mDataProp": "ftype", "sWidth": "9%", "sClass": "library_type"},
/* Type */ {"sTitle": "Type", "sName": "ftype", "bSearchable": false, "mDataProp": "image", "sWidth": "9%", "sClass": "library_type"},
/* Upload Time */ {"sTitle": "Upload Time", "sName": "utime", "mDataProp": "utime", "sClass": "library_upload_time"},
/* Last Modified */ {"sTitle": "Last Modified", "sName": "mtime", "bVisible": false, "mDataProp": "mtime", "sClass": "library_modified_time"},
],
@ -347,8 +347,7 @@ function createDataTable(data) {
"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);
@ -358,8 +357,7 @@ function createDataTable(data) {
}
},
"fnRowDeselected": function ( node ) {
var x;
//seems to happen if everything is deselected
if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", false);
@ -380,7 +378,7 @@ function createDataTable(data) {
});
oTable.fnSetFilteringDelay(350);
setupLibraryToolbar();
setupLibraryToolbar(oTable);
$('#library_order_reset').click(function() {
ColReorder.fnReset( oTable );

View file

@ -154,6 +154,11 @@ $(document).ready(function() {
}
else if (aData.empty === true) {
node = nRow.children[0];
node.innerHTML = '';
sSeparatorHTML = '<span>Show Empty</span>';
fnPrepareSeparatorRow(sSeparatorHTML, "show-builder-empty odd");
}
else {
$(nRow).attr("id", "sched_"+aData.id);
@ -189,7 +194,7 @@ $(document).ready(function() {
$.post( "/showbuilder/schedule-remove",
{"ids": ids, "format": "json"},
function(data) {
var x;
oTable.fnDraw();
});
};
@ -226,9 +231,18 @@ $(document).ready(function() {
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [],
"fnPreRowSelect": function ( e ) {
var node = e.currentTarget;
//don't select separating rows, or shows without privileges.
if ($(node).hasClass("show-builder-header")
|| $(node).hasClass("show-builder-footer")
|| $(node).hasClass("show-builder-not-allowed")){
return false;
}
return true;
},
"fnRowSelected": function ( node ) {
var x;
//seems to happen if everything is selected
if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", true);
@ -238,8 +252,7 @@ $(document).ready(function() {
}
},
"fnRowDeselected": function ( node ) {
var x;
//seems to happen if everything is deselected
if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", false);
@ -250,24 +263,24 @@ $(document).ready(function() {
}
},
// R = ColReorder, C = ColVis, see datatables doc for others
// R = ColReorderResize, C = ColVis, T = TableTools
"sDom": 'Rr<"H"CT<"#show_builder_toolbar">>t<"F">',
//options for infinite scrolling
//"bScrollInfinite": true,
//"bScrollCollapse": true,
//"sScrollY": "400px",
"sAjaxDataProp": "schedule",
"sAjaxSource": "/showbuilder/builder-feed"
"sAjaxSource": "/showbuilder/builder-feed"
});
$('[name="sb_cb_all"]').click(function(){
var oTT = TableTools.fnGetInstance('show_builder_table');
if ($(this).is(":checked")) {
oTT.fnSelectAll();
var allowedNodes;
allowedNodes = oTable.find('tr:not(.show-builder-header):not(.show-builder-footer):not(.show-builder-not-allowed)');
allowedNodes.each(function(i, el){
oTT.fnSelect(el);
});
}
else {
oTT.fnSelectNone();
@ -299,7 +312,7 @@ $(document).ready(function() {
placeholder: "placeholder show-builder-placeholder",
forceHelperSize: true,
forcePlaceholderSize: true,
items: 'tr:not(.show-builder-header):not(.show-builder-footer)',
items: 'tr:not(.show-builder-header):not(.show-builder-footer):not(.show-builder-not-allowed):not(.show-builder-empty)',
//cancel: ".show-builder-header .show-builder-footer",
receive: function(event, ui) {
var x;