Skip to content

Commit

Permalink
Fix bad success url for image form
Browse files Browse the repository at this point in the history
  • Loading branch information
lopes-vincent committed Jan 2, 2020
1 parent 39dc45f commit ac2eb16
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
17 changes: 15 additions & 2 deletions core/lib/Thelia/Controller/Admin/FileController.php
Expand Up @@ -310,7 +310,14 @@ public function getImageListAjaxAction($parentId, $parentType)
{
$this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE);
$this->checkXmlHttpRequest();
$args = array('imageType' => $parentType, 'parentId' => $parentId);

$successUrl = $this->getRequest()->get('successUrl');

$args = [
'imageType' => $parentType,
'parentId' => $parentId,
'successUrl' => $successUrl
];

return $this->render('includes/image-upload-list-ajax', $args);
}
Expand Down Expand Up @@ -344,7 +351,13 @@ public function getImageFormAjaxAction($parentId, $parentType)
{
$this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE);
$this->checkXmlHttpRequest();
$args = array('imageType' => $parentType, 'parentId' => $parentId);
$successUrl = $this->getRequest()->get('successUrl');

$args = [
'imageType' => $parentType,
'parentId' => $parentId,
'successUrl' => $successUrl
];

return $this->render('includes/image-upload-form', $args);
}
Expand Down
3 changes: 3 additions & 0 deletions templates/backOffice/default/assets/js/image-upload.js
Expand Up @@ -58,6 +58,9 @@ $(function($){
$.ajax({
type: "POST",
url: imageListUrl,
data: {
successUrl: imageSuccessUrl
},
statusCode: {
404: function() {
$imageListArea.html(
Expand Down
5 changes: 5 additions & 0 deletions templates/backOffice/default/includes/image-upload-form.html
Expand Up @@ -44,11 +44,15 @@
</div>
</form>

{if !$successUrl}
{$successUrl = {navigate to="current"}}
{/if}
<div class="existing-image">
{include file='includes/image-upload-list-ajax.html'
imageType=$imageType
parentId=$parentId
resource=$resource
successUrl=$successUrl
}
</div>

Expand All @@ -59,6 +63,7 @@
<script>
var imageDropZoneUrl = "{url path="/admin/image/type/%image/%id/save-ajax" image=$imageType id=$parentId}";
var imageListUrl = "{url path="/admin/image/type/%image/%id/list-ajax" image=$imageType id=$parentId}";
var imageSuccessUrl = "{$successUrl nofilter}";
var imageReorder = "{url path="/admin/image/type/%image/%id/update-position" image=$imageType id=$parentId}";
var imageListErrorMessage = "{intl l='Can\'t load images, please refresh this page.'}";
var imageReorderErrorMessage = "{intl l='Can\'t reorder images, please refresh this page.'}";
Expand Down
Expand Up @@ -55,8 +55,11 @@
</div>
</div>

{if !$successUrl}
{$successUrl = {navigate to="current"}}
{/if}
<form method="POST" action="{url path="/admin/image/type/%image/%id/update-title" image=$imageType id=$ID}" class="clearfix">
<input type="hidden" name="success_url" value="{navigate to='current'}"/>
<input type="hidden" name="success_url" value="{$successUrl}"/>
<input type="hidden" name="locale" value="{$edit_language_locale}"/>

<div class="input-group">
Expand Down

0 comments on commit ac2eb16

Please sign in to comment.