mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-28 20:45:00 +02:00
Remove last document check (#10315)
Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
@@ -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<boolean> {
|
||||
return false
|
||||
}
|
||||
|
||||
return await isLatestDraftDoc(obj)
|
||||
return await isDraftDoc(obj)
|
||||
}
|
||||
|
||||
async function canArchiveDocument (obj?: Doc | Doc[]): Promise<boolean> {
|
||||
@@ -334,7 +333,7 @@ async function transferDocuments (selection: Document | Document[]): Promise<voi
|
||||
showPopup(TransferDocumentPopup, { sourceDocumentIds, sourceSpaceId, sourceProjectId })
|
||||
}
|
||||
|
||||
async function isLatestDraftDoc (obj?: Doc | Doc[]): Promise<boolean> {
|
||||
async function isDraftDoc (obj?: Doc | Doc[]): Promise<boolean> {
|
||||
if (obj == null) {
|
||||
return false
|
||||
}
|
||||
@@ -353,30 +352,6 @@ async function isLatestDraftDoc (obj?: Doc | Doc[]): Promise<boolean> {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user