diff --git a/README.md b/README.md index 54df376..0a0b3b2 100644 --- a/README.md +++ b/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. diff --git a/node_media_action_bridge.links.menu.yml b/node_media_action_bridge.links.menu.yml index ca0aae2..0a26b64 100644 --- a/node_media_action_bridge.links.menu.yml +++ b/node_media_action_bridge.links.menu.yml @@ -2,4 +2,4 @@ node_media_action_bridge.list: title: 'Node media actions' description: 'Create node Actions that run configured media Actions on related media.' route_name: node_media_action_bridge.list - parent: system.admin_config_islandora + parent: system.admin_config_islandora diff --git a/node_media_action_bridge.routing.yml b/node_media_action_bridge.routing.yml index 4e88c1e..d49f8ae 100644 --- a/node_media_action_bridge.routing.yml +++ b/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' diff --git a/src/Form/BridgeForm.php b/src/Form/BridgeForm.php index 20f11d9..892e0de 100644 --- a/src/Form/BridgeForm.php +++ b/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' => '

' . $this->t('This form creates a node-level Action that runs an existing configured media Action against every media item whose field_media_of references the selected node.') . '

', + ], + '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' => '

' . $this->t('What happens when it runs:') . ' ' . $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.') . '

', + ], + 'tip' => [ + '#markup' => '

' . $this->t('Tip:') . ' ' . $this->t('If the media Action you need is not listed, configure/create that media Action first, then return to this form.') . '

', + ], + ]; + + $response = new AjaxResponse(); + $response->addCommand(new OpenModalDialogCommand( + $this->t('How to use this form'), + $content, + ['width' => 700], + )); + return $response; + } + /** * Machine-name existence callback. */