From 096556fa74c58c8c5b22425e8391819cffca7b7d Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Thu, 18 Sep 2014 10:32:56 -0400 Subject: [PATCH] Added show_logo_name field to data object to avoid deleting current logo when none is being uploaded --- airtime_mvc/application/services/ShowService.php | 11 +++++++---- airtime_mvc/public/js/airtime/schedule/add-show.js | 7 +++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index 646fb72c7..fbf319f64 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -199,10 +199,13 @@ class Application_Service_ShowService if ($this->isUpdate) { - // Delete previous show images $showId = $this->ccShow->getDbId(); - if (!Rest_ShowController::deleteFilesFromStor($showId)) { - throw new Exception("Error deleting show images"); + + // Only delete the previous logo if a new one is being uploaded + if ($showData["show_logo"] && $showData["show_logo_name"] !== "") { + if (!Rest_ShowController::deleteShowImagesFromStor($showId)) { + throw new Exception("Error deleting show images"); + } } if (!$this->ccShow->getCcShowDayss()->isEmpty()) { @@ -754,7 +757,7 @@ SQL; // Delete show images $showId = $ccShowInstance->getDbShowId(); - if (!Rest_ShowController::deleteFilesFromStor($showId)) { + if (!Rest_ShowController::deleteShowImagesFromStor($showId)) { throw new Exception("Error deleting show images"); } diff --git a/airtime_mvc/public/js/airtime/schedule/add-show.js b/airtime_mvc/public/js/airtime/schedule/add-show.js index 9e15ecf5e..40aebc4d5 100644 --- a/airtime_mvc/public/js/airtime/schedule/add-show.js +++ b/airtime_mvc/public/js/airtime/schedule/add-show.js @@ -236,12 +236,14 @@ function setAddShowEvents(form) { // If we're adding a new show, hide the "Current Logo" element/label if ($(".button-bar.bottom").find(".ui-button-text").text() === "Update show") { - $("#show_logo_current-element").show(); - $("#show_logo_current-label").show(); // Display the current show logo if it exists if ($("#show_logo_current").attr("src") !== "") { + $("#show_logo_current-element").show(); + $("#show_logo_current-label").show(); $("#show_logo_current").show(); } else { + $("#show_logo_current-element").hide(); + $("#show_logo_current-label").hide(); $("#show_logo_current").hide(); } } else { @@ -668,6 +670,7 @@ function setAddShowEvents(form) { && $('#upload')[0].files[0]) { image = new FormData(); image.append('file', $('#upload')[0].files[0]); + data['show_logo_name'] = $('#upload')[0].files[0].name; } $.ajax({