Problem/Motivation
We discuss here that we want to move summary into Paragraphs entity.
Also improve collapsed/closed summary: don't show empty fields and show the missing summary for paragraph types title and subtitle
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | interdiff-2857112-17-20.txt | 6.03 KB | toncic |
| #20 | add_summary_in_paragraphs-20.patch | 16.71 KB | toncic |
| #17 | interdiff-2857112-15-17.txt | 966 bytes | toncic |
| #17 | add_summary_in_paragraphs-17.patch | 11.14 KB | toncic |
| #15 | interdiff-2857112-12-14.txt | 1.58 KB | toncic |
Comments
Comment #2
toncic commentedThis is part of paragraphs.
Comment #3
toncic commentedI will try.
Comment #4
toncic commentedNow we have method getCollapsedSummary in Paragraphs.
Comment #5
berdirUff, this method is quite weird :)
I know we're just moving it, but I think we should clean it up at least a bit, we can move some more complicated things including more tests to a follow-up.
this now being a method on the paragraph, we could actually move/improve test coverage as a kernel test, which would be faster and easier than trying to do everything through the widet.
$field_name => $field_definition are much better names for this.
getImageSummary() can be protected.
text types is no including plain text types. A hardcoded list is also a pretty limited approach. tmgmt tries to be a bit more flexible, but it's tricky stuff.
but not that behaviors field is string_long, so we'll have to skip that.
we can possibly use \Drupal\Component\Utility\Unicode::truncate() for this. I also don't get the logic with checking for 50 and then cutting of at 150?
this blindly assumes that the reference is a pargraph, that's not guaranteed, could be anything. check the entity against ParagraphsInterface
don't understand why we include both uid and revision_uid here. Also, pargraphs doesn't have a uid field, actually. and the revision_uid field seems hardly interesting for a summary.
I'd just start the summary hardcoded with the type and drop this.
if we strip tags here, then we don't need to do it again here.
why not support file fields too?
getFilename()
again, truncate()...
Returns.
The summary isn't collapsed, we just use it in the collapsed/closed widget state. So maybe just getSummary()?
And "to return" doesn't really make sense.
empty newline added.
Comment #6
miro_dietikerOr should we even create a service?
The reason why we didn't care too much about this summary hardcoding was - it is super easy to override in a widget subclass. After moving i need to alter / replace the entity class..
We still have discussions about when to use rendered paras and when to create the summary. Imho the summary currently is related a lot to how we display it and is intentionally in the experimental interface domain. Moving it to the entity disallows us further api changes :-!
Also i don't like that this is blocking other important issues.
Comment #7
miro_dietikerComment #8
berdirThis is not experimental, it was already in the classic one as well.
The only API here is that you get a string back. We make no promises on how that is build and what it contains, so I don't think this blocks further improvements on that. And however we end up using it, I think the concept of having a text summary seems generally useful, for example for that library use case that we have no and possibly other things as well.
Comment #9
miro_dietikerOut of my mind we have two extra requirements:
A flag if recursion into children is wanted
A flag if it should be full or reduced.
The reduced version will skip elements that have an icon, covered in the ui already.. and here's the connection with the ui...
Dunno how to cover those and how to bring the icons into the ui. There might be multiple possible locations for the icons.
Comment #10
berdir> A flag if recursion into children is wanted
Sure? That might make sense at first, but it would likely not make much sense at do this for container paragraphs that contain nothing (except some behavior settings maybe) but nested paragraphs.
> A flag if it should be full or reduced.
Yes, I was wondering about the type for example as well, that is now and likely also in the future in the UI somehow. also doesn't actually seem to be in the summary despite being in the code, will check that. But again, letting code decide that is tricky, just because we *support* icons doesn't mean everyone will have time, so possibly a setting instead.
But we can also add a currently empty $context or $options array and we'll add options through that in the future. then we're flexible.
Comment #11
miro_dietikerExclusion of recursion: Absolutely sure. For instance the drag and drop mode shows a summary AND also always shows the childrens below, indented. Repeating the children on the parent would lead do weird duplication. Also "container only" are likely to have plugins enabled and thus if no content fields, the summary would simply tell styles or grid settings chosen. And if none, then an empty summary is perfectly what i expect. :-)
A pattern about summary could be that the (tbd) icon methods will return icon definitions with keys. Then we could pass in options to the summary with some skip key that gets the icon keys that are displayed otherwise. The summary then excludes them on creation.
Comment #12
toncic commentedCreated follow-up: #2858133: Allow full or reduced summary
Comm #5 .6 : I would not like to add paragraphs_type->label on the begging, because we already have information about type, this is kind of duplicate information.
I think that we have wrong condition in getNestedSummary:
if ($paragraph_entity instanceof ParagraphInterface) {Still thinking how to fix that.
Comment #13
toncic commentedOnly to check tests.
Comment #15
toncic commentedSo, we still need separate case for 'entity_reference' and 'entity_reference_revisions'.
Also we should test a validation message and validation error because they are not displaying correctly, but for that we can open new issue, is not part of summary method.
Comment #16
primsi commentedI was thinking if we should add some kind of alter to allow other modules to change this summary given the concerns raised in #6. Thouths?
Comment #17
toncic commented#16. Let's see what other will say.
Uploading patch with small changes for length of summary string.
For now we have everything what we had before and plus this #2858075: Improve Paragraph collapsed/closed summary: don't show empty fields solved.
Comment #18
ginovski commentedThere is a space before the comma in the text paragraph, could add trim() to the summary?
Other than that, seems ready.
Comment #19
ginovski commentedComment #20
toncic commentedFixed adding title in collapsed summary, also added tests.
Comment #22
miro_dietikerCommitted, but needs work as in the follow-ups from the discussions are not yet created.
Comment #23
ginovski commentedAdding related issues.
Comment #24
berdir