add ability to use multiple episode dataTables
This commit is contained in:
parent
fb35881df7
commit
28ca9c0e0f
|
@ -480,7 +480,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
oTable.fnStandingRedraw();
|
oTable.fnStandingRedraw();
|
||||||
};
|
};
|
||||||
|
|
||||||
mod.fnDeleteItems = function(aMedia) {
|
mod.fnDeleteItems = function(aMedia, podcastId) {
|
||||||
//Prevent the user from spamming the delete button while the AJAX request is in progress
|
//Prevent the user from spamming the delete button while the AJAX request is in progress
|
||||||
AIRTIME.button.disableButton("btn-group #sb-delete", false);
|
AIRTIME.button.disableButton("btn-group #sb-delete", false);
|
||||||
var openTabObjectIds = $(".obj_id"),
|
var openTabObjectIds = $(".obj_id"),
|
||||||
|
@ -505,11 +505,11 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
chosenItems = {};
|
chosenItems = {};
|
||||||
|
|
||||||
// TODO: correct check whether used to delete episodes
|
if (typeof(podcastId) === "undefined") {
|
||||||
if (oTable == $datatables[mod.DataTableTypeEnum.PODCAST_EPISODES]) {
|
|
||||||
mod.podcastEpisodeTableWidget.reload();
|
|
||||||
} else {
|
|
||||||
oTable.fnStandingRedraw();
|
oTable.fnStandingRedraw();
|
||||||
|
} else {
|
||||||
|
AIRTIME.podcast.episodeTables[podcastId].reload(this.podcast_id);
|
||||||
|
AIRTIME.podcast.episodeTables[podcastId].clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Re-enable the delete button
|
//Re-enable the delete button
|
||||||
|
@ -1331,8 +1331,8 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
return oTable;
|
return oTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
mod.openPodcastEpisodeDialog = function () {
|
mod.openPodcastEpisodeDialog = function (podcastId) {
|
||||||
var episode = mod.podcastEpisodeTableWidget.getSelectedRows()[0];
|
var episode = AIRTIME.podcast.episodeTables[podcastId].getSelectedRows()[0];
|
||||||
$("body").append("<div id='podcast_episode_dialog'></div>");
|
$("body").append("<div id='podcast_episode_dialog'></div>");
|
||||||
var dialog = $("#podcast_episode_dialog").html(episode.description);
|
var dialog = $("#podcast_episode_dialog").html(episode.description);
|
||||||
dialog.html(dialog.text());
|
dialog.html(dialog.text());
|
||||||
|
|
|
@ -6,6 +6,7 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod = AIRTIME.podcast;
|
mod = AIRTIME.podcast;
|
||||||
|
mod.episodeTables = {};
|
||||||
|
|
||||||
var endpoint = '/rest/podcast/', PodcastEpisodeTable;
|
var endpoint = '/rest/podcast/', PodcastEpisodeTable;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
successMsg.hide("fast");
|
successMsg.hide("fast");
|
||||||
}, 5000);
|
}, 5000);
|
||||||
AIRTIME.library.podcastDataTable.fnDraw();
|
AIRTIME.library.podcastDataTable.fnDraw();
|
||||||
|
self.$scope.tab.setName(self.$scope.podcast.title);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,13 +123,14 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
self.$scope.tab.setName(self.$scope.podcast.title);
|
self.$scope.tab.setName(self.$scope.podcast.title);
|
||||||
// Add an onclose hook to the tab to remove the table object and the
|
// Add an onclose hook to the tab to remove the table object and the
|
||||||
// import listener so we don't cause memory leaks.
|
// import listener so we don't cause memory leaks.
|
||||||
if (self.episodeTable) {
|
var podcastId = self.$scope.podcast.id.toString();
|
||||||
self.$scope.tab.assignOnCloseHandler(function () {
|
self.$scope.tab.assignOnCloseHandler(function () {
|
||||||
self.episodeTable.destroy();
|
if ( AIRTIME.podcast.episodeTables.hasOwnProperty(podcastId) ) {
|
||||||
self.episodeTable = null;
|
AIRTIME.podcast.episodeTables[podcastId].destroy();
|
||||||
|
AIRTIME.podcast.episodeTables[podcastId] = null;
|
||||||
self.$scope.$destroy();
|
self.$scope.$destroy();
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -348,6 +351,7 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
// Add podcast episode table in right-side panel below podcast edit form
|
// Add podcast episode table in right-side panel below podcast edit form
|
||||||
var episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatableWithButtonEvents(
|
var episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatableWithButtonEvents(
|
||||||
$("#podcast_episodes_" + podcast.id),
|
$("#podcast_episodes_" + podcast.id),
|
||||||
|
podcast.id.toString()
|
||||||
);
|
);
|
||||||
episodeTable.reload(podcast.id);
|
episodeTable.reload(podcast.id);
|
||||||
episodeTable.clearSelection()
|
episodeTable.clearSelection()
|
||||||
|
@ -436,7 +440,7 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.importListener = setInterval(function () {
|
self.importListener = setInterval(function () {
|
||||||
var podcastId = self.config.podcastId, pendingRows = [];
|
var podcastId = self.config.podcastId, pendingRows = [];
|
||||||
if (!podcastId) return false;
|
if (!podcastId) return false;
|
||||||
var dt = self.getDatatable(), data = dt.fnGetData();
|
var dt = self.getDatatable(), data = dt.fnGetData();
|
||||||
// Iterate over the table data to check for any rows pending import
|
// Iterate over the table data to check for any rows pending import
|
||||||
$.each(data, function () {
|
$.each(data, function () {
|
||||||
|
@ -579,7 +583,7 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
csrf_token: $("#csrf").val(),
|
csrf_token: $("#csrf").val(),
|
||||||
episode: this
|
episode: this
|
||||||
}), function () {
|
}), function () {
|
||||||
dt.reload(this.podcast_id);
|
dt.reload(dt.config.podcastId);
|
||||||
});
|
});
|
||||||
|
|
||||||
remainingDiskSpace -= this.enclosure.length;
|
remainingDiskSpace -= this.enclosure.length;
|
||||||
|
@ -592,20 +596,18 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
* Delete one or more podcast episodes.
|
* Delete one or more podcast episodes.
|
||||||
*
|
*
|
||||||
* @param {id:string, type:string}[] data Array of data objects to be deleted
|
* @param {id:string, type:string}[] data Array of data objects to be deleted
|
||||||
* @param {PodcastEpisodeTable} dt PodcastEpisode table containing the data
|
* @param podcastId:string
|
||||||
*/
|
*/
|
||||||
mod.deleteSelectedEpisodes = function (data, dt) {
|
mod.deleteSelectedEpisodes = function (data, podcastId) {
|
||||||
$.each(data, function () {
|
$.each(data, function () {
|
||||||
AIRTIME.library.fnDeleteItems(data);
|
AIRTIME.library.fnDeleteItems(data, podcastId);
|
||||||
});
|
});
|
||||||
dt.reload(this.podcast_id);
|
|
||||||
dt.clearSelection();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the podcast episode table with working buttons
|
* Initialize the podcast episode table with working buttons
|
||||||
*/
|
*/
|
||||||
mod.initPodcastEpisodeDatatableWithButtonEvents = function (domNode) {
|
mod.initPodcastEpisodeDatatableWithButtonEvents = function (domNode, podcastId) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the import statuses of each selected episode to see which
|
* Check the import statuses of each selected episode to see which
|
||||||
|
@ -637,8 +639,8 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
title: "Import",
|
title: "Import",
|
||||||
eventHandlers: {
|
eventHandlers: {
|
||||||
click: function () {
|
click: function () {
|
||||||
var episodes = mod.podcastEpisodeTableWidget.getSelectedRows();
|
var episodes = mod.episodeTables[podcastId].getSelectedRows();
|
||||||
AIRTIME.podcast.importSelectedEpisodes(episodes, mod.podcastEpisodeTableWidget);
|
AIRTIME.podcast.importSelectedEpisodes(episodes, mod.episodeTables[podcastId]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validateConstraints: function () {
|
validateConstraints: function () {
|
||||||
|
@ -649,7 +651,7 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
{
|
{
|
||||||
eventHandlers: {
|
eventHandlers: {
|
||||||
click: function () {
|
click: function () {
|
||||||
var episodes = mod.podcastEpisodeTableWidget.getSelectedRows();
|
var episodes = mod.episodeTables[podcastId].getSelectedRows();
|
||||||
AIRTIME.podcast.editSelectedEpisodes(episodes);
|
AIRTIME.podcast.editSelectedEpisodes(episodes);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -661,12 +663,11 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
{
|
{
|
||||||
eventHandlers: {
|
eventHandlers: {
|
||||||
click: function () {
|
click: function () {
|
||||||
var data = [], episodes = mod.podcastEpisodeTableWidget.getSelectedRows();
|
var data = [], episodes = mod.episodeTables[podcastId].getSelectedRows();
|
||||||
$.each(episodes, function () {
|
$.each(episodes, function () {
|
||||||
data.push({id: this.file.id, type: this.file.ftype});
|
data.push({id: this.file.id, type: this.file.ftype});
|
||||||
});
|
});
|
||||||
console.log("podcast deletion:", data, mod.podcastEpisodeTableWidget);
|
AIRTIME.podcast.deleteSelectedEpisodes(data, podcastId);
|
||||||
AIRTIME.podcast.deleteSelectedEpisodes(data, mod.podcastEpisodeTableWidget);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validateConstraints: function () {
|
validateConstraints: function () {
|
||||||
|
@ -683,30 +684,32 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
};
|
};
|
||||||
|
|
||||||
$.extend(true, podcastEpisodeButtons, {
|
$.extend(true, podcastEpisodeButtons, {
|
||||||
// addToScheduleBtn: {
|
addToScheduleBtn: {
|
||||||
// title : $.i18n._('Add to Schedule'),
|
title : $.i18n._('Add to Schedule'),
|
||||||
// iconClass : '',
|
iconClass : 'icon-plus',
|
||||||
// extraBtnClass : 'btn-small',
|
extraBtnClass : 'btn-small',
|
||||||
// elementId : '',
|
elementId : '',
|
||||||
// eventHandlers : {
|
eventHandlers : {
|
||||||
// click: function () {
|
click: function () {
|
||||||
// var data = [], selected = mod.podcastEpisodeTableWidget.getSelectedRows();
|
var data = [], selected = AIRTIME.podcast.episodeTables[podcastId].getSelectedRows();
|
||||||
// $.each(selected, function () { data.push(this.file); });
|
$.each(selected, function () { data.push(this.file); });
|
||||||
// mod.addToSchedule(data);
|
AIRTIME.library.addToSchedule(data);
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// validateConstraints: function () {
|
validateConstraints: function () {
|
||||||
// // TODO: change text + behaviour for playlists, smart blocks, etc.
|
// TODO: change text + behaviour for playlists, smart blocks, etc.
|
||||||
// return checkSelectedEpisodeImportStatus.call(this, true);
|
return checkSelectedEpisodeImportStatus.call(this, true);
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
viewDescBtn: {
|
viewDescBtn: {
|
||||||
title : $.i18n._("View"),
|
title : $.i18n._("View"),
|
||||||
iconClass : "icon-globe",
|
iconClass : "icon-globe",
|
||||||
extraBtnClass : "btn-small",
|
extraBtnClass : "btn-small",
|
||||||
elementId : "",
|
elementId : "",
|
||||||
eventHandlers : {
|
eventHandlers : {
|
||||||
click: mod.openPodcastEpisodeDialog
|
click: function () {
|
||||||
|
AIRTIME.library.openPodcastEpisodeDialog(podcastId);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
validateConstraints: function () {
|
validateConstraints: function () {
|
||||||
return this.getSelectedRows().length == 1;
|
return this.getSelectedRows().length == 1;
|
||||||
|
@ -714,7 +717,7 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mod.podcastEpisodeTableWidget = AIRTIME.podcast.initPodcastEpisodeDatatable(
|
mod.episodeTables[podcastId] = AIRTIME.podcast.initPodcastEpisodeDatatable(
|
||||||
domNode,
|
domNode,
|
||||||
podcastEpisodeButtons,
|
podcastEpisodeButtons,
|
||||||
{
|
{
|
||||||
|
@ -728,19 +731,19 @@ var AIRTIME = (function (AIRTIME) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
mod.podcastEpisodeDataTable = mod.podcastEpisodeTableWidget.getDatatable();
|
mod.podcastEpisodeDataTable = mod.episodeTables[podcastId].getDatatable();
|
||||||
mod.podcastEpisodeTableWidget.assignDblClickHandler(function () {
|
mod.episodeTables[podcastId].assignDblClickHandler(function () {
|
||||||
var data = mod.podcastEpisodeDataTable.fnGetData(this);
|
var data = mod.podcastEpisodeDataTable.fnGetData(this);
|
||||||
if (!$.isEmptyObject(data.file)) {
|
if (!$.isEmptyObject(data.file)) {
|
||||||
mod.dblClickAdd(data.file, data.file.ftype);
|
mod.dblClickAdd(data.file, data.file.ftype);
|
||||||
} else {
|
} else {
|
||||||
if (data.ingested >= 0) { // Only import if the file isn't pending
|
if (data.ingested >= 0) { // Only import if the file isn't pending
|
||||||
AIRTIME.podcast.importSelectedEpisodes([data], mod.podcastEpisodeTableWidget);
|
AIRTIME.podcast.importSelectedEpisodes([data], mod.episodeTables[podcastId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return mod.podcastEpisodeTableWidget;
|
return mod.episodeTables[podcastId];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue