Compare commits

..

2 Commits

Author SHA1 Message Date
astanley 1c009bdca7 added popup 2 weeks ago
astanley 8250b219d8 added popup 2 weeks ago
  1. 2
      README.md
  2. 53
      src/Form/BridgeForm.php

2
README.md

@ -20,7 +20,7 @@ It then checks the underlying media Action's access for each media entity and ex
3. Go to:
`/admin/config/islandora/node-media-actions`
`/admin/config/content/node-media-actions`
4. Click **Add node media action**.
5. Enter the label you want exposed at node level and choose an existing configured media Action.

53
src/Form/BridgeForm.php

@ -7,6 +7,8 @@ use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Action\ActionManager;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\OpenModalDialogCommand;
/**
* Add/edit form for node media Action wrappers.
@ -59,6 +61,20 @@ class BridgeForm extends FormBase {
}
natcasesort($options);
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
$form['usage_help'] = [
'#type' => 'button',
'#value' => $this->t('How to use this form'),
'#ajax' => [
'callback' => '::usageHelpModal',
],
'#attributes' => [
'class' => ['button', 'button--small'],
],
'#limit_validation_errors' => [],
];
$form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Node Action label'),
@ -103,6 +119,43 @@ class BridgeForm extends FormBase {
return $form;
}
/**
* Opens the usage instructions in a modal dialog.
*/
public function usageHelpModal(array &$form, FormStateInterface $form_state): AjaxResponse {
$content = [
'#type' => 'container',
'intro' => [
'#markup' => '<p>' . $this->t('This form creates a node-level Action that runs an existing configured media Action against every media item whose <code>field_media_of</code> references the selected node.') . '</p>',
],
'steps' => [
'#theme' => 'item_list',
'#list_type' => 'ol',
'#items' => [
$this->t('Enter the label you want users to see when selecting the node Action.'),
$this->t('Accept the generated machine name, or change it before the Action is first saved.'),
$this->t('Choose the configured media Action that should be executed for the node’s associated media.'),
$this->t('Click Save. The module creates a configured node Action automatically.'),
$this->t('Use that node Action from Views Bulk Operations, the Collection Manager, or any other interface that exposes configured node Actions.'),
],
],
'notes' => [
'#markup' => '<p><strong>' . $this->t('What happens when it runs:') . '</strong> ' . $this->t('The wrapper finds all media referencing the node through field_media_of, checks access for the selected media Action, and executes that Action against the eligible media items.') . '</p>',
],
'tip' => [
'#markup' => '<p><strong>' . $this->t('Tip:') . '</strong> ' . $this->t('If the media Action you need is not listed, configure/create that media Action first, then return to this form.') . '</p>',
],
];
$response = new AjaxResponse();
$response->addCommand(new OpenModalDialogCommand(
$this->t('How to use this form'),
$content,
['width' => 700],
));
return $response;
}
/**
* Machine-name existence callback.
*/

Loading…
Cancel
Save