FIX Ensure after uploading document you are redirected back to the document set

This commit is contained in:
Robbie Averill 2017-05-18 11:51:32 +12:00
parent 961306ecc0
commit 8d2f707f48
2 changed files with 22 additions and 2 deletions

View File

@ -178,7 +178,7 @@ class DMSDocumentAddController extends LeftAndMain
/**
* Returns the link to be used to return the user after uploading a document. If a document set ID (dsid) is present
* then it will be redirected back to the page that owns the document set. @todo redirect back to the document set
* then it will be redirected back to that document set in a page.
*
* If no document set ID is present then we assume that it has been added from the model admin, so redirect back to
* that instead.
@ -192,7 +192,11 @@ class DMSDocumentAddController extends LeftAndMain
$modelAdmin->init();
return $modelAdmin->Link();
}
return Controller::join_links(singleton('CMSPagesController')->Link(), 'edit/show', $this->currentPageID());
return Controller::join_links(
singleton('CMSPagesController')->Link(),
'edit/EditForm/field/Document%20Sets/item',
$this->getRequest()->getVar('dsid')
);
}
public function documentautocomplete()

View File

@ -35,4 +35,20 @@ class DMSDocumentAddControllerTest extends FunctionalTest
Config::inst()->update('DMSDocumentAddController', 'allowed_extensions', array('php', 'php5'));
$this->assertSame(array('jpg', 'gif', 'php', 'php5'), $controller->getAllowedExtensions());
}
/**
* Test that the back link will be the document set that a file is uploaded into if relevant, otherwise the model
* admin that it was uploaded from
*/
public function testBacklink()
{
$controller = new DMSDocumentAddController;
$controller->init();
$this->assertContains('admin/documents', $controller->Backlink());
$request = new SS_HTTPRequest('GET', '/', array('dsid' => 123));
$controller->setRequest($request);
$this->assertContains('EditForm', $controller->Backlink());
$this->assertContains('123', $controller->Backlink());
}
}