Support from Acquia helps fund testing for Drupal Acquia logo

Comments

oknate created an issue. See original summary.

oknate’s picture

Issue summary: View changes
DamienMcKenna’s picture

Assigned: oknate » Unassigned
DamienMcKenna’s picture

Title: Add support for inline entity form » Add support for inline entity form (D8)
DamienMcKenna’s picture

Working through the implementation details, or at least one possible approach:

  • Use hook_inline_entity_form_entity_form_alter() to trigger a lock on the item.
  • Use hook_field_widget_form_alter() to remove the "Edit" button if the item is locked and user doesn't have the "Break content lock" permission.
  • Use hook_field_widget_form_alter() to replace the "Edit" button and add an "Unlock" button, which would also then insert the "Edit" button, if the item is locked and the user doesn't have the "Break content lock" permission.
  • Use hook_inline_entity_form_entity_form_alter() and hook_field_widget_form_alter() to add submission callbacks to unlock the items.
DamienMcKenna’s picture

WIP, lock entities when they're first loaded by IEF; this will require more work, but it should at least do the initial lock.

DamienMcKenna’s picture

Status: Active » Needs review
DamienMcKenna’s picture

Alternative patch that can be used with other patches.

Note: this was based on a codebase which had the following patches applied: #2919019-3: content_lock_entity_operation doesn't work if the entity list is cached, #2949198-9: Lock form should indicate if entity no longer locked., #2949202-2]

DamienMcKenna’s picture

Still to do:

  • Break the lock when the person clicks the "cancel" button.
  • Break the lock when the person saves the node.
  • Break the lock when the person clicks the node's "unlock" button.
  • Test coverage.
DamienMcKenna’s picture

And now we have recursive unlocking of nested entities.

DamienMcKenna’s picture

It might be worth considering the nested entity unlocking a separate thing, I'd be happy to spin it off into another issue if desired.

Status: Needs review » Needs work

The last submitted patch, 10: content_lock-n2973048-10.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
6.05 KB
613 bytes

Doh. A small typoo because I no longer live in a git-powered world and have to copy/paste changes to a real git checkout :-\

DamienMcKenna’s picture

Note: this doesn't cover items locked which are referenced via Entity Embed, I'll be posting that somewhere else as it doesn't really belong here.

DamienMcKenna’s picture

The break-lock button doesn't work well:

  • It loads a whole new page, which would potentially loose all of the content changes on the form.
  • After clicking the confirmation button it loads a new page with the following image:
    Borken

I think the unlock button needs to be changed entirely to work within IEF's architecture so that it works inline, i.e. via AJAX.

DamienMcKenna’s picture

Status: Needs review » Needs work

Problems so far:

  • The "Complex" IEF widget doesn't indicate whether items are locked.
    • This is a bit complex to do as I'm not sure how to edit the list of operations on that form without digging really deep into hook_entity_form(), or extending the IEF widgets and updating the site configuration to use the new widgets, which is a bit more than I think this module should have to deal with.
  • The "Complex" IEF widget should add a button to break locked items and remove the "edit" button when appropriate.
    • See above.
  • The break-lock link loads a new page, which looses content changes.
    • This needs to be replaced with something native to IEF.
  • There's no way to "cancel" the expanded entity form, the entire nested form is disabled including the existing "cancel" button.
    • This is complicated as Content Lock just sets $entity_form['#disabled']=TRUE; which locks the entire form.
    • Not sure on options to lock the form but still have "cancel" and "break lock" buttons show; an alternative would be to disallow editing a locked item entirely, see above.
  • Clicking "Cancel" after editing an item doesn't break the lock.
    • This needs a custom callback to be added.
  • The "this item is locked" message isn't removed after the edit form is closed (either "update" or "cancel").
    • Not sure how to do this, I'm not sure if the message is re-displayed while the form is closed, or if there's something else to it.
    • It might be useful to move the messages into inline blocks at the top of the $entity_form structure, so that when that structure is closed the message disappears.
DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
1.77 KB
6.34 KB

This makes two changes:

  • The $quiet argument to ContentLock::locking() now also skips the "break lock" message.
  • The IEF integration doesn't display messages anymore.

This is a temporary workaround, I'm hoping I'll get to work on the proper fixes some more soon.

DamienMcKenna’s picture

Status: Needs review » Needs work

Needs work, per #16.