Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heddn created an issue. See original summary.

heddn’s picture

Issue summary: View changes
geek-merlin’s picture

Title: Sort ordering » Choose and order selectable styles
Issue summary: View changes

@heddn: Feel free to change back if you feel i hijack this.

geek-merlin’s picture

inversed’s picture

Has anyone been able to setup an Entity Reference View for this?

geek-merlin’s picture

Workaround: use text-list and DS regions.
Also see #2867781: Add CSS classes for entity.

brandonratz’s picture

@inversed, I think you would need to use https://www.drupal.org/project/config_views for an Entity Reference View.

inversed’s picture

@brandonratz, that seemed promising as now, I can create an Entity Reference View that lists the classes, however, I still can't use that View as a filter for the Classy Paragraphs entity reference.

I wonder if I'm missing something obvious or if this usage is just unsupported.

brandonratz’s picture

@inversed, Promising is about as far as I got with it. I cannot get a filter to work either. The config_views may only support specific system config and would have to be extended to support this entity directly.

szato’s picture

Status: Active » Needs review
FileSize
5.65 KB

Hi,
I created an Entity Reference Selector plugin for filtering Paragraphs classy styles with ordering functionality (by Label/Machine name). We are using in our Parade project specific machine name prefixes for "grouping" classy paragraphs styles, like 'color_', 'layout_'. So I added a ''Classy paragraphs machine name starts with" filter option too.

szato’s picture

Pach file fix.

jwineichen’s picture

The #11 patch is slick. Thanks for the work, @szato.

brockfanning’s picture

#11 works for me, and seems like a good way to solve the problem.

rteijeiro’s picture

+++ b/src/Plugin/EntityReferenceSelection/ClassyParagraphsSelection.php
@@ -0,0 +1,157 @@
+          '#description' => t('You can filter for matching machine names.') . ' ' . t('Possible to filter newly added classes dynamically without updating the field config.'),

Just a silly question. Why using concatenation for these two strings?

The rest seems right for me. Patch applies cleanly.

Any idea about how I can properly test it?

szato’s picture

Status: Needs review » Reviewed & tested by the community

Hi rteijeiro,

thank you for the review.
Concatenation: we are using the same t() string on line #77. So the reason is re-using translated string.

Testing:
1) Download and install the dev version of classy paragraphs module.
2) Apply the patch #11.
3) Add classy paragraphs field and choose 'Classy paragraphs' reference method for 'REFERENCE TYPE' at field settings.
4) If you enjoyed, set 'Reviewed & tested by the community' for issue :)

szato’s picture

Status: Reviewed & tested by the community » Needs review
jsbalsera’s picture

Status: Needs review » Reviewed & tested by the community

I have tested the patch and it works perfectly, thank you for your work. Additionally phpcs didn't flag any error, therefore I change the status :-)

grathbone’s picture

Running into a problem with this patch where the configuration isn't merging with the default $selection_handler_settings when selecting filter by machine_name, since the 'filter' array is already set in the configuration. May need to make it recursively merge the array.

VISIOS’s picture

Tested and works. Very helpful and great addition to the editor UX.

bgilhome’s picture

The patch gave me ajax errors that indexes in the handler settings weren't defined - eg. $selection_handler_settings['filter']['target_bundles']. I fixed it by adding the extra filter settings via implementing defaultConfiguration() for the plugin. Patch and interdiff attached.

dscl’s picture

Status: Reviewed & tested by the community » Needs review

Considering there is a new patch on #20, I'm moving the issue back to needs review.
If the patch on #20 is not the one to be merged, we can go back to #11 that was RTBC'ed.

I will try to find the time to test the #20, but hopefully somebody will do it first. :)

szato’s picture

Status: Needs review » Reviewed & tested by the community

Tested, #20 forks for me.

szato’s picture

BEGRAFX’s picture

