Export task is not cleared after file download #891

Closed
opened 2022-04-08 12:35:49 +00:00 by vistamedia · 1 comment
vistamedia commented 2022-04-08 12:35:49 +00:00 (Migrated from github.com)

The export task is not cleared after file download :

  1. Try you export records from a list view.
  2. Click on a filter or on the pagination
  3. It will download the file again

This issue is more related to Joomla than JCB, but it happens primarily on download tasks because it exits the controller instead of redirecting to the list view.

Here is simple fix that you can add to Joomla Components > Libs & Helpers > Global Admin Event

$doc = JFactory::getDocument();
$js = <<<JS
/**

  • Proper fix for Joomla.submitform() not clearing form.task.value after form submits
    */
    [Component]_Joomla_submitform_original = Joomla.submitform;
    Joomla.submitform = function(task, form, validate)
    {
    var return_value = [Component]_Joomla_submitform_original(task, form, validate);

    // If page was not reloaded for any reason we also need to clear the task
    // e.g. validation prevented submit or task was AJAX-based or the task was a file download
    // This is need because this method is called without task in some cases, e.g. a change in view's filters !!
    if (task)
    {
    if (!form) form = document.getElementById('adminForm');
    if (form) form.task.value = '';
    }

    return return_value;
    };
    JS;
    $doc->addScriptDeclaration($js);

Of course the best way would be to implement it in the compiler ;-)

The export task is not cleared after file download : 1. Try you export records from a list view. 2. Click on a filter or on the pagination 3. It will download the file again This issue is more related to Joomla than JCB, but it happens primarily on download tasks because it exits the controller instead of redirecting to the list view. Here is simple fix that you can add to Joomla Components > Libs & Helpers > Global Admin Event $doc = JFactory::getDocument(); $js = <<<JS /** * Proper fix for Joomla.submitform() not clearing form.task.value after form submits */ [[[Component]]]_Joomla_submitform_original = Joomla.submitform; Joomla.submitform = function(task, form, validate) { var return_value = [[[Component]]]_Joomla_submitform_original(task, form, validate); // If page was not reloaded for any reason we also need to clear the task // e.g. validation prevented submit or task was AJAX-based or the task was a file download // This is need because this method is called without task in some cases, e.g. a change in view's filters !! if (task) { if (!form) form = document.getElementById('adminForm'); if (form) form.task.value = ''; } return return_value; }; JS; $doc->addScriptDeclaration($js); Of course the best way would be to implement it in the compiler ;-)

Okay I agree that we must fix this.. it has bugged me for a long time. I need more details...

Okay I agree that we must fix this.. it has bugged me for a long time. I need more details...
Llewellyn added the
Bug
label 2022-08-05 08:30:35 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#891
No description provided.