Use on other entity types

Created on 4 February 2021, almost 4 years ago
Updated 20 February 2024, 9 months ago

Problem/Motivation

This module could be useful on other entity forms.

Proposed resolution

The selectors in node-edit-protection.js could be dynamic in order to select other entity forms.
E.g. "edit-protected-form" instead of "node-form".

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇫🇷France prudloff Lille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy kopeboy Milan

    Would be nice to have a settings page to allow the site builder to enable it per entity type or form id

  • Status changed to Needs work 9 months ago
  • 🇩🇪Germany donquixote

    I don't think this is the way to do it.

    First, the patch contains some unrelated changes that have potentially harmful side effects.

    -      $(".node-form :input").each(function() {
    +      $("." + contentType + "-form :input", context).each(function() {
    

    The basic idea of filtering for context here is good, but this does not work if context is an element within the `.node-form`.
    E.g. if you have an ajaxified element inside the node form, then inputs within the ajax-loaded content will be filtered out.

    Put a multiple-value link field in the form. Click "Add another item". Edit the new value. Navigate away.
    The edit protection dialog won't show up.

  • 🇩🇪Germany donquixote

    Secondly, the code treats the Drupal.behaviors.* object as a namespace, which is not really how this is normally done.
    The common pattern for globally available functions seems to be Drupal.modulename.foo = function () {...}.

    It is not wrong, but it is generally good to follow familiar patterns.

  • 🇩🇪Germany donquixote

    For this specific issue, I think a good solution would be to use php to add a class to the form, and then in js just pick up that class.

Production build 0.71.5 2024