diff --git a/public/document-fields.js b/public/document-fields.js new file mode 100644 index 0000000..ffd8652 --- /dev/null +++ b/public/document-fields.js @@ -0,0 +1,605 @@ +// document-fields.js - Скрипт для управления полями документа в задачах + +(function() { + 'use strict'; + + // Конфигурация + const CONFIG = { + modalId: 'documentFieldsModal', + modalStyles: ` + + `, + buttonStyles: ` + + ` + }; + + // Текущий пользователь + let currentUser = null; + + // Получение текущего пользователя + async function getCurrentUser() { + try { + const response = await fetch('/api/user'); + const data = await response.json(); + if (data.user) { + currentUser = data.user; + console.log('✅ DocumentFields: текущий пользователь', currentUser); + } + return currentUser; + } catch (error) { + console.error('❌ DocumentFields: ошибка получения пользователя', error); + return null; + } + } + + // Создание модального окна + function createModal() { + // Добавляем стили + if (!document.getElementById('document-fields-styles')) { + const styleElement = document.createElement('div'); + styleElement.id = 'document-fields-styles'; + styleElement.innerHTML = CONFIG.modalStyles + CONFIG.buttonStyles; + document.head.appendChild(styleElement); + } + + // Проверяем, существует ли уже модальное окно + if (document.getElementById(CONFIG.modalId)) { + return; + } + + const modalHTML = ` +