From b4540ece17e86aeea9771b01f4144db8988c3fe5 Mon Sep 17 00:00:00 2001 From: Artyom Savchenko Date: Fri, 19 Dec 2025 12:59:42 +0700 Subject: [PATCH] Remove last document check (#10315) Signed-off-by: Artem Savchenko --- .../src/index.ts | 29 ++----------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/plugins/controlled-documents-resources/src/index.ts b/plugins/controlled-documents-resources/src/index.ts index 56c0f974db..4f12848d48 100644 --- a/plugins/controlled-documents-resources/src/index.ts +++ b/plugins/controlled-documents-resources/src/index.ts @@ -28,7 +28,6 @@ import { type DocumentQuery, type Ref, type RelatedDocument, - SortingOrder, type WithLookup } from '@hcengineering/core' import { type Resources } from '@hcengineering/platform' @@ -216,7 +215,7 @@ async function canDeleteDocument (obj?: Doc | Doc[]): Promise { return false } - return await isLatestDraftDoc(obj) + return await isDraftDoc(obj) } async function canArchiveDocument (obj?: Doc | Doc[]): Promise { @@ -334,7 +333,7 @@ async function transferDocuments (selection: Document | Document[]): Promise { +async function isDraftDoc (obj?: Doc | Doc[]): Promise { if (obj == null) { return false } @@ -353,30 +352,6 @@ async function isLatestDraftDoc (obj?: Doc | Doc[]): Promise { if (doc.state !== DocumentState.Draft) { return false } - - const { template, seqNumber } = doc - const docClass = h.hasMixin(doc, documents.mixin.DocumentTemplate) - ? documents.mixin.DocumentTemplate - : documents.class.Document - const latestDoc = await client.findOne( - docClass, - { template, seqNumber }, - { - sort: { - major: SortingOrder.Descending, - minor: SortingOrder.Descending, - patch: SortingOrder.Descending - } - } - ) - - if (latestDoc == null || latestDoc.state !== DocumentState.Draft) { - return false - } - - if (latestDoc._id !== doc._id) { - return false - } } return objs.length > 0