Issue 1313 tcEdit AssignRequirements Restored - sebiboga/testlink-upgraded GitHub Wiki
The modern Test Case Editor (gui/templates/testcases/tcEdit.html) regains the
legacy Assign Requirements affordance that was dropped during
modernization: nothing on the editor let a user link requirements to the test
case being edited.
{if $gui->opt_requirements==TRUE && $gui->grants->req_tcase_link_management=='yes' && isset($gui->tc.testcase_id)}
<br /><div><a href="javascript:openReqWindow({$gui->tc.testcase_id})">{$labels.assign_requirements}</a></div>
{/if}-
opt_requirements— project optionrequirementsEnabled(tcEdit.php:406-412); -
req_tcase_link_management— right 28 (tcEdit.php:654-662); - the link opens a popup
lib/requirements/reqTcAssign.php?id=<tcase_id>&edit=testcase(testcase mode) that lists Assigned + Free requirements per requirement spec and assigns/unassigns via POST (assign_to_tcase,delReqVersionTCVersionLinkByID); the whole popup feature is gated on right 28 (reqTcAssign.php:402-407).
-
BFF
api/testcasesedit/index.phpbuildEditPayload():- reads
req_tcase_link_managementright via$user->hasRight($db, 'req_tcase_link_management', $tprojId); - reads
requirementsEnabledfrom the projectoptionsblob (intval($projRow['opt']->requirementsEnabled ?? 0)), same source as legacy; - emits
grants.req_tcase_link_managementand top-levelrequirements_enabled.
- reads
-
HTML
gui/templates/testcases/tcEdit.html:- toolbar button
#btnAssignReqs(fa-bookmark) shown only whenctx.info.requirements_enabled && ctx.info.grants.req_tcase_link_management(exact legacy gate minus the always-true-in-editorisset(testcase_id)check); -
#assignReqsModal— same Free/Assigned dual-select layout as the already-modernizedtcView.html:129-162/testSpec.html; -
arqApiGet/arqApiPost/arqOptLabel/openAssignReqs/arqLoadReqs/arqDoAssign/ arqDoUnassign— same client logic astcView.html:547-646, hitting the shared/api/requirementsrouter:GET /assign-reqspecs,GET /assign-reqs?req_spec_id=&tcase_id=,POST /assign-reqs {tcase_id, req_ids[]},POST /unassign-reqs {link_ids[]}. Those endpoints already enforce right 28 (arNeedManageRight), so the client gate is a UX nicety and the security boundary is unchanged.
- toolbar button
-
i18n —
tcedit.assignRequirementsadded to all 10 locale bundles (values mirroring the existingtcview.assignRequirementstranslations); the modal reusesreqAssign.*+tspec.cancel+rpt.close(already present).
-
requirements_enabled=1+ right present → button visible; flipping the project option to 0 hides it (offsetParent === null). - Modal lists
[TCED-SPEC1] - TCED-SPEC1, Free containsTCED-REQ1 - Req A (v. 1). - Assign → toast "1 requirement(s) assigned.", row moves to Assigned,
req_coveragerow created (req_id 3, req_version_id 4, testcase_id 5, tcversion_id 6, link_status 1, author 1), INFO audit eventaudit_reqv_assigned_tcv. - Unassign → toast "1 link(s) removed.", row deleted, INFO audit event
audit_reqv_assignment_removed_tcv. - Save-flow regression green ("Test case saved.", summary persisted).
- Event Viewer: only log_level-16 audits, zero Error/Warning. Browser console clean.
Screenshot: docs/screenshots/issue-1313-tcedit-assign-requirements-modal.png.