Merge branch 'saas-dev-publishing' into saas-dev-publishing-episode-view

Conflicts:
	airtime_mvc/public/js/airtime/library/podcast.js
This commit is contained in:
Duncan Sommerville 2015-11-04 15:18:50 -05:00
commit 6cb28e0911
6 changed files with 37 additions and 30 deletions

View file

@ -30,7 +30,6 @@ var AIRTIME = (function (AIRTIME) {
//a roundtrip by not fetching it again here.
$scope.podcast = podcast;
$scope.tab = tab;
tab.setName($scope.podcast.title);
$scope.csrf = jQuery("#csrf").val();
tab.contents.find("table").attr("id", "podcast_episodes_" + podcast.id);
@ -50,36 +49,28 @@ var AIRTIME = (function (AIRTIME) {
};
/**
* Internal function.
*
* Make a PUT request to the server to update the podcast object.
*
* @private
* Save and update the podcast object.
*/
self._updatePodcast = function () {
$scope.savePodcast = function () {
$http.put(endpoint + $scope.podcast.id, {csrf_token: $scope.csrf, podcast: $scope.podcast})
.success(function () {
self.episodeTable.getDatatable().fnDraw();
AIRTIME.library.podcastDataTable.fnDraw();
tab.setName($scope.podcast.title);
});
};
/**
* For imported podcasts.
*
* Save each of the selected episodes and update the podcast object.
*/
$scope.savePodcast = function () {
$scope.importEpisodes = function () {
var episodes = self.episodeTable.getSelectedRows();
// TODO: Should we implement a batch endpoint for this instead?
jQuery.each(episodes, function () {
$http.post(endpoint + $scope.podcast.id + '/episodes', {
csrf_token: $scope.csrf,
episode: this
}).success(function () {
self.reloadEpisodeTable();
self.episodeTable.getDatatable().fnDraw();
});
});
self._updatePodcast();
};
/**
@ -122,7 +113,20 @@ var AIRTIME = (function (AIRTIME) {
/* Publication Date */ { "sTitle" : $.i18n._("Publication Date") , "mDataProp" : "pub_date" , "sClass" : "podcast_episodes_pub_date" , "sWidth" : "170px" }
]
},
buttons = { slideToggle: {} };
buttons = {
slideToggle: {},
importBtn: {
title : $.i18n._('Import Selected'),
iconClass : '',
extraBtnClass : 'btn-new',
elementId : '',
eventHandlers : {
click: function () {
$scope.importEpisodes();
}
}
}
};
self.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(
$scope.tab.contents.find('.podcast_episodes'),
params,
@ -146,6 +150,7 @@ var AIRTIME = (function (AIRTIME) {
PodcastController.prototype.initialize = function() {
// TODO: this solves a race condition, but we should look for the root cause
AIRTIME.tabs.onResize();
this.$scope.tab.setName(this.$scope.podcast.title);
this._initTable();
};
@ -176,15 +181,6 @@ var AIRTIME = (function (AIRTIME) {
$stationPodcastTab = undefined;
};
/**
* For the station podcast.
*
* Update the station podcast object.
*/
$scope.savePodcast = function () {
self._updatePodcast();
};
self.deleteSelectedEpisodes = function () {
var episodes = self.episodeTable.getSelectedRows();
jQuery.each(episodes, function () {
@ -261,6 +257,11 @@ var AIRTIME = (function (AIRTIME) {
);
};
StationPodcastController.prototype.initialize = function() {
PodcastController.prototype.initialize.call(this);
this.$scope.tab.setName(jQuery.i18n._("Station Podcast"));
};
/**
* Reload the Station podcast episode table.
*