действия

This commit is contained in:
2026-03-05 22:58:14 +05:00
parent 4e74132143
commit c958a7f913
4 changed files with 66 additions and 29 deletions

View File

@@ -29,7 +29,7 @@ if (currentUser && !isDeleted && !isClosed) {
actions.push({
label: '▶️ Приступить',
handler: () => window.updateStatus(taskId, currentUser.id, 'in_progress'),
primary: true
primary: true
});
}
// Кнопка "Выполнено" (если статус 'in_progress', 'overdue' или 'rework')
@@ -41,11 +41,21 @@ if (currentUser && !isDeleted && !isClosed) {
actions.push({
label: '✅ Выполнено',
handler: handler,
primary: true
primary: true
});
}
}
}
// Копия доступна всем, у кого есть кнопка
if (typeof openCopyModal === 'function') {
actions.push({ label: '📋 Создать копию',
handler: () => openCopyModal(taskId),
primary: true
});
log('nav-task-actions assignRemove_openModal yes');
} else {
log('nav-task-actions assignRemove_openModal not');
}
// Действия для активных (не удалённых, не закрытых) задач
if (!isDeleted && !isClosed && currentUser.login === 'minicrm') {
if (typeof openTaskChat === 'function') {
@@ -81,7 +91,7 @@ if (currentUser && !isDeleted && !isClosed) {
// ${currentUser && currentUser.role === 'tasks' && canEdit || currentUser.role === 'admin'
// Администраторы и роль tasks
if (currentUser && (currentUser.role === 'admin' || (currentUser.role === 'tasks' && canEdit))) {
if (currentUser && (currentUser.role === 'admin' || (currentUser.role === 'tasks' && canEdit))) {
if (typeof assignAdd_openModal === 'function') {
actions.push({ label: '🧑‍💼➕ Добавить исполнителя',
@@ -102,35 +112,27 @@ if (currentUser && !isDeleted && !isClosed) {
log('nav-task-actions assignRemove_openModal not');
}
//}
// Копия доступна всем, у кого есть кнопка
if (typeof openCopyModal === 'function') {
actions.push({ label: '📋 Создать копию', handler: () => openCopyModal(taskId) });
log('nav-task-actions assignRemove_openModal yes');
} else {
log('nav-task-actions assignRemove_openModal not');
}
// Доработка для документа (исполнитель)
//if (task.task_type === 'document' && userRole === 'Исполнитель') {
if (currentUser && (currentUser.role === 'admin' && currentUser.login === 'minicrm')) {
if (typeof openReworkModal === 'function') {
actions.push({ label: '🔄 Переделать документ', handler: () => openReworkModal(taskId) });
log('nav-task-actions assignRemove_openModal yes');
} else {
log('nav-task-actions assignRemove_openModal not');
}
//}
// Доработка и изменение срока для необычных задач (исполнитель)
//if (!isDeleted && !isClosed && task.task_type !== 'regular' &&task.assignments && task.assignments.some(a => parseInt(a.user_id) === window.currentUser?.id)) {
if (typeof openReworkModal === 'function') { actions.push({ label: '🔄 Доработка', handler: () => openReworkModal(taskId) });
}
}
// Доработка и изменение срока для необычных задач (исполнитель)
if (!isDeleted && !isClosed && task.task_type !== 'regular' && task.assignments && task.assignments.some(a => parseInt(a.user_id) === currentUser?.id)) {
if (typeof openReworkModal === 'function') { actions.push({ label: '🔄 Доработка', handler: () => openReworkModal(taskId),primary_task: true});
log('nav-task-actions openReworkModal yes');
} else {log('nav-task-actions openReworkModal not');}
if (typeof openChangeDeadlineModal === 'function') { actions.push({ label: '📅 Изменить срок', handler: () => openChangeDeadlineModal(taskId) });
if (typeof openChangeDeadlineModal === 'function') { actions.push({ label: '📅 Изменить срок', handler: () => openChangeDeadlineModal(taskId),primary_task: true });
log('nav-task-actions openChangeDeadlineModal yes');
} else {log('nav-task-actions openChangeDeadlineModal not');}
//}
}
if (currentUser && currentUser.login === 'minicrm') {
// Закрытие (только minicrm)
//if (window.currentUser && window.currentUser.login === 'minicrm') {
if (typeof closeTask === 'function') actions.push({ label: '🔒 Закрыть задачу', handler: () => closeTask(taskId) });
@@ -200,7 +202,8 @@ log('nav-task-actions openChangeDeadlineModal yes');
// primary
const primaryActions = actions.filter(a => a.primary);
const adminActions = actions.filter(a => a.admin && !a.primary);
const userActions = actions.filter(a => !a.primary && !a.admin);
const taskActions = actions.filter(a => a.primary_task && !a.primary && !a.primary);
const userActions = actions.filter(a => !a.primary && !a.admin && !a.primary_task);
// Создаём затемнение
const overlay = document.createElement('div');
overlay.id = 'task-action-modal';
@@ -290,6 +293,37 @@ if (primaryActions.length > 0) {
});
modal.appendChild(primaryContainer);
}
// === Блок taskActions ===
if (taskActions.length > 0) {
const taskContainer = document.createElement('div');
taskContainer.style.marginBottom = '20px';
taskActions.forEach(a => {
const btn = document.createElement('button');
btn.textContent = a.label;
btn.style.cssText = `
width: 100%;
padding: 14px;
background-color: #dfc63cff; // цвет
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 = '#dfc63cff';
btn.onmouseout = () => btn.style.backgroundColor = '#dfc63cff';
btn.onclick = (event) => {
event.stopPropagation();
a.handler();
removeModal();
};
taskContainer.appendChild(btn);
});
modal.appendChild(taskContainer);
}
// === Блок admin ===
if (adminActions.length > 0) {
const adminContainer = document.createElement('div');
@@ -321,6 +355,7 @@ if (adminActions.length > 0) {
});
modal.appendChild(adminContainer);
}
// === Блок остальных (user) ===
if (userActions.length > 0) {
const grid = document.createElement('div');