diff --git a/public/nav-task-actions.js b/public/nav-task-actions.js index 1929efb..c4aab88 100644 --- a/public/nav-task-actions.js +++ b/public/nav-task-actions.js @@ -47,7 +47,7 @@ if (currentUser && !isDeleted && !isClosed) { } } // Действия для активных (не удалённых, не закрытых) задач - if (!isDeleted && !isClosed) { + if (!isDeleted && !isClosed && currentUser.login === 'minicrm') { if (typeof openTaskChat === 'function') { actions.push({ label: '💬 Чат', handler: () => openTaskChat(taskId) }); log('nav-task-actions openTaskChat yes'); @@ -84,13 +84,19 @@ if (currentUser && !isDeleted && !isClosed) { if (currentUser && (currentUser.role === 'admin' || (currentUser.role === 'tasks' && canEdit))) { if (typeof assignAdd_openModal === 'function') { - actions.push({ label: '🧑‍💼➕ Добавить исполнителя', handler: () => assignAdd_openModal(taskId) }); + actions.push({ label: '🧑‍💼➕ Добавить исполнителя', + handler: () => assignAdd_openModal(taskId), + admin: true + }); log('nav-task-actions assignAdd_openModal yes'); } else { log('nav-task-actions assignAdd_openModal not'); } if (typeof assignRemove_openModal === 'function') { - actions.push({ label: '🧑‍💼❌ Удалить исполнителя', handler: () => assignRemove_openModal(taskId) }); + actions.push({ label: '🧑‍💼❌ Удалить исполнителя', + handler: () => assignRemove_openModal(taskId), + admin: true + }); log('nav-task-actions assignRemove_openModal yes'); } else { log('nav-task-actions assignRemove_openModal not'); @@ -193,7 +199,8 @@ log('nav-task-actions openChangeDeadlineModal yes'); // primary const primaryActions = actions.filter(a => a.primary); - const otherActions = actions.filter(a => !a.primary); + const adminActions = actions.filter(a => a.admin && !a.primary); + const userActions = actions.filter(a => !a.primary && !a.admin); // Создаём затемнение const overlay = document.createElement('div'); overlay.id = 'task-action-modal'; @@ -252,7 +259,7 @@ log('nav-task-actions openChangeDeadlineModal yes'); header.appendChild(closeBtn); modal.appendChild(header); -// === НОВЫЙ БЛОК: primary actions === +// === БЛОК: primary actions === if (primaryActions.length > 0) { const primaryContainer = document.createElement('div'); primaryContainer.style.marginBottom = '20px'; @@ -283,8 +290,39 @@ if (primaryActions.length > 0) { }); modal.appendChild(primaryContainer); } - // Сетка кнопок (flex-wrap с 3 колонками) -if (otherActions.length > 0) { +// === Блок admin === +if (adminActions.length > 0) { + const adminContainer = document.createElement('div'); + adminContainer.style.marginBottom = '20px'; + adminActions.forEach(a => { + const btn = document.createElement('button'); + btn.textContent = a.label; + btn.style.cssText = ` + width: 100%; + padding: 14px; + background-color: #e74c3c; // красный цвет для админских + color: white; + border: none; + border-radius: 8px; + font-size: 16px; + font-weight: 500; + cursor: pointer; + transition: background-color 0.2s; + margin-bottom: 10px; + `; + btn.onmouseover = () => btn.style.backgroundColor = '#c0392b'; + btn.onmouseout = () => btn.style.backgroundColor = '#e74c3c'; + btn.onclick = (event) => { + event.stopPropagation(); + a.handler(); + removeModal(); + }; + adminContainer.appendChild(btn); + }); + modal.appendChild(adminContainer); +} +// === Блок остальных (user) === +if (userActions.length > 0) { const grid = document.createElement('div'); grid.style.cssText = ` display: flex; @@ -292,7 +330,7 @@ if (otherActions.length > 0) { gap: 10px; justify-content: center; `; - otherActions.forEach(a => { + userActions.forEach(a => { const btn = document.createElement('button'); btn.textContent = a.label; btn.style.cssText = ` @@ -308,8 +346,8 @@ if (otherActions.length > 0) { cursor: pointer; transition: background-color 0.2s; `; - btn.onmouseover = () => { btn.style.backgroundColor = '#2980b9'; }; - btn.onmouseout = () => { btn.style.backgroundColor = '#3498db'; }; + btn.onmouseover = () => btn.style.backgroundColor = '#2980b9'; + btn.onmouseout = () => btn.style.backgroundColor = '#3498db'; btn.onclick = (event) => { event.stopPropagation(); a.handler();