From b0c86c0d33c061a7f559f97d75666923ad0ac9df Mon Sep 17 00:00:00 2001 From: Eric Bremner <ebremner@uwaterloo.ca> Date: Sun, 14 Apr 2024 18:00:43 -0400 Subject: [PATCH] ISTWCMS-5412: adding block for publication authors --- .../views.view.uw_view_pub_authors.yml | 943 ++++++++++++++++++ src/Plugin/Block/PublicationAuthorsBlock.php | 123 +++ 2 files changed, 1066 insertions(+) create mode 100644 config/install/views.view.uw_view_pub_authors.yml create mode 100644 src/Plugin/Block/PublicationAuthorsBlock.php diff --git a/config/install/views.view.uw_view_pub_authors.yml b/config/install/views.view.uw_view_pub_authors.yml new file mode 100644 index 0000000..996dfc5 --- /dev/null +++ b/config/install/views.view.uw_view_pub_authors.yml @@ -0,0 +1,943 @@ +langcode: en +status: true +dependencies: + module: + - bibcite_entity + - user + - views_autocomplete_filters +id: uw_view_pub_authors +label: 'Dashboard - publication authors' +module: views +description: 'Find and manage contributors.' +tag: default +base_table: bibcite_contributor +base_field: id +display: + default: + id: default + display_title: Master + display_plugin: default + position: 0 + display_options: + title: 'Publication authors' + fields: + leading_title: + id: leading_title + table: bibcite_contributor + field: leading_title + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: leading_title + plugin_id: field + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: false + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + prefix: + id: prefix + table: bibcite_contributor + field: prefix + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: prefix + plugin_id: field + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: false + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + first_name: + id: first_name + table: bibcite_contributor + field: first_name + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: first_name + plugin_id: field + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: false + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + middle_name: + id: middle_name + table: bibcite_contributor + field: middle_name + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: middle_name + plugin_id: field + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: false + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + last_name: + id: last_name + table: bibcite_contributor + field: last_name + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: last_name + plugin_id: field + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: false + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + nick: + id: nick + table: bibcite_contributor + field: nick + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: nick + plugin_id: field + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: false + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + suffix: + id: suffix + table: bibcite_contributor + field: suffix + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: suffix + plugin_id: field + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: false + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + name: + id: name + table: bibcite_contributor + field: name + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + plugin_id: field + label: Name + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: string + settings: + link_to_entity: true + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + operations: + id: operations + table: bibcite_contributor + field: operations + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + plugin_id: entity_operations + label: Operations + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + destination: true + pager: + type: full + options: + offset: 0 + items_per_page: 50 + total_pages: null + id: 0 + tags: + next: ›› + previous: ‹‹ + first: '« First' + last: 'Last »' + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + quantity: 9 + exposed_form: + type: basic + options: + submit_button: Filter + reset_button: true + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + access: + type: perm + options: + perm: 'view bibcite_contributor' + cache: + type: tag + options: { } + empty: + area_text_custom: + id: area_text_custom + table: views + field: area_text_custom + relationship: none + group_type: group + admin_label: '' + plugin_id: text_custom + empty: true + content: 'No contributors available.' + tokenize: false + sorts: + last_name: + id: last_name + table: bibcite_contributor + field: last_name + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: last_name + plugin_id: standard + order: ASC + expose: + label: 'Last name' + field_identifier: last_name + exposed: true + first_name: + id: first_name + table: bibcite_contributor + field: first_name + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: first_name + plugin_id: standard + order: ASC + expose: + label: 'First name' + field_identifier: first_name + exposed: true + nick: + id: nick + table: bibcite_contributor + field: nick + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: nick + plugin_id: standard + order: ASC + expose: + label: Nickname + field_identifier: nick + exposed: true + leading_title: + id: leading_title + table: bibcite_contributor + field: leading_title + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: leading_title + plugin_id: standard + order: ASC + expose: + label: 'Leading initial' + field_identifier: leading_title + exposed: true + prefix: + id: prefix + table: bibcite_contributor + field: prefix + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: prefix + plugin_id: standard + order: ASC + expose: + label: Prefix + field_identifier: prefix + exposed: true + middle_name: + id: middle_name + table: bibcite_contributor + field: middle_name + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: middle_name + plugin_id: standard + order: ASC + expose: + label: 'Middle name' + field_identifier: middle_name + exposed: true + suffix: + id: suffix + table: bibcite_contributor + field: suffix + relationship: none + group_type: group + admin_label: '' + entity_type: bibcite_contributor + entity_field: suffix + plugin_id: standard + order: ASC + expose: + label: Suffix + field_identifier: suffix + exposed: true + arguments: { } + filters: + combine: + id: combine + table: views + field: combine + relationship: none + group_type: group + admin_label: '' + plugin_id: combine + operator: allwords + value: '' + group: 1 + exposed: true + expose: + operator_id: combine_op + label: Name + description: '' + use_operator: false + operator: combine_op + operator_limit_selection: false + operator_list: { } + identifier: combine + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + anonymous: '0' + administrator: '0' + placeholder: '' + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + fields: + leading_title: leading_title + prefix: prefix + first_name: first_name + middle_name: middle_name + last_name: last_name + nick: nick + suffix: suffix + filter_groups: + operator: AND + groups: + 1: AND + style: + type: table + options: + grouping: { } + row_class: '' + default_row_class: true + columns: + leading_title: leading_title + prefix: prefix + first_name: first_name + middle_name: middle_name + last_name: last_name + nick: nick + suffix: suffix + bibcite_contributor_bulk_form: bibcite_contributor_bulk_form + name: name + operations: operations + default: '-1' + info: + leading_title: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + prefix: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + first_name: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + middle_name: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + last_name: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + nick: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + suffix: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + bibcite_contributor_bulk_form: + align: '' + separator: '' + empty_column: false + responsive: '' + name: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + operations: + align: '' + separator: '' + empty_column: false + responsive: '' + override: true + sticky: true + summary: '' + empty_table: true + caption: '' + description: '' + row: + type: fields + query: + type: views_query + options: + query_comment: '' + disable_sql_rewrite: false + distinct: false + replica: false + query_tags: { } + relationships: { } + use_ajax: true + show_admin_links: false + header: { } + footer: { } + display_extenders: { } + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url + - url.query_args + - 'url.query_args:sort_by' + - 'url.query_args:sort_order' + - user.permissions + tags: { } + pub_reference_authors: + id: pub_reference_authors + display_title: Embed + display_plugin: embed + position: 2 + display_options: + display_extenders: + metatag_display_extender: + metatags: { } + tokenize: false + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url + - url.query_args + - 'url.query_args:sort_by' + - 'url.query_args:sort_order' + - user.permissions + tags: { } diff --git a/src/Plugin/Block/PublicationAuthorsBlock.php b/src/Plugin/Block/PublicationAuthorsBlock.php new file mode 100644 index 0000000..bc5e5ce --- /dev/null +++ b/src/Plugin/Block/PublicationAuthorsBlock.php @@ -0,0 +1,123 @@ +<?php + +namespace Drupal\uw_dashboard\Plugin\Block; + +use Drupal\Core\Block\BlockBase; +use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Provides a 'Publication keywords' block. + * + * @Block( + * id = "uw_publication_authors_block", + * admin_label = @Translation("Publication authors"), + * ) + */ +class PublicationAuthorsBlock extends BlockBase implements ContainerFactoryPluginInterface { + + /** + * Entity type manager from the core. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * {@inheritdoc} + */ + public static function create( + ContainerInterface $container, + array $configuration, + $plugin_id, + $plugin_definition + ) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity_type.manager') + ); + } + + /** + * ContentManagementMenuBlock constructor. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param mixed $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager + * Entity type manager. + */ + public function __construct( + array $configuration, + $plugin_id, + $plugin_definition, + EntityTypeManagerInterface $entityTypeManager + ) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->entityTypeManager = $entityTypeManager; + } + + /** + * {@inheritdoc} + */ + public function build() { + + // Load the view. + /** @var \Drupal\views\ViewExecutable $view */ + $view = $this->entityTypeManager + ->getStorage('view') + ->load('uw_view_pub_authors') + ->getExecutable(); + + // Set the display. + $view->setDisplay('pub_reference_authors'); + + // Execute the view. + $view->execute(); + + // Get the title. + $title = $view->getTitle(); + + // Get the rendered title for the view. + $the_title_render_array = [ + '#markup' => $this->t('@title', ['@title' => $title]), + '#allowed_tags' => ['h2'], + ]; + + // Display using the view template so ajax works properly. + return [ + '#type' => 'view', + '#name' => $the_title_render_array, + '#view' => $view, + '#display_id' => 'pub_reference_authors', + '#embed' => TRUE, + '#cache' => $view->getCacheTags(), + ]; + } + + /** + * {@inheritdoc} + */ + public function blockForm($form, FormStateInterface $form_state) { + + // Get the parent form. + $form = parent::blockForm($form, $form_state); + + return $form; + } + + /** + * {@inheritdoc} + */ + public function blockSubmit($form, FormStateInterface $form_state) { + + } + +} -- GitLab