#1963936: Support job comments had to add a ton of form alter code to inject an addition button and information for each data item.

Core should provide an empty default method to do either of that. We could even move our default stuff (accept/reject buttons for actions and soon old revisions) into those methods so that plugins could also alter what's there by default.

Comments

berdir’s picture

Assigned: Unassigned » blueminds
blueminds’s picture

Please see the patch.

Within this issue a very vague test coverage of the review tool has been added. Here is an issue to provide full #2022439

blueminds’s picture

Status: Active » Needs review
berdir’s picture

+++ b/tests/tmgmt_test.ui.translator.incundefined
@@ -52,4 +52,15 @@ class TMGMTTestTranslatorUIController extends TMGMTDefaultTranslatorUIController
+      '#markup' => 'testing output of review data item element from translator'

Let's use t() and some placeholders, e.g. for the data_item_key to verify that we get the correct information. uppercase Testing and . at the end, even if it's just for tests :)

+++ b/ui/tmgmt_ui.moduleundefined
@@ -508,6 +510,11 @@ function _tmgmt_ui_review_form_element($data, TMGMTJobItem $job_item, &$zebra, $
+  $plugin_name = $job_item->getTranslator()->plugin;
+  $translator_ui_controller = tmgmt_translator_ui_controller($plugin_name);
+  $source_ui_controller = tmgmt_source_ui_controller($plugin_name);

@@ -615,6 +622,11 @@ function _tmgmt_ui_review_form_element($data, TMGMTJobItem $job_item, &$zebra, $
+      // Give the translator ui controller a chance to affect the data item element.
+      $form[$target_key] = $translator_ui_controller->reviewDataItemElement($form[$target_key], $form_state, $key, $data[$key], $job_item);
+      // Give the source ui controller a chance to affect the data item element.
+      $form[$target_key] = $source_ui_controller->reviewDataItemElement($form[$target_key], $form_state, $key, $data[$key], $job_item);

Just access it directly. $job_item->getTranslatorController() and $job_item->getSourceController(). You requested the source ui controller using the translator plugin name, that only works because the test module implements both ;)

+++ b/ui/tmgmt_ui.testundefined
@@ -278,6 +278,31 @@ class TMGMTUITestCase extends TMGMTBaseTestCase {
 
+  public function testReviewTool() {

Should have a one line description and just testReview().

+++ b/ui/tmgmt_ui.testundefined
@@ -278,6 +278,31 @@ class TMGMTUITestCase extends TMGMTBaseTestCase {
+    $data_item_text = 'Text for job item with type test and id 1.';
...
+    $this->assertText('testing output of review data item element from translator');

I wouldn't hardcode this but get it from $item->data..

+++ b/ui/tmgmt_ui.testundefined
@@ -278,6 +278,31 @@ class TMGMTUITestCase extends TMGMTBaseTestCase {
+    // TMGMTTranslatorUIControllerInterface::reviewDataItemElement

Missing ()

blueminds’s picture

comments implemented.

RE $job_item->getTranslatorController() - that gives me the plugin controller but what I need there is the ui controller.

berdir’s picture

Status: Needs review » Fixed

Ah yes, sorry about the UI controller. We should probably have methods for those but that's a different topic. Committed and pushed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.