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 );