SAAS-1165 - initial work on left-hand pane for podcast episodes

This commit is contained in:
Duncan Sommerville 2015-11-04 13:22:33 -05:00
parent b4ec3eeb3f
commit e7869b54c7
5 changed files with 118 additions and 48 deletions

View File

@ -16,6 +16,7 @@
<div class="outer-datatable-wrapper">
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable"></table>
<table id="podcast_table" cellpadding="0" cellspacing="0" class="datatable"></table>
<table id="podcast_episodes_table" cellpadding="0" cellspacing="0" class="datatable"></table>
</div>
</div>

View File

@ -8,7 +8,8 @@ var AIRTIME = (function(AIRTIME) {
chosenItems = {},
visibleChosenItems = {},
$previouslySelected,
flagForDeselection = false;
flagForDeselection = false,
$datatables = {};
// we need to know whether the criteria value is string or
@ -87,6 +88,13 @@ var AIRTIME = (function(AIRTIME) {
"stream": "ws"
});
mod.DataTableTypeEnum = Object.freeze({
//FILE: "au",
LIBRARY : "library",
PODCAST : "podcast",
PODCAST_EPISODES: "podcastEpisodes"
});
// TODO: once the new manual pages are added, change links!
mod.placeholder = function(mediaType) {
switch (mediaType) {
@ -744,7 +752,7 @@ var AIRTIME = (function(AIRTIME) {
});
$datatables[mod.DataTableTypeEnum.LIBRARY] = mod.libraryDataTable;
/* ############################################
END DATATABLES
@ -864,7 +872,14 @@ var AIRTIME = (function(AIRTIME) {
}
}
AIRTIME.library.setCurrentTable();
var selected = $("a[href$='"+location.hash+"']"), table;
if (selected.parent().data("selection-id") == AIRTIME.library.MediaTypeIntegerEnum.PODCAST) {
table = mod.DataTableTypeEnum.PODCAST;
} else {
table = mod.DataTableTypeEnum.LIBRARY;
}
AIRTIME.library.setCurrentTable(table);
setColumnFilter(oTable);
oTable.fnSetFilteringDelay(350);
@ -1230,20 +1245,20 @@ var AIRTIME = (function(AIRTIME) {
};
mod.setCurrentTable = function() {
var selected = $("a[href$='"+location.hash+"']");
if (selected.parent().data("selection-id") == AIRTIME.library.MediaTypeIntegerEnum.PODCAST) {
$("#library_display_wrapper").hide();
$('#podcast_table_wrapper').show();
oTable = mod.podcastDataTable;
} else {
$('#podcast_table_wrapper').hide();
$("#library_display_wrapper").show();
oTable = mod.libraryDataTable;
}
mod.setCurrentTable = function (table) {
var dt = $datatables[table],
wrapper = $(dt).closest(".dataTables_wrapper");
$("#library_content").find(".dataTables_wrapper").hide();
wrapper.show();
oTable = dt;
oTable.fnDraw();
};
/** Create the podcast datatable widget */
/**
* Create the podcast datatable widget
*
* XXX: should this be moved to podcast.js
*/
mod.initPodcastDatatable = function()
{
var aoColumns = [
@ -1286,9 +1301,59 @@ var AIRTIME = (function(AIRTIME) {
}
});
mod._initPodcastEpisodeDatatable();
mod.podcastTableWidget.assignDblClickHandler(function () {
var podcast = mod.podcastDataTable.fnGetData($(this).index());
mod.podcastEpisodeTableWidget.reload(podcast.id);
mod.setCurrentTable(mod.DataTableTypeEnum.PODCAST_EPISODES);
});
mod.podcastDataTable = mod.podcastTableWidget.getDatatable();
$datatables[mod.DataTableTypeEnum.PODCAST] = mod.podcastDataTable;
};
/**
* Initialize the podcast episode view for the left-hand pane
*
* @private
*/
mod._initPodcastEpisodeDatatable = function () {
var buttons = {
addToScheduleBtn: {
// TODO: compatibility with checkAddButton function
title : $.i18n._('Add to Schedule'),
iconClass : '',
extraBtnClass : 'btn-small',
elementId : '',
eventHandlers : {
click: function (e) {
console.log(mod.podcastEpisodeDataTable.fnGetData($(this).index()));
}
}
}
};
mod.podcastEpisodeTableWidget = AIRTIME.podcast.initPodcastEpisodeDatatable(
$("#podcast_episodes_table"),
{
bServerSide : false,
sAjaxSource : null,
// Initialize the table with empty data so we can defer loading
// If we load sequentially there's a delay before the table appears
aaData : {},
aoColumns : [
/* GUID */ { "sTitle" : "" , "mDataProp" : "guid" , "sClass" : "podcast_episodes_guid" , "bVisible" : false },
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "title" , "sClass" : "podcast_episodes_title" , "sWidth" : "170px" },
/* Author */ { "sTitle" : $.i18n._("Author") , "mDataProp" : "author" , "sClass" : "podcast_episodes_author" , "sWidth" : "170px" },
/* Description */ { "sTitle" : $.i18n._("Description") , "mDataProp" : "description" , "sClass" : "podcast_episodes_description" , "sWidth" : "300px" },
/* Link */ { "sTitle" : $.i18n._("Link") , "mDataProp" : "link" , "sClass" : "podcast_episodes_link" , "sWidth" : "170px" },
/* Publication Date */ { "sTitle" : $.i18n._("Publication Date") , "mDataProp" : "pub_date" , "sClass" : "podcast_episodes_pub_date" , "sWidth" : "170px" }
]
},
buttons
);
mod.podcastEpisodeDataTable = $datatables[mod.DataTableTypeEnum.PODCAST_EPISODES] = mod.podcastEpisodeTableWidget.getDatatable();
};
mod.libraryInit = libraryInit;

View File

@ -122,8 +122,12 @@ var AIRTIME = (function (AIRTIME) {
/* Publication Date */ { "sTitle" : $.i18n._("Publication Date") , "mDataProp" : "pub_date" , "sClass" : "podcast_episodes_pub_date" , "sWidth" : "170px" }
]
},
buttons = {};
self.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable($scope.podcast, $scope.tab, params, buttons);
buttons = { slideToggle: {} };
self.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(
$scope.tab.contents.find('.podcast_episodes'),
params,
buttons
);
self.reloadEpisodeTable();
};
@ -172,7 +176,6 @@ var AIRTIME = (function (AIRTIME) {
$stationPodcastTab = undefined;
};
/**
* For the station podcast.
*
@ -239,8 +242,8 @@ var AIRTIME = (function (AIRTIME) {
self.deleteSelectedEpisodes();
}
}
}
},
slideToggle: {}
},
params = {
sAjaxSource : endpoint + $scope.podcast.id + '/episodes',
@ -251,7 +254,11 @@ var AIRTIME = (function (AIRTIME) {
]
};
this.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable($scope.podcast, $scope.tab, params, buttons);
this.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(
$scope.tab.contents.find('.podcast_episodes'),
params,
buttons
);
};
/**
@ -441,23 +448,23 @@ var AIRTIME = (function (AIRTIME) {
*
* Selection for the internal table represents episodes marked for ingest and is disabled for ingested episodes.
*
* @param {Object} podcast the podcast data JSON object.
* @param {Tab} tab Tab object the podcast will be opened in
* @param {Object} domNode the jQuery DOM node to create the table inside.
* @param {Object} params JSON object containing datatables parameters to override
* @param {Object} buttons JSON object containing datatables button parameters
*
* @returns {*} the created Table object
*/
mod.initPodcastEpisodeDatatable = function(podcast, tab, params, buttons) {
buttons = $.extend({
slideToggle: {
title : '',
iconClass : 'spl-no-r-margin icon-chevron-up',
extraBtnClass : 'toggle-editor-form',
elementId : '',
eventHandlers : {}
}
}, buttons);
mod.initPodcastEpisodeDatatable = function(domNode, params, buttons) {
if ('slideToggle' in buttons)
buttons = $.extend(true, {
slideToggle: {
title : '',
iconClass : 'spl-no-r-margin icon-chevron-up',
extraBtnClass : 'toggle-editor-form',
elementId : '',
eventHandlers : {}
}
}, buttons);
params = $.extend(params,
{
oColVis: {
@ -476,12 +483,11 @@ var AIRTIME = (function (AIRTIME) {
_initPodcastTable();
}
// Set up the div with id "podcast_table" as a datatable.
var podcastEpisodesTableWidget = new PodcastTable(
tab.contents.find('.podcast_episodes'), // DOM node to create the table inside.
true, // Enable item selection
buttons, // Toolbar buttons
params // Datatables overrides.
domNode, // DOM node to create the table inside.
true, // Enable item selection
buttons, // Toolbar buttons
params // Datatables overrides.
);
podcastEpisodesTableWidget.getDatatable().addTitles("td");

View File

@ -140,27 +140,21 @@ AIRTIME = (function(AIRTIME) {
$(window).on('hashchange', function() {
var selected = $("a[href$='"+location.hash+"']"),
dashboardLink = $(".media_type_selector:first"),
t;
tableType;
if (selected.parent().data("selection-id") == AIRTIME.library.MediaTypeIntegerEnum.PODCAST) {
$("#library_display_wrapper").hide();
$("#podcast_table_wrapper").show();
t = AIRTIME.library.podcastDataTable;
tableType = AIRTIME.library.DataTableTypeEnum.PODCAST;
} else {
$("#library_display_wrapper").show();
$("#podcast_table_wrapper").hide();
t = AIRTIME.library.libraryDataTable;
tableType = AIRTIME.library.DataTableTypeEnum.LIBRARY;
}
AIRTIME.library.setCurrentTable();
dashboardLink.find("a").attr("href", selected.attr("href"));
AIRTIME.library.selectNone();
$(".media_type_selector").each(function () {
$(this).removeClass("selected");
});
selected.parent().addClass("selected");
t.fnDraw();
AIRTIME.library.setCurrentTable(tableType);
$("#library_filter").text(selected.text());
// Highlight the dashboard link
dashboardLink.addClass("highlight");

View File

@ -94,6 +94,10 @@ var AIRTIME = (function(AIRTIME) {
return self;
};
Table.prototype.assignDblClickHandler = function(fn) {
$(this._datatable, 'tbody tr').on('dblclick', this._SELECTORS.SELECTION_TABLE_ROW, fn);
};
/* Set up global event handlers for the datatable.
* @param bItemSelection Whether or not row selection behaviour should be enabled for this widget.