I've applied patch 11 and then patch 20, and 11 responds with, "Skipped patch 'src/Plugin/EntityReferenceSelection/ClassyParagraphsSelection.php'." and when I apply 20...

"git apply -v choose_and_order-2830403-20.patch
Checking patch src/Plugin/EntityReferenceSelection/ClassyParagraphsSelection.php...
error: src/Plugin/EntityReferenceSelection/ClassyParagraphsSelection.php: already exists in working directory

Yet when I refresh the Extend window, I find "Parade Conditional field" is inactivated, and if I attempt to activate it, I still get the message, "The Parade module requires the ClassyParagraphsSelection class. For more information, see the Choose and order selectable styles issue for Classy paragraphs style to apply patch." and the link for "patch" takes me to patch 11.

szato’s picture

Hi BEGRAFX,

1) You get an error because of you applied patch #11, you didn't remove it and tried to apply patch #20.
2) The dependency problem is parade issue, not classy paragraphs.

szato’s picture

Added missing entity_reference_selection.classy_paragraphs schema.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 26: choose_and_order-2830403-26.patch, failed testing. View results

szato’s picture

Pach file fix (Add missing entity_reference_selection.classy_paragraphs schema)

szato’s picture

Status: Needs work » Needs review
BEGRAFX’s picture

@szato,

In #25, you mention that I need to remove the previous patch before applying the newer one. I have looked through the patching information, and I don't see any information/instructions on removing a patch. Can you help me on that one?

szato’s picture

@BEGRAFX,

if you are using 'git apply', then:
git apply -R <patch>

BEGRAFX’s picture

OK, I used the -R method, which apparently worked fine. There were no messages of any kind. However, when I attempted to apply patch 27 on another project:

git apply -v choose_and_order-2830403-27.patch
Skipped patch 'config/schema/classy_paragraphs_style.schema.yml'.
Skipped patch 'src/Plugin/EntityReferenceSelection/ClassyParagraphsSelection.php'.

is the result.

szato’s picture

@BEGRAFIX,

it's a local checkout of git repository?

Note: git apply will fail to do anything when used within a local checkout of a git repository (other than the one for the project the patch is made for), such as if you are patching a module that is within a site that is in Git version control. Use patch -p1 < path/file.patch instead. Patches created before Git might need to be applied with: patch -p1 < path/file.patch

Pls read the documentation at https://www.drupal.org/patch/apply
...and use the patch command.

BEGRAFX’s picture

No, this is on a site I have in development. I have installed the Classy Paragraphs module since it is a required module for Parade. The site is currently on my MAMP development server. I install/enable Classy Paragraphs, and it is fine. However when I then try to enable Parade, I get the message

The Parade module requires the ClassyParagraphsSelection class. For more information, see the Choose and order selectable styles issue for Classy paragraphs style to apply patch.

and when I attempt to apply the patch, I get the result mentioned in #32.

Clicking the link in the message brings me to this thread.

GAMe’s picture

Does anyone know whats going on with this module. It doesn't seem to be getting a lot of love as the last dev and stable release were 2016. I too need this for Parade... anyone who could pick this up would be a hero in my eyes :-)

GAMe’s picture

