Browse Source

added popup

main
astanley 2 weeks ago
parent
commit
8250b219d8
  1. 2
      README.md
  2. 8
      node_media_action_bridge.routing.yml
  3. 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.

8
node_media_action_bridge.routing.yml

@ -1,5 +1,5 @@
node_media_action_bridge.list:
path: '/admin/config/islandora/node-media-actions'
path: '/admin/config/content/node-media-actions'
defaults:
_controller: '\Drupal\node_media_action_bridge\Controller\BridgeController::listing'
_title: 'Node media actions'
@ -7,7 +7,7 @@ node_media_action_bridge.list:
_permission: 'administer node media action bridge'
node_media_action_bridge.add:
path: '/admin/config/islandora/node-media-actions/add'
path: '/admin/config/content/node-media-actions/add'
defaults:
_form: '\Drupal\node_media_action_bridge\Form\BridgeForm'
_title: 'Add node media action'
@ -15,7 +15,7 @@ node_media_action_bridge.add:
_permission: 'administer node media action bridge'
node_media_action_bridge.edit:
path: '/admin/config/islandora/node-media-actions/{wrapper_id}/edit'
path: '/admin/config/content/node-media-actions/{wrapper_id}/edit'
defaults:
_form: '\Drupal\node_media_action_bridge\Form\BridgeForm'
_title: 'Edit node media action'
@ -23,7 +23,7 @@ node_media_action_bridge.edit:
_permission: 'administer node media action bridge'
node_media_action_bridge.delete:
path: '/admin/config/islandora/node-media-actions/{wrapper_id}/delete'
path: '/admin/config/content/node-media-actions/{wrapper_id}/delete'
defaults:
_form: '\Drupal\node_media_action_bridge\Form\BridgeDeleteForm'
_title: 'Delete node 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