Tag - Add a Tag.merge API action and SearchKit "Merge Tags" bulk task - #36512
Open
mattwire wants to merge 1 commit into
Open
Tag - Add a Tag.merge API action and SearchKit "Merge Tags" bulk task#36512mattwire wants to merge 1 commit into
mattwire wants to merge 1 commit into
Conversation
Merging duplicate/overlapping tags was only possible through the dedicated CRM_Tag_Form_Merge popup, with no way to do it as part of a SearchKit-driven workflow (e.g. selecting several rows in a tag listing and merging them in one step). Add Civi\Api4\Action\Tag\Merge, wrapping the existing CRM_Core_BAO_EntityTag::mergeTags() logic (which already handles child reparenting, used_for union, and de-duping entity-tag rows) behind a proper API4 action that accepts a target tag plus a list of tags to merge into it, with an optional new label for the result. Reserved tags require the "administer reserved tags" permission to merge, mirroring the existing form's behavior. Register a "Merge Tags" bulk task in SearchKit's GetSearchTasks for any Tag-backed SearchDisplay with update+delete actions and 2+ rows selected, with a new Angular controller/template for picking the merge target and an optional new label.
|
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
PR commands & links...
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Adds a
Tag.mergeAPI4 action and wires it up as a SearchKit bulk task, so merging duplicate/overlapping tags can be done by selecting rows in a Tag listing instead of only through the dedicatedCRM_Tag_Form_Mergepopup.Before
Tag merging was only reachable via
civicrm/tag/merge, a standalone form outside of any SearchKit-driven listing. There was no API action wrapping the merge logic, so it couldn't be exposed as a bulk task on a TagSearchDisplay.After
A new
Tag.mergeaction takes atargetId, a list oftagIdsto merge into it, and an optional newlabel. Any TagSearchDisplaywithupdateanddeleteactions gets a "Merge Tags" bulk task once 2+ rows are selected, opening a dialog to pick the merge target and label.Technical Details
Civi\Api4\Action\Tag\Mergewraps the existingCRM_Core_BAO_EntityTag::mergeTags()logic (already handles child reparenting,used_forunion, and de-dupingEntityTagrows) — it isn't reimplemented, just exposed through a proper API4 action.administer reserved tagsto merge, mirroring the existing form's permission check.GetSearchTasks.phpregisters themergetask forTagdisplays;crmSearchTaskTagMerge.ctrl.js/.htmlis a new, purpose-built controller (not the genericapiBatchmechanism — merge needs to pick one selected row as the target, whichapiBatch's one-call-per-row model can't express) for choosing the target tag and label.TagTest.phpcovers a normal merge and the reserved-tag permission check.Comments
Manually verified in the browser: selecting 3 tags in a Tag listing, merging into one with a new label, correctly reparents children and unions
used_for.