Closed (fixed)
Project:
Paragraphs
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
21 Feb 2018 at 13:25 UTC
Updated:
8 Mar 2018 at 17:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
johnchqueAdding setting. :) Enabled by default.
Comment #4
johnchqueAdding schema. :)
Comment #5
johnchqueRebased, tests added. :)
Comment #6
miro_dietikerWe discussed in the meta issue to determine how these settings should be stored and what exact settings.
The decision was to offer a single setting (also schema) to enable widget features. It should be a checkboxes element in UI.
Initially we want to have two features to enable / disable
- duplicate
- collapse all /expand all (one feature for both)
Right, exactly added with this issue here.
Best is you also create some getter to check of a feature is enabled for code simplicity.
And then there will be the third feature soon to enable/disable the „add before“ functionality.
Comment #7
johnchqueAdding tests, changing to what Miro addressed in the previous comment.
Comment #9
johnchqueThis should work. :)
Comment #11
johnchqueUpdating tests. :)
Comment #12
miro_dietikerThis starts to look pretty nice. :-)
:-) totally
Enable, not show.
That's a bad key. More edit-collapse-all
As this is a new functionality, we might need a second parameter for the default value if there is no feature setting data. Otherwise to keep the current two features enabled, we need a hook_update.
@Berdir How to handle defaults?
I would guess there's aa much more compact solution in php, with array_search, _map, _filter
multiple => Collapse / Edit All
Comment #13
berdirOne thing is that this key should explicitly list the default features that should be enough for the start.
It gets more complicated when we add additional features that should be enabled by default, e.g. by making more existing fuctionality configurable.
I guess it doesn't do recursive merge, so what we could do is have getFeatures() that explicitly returns $configured_features_list + ['some_key' => TRUE, 'other_key' => FALSE]
Comment #14
johnchqueI see, should be better now.
Comment #15
berdirThe if nothing is selected part is wrong and should be removed. It's perfectly valid to disable all features, then nothing is enabled.
you can use array_filter() to filter out the non-selected ones, and you should get the options once, not inside the loop.
You could then even combine it with $feature_labels = array_intersect_key($this->getSettingOptions('features'), array_filter($this->getSetting('features'));
Question is whether this should be in access or not. Considering that we already have the duplicateButtonAccess() method, we could just put it in there?
The dragdrop check is no longer needed, we don't go in there anymore when dragdrop is enabled.
You can simplify this to a if (!empty($features[$feature]), doesn't need the array_filter anymore then.
Comment #16
johnchqueYeah, that would be much better indeed, addressing changes. :)
Comment #18
miro_dietikerYippie, committed. We have nice settings now.