From 86ad9270c45fbf7ab5c51662e21a812e4f2e1a39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernd=20Oliver=20S=C3=BCnderhauf?=
 <31389-pancho@users.noreply.drupalcode.org>
Date: Fri, 18 Nov 2022 20:22:54 -0500
Subject: [PATCH] Issue #3049714 by Pancho, arunkumark: Add export and import
 tabs to FillPdfForm

---
 fillpdf.links.task.yml       | 18 ++++++++++++++++++
 fillpdf.routing.yml          |  2 +-
 src/Form/FillPdfFormForm.php | 15 ---------------
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/fillpdf.links.task.yml b/fillpdf.links.task.yml
index ee502ad..c605df1 100644
--- a/fillpdf.links.task.yml
+++ b/fillpdf.links.task.yml
@@ -9,3 +9,21 @@ fillpdf.settings:
   route_name: fillpdf.settings
   base_route: fillpdf.forms_admin
   weight: 30
+
+entity.fillpdf_form.canonical:
+  title: 'Edit'
+  route_name: entity.fillpdf_form.canonical
+  base_route: entity.fillpdf_form.canonical
+  weight: -10
+
+entity.fillpdf_form.export_form:
+  title: 'Export'
+  route_name: entity.fillpdf_form.export_form
+  base_route: entity.fillpdf_form.canonical
+  weight: 10
+
+entity.fillpdf_form.import_form:
+  title: 'Import'
+  route_name: entity.fillpdf_form.import_form
+  base_route: entity.fillpdf_form.canonical
+  weight: 15
diff --git a/fillpdf.routing.yml b/fillpdf.routing.yml
index fe16e97..9040e6c 100644
--- a/fillpdf.routing.yml
+++ b/fillpdf.routing.yml
@@ -60,7 +60,7 @@ entity.fillpdf_form.import_form:
     _entity_form: fillpdf_form.import
     _title: 'Import FillPDF form configuration and field mappings'
   requirements:
-    _entity_access: fillpdf_form.view
+    _entity_access: fillpdf_form.update
 
 entity.fillpdf_form.duplicate_form:
   path: '/admin/structure/fillpdf/{fillpdf_form}/duplicate'
diff --git a/src/Form/FillPdfFormForm.php b/src/Form/FillPdfFormForm.php
index 0048b10..e83f0b9 100644
--- a/src/Form/FillPdfFormForm.php
+++ b/src/Form/FillPdfFormForm.php
@@ -12,7 +12,6 @@ use Drupal\Core\File\FileSystemInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Link;
 use Drupal\Core\Render\RendererInterface;
-use Drupal\Core\Url;
 use Drupal\fillpdf\Component\Utility\FillPdf;
 use Drupal\fillpdf\FillPdfAdminFormHelperInterface;
 use Drupal\fillpdf\FillPdfLinkManipulatorInterface;
@@ -435,20 +434,6 @@ class FillPdfFormForm extends ContentEntityForm {
 
     $form['fillpdf_fields']['#weight'] = 100;
 
-    $form['export_fields'] = [
-      '#prefix' => '<div>',
-      '#markup' => Link::fromTextAndUrl($this->t('Export these field mappings'), Url::fromRoute('entity.fillpdf_form.export_form', ['fillpdf_form' => $fillpdf_form->id()]))->toString(),
-      '#suffix' => '</div>',
-      '#weight' => 100,
-    ];
-
-    $form['import_fields'] = [
-      '#prefix' => '<div>',
-      '#markup' => Link::fromTextAndUrl($this->t('Import a previous export into this PDF'), Url::fromRoute('entity.fillpdf_form.import_form', ['fillpdf_form' => $fillpdf_form->id()]))->toString(),
-      '#suffix' => '</div>',
-      '#weight' => 100,
-    ];
-
     return $form;
   }
 
-- 
GitLab