From 6cebffd89bce5e4ed15d4fbd2ceb7680ec74894a Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 21 Jan 2016 13:37:45 +1300 Subject: [PATCH] BUG Fix SSViewerTest not restoring old requirements BUG Fix incorrect js path in UploadField.php Restore changes missing from merge --- admin/javascript/src/LeftAndMain.BatchActions.js | 12 ++++++++---- forms/UploadField.php | 2 +- tests/view/SSViewerTest.php | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/admin/javascript/src/LeftAndMain.BatchActions.js b/admin/javascript/src/LeftAndMain.BatchActions.js index 7b53d0694..8099e70f2 100644 --- a/admin/javascript/src/LeftAndMain.BatchActions.js +++ b/admin/javascript/src/LeftAndMain.BatchActions.js @@ -173,7 +173,7 @@ $.entwine('ss.tree', function($){ ids = this.getIDs(), allIds = [], viewMode = $('.cms-content-batchactions-button'), - selectedAction = this.find(':input[name=Action]').val(); + actionUrl = this.find(':input[name=Action]').val(); // Default to refreshing the entire tree if(rootNode == null) rootNode = st; @@ -183,7 +183,7 @@ $.entwine('ss.tree', function($){ } // If no action is selected, enable all nodes - if(!selectedAction || selectedAction == -1 || !viewMode.hasClass('active')) { + if(!actionUrl || actionUrl == -1 || !viewMode.hasClass('active')) { $(rootNode).find('li').each(function() { $(this).setEnabled(true); }); @@ -197,8 +197,12 @@ $.entwine('ss.tree', function($){ }); // Post to the server to ask which pages can have this batch action applied - var applicablePagesURL = selectedAction + '/applicablepages/?csvIDs=' + allIds.join(','); - jQuery.getJSON(applicablePagesURL, function(applicableIDs) { + // Retain existing query parameters in URL before appending path + var actionUrlParts = $.path.parseUrl(actionUrl); + var applicablePagesUrl = actionUrlParts.hrefNoSearch + '/applicablepages/'; + applicablePagesUrl = $.path.addSearchParams(applicablePagesUrl, actionUrlParts.search); + applicablePagesUrl = $.path.addSearchParams(applicablePagesUrl, {csvIDs: allIds.join(',')}); + jQuery.getJSON(applicablePagesUrl, function(applicableIDs) { // Set a CSS class on each tree node indicating which can be batch-actioned and which can't jQuery(rootNode).find('li').each(function() { $(this).removeClass('treeloading'); diff --git a/forms/UploadField.php b/forms/UploadField.php index dc2793d98..025888618 100644 --- a/forms/UploadField.php +++ b/forms/UploadField.php @@ -1540,7 +1540,7 @@ class UploadField_SelectHandler extends RequestHandler { public function index() { // Requires a separate JS file, because we can't reach into the iframe with entwine. - Requirements::javascript(FRAMEWORK_DIR . '/javascript/UploadField_select.js'); + Requirements::javascript(FRAMEWORK_DIR . '/javascript/dist/UploadField_select.js'); return $this->renderWith('CMSDialog'); } diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php index 5745e1c4e..41e79491f 100644 --- a/tests/view/SSViewerTest.php +++ b/tests/view/SSViewerTest.php @@ -147,10 +147,12 @@ class SSViewerTest extends SapphireTest { $requirements->expects($this->once())->method('javascript')->with($jsFile); $requirements->expects($this->once())->method('css')->with($cssFile); + $origReq = Requirements::backend(); Requirements::set_backend($requirements); - $template = $this->render("<% require javascript($jsFile) %> <% require css($cssFile) %>"); + Requirements::set_backend($origReq); + $this->assertFalse((bool)trim($template), "Should be no content in this return."); }