mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-12 12:47:45 +02:00
EZQMS-1393: implemented folders in controlled documents (#7803)
* EZQMS-1393: implemented folders in controlled documents Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com> * formatting Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com> --------- Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
@@ -357,3 +357,55 @@ export async function createDocumentTemplateMetadata (
|
||||
|
||||
return { success: success.result, seqNumber, code, documentMetaId, projectDocumentId }
|
||||
}
|
||||
|
||||
export async function createNewFolder (
|
||||
client: TxOperations,
|
||||
space: Ref<DocumentSpace>,
|
||||
project: Ref<Project> | undefined,
|
||||
parent: Ref<ProjectDocument> | undefined,
|
||||
title: string
|
||||
): Promise<{
|
||||
success: boolean
|
||||
documentMetaId: Ref<DocumentMeta>
|
||||
projectDocumentId: Ref<ProjectDocument>
|
||||
}> {
|
||||
const projectId = project ?? documents.ids.NoProject
|
||||
|
||||
const ops = client.apply()
|
||||
|
||||
const documentMetaId = await ops.createDoc(documents.class.DocumentMeta, space, { documents: 0, title })
|
||||
|
||||
let path: Array<Ref<DocumentMeta>> = []
|
||||
if (parent !== undefined) {
|
||||
path = await getParentPath(client, parent)
|
||||
}
|
||||
|
||||
const parentMeta = path[0] ?? documents.ids.NoParent
|
||||
const lastRank = await getFirstRank(client, space, projectId, parentMeta)
|
||||
|
||||
const projectMetaId = await ops.createDoc(documents.class.ProjectMeta, space, {
|
||||
project: projectId,
|
||||
meta: documentMetaId,
|
||||
path,
|
||||
parent: parentMeta,
|
||||
documents: 0,
|
||||
rank: makeRank(lastRank, undefined)
|
||||
})
|
||||
|
||||
const projectDocumentId = await client.addCollection(
|
||||
documents.class.ProjectDocument,
|
||||
space,
|
||||
projectMetaId,
|
||||
documents.class.ProjectMeta,
|
||||
'documents',
|
||||
{
|
||||
project: projectId,
|
||||
initial: projectId,
|
||||
document: documents.ids.Folder
|
||||
}
|
||||
)
|
||||
|
||||
const success = await ops.commit()
|
||||
|
||||
return { success: success.result, documentMetaId, projectDocumentId }
|
||||
}
|
||||
|
||||
@@ -107,20 +107,28 @@ export const documentsPlugin = plugin(documentsId, {
|
||||
DocumentMetaPresenter: '' as AnyComponent,
|
||||
DocumentVersionPresenter: '' as AnyComponent,
|
||||
DeleteCategoryPopup: '' as AnyComponent,
|
||||
DocumentIcon: '' as AnyComponent
|
||||
DocumentIcon: '' as AnyComponent,
|
||||
CreateFolder: '' as AnyComponent
|
||||
},
|
||||
action: {
|
||||
ChangeDocumentOwner: '' as Ref<Action<Doc, any>>,
|
||||
CreateChildDocument: '' as Ref<Action<Document, any>>,
|
||||
CreateChildTemplate: '' as Ref<Action<Document, any>>,
|
||||
CreateChildFolder: '' as Ref<Action<Document, any>>,
|
||||
RenameFolder: '' as Ref<Action<Document, any>>,
|
||||
DeleteFolder: '' as Ref<Action<Document, any>>,
|
||||
CreateDocument: '' as Ref<Action<DocumentSpace, any>>,
|
||||
CreateTemplate: '' as Ref<Action<DocumentSpace, any>>,
|
||||
CreateFolder: '' as Ref<Action<DocumentSpace, any>>,
|
||||
DeleteDocumentCategory: '' as Ref<Action<Doc, any>>,
|
||||
DeleteDocument: '' as Ref<Action>,
|
||||
ArchiveDocument: '' as Ref<Action>,
|
||||
EditDocSpace: '' as Ref<Action>,
|
||||
TransferDocument: '' as Ref<Action>,
|
||||
Print: '' as Ref<Action<Doc, { signed: boolean }>>
|
||||
Print: '' as Ref<Action<Doc, { signed: boolean }>>,
|
||||
PrintProjectDocument: '' as Ref<Action<Doc, { signed: boolean }>>,
|
||||
OpenDocument: '' as Ref<Action<Doc, { signed: boolean }>>,
|
||||
OpenDocumentInNewTab: '' as Ref<Action<Doc, { signed: boolean }>>
|
||||
},
|
||||
function: {
|
||||
CanChangeDocumentOwner: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
|
||||
@@ -131,6 +139,7 @@ export const documentsPlugin = plugin(documentsId, {
|
||||
CheckmarkCircle: '' as Asset,
|
||||
DocumentApplication: '' as Asset,
|
||||
NewDocument: '' as Asset,
|
||||
Folder: '' as Asset,
|
||||
Document: '' as Asset,
|
||||
Library: '' as Asset,
|
||||
StateDraft: '' as Asset,
|
||||
@@ -212,6 +221,8 @@ export const documentsPlugin = plugin(documentsId, {
|
||||
ChangeOwnerWarning: '' as IntlString,
|
||||
CreateDocument: '' as IntlString,
|
||||
CreateTemplate: '' as IntlString,
|
||||
CreateFolder: '' as IntlString,
|
||||
RenameFolder: '' as IntlString,
|
||||
DeleteCategory: '' as IntlString,
|
||||
DeleteCategoryHint: '' as IntlString,
|
||||
DeleteCategoryWarning: '' as IntlString,
|
||||
@@ -228,6 +239,7 @@ export const documentsPlugin = plugin(documentsId, {
|
||||
Path: '' as IntlString,
|
||||
CreateChildDocument: '' as IntlString,
|
||||
CreateChildTemplate: '' as IntlString,
|
||||
CreateChildFolder: '' as IntlString,
|
||||
All: '' as IntlString,
|
||||
ImpactAnalysis: '' as IntlString,
|
||||
ImpactedDocuments: '' as IntlString,
|
||||
@@ -270,7 +282,8 @@ export const documentsPlugin = plugin(documentsId, {
|
||||
},
|
||||
ids: {
|
||||
NoParent: '' as Ref<DocumentMeta>,
|
||||
NoProject: '' as Ref<Project>
|
||||
NoProject: '' as Ref<Project>,
|
||||
Folder: '' as Ref<HierarchyDocument>
|
||||
},
|
||||
sequence: {
|
||||
Templates: '' as Ref<Sequence>,
|
||||
|
||||
@@ -443,9 +443,9 @@ async function _transferDocuments (
|
||||
if (bundle.DocumentMeta.length !== 1) return false
|
||||
if (bundle.ProjectMeta.length !== 1) return false
|
||||
if (bundle.DocumentMeta[0].space !== cx.request.sourceSpaceId) return false
|
||||
if (bundle.ControlledDocument.length < 1) return false
|
||||
|
||||
const isTemplate = hierarchy.hasMixin(bundle.ControlledDocument[0], documents.mixin.DocumentTemplate)
|
||||
const anydoc = bundle.ControlledDocument[0]
|
||||
const isTemplate = anydoc !== undefined && hierarchy.hasMixin(anydoc, documents.mixin.DocumentTemplate)
|
||||
if (isTemplate && hierarchy.isDerived(cx.targetSpace._class, documents.class.ExternalSpace)) return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user