So I have applied patch 27 and im not getting the classy paragraphs error when enabling the modules however when I go into edit parade demo for example the dropdowns for color and layout are empty and I cant select anything. :-( Am I missing something or is this another issue?

-- Turns out I was missing something I needed to add the classy styles to the ref field as these weren't completed by default.

Thanks

cgmonroe’s picture

Patch in 28 works for me.

I'd say it's RTBC except I don't think it's the right solution to the problem of limiting classes. It can solve this, but with 20+ paragraphs, the "book work" to keep what shows up on which paragraphs is a bit much. E.g. add a new class for blog sidebar paragraph and have to edit 20 paragraph types. Not very maintainable. (Yes, you can play games with naming and inverse but on an existing site that changes a lot, this is hard to do).

IMHO, I think it might be better to redo the class entity to use bundles. Then you could create different fields that use different bundles. An example of this would be something like:

Suppose you had the following Paragraph Class Entities Definitions, listed in bundle name - entity name format.

section - bg-grey
section - bg-white
section - narrow-margins
blog - align-right
blog - align-left
blog - callout-width-33
blog - callout-width-50

Section type paragraph could have a Section Classes field that was limited to the section bundle.

Blog paragraphs could have a Blog Classes field that was limited to the blog bundle.

Need to add a new blog class? Just add a new Paragraph Class Entity of the blog bundle type and it shows up.

With this format, I think the standard select the related entity bundles field widget would work.

There is a bundled config entity type in core. Probably the biggest headache would be getting the update scripts to work properly.

bdevore’s picture

Also wondering why this is languishing as it's a nicely defined solution that's not too complex. I've looked at Bricks/Modifiers but for my users it seems like too many options for them. As a workaround you can use Paragraphs/Field Group 3.x-Dev (You'll need the patch in this thread https://www.drupal.org/project/field_group/issues/2858336) and a text list of options to pull the tokens from.

mayurgajar’s picture

Patch #11 throws error : Error Fatal error: Unsupported operand types
so uploading this new patch #choose-and-order-2830403-39.patch

mayurgajar’s picture

Patch is failing in certain manual testing scenarios so removing the patch #choose-and-order-2830403-39.patch
DO NOT USE PATCH #39

amarlata’s picture

When I applied patch #11 in Drupal 9

Notice: Undefined index: handler_settings in Drupal\classy_paragraphs\Plugin\EntityReferenceSelection\ClassyParagraphsSelection->buildConfigurationForm() (line 26 of modules/contrib/classy_paragraphs/src/Plugin/EntityReferenceSelection/ClassyParagraphsSelection.php).

Error: Unsupported operand types in Drupal\classy_paragraphs\Plugin\EntityReferenceSelection\ClassyParagraphsSelection->buildConfigurationForm() (line 30 of modules/contrib/classy_paragraphs/src/Plugin/EntityReferenceSelection/ClassyParagraphsSelection.php).

amarlata’s picture

Patch for Drupal 9. Fix Missing handler settings after upgrade to drupal 9. handler_settings' is removed from drupal:9.0.0

https://www.drupal.org/project/paragraphs/issues/3138499
https://www.drupal.org/project/drupal/issues/3114032

amarlata’s picture

Patch for Drupal 9. Fix Missing handler settings after upgrade to drupal 9. handler_settings' is removed from drupal:9.0.0

https://www.drupal.org/project/paragraphs/issues/3138499
https://www.drupal.org/project/drupal/issues/3114032

#42 patch is not applying.

grathbone’s picture

Kept running into ajax issues due to unset indexes in the config array.

Not sure if this is the correct solution or adding them to default config also.

The main issue seemed to be happening when switching between modes.

rroose’s picture

#43 worked for me after updating my site to Drupal 9. Thanks amarlata!

spfaffly’s picture

#44 helped me solve an issue on an earlier patch. It resolved a notice error:

Notice: Undefined index: handler_settings in /var/www/docroot/modules/contrib/classy_paragraphs/src/Plugin/EntityReferenceSelection/ClassyParagraphsSelection.php on line 134

Thanks @grathbone!

szato’s picture

Status: Needs review » Reviewed & tested by the community

Checked with D9 core. Works, no notices.

i-trokhanenko’s picture

Assigned: Unassigned » i-trokhanenko

  • grathbone authored 70c0db8 on 8.x-1.x
    Issue #2830403 by szato, amarlata, bgilhome, mayurgajar, grathbone, i-...
i-trokhanenko’s picture

Assigned: i-trokhanenko » Unassigned
Status: Reviewed & tested by the community » Fixed

Committed #44. Thanks!

Status: Fixed » Closed (fixed)

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