From 1f1c5cb46bcd59270b0eb63c0b4bef95c9fc5212 Mon Sep 17 00:00:00 2001
From: s j <sj@1729.be>
Date: Mon, 28 Jun 2021 07:45:31 +0000
Subject: [PATCH] imp: add a message on repurchase or transfer, redirect to
 pending transactions

---
 src/Form/RepurchaseShareTransactionForm.php | 6 ++++++
 src/Form/ShareTransactionForm.php           | 1 +
 src/Form/TransferShareForm.php              | 6 ++++++
 3 files changed, 13 insertions(+)

diff --git a/src/Form/RepurchaseShareTransactionForm.php b/src/Form/RepurchaseShareTransactionForm.php
index 65f2e26e..d9e7c05d 100644
--- a/src/Form/RepurchaseShareTransactionForm.php
+++ b/src/Form/RepurchaseShareTransactionForm.php
@@ -77,5 +77,11 @@ class RepurchaseShareTransactionForm extends FormBase {
     $context = ['share_ids' => $selected_shares];
     $t->attachSharesToTransaction(
       $form_state->getValue('shareholder_shares_at_date')['date'], $context);
+
+    $this->messenger()->addMessage(
+      $this->t('Created a new draft transaction.'));
+
+    // @todo: create a pending transactions route or reset redirect and add 'validate' on entity view.
+    $form_state->setRedirect('view.share_transactions.page_2');
   }
 }
diff --git a/src/Form/ShareTransactionForm.php b/src/Form/ShareTransactionForm.php
index 3d27f805..c5d198fe 100644
--- a/src/Form/ShareTransactionForm.php
+++ b/src/Form/ShareTransactionForm.php
@@ -103,6 +103,7 @@ class ShareTransactionForm extends ContentEntityForm {
         ]));
     }
     //$form_state->setRedirect('entity.share_transaction.canonical', ['share_transaction' => $entity->id()]);
+    // @todo: create a pending transactions route or reset redirect and add 'validate' on entity view.
     $form_state->setRedirect('view.share_transactions.page_2');
   }
 
diff --git a/src/Form/TransferShareForm.php b/src/Form/TransferShareForm.php
index ff1a6d3c..048ee18a 100644
--- a/src/Form/TransferShareForm.php
+++ b/src/Form/TransferShareForm.php
@@ -120,6 +120,12 @@ class TransferShareForm extends FormBase {
       $form_state->getValue('shareholder_shares_at_date')['date'], $context);
     $t2->attachSharesToTransaction(
       $form_state->getValue('shareholder_shares_at_date')['date'], $context);
+
+    $this->messenger()->addMessage(
+      $this->t('Created a new draft transaction.'));
+
+    // @todo: create a pending transactions route or reset redirect and add 'validate' on entity view.
+    $form_state->setRedirect('view.share_transactions.page_2');
   }
 
 }
-- 
GitLab