Initial publishing fixes and tweaks

This commit is contained in:
Duncan Sommerville 2015-10-19 13:42:27 -04:00
parent be3a3fbd9f
commit c8069aaedd
5 changed files with 21 additions and 28 deletions

View File

@ -12,7 +12,7 @@
</label> </label>
<label> <label>
<?php echo _("Creator") ?> <?php echo _("Creator") ?>
<input disabled ng-model="media.creator" type="text"/> <input disabled ng-model="media.artist_name" type="text"/>
</label> </label>
<fieldset> <fieldset>
<legend><?php echo _("Publish to:"); ?></legend> <legend><?php echo _("Publish to:"); ?></legend>

View File

@ -68,7 +68,7 @@ var AIRTIME = (function (AIRTIME) {
function _initAppFromResponse(data) { function _initAppFromResponse(data) {
var podcast = JSON.parse(data.podcast), var podcast = JSON.parse(data.podcast),
uid = AIRTIME.library.MediaTypeStringEnum.PODCAST+"_"+podcast.id, uid = AIRTIME.library.MediaTypeStringEnum.PODCAST+"_"+podcast.id,
tab = AIRTIME.tabs.openTab(data, uid, null), tab = AIRTIME.tabs.openTab(data.html, uid, null),
table = mod.initPodcastEpisodeDatatable(podcast.episodes); table = mod.initPodcastEpisodeDatatable(podcast.episodes);
_bootstrapAngularApp(podcast, tab, table); _bootstrapAngularApp(podcast, tab, table);
} }

View File

@ -15,13 +15,13 @@ var AIRTIME = (function (AIRTIME) {
//AngularJS app //AngularJS app
var publishApp = angular.module(PUBLISH_APP_NAME, []) var publishApp = angular.module(PUBLISH_APP_NAME, [])
.controller('RestController', function($scope, $http, mediaId) { .controller('RestController', function($scope, $http, mediaId, tab) {
$http.get(endpoint + mediaId, { csrf_token: jQuery("#csrf").val() }) $http.get(endpoint + mediaId, { csrf_token: jQuery("#csrf").val() })
.success(function(json) { .success(function(json) {
console.log(json); console.log(json);
$scope.media = json; $scope.media = json;
AIRTIME.tabs.setActiveTabName($scope.media.track_title); tab.setName($scope.media.track_title);
}); });
$scope.save = function() { $scope.save = function() {
@ -46,8 +46,9 @@ var AIRTIME = (function (AIRTIME) {
ids.push(el.id); ids.push(el.id);
});*/ });*/
function _bootstrapAngularApp(mediaId) { function _bootstrapAngularApp(mediaId, tab) {
publishApp.value('mediaId', mediaId); publishApp.value('mediaId', mediaId);
publishApp.value('tab', tab);
var wrapper = AIRTIME.tabs.getActiveTab().contents.find(".editor_pane_wrapper"); var wrapper = AIRTIME.tabs.getActiveTab().contents.find(".editor_pane_wrapper");
wrapper.attr("ng-controller", "RestController"); wrapper.attr("ng-controller", "RestController");
angular.bootstrap(wrapper.get(0), [PUBLISH_APP_NAME]); angular.bootstrap(wrapper.get(0), [PUBLISH_APP_NAME]);
@ -75,10 +76,8 @@ var AIRTIME = (function (AIRTIME) {
jQuery.get(dialogUrl, { csrf_token: jQuery("#csrf").val() }) jQuery.get(dialogUrl, { csrf_token: jQuery("#csrf").val() })
.success(function(html) { .success(function(html) {
var tab = AIRTIME.tabs.openTab(html, mediaId, null);
var jsonWrapper = {'html' : html}; //Silly wrapper to make the openTab function happy _bootstrapAngularApp(mediaId, tab);
AIRTIME.tabs.openTab(jsonWrapper, mediaId);
_bootstrapAngularApp(mediaId);
}); });
/* /*

View File

@ -1074,7 +1074,7 @@ var AIRTIME = (function(AIRTIME){
{format: "json", type: 'playlist'}, {format: "json", type: 'playlist'},
function(json) { function(json) {
var uid = AIRTIME.library.MediaTypeStringEnum.PLAYLIST+"_"+json.id; var uid = AIRTIME.library.MediaTypeStringEnum.PLAYLIST+"_"+json.id;
AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents);
redrawLib(); redrawLib();
}); });
}; };
@ -1088,7 +1088,7 @@ var AIRTIME = (function(AIRTIME){
{format: "json"}, {format: "json"},
function(json) { function(json) {
var uid = AIRTIME.library.MediaTypeStringEnum.WEBSTREAM+"_"+json.id; var uid = AIRTIME.library.MediaTypeStringEnum.WEBSTREAM+"_"+json.id;
AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents);
redrawLib(); redrawLib();
}); });
}; };
@ -1103,13 +1103,13 @@ var AIRTIME = (function(AIRTIME){
{format: "json", type: 'block'}, {format: "json", type: 'block'},
function(json){ function(json){
var uid = AIRTIME.library.MediaTypeStringEnum.BLOCK+"_"+json.id; var uid = AIRTIME.library.MediaTypeStringEnum.BLOCK+"_"+json.id;
AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents);
redrawLib(); redrawLib();
}); });
}; };
mod.fileMdEdit = function(json, uid) { mod.fileMdEdit = function(json, uid) {
AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initFileMdEvents); AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initFileMdEvents);
}; };
mod.fnEdit = function(id, type, url) { mod.fnEdit = function(id, type, url) {
@ -1120,7 +1120,7 @@ var AIRTIME = (function(AIRTIME){
{format: "json", id: id, type: type}, {format: "json", id: id, type: type},
function(json) { function(json) {
var uid = AIRTIME.library.MediaTypeFullToStringEnum.type+"_"+id; var uid = AIRTIME.library.MediaTypeFullToStringEnum.type+"_"+id;
AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents);
redrawLib(); redrawLib();
}); });
}; };
@ -1156,7 +1156,7 @@ var AIRTIME = (function(AIRTIME){
{format: "json", ids: id, modified: lastMod, type: type}, {format: "json", ids: id, modified: lastMod, type: type},
function(json){ function(json){
var uid = AIRTIME.library.MediaTypeStringEnum.WEBSTREAM+"_"+id; var uid = AIRTIME.library.MediaTypeStringEnum.WEBSTREAM+"_"+id;
AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents);
redrawLib(); redrawLib();
}); });
}; };
@ -1204,7 +1204,7 @@ var AIRTIME = (function(AIRTIME){
mod.replaceForm = function(json){ mod.replaceForm = function(json){
$pl.find('.editor_pane_wrapper').html(json.html); $pl.find('.editor_pane_wrapper').html(json.html);
var uid = AIRTIME.library.MediaTypeStringEnum.BLOCK+"_"+json.id; var uid = AIRTIME.library.MediaTypeStringEnum.BLOCK+"_"+json.id;
AIRTIME.tabs.openTab(json, uid, AIRTIME.playlist._initPlaylistTabEvents); AIRTIME.tabs.openTab(json.html, uid, AIRTIME.playlist._initPlaylistTabEvents);
}; };

View File

@ -49,17 +49,14 @@ var AIRTIME = (function(AIRTIME){
/** /**
* Tab object constructor * Tab object constructor
* *
* @param {{}} json a javascript object of the form * @param {string} html the HTML to render as the tab contents
* {
* 'html': the HTML to render as the tab contents
* }
* @param {string} uid the unique ID for the tab. Uses the values in * @param {string} uid the unique ID for the tab. Uses the values in
* AIRTIME.library.MediaTypeStringEnum and the object ID * AIRTIME.library.MediaTypeStringEnum and the object ID
* to create a string of the form TYPE_ID. * to create a string of the form TYPE_ID.
* @returns {Tab} the created Tab object * @returns {Tab} the created Tab object
* @constructor * @constructor
*/ */
var Tab = function(json, uid) { var Tab = function(html, uid) {
var self = this; var self = this;
AIRTIME.library.selectNone(); AIRTIME.library.selectNone();
@ -75,7 +72,7 @@ var AIRTIME = (function(AIRTIME){
// TODO: clean this up a bit and use js instead of strings to create elements // TODO: clean this up a bit and use js instead of strings to create elements
var wrapper = "<div data-tab-id='" + self.id + "' id='pl-tab-content-" + self.id + "' class='side_playlist pl-content'><div class='editor_pane_wrapper'></div></div>", var wrapper = "<div data-tab-id='" + self.id + "' id='pl-tab-content-" + self.id + "' class='side_playlist pl-content'><div class='editor_pane_wrapper'></div></div>",
t = $("#show_builder").append(wrapper).find("#pl-tab-content-" + self.id), t = $("#show_builder").append(wrapper).find("#pl-tab-content-" + self.id),
pane = $(".editor_pane_wrapper:last").append(json.html), pane = $(".editor_pane_wrapper:last").append(html),
name = pane.find("#track_title").length > 0 ? pane.find("#track_title").val() + $.i18n._(" - Metadata Editor") name = pane.find("#track_title").length > 0 ? pane.find("#track_title").val() + $.i18n._(" - Metadata Editor")
: pane.find(".playlist_name_display").val(), : pane.find(".playlist_name_display").val(),
tab = tab =
@ -261,18 +258,15 @@ var AIRTIME = (function(AIRTIME){
/** /**
* Create a new Tab object and open it in the ShowBuilder pane * Create a new Tab object and open it in the ShowBuilder pane
* *
* @param {{}} json a javascript object of the form * @param {string} html the HTML to render as the tab contents
* {
* 'html': the HTML to render as the tab contents
* }
* @param {string} uid the unique ID for the tab. Uses the values in * @param {string} uid the unique ID for the tab. Uses the values in
* AIRTIME.library.MediaTypeStringEnum and the object ID * AIRTIME.library.MediaTypeStringEnum and the object ID
* @param {function} callback an optional callback function to call once the * @param {function} callback an optional callback function to call once the
* Tab object is initialized * Tab object is initialized
* @returns {Tab} the created Tab object * @returns {Tab} the created Tab object
*/ */
mod.openTab = function(json, uid, callback) { mod.openTab = function(html, uid, callback) {
var newTab = new Tab(json, uid); var newTab = new Tab(html, uid);
if (callback) callback(newTab); if (callback) callback(newTab);
return newTab; return newTab;
}; };