добавление фаилов исполнителем
This commit is contained in:
57
public/ui.js
57
public/ui.js
@@ -82,7 +82,7 @@ function renderTasks() {
|
||||
<div class="task-content ${isExpanded ? 'expanded' : ''}">
|
||||
<div class="task-actions">
|
||||
${!isDeleted && !isClosed ? `
|
||||
${canEdit ? `<button class="add-file-btn" onclick="openAddFileModal(${task.id})" title="Добавить файл">📎</button>` : ''}
|
||||
<button class="add-file-btn" onclick="openAddFileModal(${task.id})" title="Добавить файл">📎</button>
|
||||
${currentUser && currentUser.login === 'kalugin.o' ? `<button class="edit-btn" onclick="openEditModal(${task.id})" title="Редактировать">✏️</button>` : ''}
|
||||
${currentUser && currentUser.login === 'kalugin.o' ? `<button class="manage-assignees-btn" onclick="openManageAssigneesModal(${task.id})" title="Управление исполнителями">👥</button>` : ''}
|
||||
<button class="copy-btn" onclick="openCopyModal(${task.id})" title="Создать копию">📋</button>
|
||||
@@ -113,13 +113,49 @@ ${currentUser && currentUser.login === 'kalugin.o' ? `<button class="manage-assi
|
||||
` : ''}
|
||||
|
||||
|
||||
<div class="file-list" id="files-${task.id}">
|
||||
<strong>Файлы:</strong>
|
||||
${task.files && task.files.length > 0 ?
|
||||
`<div class="file-icons-container">${task.files.map(file => renderFileIcon(file)).join('')}</div>` :
|
||||
'<span class="no-files">нет файлов</span>'
|
||||
}
|
||||
</div>
|
||||
<div class="file-list" id="files-${task.id}">
|
||||
<strong>Файлы:</strong>
|
||||
${task.files && task.files.length > 0 ?
|
||||
`<div class="file-icons-container">
|
||||
${task.files.map(file => {
|
||||
// Определяем, может ли пользователь видеть этот файл
|
||||
let canSeeFile = false;
|
||||
|
||||
// 1. Администратор видит все файлы
|
||||
if (currentUser.role === 'admin') {
|
||||
canSeeFile = true;
|
||||
}
|
||||
// 2. Создатель задачи видит все файлы
|
||||
else if (parseInt(task.created_by) === currentUser.id) {
|
||||
canSeeFile = true;
|
||||
}
|
||||
// 3. Исполнитель видит:
|
||||
// - Файлы, загруженные создателем
|
||||
// - Свои файлы
|
||||
else {
|
||||
// Получаем ID создателя задачи
|
||||
const creatorId = parseInt(task.created_by);
|
||||
|
||||
// Файл загружен создателем
|
||||
if (parseInt(file.user_id) === creatorId) {
|
||||
canSeeFile = true;
|
||||
}
|
||||
// Файл загружен текущим пользователем (исполнителем)
|
||||
else if (parseInt(file.user_id) === currentUser.id) {
|
||||
canSeeFile = true;
|
||||
}
|
||||
// Если файл загружен другим исполнителем - не показываем
|
||||
else {
|
||||
canSeeFile = false;
|
||||
}
|
||||
}
|
||||
|
||||
return canSeeFile ? renderFileIcon(file) : '';
|
||||
}).join('')}
|
||||
</div>` :
|
||||
'<span class="no-files">нет файлов</span>'
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="task-assignments">
|
||||
@@ -556,10 +592,11 @@ function openAddFileModal(taskId) {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
console.log('Попытка 1');
|
||||
|
||||
if (!response.ok) {
|
||||
// Попробуем с полем 'file'
|
||||
console.log('Попытка с именем поля "file"...');
|
||||
console.log('Попытка 2 с именем поля "file"...');
|
||||
formData.delete('files');
|
||||
formData.append('file', file);
|
||||
|
||||
@@ -568,7 +605,7 @@ function openAddFileModal(taskId) {
|
||||
body: formData
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (response.ok) {
|
||||
alert('Файл успешно добавлен');
|
||||
await loadTaskFiles(taskId);
|
||||
|
||||
Reference in New Issue
Block a user