Problem/Motivation

Follow-up to #2831763: Use Paragraphs types icons in the "Modal" add mode.

After the parent is committed, in ParagraphsWidget::buildModalAddForm there will be:

$element['#attached']['drupalSettings']['paragraphs'] = [
  'title' => $this->t('Add @title', ['@title' => $this->getSetting('title')]),
];

Berdir:

We . . . need a follow-up . . . because this ["drupalSettings"] is global and having multiple paragraphs with different labels will not work.

I think we should instead set this as a data property somewhere on the button/template that we use, then we can get it from that.

Proposed resolution

Instead of using drupalSettings, set the window title as the value of a data-* (e.g., data-title) attribute of an HTML element we are generating. Then make paragraphs.modal.js retrieve it and put in on the form.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

VladimirMarko created an issue. See original summary.

VladimirMarko’s picture

Status: Active » Postponed
FileSize
1.33 KB

This patch depends on #2831763: Use Paragraphs types icons in the "Modal" add mode. Tests are missing.

Berdir’s picture

Status: Postponed » Needs review

Was wondering if we can't just use the button label, which is exactly the same.

VladimirMarko’s picture

Done. Still without tests.

VladimirMarko’s picture

Added a test. As I added ParagraphsTestBaseTrait::setParagraphsWidgetSettings, there will be a merge conflict with #2896115: Autocollapse all Paragraphs except current.

The last submitted patch, 5: make_the_title_of_the-2898685-5-test-only.patch, failed testing. View results

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine, but yes, this or the other issue will need to rerolled.

miro_dietiker’s picture

I plan to first review and commit the other issue. However if it is not ready yet, i'll commit this first.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Needs work

Committed the other issue. This needs a re-roll.

Berdir’s picture

Status: Needs work » Needs review
FileSize
4.01 KB

Conflict is trivial, both patches simply added the same method. So that part is now gone.

  • miro_dietiker committed 91744e6 on 8.x-1.x authored by Berdir
    Issue #2898685 by VladimirMarko, Berdir: Make the title of the modal...
miro_dietiker’s picture

Status: Needs review » Fixed

Then committed :-)

Status: Fixed » Closed (fixed)

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