Comments on farmOS records

Created on 4 April 2023, over 1 year ago
Updated 24 April 2024, 8 months ago

Problem/Motivation

Drupal comes with a core "Comment" module which allows users to add comment/discussion threads on entities. Typically this is used on Node entities, but I think it would be very useful to have comments on farmOS assets, logs, and other record types. This idea has been discussed in the past, and we decided to wait until Drupal 8+ to undertake it.

Proposed resolution

Provide a new farmOS Comment module that depends on the Drupal core Comment module and configures comments on assets and logs. It can also provide standard configuration for use on other entity types, if other modules want to enable that.

Remaining tasks

  • Initial farmOS Comment module (farm_comment)
  • Create Comment bundles for Asset and Log entities (asset_comment and log_comment)
  • Add support for Comment fields in field factory service
  • Add "Comments" base field (comment) to Assets and Logs
  • Configure comment permissions for managed roles

Questions:

  • No
  • Yes
  • Start simple
  • No reason not to
  • Should we document this in the farmOS data model?
  • See comments below.
  • No

User interface changes

Comment threads on Asset and Log records.

API changes

TBD

Data model changes

TBD

✨ Feature request
Status

Fixed

Version

3.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States m.stenta

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

Comments & Activities

  • Issue created by @m.stenta
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta
  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta

    I opened a draft PR with my progress on this so far. Not complete, but the basic functionality is working. Still need to address all the questions in the issue description.

    https://github.com/farmOS/farmOS/pull/668

  • πŸ‡ΊπŸ‡ΈUnited States m.stenta

    Should comment be enabled as a default farmOS module?

    We talked about this on the dev call today, and consensus was that "no" this should be optional.

    Should comment subject field be hidden?

    My branch hides it, but this is open to further discussion if anyone feels strongly otherwise.

    How should permissions work? Should Viewer role be able to see comments?

    The simplest way to start is to add the non-administrative comment permissions to all managed farmOS roles by default. We can refine this further in follow-up work.

    Should comments be accessible via API?

    I don't see any reason not to. This will work the same as all other entities by default, so restricting it would be more work anyway.

    Should we document this in the farmOS data model?

    I could see arguments both ways for this.

    The broader question is are they something we want to officially consider part of the "farmOS data model" - or more of just an application-specific add-on feature? Comments will not be enabled by default, and will only be added if a particular farm decides they would be useful. They are very much an "add-on" enhancement, intended mainly for internal discussions, but not canonical "management data".

    They are also somewhat Drupal-specific in their implementation.

    How will other modules enable comments on their entity types?

    Refer to the farm_comment_asset or farm_comment_log modules as an example. Some config needs to be provided, including the entity comment type, the comment_body field for that type, and entity form/view display config to hide the subject field. They also need to implement hook_entity_base_field_info() and use the farm_comment_base_field_definition($entity_type) helper function to generate a comment base field definition on their entity type(s).

    Should we provide configuration options for default behavior of assets and logs and their bundles? (eg: allow the user to decide which types allow comments by default)

    We discussed this and decided that the simplest approach is to create two separate modules for enabling comments on assets/logs (farm_comment_asset and farm_comment_log). There isn't an immediate need for more flexibility than that, but if there is in the future we can consider that in follow-up work.

  • πŸ‡ΊπŸ‡ΈUnited States m.stenta
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta
  • πŸ‡ΊπŸ‡ΈUnited States m.stenta

    Updated PR against farmOS 3.x branch: https://github.com/farmOS/farmOS/pull/798

  • πŸ‡ΊπŸ‡ΈUnited States m.stenta

    I think that all that's left to do for MVP is some simple styling to distinguish the "authored by" and "links" from the comment text itself, and maybe also wrapping/delineating separate comments visually so they are more easily distinguished from each other.

  • Status changed to Fixed 9 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024