Comments

tclark62 created an issue. See original summary.

megachriz’s picture

Yes, this is a feature that is planned to be added. Apparently, there wasn't an issue for it yet, so thanks for creating that.

It may take a while before I've time to address this. I give Feeds and Feeds Migrate more priority.

Patches are welcome of course!

tclark62’s picture

Status: Active » Needs review
StatusFileSize
new2.96 KB

This patch adds the ability to give each plugin instance a unique name. It also displays those names on the Tamper List Form along with the other plugin information.

Status: Needs review » Needs work

The last submitted patch, 3: feeds_tamper-add-plugin-name-3008407-3.patch, failed testing. View results

tclark62’s picture

Status: Needs work » Needs review
StatusFileSize
new2.95 KB

Trying patch again. Feedback is welcome; I'm relatively new at contributing patches from scratch.

Status: Needs review » Needs work

The last submitted patch, 5: feeds_tamper-add-plugin-name-3008407-5.patch, failed testing. View results

tclark62’s picture

StatusFileSize
new2.84 KB

One more time!

tclark62’s picture

Status: Needs work » Needs review
StatusFileSize
new2.74 KB

Correcting the file names.

megachriz’s picture

A patch for a module need to be created from within the module folder.

cd feeds_tamper
git diff > ../feeds_tamper-my-change.patch

Edit: I see you just did that!

Status: Needs review » Needs work

The last submitted patch, 8: feeds_tamper-add-plugin-name-3008407-8.patch, failed testing. View results

tclark62’s picture

Status: Needs work » Needs review
StatusFileSize
new4.51 KB

Added testing of UI for new field.

Status: Needs review » Needs work

The last submitted patch, 11: feeds_tamper-add-plugin-name-3008407-10.patch, failed testing. View results

megachriz’s picture

The name for the new setting is not consistent in the patch. In some case it is called "name", in other cases "tamper_name". I think I should call it "name" everywhere.

megachriz’s picture

Or perhaps "label" is the better name for this setting. "Name" could also mean machine name, I think "label" covers its use better.

tclark62’s picture

Status: Needs work » Needs review
StatusFileSize
new4.51 KB

Good point about the inconsistency! I changed from tamper_name/name to label.

The only reason I didn't use 'Label' initially was because I think the tamper plugin types have labels, but I think it's fine to call it the label since it's for the individual tamper rule, not the plugin type in general.

I'm still learning how to properly write tests, so if you could offer any feedback on what's wrong with those, I'd be happy to adjust accordingly! (I say this since I know that this patch will fail the module UI tests.)

Status: Needs review » Needs work

The last submitted patch, 15: feeds_tamper-add-plugin-name-3008407-15.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

megachriz’s picture

  1. +++ b/src/Form/TamperFormBase.php
    @@ -86,6 +87,14 @@ abstract class TamperFormBase extends FormBase {
    +        '#default_value' => $this->plugin->getConfiguration()[self::VAR_TAMPER_LABEL],
    

    I think the issue is that 'label' doesn't initially exist on the configuration array. Tamper plugins have the method getSetting() that returns NULL when the config key does not exist. Thus I think $this->plugin->getSetting(self::VAR_TAMPER_LABEL) would at least fix a part of the test failures.

  2. +++ b/src/Form/TamperListForm.php
    @@ -196,6 +197,11 @@ class TamperListForm extends FormBase {
    +        ¶
    ...
    +        ¶
    

    Extra whitespace here.

  3. +++ b/src/Form/TamperListForm.php
    @@ -196,6 +197,11 @@ class TamperListForm extends FormBase {
    +        $row['Label'] = [
    

    The first character of 'Label' is capitalized here. It should be lowercase.

tclark62’s picture

Status: Needs work » Needs review
StatusFileSize
new5.37 KB

Yup, that makes sense. Thanks for the feedback, very helpful! I added a couple checks to make sure the label is there (on the edit form and on the list form). Even though the field is required, I thought that would be helpful in case anyone applies it as a patch.

Edit: The patch is named improperly...

Status: Needs review » Needs work

The last submitted patch, 18: feeds_tamper-add-plugin-name-3008407-17.patch, failed testing. View results

megachriz’s picture

That test failure makes no sense to me.

+++ b/src/Form/TamperEditForm.php
@@ -41,8 +41,10 @@ class TamperEditForm extends TamperFormBase {
+    $has_label = !empty($this->plugin->getConfiguration()[self::VAR_TAMPER_LABEL]);
...
+    $form[self::VAR_PLUGIN_CONFIGURATION][self::VAR_TAMPER_LABEL]['#default_value'] = $has_label ? $this->plugin->getConfiguration()[self::VAR_TAMPER_LABEL] : NULL;

This could be made simpler by calling getSetting() on the Tamper plugin.

tclark62’s picture

Status: Needs work » Needs review
StatusFileSize
new6.71 KB

You're right, I did that the wrong way. I corrected that and added the last of the testing information that should be necessary.

tclark62’s picture

StatusFileSize
new6.7 KB

Corrected the proper way to get the label value in the prepareConfig.

tclark62’s picture

StatusFileSize
new6.7 KB

Minor coding standard correction.

Summary of this patch: Adds a Label to each Tamper field, which is displayed in the list of Tamper fields so that you can give each a custom label which allows you to identify which is which. This doubles as a way to ascribe a plain language phrase to what a potentially complicated replacement pattern is doing.

megachriz’s picture

StatusFileSize
new8.82 KB
new5.17 KB

It took me a while before I got time to look into this issue again, thanks for the patches!

I've updated the code with the following changes:

  • The label defaults to the plugin's label.
  • When changing the plugin, the label gets set to the new plugin's label.
  • The label of the label field is shortened to 'Label'.
  • The description of the label field is now the same as in the D7 version.
  • A javascript test is added to assert that the plugin's label changes when selecting an other plugin.
  • Small cleanups.

  • MegaChriz committed 68e03ad on 8.x-2.x authored by tclark62
    Issue #3008407 by tclark62, MegaChriz: Added ability to name each tamper...
megachriz’s picture

Title: Add Ability to Name Each Tamper Plugin » Add ability to mame each tamper plugin
Status: Needs review » Fixed

Committed #24 with a small difference in the config schema file: I added the declaration of 'label' before 'description'.

megachriz’s picture

Title: Add ability to mame each tamper plugin » Add ability to name each tamper plugin

Status: Fixed » Closed (fixed)

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