Editing/Removing a specific flagging is not possible when you have multiple flaggings on the same entity

Created on 12 November 2023, about 1 year ago

Problem/Motivation

Flaggins are fieldable entities and we are able to set different field values for different flaggings. But when it comes to edit or remove the flaggings sometimes it's impossible to edit or remove the desired flagging. How?

When a user has more than one flaggings for an entity of the same flag type, editing/removing a specific flag is not possible. It's always going to the first flag when you set the link type to "Field Entry Form" and hit the "Unflag" link on the flagged entity.

What's the use case for multiple flaggings on the same entity?

So far so good, but when it comes to editing or removing these flagging, you are helpless.

I was able to easily achieve the desired functionality by adding a taxonomy reference field and a text field to a flag type. However, when it came to deleting or editing these items added to the lists, I realized that the interface provided by the flag module does not work, and clicking on the link only edits or removes the flagging that was created first. After a little research into the code, I realized that it is not too difficult to create a route to at least provide this.

Steps to reproduce

  • Create a new flag for nodes and set the "Link type" to "Field Entry Form" on the edit form
  • Attach some fields to your flag
  • Create multiple flaggings on a node by going to /flag/details/flag/{flag_machine_name}/{node_id} more than once and input different values for your fields created on the previous step (You should do this by copying and pasting link on the address bar since the UI does not allow to do this more than once)
  • Then go to the node page. You'll see only one unflag link. No matter how many flaggings you have created on the previous step, clicking on it will only load the first flag.
  • Or create a view that will display all the flaggings of a user (you may just duplicate and modify the one that comes with the submodule Flag Bookmark). You'll see all the flaggings that you've created, all the fields that you have input differently but one thing is the same: the unflag link. All the unflag links will head to the first flagging that you have created to edit or remove it.

Proposed resolution

Implement a route and a method to load the desired flagging by its ID to edit or remove. At least it will allow to edit/remove specific flagging with customly created links. I will be creating a MR with the changes needed.

Remaining tasks

If dealing with multiple flaggings will be a part of this module's features, some UI enhancements may be needed.

User interface changes

There is no UI change currently but this may evolve to a point that would need it.

API changes

None

Data model changes

None

📌 Task
Status

Active

Version

4.0

Component

Flag core

Created by

🇹🇷Turkey makbay

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024