From 40a2aa10d8b93490f09ad3842543029daa7ded19 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Thu, 29 Oct 2015 13:09:50 -0400 Subject: [PATCH] SAAS-1083 - Implement unpublishing --- .../application/services/PublishService.php | 2 +- .../scripts/library/publish-dialog.phtml | 8 +++--- .../public/js/airtime/library/publish.js | 27 +++++++++++++------ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/airtime_mvc/application/services/PublishService.php b/airtime_mvc/application/services/PublishService.php index 5f21b4ddd..8673efafe 100644 --- a/airtime_mvc/application/services/PublishService.php +++ b/airtime_mvc/application/services/PublishService.php @@ -29,7 +29,7 @@ class Application_Service_PublishService { public static function publish($fileId, $data) { foreach ($data as $k => $v) { $service = PublishServiceFactory::getService($k); - if ($v) $service->publish($fileId); + $service->$v($fileId); } } diff --git a/airtime_mvc/application/views/scripts/library/publish-dialog.phtml b/airtime_mvc/application/views/scripts/library/publish-dialog.phtml index 15911a68a..fc5f6df43 100644 --- a/airtime_mvc/application/views/scripts/library/publish-dialog.phtml +++ b/airtime_mvc/application/views/scripts/library/publish-dialog.phtml @@ -21,8 +21,8 @@
- " - . "Published tracks can be removed or updated below.") ?> + " + . _("Published tracks can be removed or updated below.") ?>
@@ -33,8 +33,8 @@
- " - . "Check the boxes above and hit 'Publish' to publish this track to the marked sources.") ?> + " + . _("Check the boxes above and hit 'Publish' to publish this track to the marked sources.") ?>
diff --git a/airtime_mvc/public/js/airtime/library/publish.js b/airtime_mvc/public/js/airtime/library/publish.js index 021e5d7bc..19986c540 100644 --- a/airtime_mvc/public/js/airtime/library/publish.js +++ b/airtime_mvc/public/js/airtime/library/publish.js @@ -41,17 +41,28 @@ var AIRTIME = (function (AIRTIME) { } $scope.publish = function () { - $http.put(endpoint + mediaId + '/publish', - { - csrf_token: jQuery("#csrf").val(), - sources: $scope.publishData - }).success(function () { - init(); - }); + var data = {}; + jQuery.each($scope.publishData, function(k, v) { + if (v) { + data[k] = 'publish'; // FIXME: should be more robust + } + }); + + if (Object.keys(data).length > 0) { + $http.put(endpoint + mediaId + '/publish', { csrf_token: jQuery("#csrf").val(), sources: data}) + .success(function () { + init(); + }); + } }; $scope.remove = function (source) { - // TODO + var data = {}; + data[source] = 'unpublish'; // FIXME: should be more robust + $http.put(endpoint + mediaId + '/publish', { csrf_token: jQuery("#csrf").val(), sources: data }) + .success(function () { + init(); + }); }; $scope.discard = function () {