Skip to content
Snippets Groups Projects
Commit c7f5cf29 authored by Bernd Oliver Suenderhauf's avatar Bernd Oliver Suenderhauf
Browse files

Issue #3023471 by Pancho: Use dropbutton for FillPdfForm entity list operations

parent 48dcc6d9
No related branches found
No related tags found
No related merge requests found
......@@ -65,8 +65,6 @@ display:
admin_title: admin_title
title: title
uri: uri
nothing: nothing
nothing_1: nothing_1
info:
fid:
sortable: false
......@@ -96,20 +94,6 @@ display:
separator: ''
empty_column: false
responsive: ''
nothing:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
nothing_1:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
default: '-1'
empty_table: false
row:
......@@ -339,20 +323,20 @@ display:
entity_type: fillpdf_form
entity_field: file
plugin_id: field
nothing:
id: nothing
table: views
field: nothing
operations:
id: operations
table: fillpdf_forms
field: operations
relationship: none
group_type: group
admin_label: ''
label: Operations
exclude: false
alter:
alter_text: true
text: Edit
make_link: true
path: 'admin/structure/fillpdf/{{ fid }}'
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
......@@ -365,7 +349,7 @@ display:
suffix: ''
target: ''
nl2br: false
max_length: null
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
......@@ -386,155 +370,9 @@ display:
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: false
plugin_id: custom
nothing_1:
id: nothing_1
table: views
field: nothing
relationship: none
group_type: group
admin_label: 'Operations: Delete'
label: ''
exclude: false
alter:
alter_text: true
text: Delete
make_link: true
path: 'admin/structure/fillpdf/{{ fid }}/delete'
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: null
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: false
plugin_id: custom
nothing_2:
id: nothing_2
table: views
field: nothing
relationship: none
group_type: group
admin_label: 'Operations: Export'
label: ''
exclude: false
alter:
alter_text: true
text: 'Export configuration'
make_link: true
path: 'admin/structure/fillpdf/{{ fid }}/export'
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: null
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: false
plugin_id: custom
nothing_3:
id: nothing_3
table: views
field: nothing
relationship: none
group_type: group
admin_label: 'Operations: Import'
label: ''
exclude: false
alter:
alter_text: true
text: 'Import configuration'
make_link: true
path: 'admin/structure/fillpdf/{{ fid }}/import'
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: null
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: false
plugin_id: custom
hide_alter_empty: true
destination: true
plugin_id: entity_operations
filters: { }
sorts: { }
title: 'FillPDF forms'
......
......@@ -25,6 +25,7 @@ use Drupal\fillpdf\Service\FillPdfAdminFormHelper;
* "export" = "Drupal\fillpdf\Form\FillPdfFormExportForm",
* "import" = "Drupal\fillpdf\Form\FillPdfFormImportForm",
* },
* "list_builder" = "Drupal\fillpdf\FillPdfFormListBuilder",
* "access" = "Drupal\fillpdf\FillPdfFormAccessControlHandler",
* },
* admin_permission = "administer pdfs",
......@@ -34,7 +35,11 @@ use Drupal\fillpdf\Service\FillPdfAdminFormHelper;
* "uuid" = "uuid",
* },
* links = {
* "delete-form" = "/admin/structure/fillpdf/{fillpdf_form}/delete"
* "edit-form" = "/admin/structure/fillpdf/{fillpdf_form}",
* "delete-form" = "/admin/structure/fillpdf/{fillpdf_form}/delete",
* "export-form" = "/admin/structure/fillpdf/{fillpdf_form}/export",
* "import-form" = "/admin/structure/fillpdf/{fillpdf_form}/import",
* "collection" = "/admin/structure/fillpdf",
* }
* )
*/
......
<?php
namespace Drupal\fillpdf;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
/**
* Provides a listing of FillPdf forms.
*
* This is a minimal listbuilder implementation only used as a provider for
* default operations in Views. Additional operations may be injected using
* hook_entity_operation(). Existing operations may be altered using
* hook_entity_operation_alter().
*
* @see hook_entity_operation()
* @see hook_entity_operation_alter()
*/
class FillPdfFormListBuilder extends EntityListBuilder {
/**
* {@inheritdoc}
*/
public function getDefaultOperations(EntityInterface $entity) {
$export = [
'title' => t('Export configuration'),
'weight' => 20,
'url' => $this->ensureDestination($entity->toUrl('export-form')),
];
$import = [
'title' => t('Import configuration'),
'weight' => 30,
'url' => $this->ensureDestination($entity->toUrl('import-form')),
];
$operations = parent::getDefaultOperations($entity) + [
'export' => $export,
'import' => $import,
];
return $operations;
}
}
......@@ -5,6 +5,7 @@
* Contains fillpdf_test.module..
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
/**
......@@ -31,3 +32,26 @@ function fillpdf_test_theme() {
return $theme;
}
/**
* Implements hook_entity_operation().
*/
function fillpdf_test_entity_operation(EntityInterface $entity) {
if ($entity->getEntityTypeId() == 'fillpdf_form') {
return [
'test' => [
'title' => t('Export configuration test'),
'url' => $entity->toUrl('export-form'),
]
];
}
}
/**
* Implements hook_entity_operation_alter().
*/
function fillpdf_test_entity_operation_alter(array &$operations, EntityInterface $entity) {
if ($entity->getEntityTypeId() == 'fillpdf_form') {
$operations['import']['title'] = t('Import configuration test');
}
}
......@@ -47,6 +47,22 @@ class AdminIdTest extends BrowserTestBase {
$this->assertSession()->pageTextContains('New FillPDF form has been created.');
}
/**
* Tests the overview form's operation links.
*/
public function testOverviewFormLinks() {
$this->uploadTestPdf('fillpdf_test_v3.pdf');
$this->drupalGet('admin/structure/fillpdf');
// Check hook_entity_operation_alter(). Only the altered link should exist.
$this->assertSession()->linkExistsExact('Import configuration test');
$this->assertSession()->linkNotExistsExact('Import configuration');
// Check hook_entity_operation(). Both links should exist.
$this->assertSession()->linkExistsExact('Export configuration test');
$this->assertSession()->linkExistsExact('Export configuration');
}
/**
* Tests the overview form's edit links.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment