Core and Modules
- drupal 8.4.0
- media_entity: 8.x-1.6+11-dev
- entity_browser: 8.x-1.3
- dropzonejs_eb_widget: 8.x-1.0-alpha8

Field:
- Entity Reference: Media Entity (Images)

Field widget:
- Entity Browser
- Entity display plugin: Rendered entity
- Display Remove button: Check
- Show widget details as open by default: Check
- Selection mode: Append to selection

Entity Browser:
- Display Plugin: iFrame
- Widget selector plugin: Tabs
- Selection display plugin: No selection display
- Widget plugin 1: Media Entity DropzoneJS
- Widget plugin 2: View

The problem:
As a second step, after adding some images to the dropzoneJS (selecting) the button must be clicked to upload the pictures. And this can take some time... And the upload button is not showing a throbber. If so, this wouldn't be a problem. But without, the normal user doesn't know exactly what's going on and whether the upload is done or not (many or large images). So the chance is high that the user clicks on.

Question:
Can we add a throbber to this upload button?

Pending technical debts:

  • Currently, the ajax command libraries are loaded inside WidgetBase. I believe they should be loaded as part of DisplayBase, or somewhere else in the stack.
  • Similarly, I found that the current ajax submit callback can be easily removed, or can be moved to somewhere else in the stack.

Pending work:

  • It works if you have selected an existing media entity, but breaks when a new entity is selected.
  • Implement progress status callback.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

handkerchief created an issue. See original summary.

sistocarta’s picture

I have the same problem.

Drupal Core 8.4.0.

is there a solution?

subhojit777’s picture

I am using Modal as display, and Acquia DAM as widget plugin. I too want this feature.

I was partially able to fix it by adding an ajax callback inside the form builder getForm(). The idea is to make use of the ajax throbber and the wait message "Please wait..." and make the end user understand that a process is in progress.

  public function getForm(array &$original_form, FormStateInterface $form_state, array $additional_widget_parameters) {
    // code..
    $form['actions']['submit']['#ajax'] = [
      'callback' => '\Drupal\media_acquiadam\Plugin\EntityBrowser\Widget\Acquiadam::ajaxSubmit',
    ];
  }

  public function ajaxSubmit(array &$form, FormStateInterface $form_state) {
    $response = new AjaxResponse();
    $response->addCommand(new CloseModalDialogCommand());
    return $response;
  }

the problem is it does not closes the modal. I am figuring out if there is a better way to do this.

subhojit777’s picture

FileSize
12.47 KB

I have managed to show a progress bar when the form is submitted.

subhojit777’s picture

It works if you have selected an existing media entity, but breaks when a new entity is selected.

I managed to find the reason. The patch is fine. I was echo-ing the time it takes for fetching the resource from the external service (WebDAM), and the output was getting appended to the `JSONResponse` and it was messing the whole thing.

subhojit777’s picture

FileSize
12.4 KB
487 bytes

Decided to move the progress type to custom widget.

subhojit777’s picture

The progress type can be modified like this #3005892-2: Show infinite progress bar during asset download

subhojit777’s picture

subhojit777’s picture

FileSize
12.65 KB
0 bytes

I have used the ajax callback to show status messages in the form. This implementation can be improved.

subhojit777’s picture

Issue summary: View changes
subhojit777’s picture

Making sure that IFrame display does not override passed AjaxResponse.

subhojit777’s picture

FileSize
12.71 KB
678 bytes