mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-23 01:55:00 +02:00
feat: implement reference versioning functionality across various com… (#10941)
* feat: implement reference versioning functionality across various components and plugins Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * fix: simplify provider function calls and label retrieval in MentionPopup component Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * refactor: improve readability of version selection and reference handling in MentionVersionPopup and reference.ts Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> * feat: add CardReferenceObjectProvider and integrate into card model and resources Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com> --------- Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -103,6 +103,7 @@ import {
|
||||
createFolder,
|
||||
createTemplate,
|
||||
deleteFolder,
|
||||
documentMetaReferenceVersionsProvider,
|
||||
documentIdentifierProvider,
|
||||
controlledDocumentReferenceObjectProvider,
|
||||
projectDocumentReferenceObjectProvider,
|
||||
@@ -442,6 +443,7 @@ export default async (): Promise<Resources> => ({
|
||||
DocumentIdentifierProvider: documentIdentifierProvider,
|
||||
ControlledDocumentReferenceObjectProvider: controlledDocumentReferenceObjectProvider,
|
||||
ProjectDocumentReferenceObjectProvider: projectDocumentReferenceObjectProvider,
|
||||
DocumentMetaReferenceVersionsProvider: documentMetaReferenceVersionsProvider,
|
||||
ControlledDocumentTitleProvider: getControlledDocumentTitle,
|
||||
DocumentMetaTitleProvider: getDocumentMetaTitle,
|
||||
FormatDocumentMarkdownValue: formatControlledDocumentValue,
|
||||
|
||||
@@ -21,7 +21,7 @@ import documents, {
|
||||
import { type Client, type Doc, type Ref, type Space } from '@hcengineering/core'
|
||||
import { type IntlString, mergeIds, type Resource } from '@hcengineering/platform'
|
||||
import { type AnyComponent, type Location } from '@hcengineering/ui/src/types'
|
||||
import type { KeyFilter, SortFunc, ViewActionAvailabilityFunction } from '@hcengineering/view'
|
||||
import type { KeyFilter, ReferenceVersion, SortFunc, ViewActionAvailabilityFunction } from '@hcengineering/view'
|
||||
|
||||
export default mergeIds(documentsId, documents, {
|
||||
component: {
|
||||
@@ -256,6 +256,9 @@ export default mergeIds(documentsId, documents, {
|
||||
CanPrintDocument: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
|
||||
CanTransferDocument: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
|
||||
ControlledDocumentTitleProvider: '' as Resource<(client: Client, ref: Ref<Doc>, doc?: Doc) => Promise<string>>,
|
||||
DocumentMetaTitleProvider: '' as Resource<(client: Client, ref: Ref<Doc>, doc?: Doc) => Promise<string>>
|
||||
DocumentMetaTitleProvider: '' as Resource<(client: Client, ref: Ref<Doc>, doc?: Doc) => Promise<string>>,
|
||||
DocumentMetaReferenceVersionsProvider: '' as Resource<
|
||||
(client: Client, ref: Ref<Doc>, doc?: Doc) => Promise<ReferenceVersion[]>
|
||||
>
|
||||
}
|
||||
})
|
||||
|
||||
@@ -64,7 +64,7 @@ import { createQuery, getClient, MessageBox } from '@hcengineering/presentation'
|
||||
import request, { type Request, RequestStatus } from '@hcengineering/request'
|
||||
import { isEmptyMarkup } from '@hcengineering/text'
|
||||
import { type Location, getUserTimezone, showPopup } from '@hcengineering/ui'
|
||||
import { type KeyFilter } from '@hcengineering/view'
|
||||
import { type KeyFilter, type ReferenceVersion } from '@hcengineering/view'
|
||||
|
||||
import { makeRank } from '@hcengineering/rank'
|
||||
import { getProjectDocumentLink } from './navigation'
|
||||
@@ -842,6 +842,29 @@ export async function getDocumentMetaTitle (
|
||||
return object.title + ` (${hint})`
|
||||
}
|
||||
|
||||
export async function documentMetaReferenceVersionsProvider (
|
||||
client: Client,
|
||||
ref: Ref<DocumentMeta>
|
||||
): Promise<ReferenceVersion[]> {
|
||||
const versions = await client.findAll(
|
||||
documents.class.ControlledDocument,
|
||||
{ attachedTo: ref },
|
||||
{
|
||||
sort: {
|
||||
major: SortingOrder.Descending,
|
||||
minor: SortingOrder.Descending
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return versions.map((doc) => ({
|
||||
id: doc._id,
|
||||
objectclass: doc._class,
|
||||
label: `${doc.title} (${getDocumentVersionString(doc)})`,
|
||||
fixed: true
|
||||
}))
|
||||
}
|
||||
|
||||
export async function controlledDocumentReferenceObjectProvider (
|
||||
client: Client,
|
||||
ref: Ref<ControlledDocument>,
|
||||
|
||||
Reference in New Issue
Block a user