Skip to content

[FE] Manage & Apply Competencies: delete a Competency Criteria Group #709

Description

@thelmick-unicon

Frontend implementation in frontend-app-authoring. Parent design: #648. Foundation this builds on: #670 (page shell), #671 (creates and renders the groups this ticket deletes). Siblings on the same page: #672 (creates associations), 5.10d (deletes a single association — reuses this ticket's group-removal logic when the last association in a group is removed; no GitHub issue yet).

Blocked by: #675 (backend delete-group endpoint, cascades associations); #672 (the activeGroupId scheme this ticket recomputes after a deletion); #681 (GET groups + criteria endpoint, needed to render the groups this ticket deletes).

Use Case

As a course author who created a Competency Criteria Group in error, or whose rule structure has changed, I want to delete a Competency Criteria Group, whether it is an unbacked placeholder box or a real, persisted group with associations, so that the competency's rule structure reflects only the groups I actually intend to keep, without leaving stray boxes or reloading the page.

Description

This ticket adds a delete action to a Competency Criteria Group box, covering both an unbacked placeholder box (a client-side-only removal) and a real, persisted group (which also removes whatever associations it contains).

Current behavior

#671 renders a competency's Competency Criteria Group box(es), with no way to delete one yet.

Requested change

This ticket builds and renders the delete/trash affordance on each group box, following the design, and wires it to the following behavior. Clicking it:

Explicitly out of scope

Acceptance Criteria

Frontend ticket. Testable once #671's groups render, #672's active-group scheme exists, and #675 exists.

Scenario: Delete an unbacked placeholder box
  Given a Competency Criteria Group box exists but no subsection has been selected into it yet
  When I click that box's delete affordance
  Then the box is removed from the page immediately
  And no backend request is made

Scenario: Delete a persisted group
  Given a Competency Criteria Group has been persisted to the backend, with or without associated subsections
  When I click that group's delete affordance
  Then the group and any associations it contains are deleted
  And the group no longer appears on the page

Scenario: Deleting the active group when other groups remain
  Given the active group has one or more other real, persisted sibling groups
  When I delete the active group
  Then one of the remaining sibling groups becomes the new active group automatically
  And subsequent subsection selections target that remaining group

Scenario: Deleting the last remaining group falls back to the placeholder
  Given the group I delete is the only remaining group for the competency
  When I delete it
  Then no real groups remain for the competency
  And a placeholder box is shown as the new implicit active target

Scenario: Backend rejects the delete request
  Given a delete request to the backend fails
  When I click delete on a persisted group
  Then the group remains visible on the page
  And an error is shown, following this feature's existing generic-error-handling pattern (#672's Technical Details → Logic)

Scenario: A course author without write access cannot delete a group
  Given I lack studio write access to the course the competency's groups belong to
  Then the delete affordance is not rendered

Technical Details

Data Structures

Logic

Example Resolution Prompt

Implement the frontend consumer of #675 in frontend-app-authoring, extending #671/#672's src/taxonomy/competency-management/criteria-groups/ directory (check whether #671/#672 already created data/api.ts/data/apiHooks.ts before adding new files). Add deleteCompetencyCriteriaGroup and useDeleteCompetencyCriteriaGroup per Technical Details → Data Structures. Build and render CriteriaGroupBox.tsx's delete/trash affordance (a Paragon icon button following the design; not rendered at all for a user without studio write access), and wire it to branch on placeholder vs. real group per Technical Details → Logic, setting userSelectedGroupId to a remaining sibling if one exists, or clearing it to fall through to the placeholder if none do. Reuse the existing "zero real groups → placeholder" conditional from #671/#672 rather than adding new placeholder-rendering logic — 5.10d depends on this same path. No confirmation dialog (Use Case 10's job). Follow #672's generic error-handling pattern on failure.

Context

Files to create and modify

Modified files (conditional: check whether #671/#672 already created these before adding new content)

File Nature of modification
src/taxonomy/competency-management/criteria-groups/CriteriaGroupBox.tsx (from #671) Add and render the delete/trash affordance (Paragon icon button, per the design; hidden without studio write access), with a click handler branching on placeholder vs. real group.
src/taxonomy/competency-management/criteria-groups/CriteriaGroupTree.tsx (from #671) Pass a delete callback down; recompute activeGroupId against the post-deletion group list.
src/taxonomy/competency-management/data/api.ts Add deleteCompetencyCriteriaGroup.
src/taxonomy/competency-management/data/apiHooks.ts Add useDeleteCompetencyCriteriaGroup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Ready for Community Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions