Problem/Motivation

Currently, the entity type is always appended to the name of a document in TMS. With the implementation of Lingotek Document Meta Data, this is no longer needed.

Proposed resolution

Add option in each translation profile to toggle setting on or off.

Remaining tasks

Tests need to be run.

User interface changes

Added checkbox inside of translation profile form to toggle setting.

Data model changes

Added member in LingotekProfile to store this new setting.

Comments

EPortela created an issue. See original summary.

EPortela’s picture

EPortela’s picture

EPortela’s picture

EPortela’s picture

EPortela’s picture

Added global setting to override profile settings.

EPortela’s picture

EPortela’s picture

EPortela’s picture

StatusFileSize
new22.67 KB
EPortela’s picture

StatusFileSize
new30.33 KB
penyaskito’s picture

Status: Active » Needs work
  1. +++ b/config/install/lingotek.profile.automatic.yml
    @@ -4,6 +4,7 @@ weight: 30
    +append_type_to_title: false
    

    If we would like to ignore it by default, we would need to write an upgrade path that sets this as TRUE, so existing users don't see a change in the current behavior. That will need tests too.

  2. +++ b/config/schema/lingotek.schema.yml
    @@ -39,6 +39,9 @@ lingotek.settings:
    +        title_append_type:
    +          label: 'Global setting to set whether to append content type to title in TMS'
    +          type: string
    
    @@ -256,6 +259,9 @@ lingotek.profile.*:
    +    append_type_to_title:
    +      type: boolean
    +      label: 'Append Content Type To Title'
    

    These are inconsistent. Let's use the same name and type.

  3. +++ b/src/Form/LingotekSettingsTabPreferencesForm.php
    @@ -153,6 +153,20 @@ class LingotekSettingsTabPreferencesForm extends LingotekConfigFormBase {
    +    $options = array(
    +      'always' => t('Always append regardless of profile setting'),
    +      'never' => t('Never append regardless of profile setting'),
    +      'profile' => t('Use profile setting (for editable profiles only)'),
    +    );
    

    I'm not sure if this is a UX pattern we want to follow, because it would be the first time. Usually we have a setting, and the profile can override that.

    For me the options would be "Use default settings", "no", "yes".

  4. +++ b/src/LingotekConfigTranslationService.php
    @@ -366,7 +366,23 @@ class LingotekConfigTranslationService implements LingotekConfigTranslationServi
    +    $lingotek_config = \Drupal::service('lingotek.configuration');
    

    Isn't this service already injected?

  5. +++ b/src/LingotekConfigTranslationService.php
    @@ -416,7 +432,23 @@ class LingotekConfigTranslationService implements LingotekConfigTranslationServi
    +    $lingotek_config = \Drupal::service('lingotek.configuration');
    

    Isn't this service already injected?

  6. +++ b/src/LingotekContentTranslationService.php
    @@ -718,9 +718,25 @@ class LingotekContentTranslationService implements LingotekContentTranslationSer
    -    $profile = $this->lingotekConfiguration->getEntityProfile($entity);
    

    If this is unrelated let's leave it there.

  7. +++ b/src/LingotekContentTranslationService.php
    @@ -1224,7 +1255,7 @@ class LingotekContentTranslationService implements LingotekContentTranslationSer
    +        $data['_lingotek_metadata']['_intelligence']['content_type'] = $entity->getEntityTypeId() . ' - ' . $entity->bundle();
    

    Are we sure we want to do this, instead of having an extra metadata key?

  8. +++ b/tests/src/Functional/LingotekNodeTranslationDownloadStatusTest.php
    @@ -82,6 +82,7 @@ class LingotekNodeTranslationDownloadStatusTest extends LingotekTestBase {
    +    $this->drupalGet('admin/lingotek/settings');
    
    @@ -102,6 +103,7 @@ class LingotekNodeTranslationDownloadStatusTest extends LingotekTestBase {
    +    $this->drupalGet('admin/lingotek/settings');
    
    @@ -122,6 +124,7 @@ class LingotekNodeTranslationDownloadStatusTest extends LingotekTestBase {
    +    $this->drupalGet('admin/lingotek/settings');
    
    @@ -142,6 +145,7 @@ class LingotekNodeTranslationDownloadStatusTest extends LingotekTestBase {
    +    $this->drupalGet('admin/lingotek/settings');
    

    Why is this necessary?

EPortela’s picture

Status: Needs work » Needs review
StatusFileSize
new28.02 KB

Thanks for reviewing the previous patch. This new patch addresses all of the points you made in the review. With point 7, we talked to Josh and he said he wanted to include the bundle type as well. Since TMS does not have another field for 'bundle type' or anything similar we have to include it inside of 'content type'.

Status: Needs review » Needs work

The last submitted patch, 13: profile-setting-toogle-append-entity-type-2979695-13.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

EPortela’s picture

Status: Needs work » Needs review
StatusFileSize
new28.03 KB
EPortela’s picture

StatusFileSize
new29.42 KB

Added test to make sure update path is working.

penyaskito’s picture

+++ b/src/Form/LingotekProfileFormBase.php
@@ -105,6 +105,23 @@ class LingotekProfileFormBase extends EntityForm {
+    $options = array(
+      'global_setting' => 'Use global setting',
+      'yes' => 'Yes',
+      'no' => 'No',
+    );

The keys don't, but the values need to be passed through $this->t()

penyaskito’s picture

StatusFileSize
new4.03 KB
new29.51 KB

Updated hook_update_N after latest commits.
Fixed precedent comment.
Fixed some comment standards.

Tests are green, and looks like there's coverage for the upgrade path. Not sure if there are enough tests for when the option is false, or overridden in the profile, but I think it's good.

Thanks!

penyaskito’s picture

StatusFileSize
new10.56 KB
new38.46 KB

Added tests for the options themselves.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

Tests passed as expected. Thanks Edward!

  • penyaskito committed f6bf4ac on 8.x-2.x authored by EPortela
    Issue #2979695 by EPortela, penyaskito: Give option to append node type...
penyaskito’s picture

Status: Reviewed & tested by the community » Fixed

Committed f6bf4ac and pushed to 8.x-2.x. Thanks!

Status: Fixed » Closed (fixed)

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