Problem/Motivation

Attach ajaxified link to the gridstack container children.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Panchuk created an issue. See original summary.

panchuk’s picture

Issue tags: +LutskGCW23, +Novice
panchuk’s picture

Assigned: Unassigned » boddy

royalpinto007 made their first commit to this issue’s fork.

royalpinto007’s picture

Status: Active » Needs review

This change was made to enhance the user experience and improve page performance. By utilizing AJAX, we are able to retrieve and update data asynchronously, allowing the user to interact with the page while data is being loaded. The Gridstack container children serve as a perfect candidate for this functionality, as they require frequent updates to their contents.

panchuk’s picture

@royalpinto007 Thanks for your contribution to Paragraphs Gridstack.

I didn't add a good description for this task, so probably you didn't understand the idea of the task.
Also, this issue is already assigned to another contributor and this is a bad tone to work on assigned tasks.

The first problem with your MR is using a 'field_children' field name to get a child paragraphs, but this is a paragraph behavior plugin and it could be applied to any type of paragraph.

  // Attach ajaxified link to gridstack container children.
  $children = $paragraph->get('field_children');

The second problem is using 'entity.node.canonical' for generating a Link to the paragraph. Also, the setOptions() method is not applicable to the Link object. It works only for a URL object.

  // Create a link for the child entity.
  $link = Link::createFromRoute($child_entity->label(), 'entity.node.canonical', ['node' => $child_entity->id()]);

  // Ajaxify the link.
  $link->setOptions([
    'attributes' => [
      'class' => ['use-ajax'],
      'data-dialog-type' => 'modal',
    ],
  ]);

And the last piece of code that doesn't work:

  // Attach the link to the child entity.
  $child_entity->link = $link;
panchuk’s picture

@royalpinto007 How did you write this code? Did you use some kind of AI e.g. ChatGPT?

panchuk’s picture

Issue tags: -Novice
panchuk’s picture

Status: Needs review » Active
royalpinto007’s picture

Oops, I didn't notice that it was already assigned to someone else. I apologize for the same.
Also, I made changes in the code taking some reference from the Stack Overflow website.

andrii momotov’s picture

Assigned: boddy » andrii momotov

andrii momotov’s picture

Assigned: andrii momotov » Unassigned
Status: Active » Needs review