Finishing import/export redirects to the defined url

This commit is contained in:
Samuel Georges 2015-07-25 09:21:43 +10:00
parent fc490b18e9
commit 502263e11b
3 changed files with 22 additions and 9 deletions

View File

@ -2,6 +2,7 @@
use Str;
use Lang;
use Backend;
use Backend\Classes\ControllerBehavior;
use League\Csv\Reader as CsvReader;
use ApplicationException;
@ -168,6 +169,7 @@ class ImportExportController extends ControllerBehavior
]);
$this->vars['importResults'] = $model->getResultStats();
$this->vars['returnUrl'] = $this->getRedirectUrlForType('import');
}
catch (Exception $ex) {
$this->controller->handleError($ex);
@ -372,11 +374,13 @@ class ImportExportController extends ControllerBehavior
}
$reference = $model->export($columns, $exportOptions);
$this->vars['fileUrl'] = $this->controller->actionUrl(
$fileUrl = $this->controller->actionUrl(
'download',
$reference.'/'.$this->exportFileName
);
);
$this->vars['fileUrl'] = $fileUrl;
$this->vars['returnUrl'] = $this->getRedirectUrlForType('export');
}
catch (Exception $ex) {
$this->controller->handleError($ex);
@ -549,4 +553,13 @@ class ImportExportController extends ControllerBehavior
return $result;
}
protected function getRedirectUrlForType($type)
{
if ($redirect = $this->getConfig($type.'[redirect]')) {
return Backend::url($redirect);
}
return $this->controller->actionUrl($type);
}
}

View File

@ -7,12 +7,12 @@
</p>
</div>
<div class="modal-footer">
<button
type="button"
<a
href="<?= $returnUrl ?>"
class="btn btn-success"
data-dismiss="popup">
<?= e(trans('backend::lang.form.complete')) ?>
</button>
</a>
</div>
<script> window.location = '<?= $fileUrl ?>' </script>

View File

@ -77,12 +77,12 @@
</div>
<div class="modal-footer">
<button
type="button"
<a
href="<?= $returnUrl ?>"
class="btn btn-success"
data-dismiss="popup">
<?= e(trans('backend::lang.form.complete')) ?>
</button>
</a>
</div>
<?php else: ?>