From b2a948889e43a034f08ae69a7c2107677e69e8c8 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Thu, 26 Feb 2026 14:45:54 +0700 Subject: [PATCH] fix(workspace): restore quick-menu handlers for events and docs --- .../components/workspace/CrmWorkspaceApp.vue | 68 +++++++++++++++++-- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/frontend/app/components/workspace/CrmWorkspaceApp.vue b/frontend/app/components/workspace/CrmWorkspaceApp.vue index 6076830..31ec9cb 100644 --- a/frontend/app/components/workspace/CrmWorkspaceApp.vue +++ b/frontend/app/components/workspace/CrmWorkspaceApp.vue @@ -200,11 +200,9 @@ const { commEventMode, commEventSaving, commEventError, - createCommEvent, - openCommEventModal, - closeCommEventModal, - setDefaultCommEventForm, - buildCommEventTitle, + createCommEvent: createCommEventInCalendar, + openCommEventModal: openCommEventModalInCalendar, + closeCommEventModal: closeCommEventModalInCalendar, eventCloseOpen, eventCloseDraft, eventCloseSaving, @@ -247,8 +245,7 @@ const { selectedDocument, filteredDocuments, updateSelectedDocumentBody, - createCommDocument, - buildCommDocumentTitle, + createCommDocument: createCommDocumentInDocuments, deleteWorkspaceDocumentById, openDocumentsTab: _openDocumentsTab, refetchDocuments, @@ -833,6 +830,63 @@ function openCommDocumentModal() { commQuickMenuOpen.value = false; } +async function createCommDocument() { + if (!selectedCommThread.value) return; + if (!commDraft.value.trim()) { + commEventError.value = "Текст документа обязателен"; + return; + } + + const created = await createCommDocumentInDocuments( + { id: selectedCommThread.value.id, contact: selectedCommThread.value.contact }, + commDraft.value, + commDocumentForm, + authDisplayName.value, + { + buildScope: (contactId: string, contactName: string) => buildContactDocumentScope(contactId, contactName), + onSuccess: () => {}, + }, + ); + + if (!created) { + commEventError.value = "Не удалось создать документ"; + return; + } + + commEventError.value = ""; + commDraft.value = ""; + setDefaultCommDocumentForm(); + commComposerMode.value = "message"; + commQuickMenuOpen.value = false; +} + +function openCommEventModal(mode: "planned" | "logged") { + if (!selectedCommThread.value) return; + openCommEventModalInCalendar(mode, true); + commComposerMode.value = mode; + commQuickMenuOpen.value = false; +} + +function closeCommEventModal() { + closeCommEventModalInCalendar(); + commComposerMode.value = "message"; + commQuickMenuOpen.value = false; +} + +async function createCommEvent() { + const contactName = selectedCommThread.value?.contact ?? ""; + const draftText = commDraft.value; + const created = await createCommEventInCalendar(contactName, draftText); + if (!created) return; + commDraft.value = ""; + commComposerMode.value = "message"; + commQuickMenuOpen.value = false; + if (selectedCommThreadId.value) { + void refreshSelectedClientTimeline(selectedCommThreadId.value); + } + void refetchContacts(); +} + function toggleCommQuickMenu() { if (!selectedCommThread.value || commEventSaving.value) return; commQuickMenuOpen.value = !commQuickMenuOpen.value;