Create a new architecture for checklists as config entities, with tasks fulfilled by conditions

Created on 13 September 2024, 2 months ago
Updated 14 September 2024, 2 months ago

Problem/Motivation

Drupal CMS is going to need the ability to manage checklists, for administrative dashboards. The best option in contrib, as far as we know, is Checklist API.

However, Checklist API has an old architecture that is based on checklists defined by hooks, which is a no-go for Drupal CMS, which has a mandate to avoid creating custom glue code modules, instead favoring recipes, which are ways to share config.

I think Checklist API should evolve into a new form based on more modern config-based paradigms.

Proposed resolution

Create a new 3.0.x branch of Checklist API, and let's create a whole new API with the following principles:

  • A Checklist config entity type, with a corresponding ChecklistInterface extends ConfigEntityInterface.
  • A checklist exposes a set of tasks, represented by a new Task value object. Tasks can have a name, a description, and an optional set of conditions (represented by condition plugins, which are an extant thing in core) to programmatically determine if the task is completed or not.
  • A Progress service which, given a checklist, can tell you whether it is complete, what remains to be done, etc. Checklist API would expose this to users as a progress bar rendered in a block associated with a particular checklist, which would allow some clean integration with the Dashboard module.
  • Config actions allowing to add a task to a checklist from a recipe. Ideally with the Task value object, and its position on the list.

The current hook-based checklist definitions and API would be completely removed. There would also not (yet) be a way to create checklists in the UI; that would come later.

🌱 Plan
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

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

Comments & Activities

  • Issue created by @phenaproxima
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • πŸ‡ΊπŸ‡ΈUnited States traviscarden

    Thanks, @phenaproxima! Just to document the fact: you and I had a conversation offline in which I invited you to make this proposal.

    I like this a lot at the conceptual level. I'm not equipped to weigh in on every detail of the proposed implementation yet. Can you comment on how your proposal might fit into 🌱 [META] Roadmap Active ?

    Note: I've created a 3.0.x branch for this.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Certainly.

    Add the ability to create/edit checklists via a GUI

    This would become a LOT easier to do with a config-based architecture, since there's already a ton of infrastructure in core for creating and editing config entities in the UI.

    and export them as features/CMI

    If checklists are config entities, you get this for free.

    Add the ability to attach (GUI-created) checklists to entities as fields, with display formatters

    I think this would be feasible because you could create an entity reference to a checklist (or checklists) with some new formatter that shows it as a progress bar. There is precedent for that.

    Add Views support

    This goal would be within reach, since Views deals first and foremost with entities. It'd probably take some work (writing the proper Views plugins/handlers), but the use of entities solves a number of foundational problems with Views integration.

    Add Rules support, or maybe just some event hooks.

    Rules is kinda defunct, no? ECA is probably the most likely successor. Having said that, I know very little about ECA's API but I'm pretty sure we could provide some kind of integration, as long as there's some kind of API for "mark a task as complete".

  • πŸ‡ΊπŸ‡ΈUnited States traviscarden
  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    I'm extremely interested in this. We have a custom "checklist field" I've been using for a while, which is currently a front end built in Vue.js that allows nestable checklist items, each item with the ability to have a note completed by the person using it, a link that may point to a reference page for more info about the task, the checklist state, as well as the "result" - (completed, not completed, not applicable), and the user who checked the box and the time it was checked.

    Right now we load the entire thing in a custom field type, which has a single database column -- this serializes the entire checklist as Yaml, which the field formatter loads into the Vue widget, and then uses JSONAPI to update (right now with a save button that re-serializes the entire list and posts it back to the entity). The field widget is just a text area so we can copy/paste entire lists from one instance to another.

    We use this for a QA checklist when reviewing new sites, as well as a launch checklist. I also have it on a personal site where I use it for a camping checklist.

    The "edit checklist" functionality right now is just edit raw Yaml -- our current UI is ok for actually running down a checklist, taking notes as you go, and outputting a report...

    Just providing some ideas of extra requirements to consider for the data model...

  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    We will need config actions in this MVP for recipes to add new tasks.

  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    I should have reloaded before editing.

  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    @phenaproxima (#4) ECA is very easy to add support for, just need to implement plugins as desired.

    For events, the easiest thing to do is just use the normal event system, and then an ECA event plugin can subscribe to that.

    If everything is in config entities, there may not be anything special needed to work with ECA -- ECA has plugins for entity events, fields, etc.

    For this proposal, are you thinking the entire checklist and its state is stored as a config entity? And it contains a list of "task" datatype? Or is there a separate place -- e.g. field data on a field attached to some content entity for the checklist state?

    I like that second architecture -- I would like to have a "template" checklist that can be reused a bunch of times. However, I do want to be able to customize the checklist each time it is used. I'm thinking the ideal model for what I'm going for might look something like this:

    1. Config entity for the base checklist, containing a set of default tasks
    2. Field attached to an entity, which has a "checklist override", and "checklist state"

    ... the checklist override could suppress specific tasks on the checklist, and add additional as appropriate.

    The checklist state would track each task's status -- checked or not, user who checked it, time it was checked, notes, link.

    A task (without its state) should also have - label, help text, optional link to instructions.

    Is that inline with what's being planned here?

    Cheers,
    John

Production build 0.71.5 2024