Problem/Motivation

If you are adding a node that is setup with mercury editor through an inline entity form it would be good if there was a link that took you directly to the mercury editor edit page for that entity.
If the primary method for adding content to an entity setup with mercury editor is through mercury editor itself, than it is presumably not feasible to edit that content inline, instead provide a link directly to the mercury editor page for that piece of content.

This hook is triggered when there is a table of entities in your inline entity form, it won't be triggered or added where there is only a single entity per inline entity form.

A future enhancement for this work would be to provide a configurable option to add this button to the inline entity form table, rather than have it be added automatically.

Proposed resolution

Apply the patch attached to this issue.

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

devanbicher created an issue. See original summary.

devanbicher’s picture

StatusFileSize
new3.36 KB

Patch to add this requested functionality.

jrockowitz’s picture

I think we need to create a MercuryEditorTasksInlineEntityForm service for just the preprocess hook.

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

immaculatexavier’s picture

Status: Active » Needs review
devanbicher’s picture

Here are the steps to setup a site to expose this functionality

  1. Enable mercury editor and inline entity form
  2. Add a new content type
  3. Add a layout paragraphs field
  4. Enable that content type with mercury editor
  5. Create a paragraph
  6. In that paragraph, add a content reference field that references nodes
  7. Have its reference use the content type you created above, save
  8. Edit the new paragraphs' form mode
  9. For the content reference field in this paragraph change the form mode to 'Inline entity form - complex'
  10. Go back to your content type and add this paragraph to the layout paragraphs field
  11. Create a new piece of content (of the type you created in step 2)
  12. You just need to title it, you don't need to add any other content, save
  13. Create another piece of content of the same type
  14. Edit the layout of that new piece of content
  15. Add a paragraph of the type you created in step 5
  16. In the content reference field of this paragraph, select 'add an existing node'
  17. Search for the piece of content you created in step 11 (it should probably be the only one in the list) and select it
  18. After the entity select modal goes away there should now be another button after 'edit' that says 'Layout'
  19. That 'layout' button in the inline entity form is what this patch adds.

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

joelsteidl’s picture

StatusFileSize
new13.33 KB

@devanbicher thanks for the detailed setup tasks. That was super helpful for writing a test.

@immaculatexavier thanks for getting the service started. I made an interface and broke up the main function into some additional methods to keep things a bit simpler.

Thoughts/Questions

  1. The UI for the "Layout" button is slightly off at least in Claro. The other buttons are actual button elements vs the href we are adding. Not sure it is worth addressing, but open to thoughts.
  2. There is currently no config for this. If you have IEF enabled under the right circumstances, it happens. Are we good with that?
  3. Similar question...it used the Local Task name for the IEF button. Any reason to make that different?

Screenshot of the buttons

devanbicher’s picture

@joelsteidl

  1. The element being a link instead of a button was a mistake that I never went back and fix. If this is getting merged, it should get changed to a button element. Thank you for catching that.
  2. I am okay with that. But that is the intended use case for us. I guess it would probably be best practice to put a configuration option in the same space where you set the 'Layout' label that allows someone to turn on or off this functionality.
  3. I think using the same label is fine, but if you are adding a configuration option in number 2, you could add another label field for this button.
jrockowitz’s picture

I think using the same label is fine, but if you are adding a configuration option in number 2, you could add another label field for this button.

The label should be the same across all implementations. I don't think it needs to be configurable for IEF

joelsteidl’s picture

@jrockowitz - I appreciate all the feedback.

I think everything is addressed in Gitlab. Let me know if you see any other issues.

jrockowitz’s picture

Status: Needs review » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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