With #2937728: Add an UI committed, Tamper plugin instances can now be added, edited, removed and be seen in a listing. Although the UI allows you to reorder Tamper plugin instances, weights of Tamper plugin instances are not yet saved.

The task is to save weights. I think the following needs to happen to achieve that:

  • When adding a Tamper plugin instance, a weight automatically needs to be assigned. I think that the weight should be one higher than the previous Tamper plugin instance for the same source.
  • When updating an existing Tamper plugin instance, we need to ensure that the weight setting doesn't get lost.
  • When reordering Tamper plugin instances on the Tamper list page, the weights need to be updated for all Tamper plugin instances after clicking "Save" at the bottom of the page.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MegaChriz created an issue. See original summary.

MegaChriz’s picture

In the D7 version, the code for upping the weight of a new Tamper plugin instance is in feeds_tamper_save_instance(). I think a similar solution should be implemented in the FeedTypeTamperMeta class. This will ensure that weights are assigned also when programmatically adding a Tamper plugin instance.

ericgsmith’s picture

Attached is a patch to order the tamper plugins.

If we want the weight to be added by the tamper meta class - this will require a little extra work there to enable. For the moment, its just leaving it up to the form to supply a weight (this is similar to how newly created ImageEffect weights are applied onto ImageStyles)

MegaChriz’s picture

It's not a bad idea to follow core's approach here. Programmatically adding tampers are probably not a common task.

One thing that I noticed is that when I repeatedly reorder tamper plugins, the weights add up constantly further. I checked the D7 version and it is also happening there. I think the cause is related to the hidden weight field be a number field instead of a select list. In the attached patch I changed the field type to 'weight'.

I made some other minor changes in the patch as well (tiny coding standard issue, docs, removing a @todo for weight).

  • MegaChriz committed 7ca344c on 8.x-2.x authored by ericgsmith
    Issue #2953361 by MegaChriz, ericgsmith: Allow Tamper plugins to be...
MegaChriz’s picture

Status: Needs review » Fixed

Committed #4 with one small difference: the drupal_set_message() call with message "Your changes have been saved." has been moved to the bottom of TamperListForm::submitForm(). It was called for every tamper instance before.

Status: Fixed » Closed (fixed)

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