From ce0c1349ca14320c4593359c59319f82f4cfc59f Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 28 Jun 2026 19:35:30 +0545 Subject: [PATCH] feat(templates/projects): add permissions modal and restricted mode logic Implement permission configuration UI and enforce restricted movement rules --- templates/projects/board.html | 113 +++++++++++++++++++++++++++++++-- templates/projects/detail.html | 99 +++++++++++++++++++++++++++++ 2 files changed, 206 insertions(+), 6 deletions(-) diff --git a/templates/projects/board.html b/templates/projects/board.html index 283bd52..f4ed627 100644 --- a/templates/projects/board.html +++ b/templates/projects/board.html @@ -33,7 +33,10 @@ newTicketOpen: false, exportOpen: false, filterOpen: false, + filterOpen: false, manageStatusesOpen: false, + permissionsOpen: false, + allowedMoveToStatusIds: {{ allowed_move_to_status_ids }}, createStatusName: '', createStatusColor: '#6B7280', @@ -199,8 +202,8 @@ touch.clientY >= rect.top && touch.clientY <= rect.bottom) targetColumn = col; col.classList.remove('bg-blue-50', 'dark:bg-blue-900/20'); }); - {% if not can_move_to_completed %} - if (targetColumn && targetColumn.getAttribute('data-status-completed') === 'true') targetColumn = null; + {% if can_move %} + if (targetColumn && targetColumn.getAttribute('data-status-id') && !this.allowedMoveToStatusIds.includes(parseInt(targetColumn.getAttribute('data-status-id')))) targetColumn = null; {% endif %} if (targetColumn && targetColumn !== originalColumn) this.moveTicketToStatus(this.draggingTicket, targetColumn.getAttribute('data-status-id')); @@ -224,8 +227,8 @@ col.addEventListener('drop', (e) => { e.preventDefault(); col.classList.remove('bg-blue-50', 'dark:bg-blue-900/20'); - {% if not can_move_to_completed %} - if (col.getAttribute('data-status-completed') === 'true') return; + {% if can_move %} + if (col.getAttribute('data-status-id') && !this.allowedMoveToStatusIds.includes(parseInt(col.getAttribute('data-status-id')))) return; {% endif %} if (this.draggingTicket) { this.moveTicketToStatus(this.draggingTicket, col.getAttribute('data-status-id')); @@ -316,6 +319,9 @@ class="space-y-6" Filter {% if selected_user_ids %}{{ selected_user_ids|length }}{% endif %} {% if is_admin %} + @@ -368,10 +374,10 @@ class="space-y-6" View Only ModeYou can view tickets but cannot move them -{% elif not can_move_to_completed %} +{% elif can_move and allowed_move_to_status_ids|length < columns|length %}
- Restricted ModeYou can move tickets to active statuses only + Restricted ModeYou can only move tickets to certain statuses
{% endif %} @@ -758,6 +764,101 @@ class="space-y-6" + +
+
+
+
+

Board Permissions

+ +
+ + +
+

Add / Update Permission

+
+ {% csrf_token %} +
+
+ + +
+
+ +
+ {% for col in columns %} + + {% endfor %} +
+
+
+ +
+
+
+
+ + +
+
+ + + + + + + + + + {% for perm in permissions %} + + + + + + {% empty %} + + {% endfor %} + +
RoleCan move toActions
{{ perm.get_role_display }} +
+ {% for status in perm.move_to_statuses.all %} + + + {{ status.name }} + + {% empty %} + None + {% endfor %} +
+
+
+ {% csrf_token %} + +
+
No permissions configured. All non-admin roles are restricted by default.
+
+
+

Superadmin and manager roles always have full access. Select the statuses a developer role can move tickets to.

+
+
+ {% endif %} {% endblock %} diff --git a/templates/projects/detail.html b/templates/projects/detail.html index b9069d6..92fee65 100644 --- a/templates/projects/detail.html +++ b/templates/projects/detail.html @@ -175,6 +175,9 @@

Ticket Statuses

{% if is_admin %} + @@ -698,6 +701,101 @@
+ +
+
+
+
+

Board Permissions

+ +
+ + +
+

Add / Update Permission

+
+ {% csrf_token %} +
+
+ + +
+
+ +
+ {% for s in project.ticket_statuses.all %} + + {% endfor %} +
+
+
+ +
+
+
+
+ + +
+
+ + + + + + + + + + {% for perm in permissions %} + + + + + + {% empty %} + + {% endfor %} + +
RoleCan move toActions
{{ perm.get_role_display }} +
+ {% for status in perm.move_to_statuses.all %} + + + {{ status.name }} + + {% empty %} + None + {% endfor %} +
+
+
+ {% csrf_token %} + +
+
No permissions configured. All non-admin roles are restricted by default.
+
+
+

Superadmin and manager roles always have full access. Select the statuses a developer role can move tickets to.

+
+
+ {% endblock %} {% block extra_scripts %} @@ -712,6 +810,7 @@ viewNoteOpen: false, viewNoteData: { id: '', title: '', content: '' }, manageStatusesOpen: false, + permissionsOpen: false, createStatusName: '', createStatusColor: '#6B7280', createStatusOrder: '0',