Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dev/doc-import-tool/src/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ async function createDocument (
requests: 0,
reviewers: [],
approvers: [],
externalApprovers: [],
coAuthors: [],
changeControl: ccRecordId,
author: owner,
Expand Down Expand Up @@ -175,6 +176,7 @@ async function createTemplateIfNotExist (
requests: 0,
reviewers: [],
approvers: [],
externalApprovers: [],
coAuthors: [],
changeControl: ccRecordId,
content: null,
Expand Down
36 changes: 34 additions & 2 deletions models/controlled-documents/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import documentsPlugin, {
documentsId,
DocumentState,
type Document,
type DocumentSpace
type DocumentSpace,
type ProjectDocument,
type ChangeControl,
type DocumentRequest
} from '@hcengineering/controlled-documents'
import { type Builder } from '@hcengineering/model'
import chunter from '@hcengineering/model-chunter'
Expand Down Expand Up @@ -977,9 +980,38 @@ export function defineNotifications (builder: Builder): void {
components: { input: { component: chunter.component.ChatMessageInput } }
})

builder.createDoc<ClassCollaborators<Document>>(core.class.ClassCollaborators, core.space.Model, {
attachedTo: documents.class.Document,
fields: ['author', 'owner'],
provideSecurity: true
})

builder.createDoc<ClassCollaborators<ProjectDocument>>(core.class.ClassCollaborators, core.space.Model, {
attachedTo: documents.class.ProjectDocument,
fields: [],
provideSecurity: true
})

builder.createDoc<ClassCollaborators<ChangeControl>>(core.class.ClassCollaborators, core.space.Model, {
attachedTo: documents.class.ChangeControl,
fields: [],
provideSecurity: true
})

builder.createDoc<ClassCollaborators<DocumentRequest>>(core.class.ClassCollaborators, core.space.Model, {
attachedTo: documents.class.DocumentRequest,
fields: ['requested', 'createdBy'],
provideSecurity: true
})

builder.mixin(documents.class.DocumentApprovalRequest, core.class.Class, core.mixin.TxAccessLevel, {
updateAccessLevel: AccountRole.Guest
})

builder.createDoc<ClassCollaborators<ControlledDocument>>(core.class.ClassCollaborators, core.space.Model, {
attachedTo: documents.class.ControlledDocument,
fields: ['author', 'owner', 'reviewers', 'approvers', 'coAuthors']
fields: ['author', 'owner', 'reviewers', 'approvers', 'coAuthors', 'externalApprovers'],
provideSecurity: true
})

builder.createDoc(
Expand Down
18 changes: 18 additions & 0 deletions models/controlled-documents/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ async function createProductChangeControlTemplate (tx: TxOperations): Promise<vo
requests: 0,
reviewers: [],
approvers: [],
externalApprovers: [],
coAuthors: [],
code: `TMPL-${seq.sequence + 1}`,
seqNumber: 0,
Expand Down Expand Up @@ -513,6 +514,19 @@ async function migrateCancelDuplicateActiveRequests (client: MigrationClient): P
await client.bulk(DOMAIN_REQUEST, operations)
}

async function migrateExternalApprovers (client: MigrationClient): Promise<void> {
await client.update(
DOMAIN_DOCUMENTS,
{
_class: documents.class.ControlledDocument,
externalApprovers: { $exists: false }
},
{
externalApprovers: []
}
)
}

export const documentsOperation: MigrateOperation = {
async migrate (client: MigrationClient, mode): Promise<void> {
await tryMigrate(mode, client, documentsId, [
Expand Down Expand Up @@ -550,6 +564,10 @@ export const documentsOperation: MigrateOperation = {
{
state: 'migrateCancelDuplicateActiveRequests',
func: migrateCancelDuplicateActiveRequests
},
{
state: 'migrateExternalApprovers',
func: migrateExternalApprovers
}
])
},
Expand Down
3 changes: 3 additions & 0 deletions models/controlled-documents/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ export class TControlledDocument extends THierarchyDocument implements Controlle
@Prop(ArrOf(TypeRef(contact.mixin.Employee)), documents.string.Approvers)
approvers!: Ref<Employee>[]

@Prop(ArrOf(TypeRef(contact.mixin.Employee)), documents.string.ExternalApprovers)
externalApprovers!: Ref<Employee>[]

@Prop(ArrOf(TypeRef(contact.mixin.Employee)), documents.string.CoAuthors)
coAuthors!: Ref<Employee>[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
//

import core, { Class, ClassCollaborators, Doc, Hierarchy, ModelDb, Ref } from '@hcengineering/core'
import core, { Class, ClassCollaborators, Doc, Hierarchy, ModelDb, Ref } from '.'

export function getClassCollaborators<T extends Doc> (
model: ModelDb,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ export * from './clone'
export * from './common'
export * from './time'
export * from './benchmark'
export * from './collaborators'

export default core
4 changes: 4 additions & 0 deletions packages/importer/src/importer/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export interface ImportControlledDocumentTemplate extends ImportDoc {
abstract?: string
reviewers?: Ref<Employee>[]
approvers?: Ref<Employee>[]
externalApprovers?: Ref<Employee>[]
coAuthors?: Ref<Employee>[]
ccReason?: string
ccImpact?: string
Expand All @@ -223,6 +224,7 @@ export interface ImportControlledDocument extends ImportDoc {
category?: Ref<DocumentCategory>
reviewers?: Ref<Employee>[]
approvers?: Ref<Employee>[]
externalApprovers?: Ref<Employee>[]
coAuthors?: Ref<Employee>[]
author?: Ref<Employee>
owner?: Ref<Employee>
Expand Down Expand Up @@ -999,6 +1001,7 @@ export class WorkspaceImporter {
category: template.category,
reviewers: template.reviewers ?? [],
approvers: template.approvers ?? [],
externalApprovers: template.externalApprovers ?? [],
coAuthors: template.coAuthors ?? [],
code,
seqNumber,
Expand Down Expand Up @@ -1118,6 +1121,7 @@ export class WorkspaceImporter {
abstract: document.abstract,
reviewers: document.reviewers ?? [],
approvers: document.approvers ?? [],
externalApprovers: document.externalApprovers ?? [],
coAuthors: document.coAuthors ?? [],
changeControl: changeControlId,
code,
Expand Down
1 change: 1 addition & 0 deletions plugins/controlled-documents-assets/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SearchDocument": "Dokument suchen...",
"CreateEnVersion": "Version zur Überprüfung erstellen",
"Approvers": "Genehmiger",
"ExternalApprovers": "Externe Genehmiger",
"CoAuthors": "Co-Autoren",
"Status": "Status",
"TemplateName": "Vorlagenname",
Expand Down
1 change: 1 addition & 0 deletions plugins/controlled-documents-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SearchDocument": "Search document...",
"CreateEnVersion": "Create version for review",
"Approvers": "Approvers",
"ExternalApprovers": "External approvers",
"CoAuthors": "Co-Authors",
"Status": "Status",
"TemplateName": "Template name",
Expand Down
1 change: 1 addition & 0 deletions plugins/controlled-documents-assets/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SearchDocument": "Rechercher un document...",
"CreateEnVersion": "Créer une version pour révision",
"Approvers": "Approuveurs",
"ExternalApprovers": "Approuveurs externes",
"CoAuthors": "Co-auteurs",
"Status": "Statut",
"TemplateName": "Nom du modèle",
Expand Down
1 change: 1 addition & 0 deletions plugins/controlled-documents-assets/lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SearchDocument": "Cerca documento...",
"CreateEnVersion": "Crea versione per revisione",
"Approvers": "Approvatori",
"ExternalApprovers": "Approvatori esterni",
"CoAuthors": "Co-autori",
"Status": "Stato",
"TemplateName": "Nome del modello",
Expand Down
1 change: 1 addition & 0 deletions plugins/controlled-documents-assets/lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"SearchDocument": "ドキュメントを検索...",
"CreateEnVersion": "レビュー用バージョンを作成",
"Approvers": "承認者",
"ExternalApprovers": "外部承認者",
"CoAuthors": "共同作成者",
"Status": "ステータス",
"TemplateName": "テンプレート名",
Expand Down
1 change: 1 addition & 0 deletions plugins/controlled-documents-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SearchDocument": "Buscar documento...",
"CreateEnVersion": "Criar versão para revisão",
"Approvers": "Aprovadores",
"ExternalApprovers": "Aprovadores externos",
"CoAuthors": "Coautores",
"Status": "Status",
"TemplateName": "Nome do modelo",
Expand Down
1 change: 1 addition & 0 deletions plugins/controlled-documents-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SearchDocument": "Найти документ...",
"CreateEnVersion": "Создать версию для оценки",
"Approvers": "Утверждающие",
"ExternalApprovers": "Внешние утверждающие",
"CoAuthors": "Соавторы",
"Status": "Статус",
"TemplateName": "Имя шаблона",
Expand Down
1 change: 1 addition & 0 deletions plugins/controlled-documents-assets/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"SearchDocument": "搜索文档...",
"CreateEnVersion": "创建审核版本",
"Approvers": "批准人",
"ExternalApprovers": "外部批准人",
"CoAuthors": "共同作者",
"Status": "状态",
"TemplateName": "模板名称",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
snapshots: 0,
reviewers: [],
approvers: [],
externalApprovers: [],
coAuthors: [],
changeControl: '' as Ref<ChangeControl>,
content: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
-->
<script lang="ts">
import { Mixin, DocumentQuery, Ref } from '@hcengineering/core'
import { DocumentSpace, type DocumentTemplate } from '@hcengineering/controlled-documents'
import { ActionContext, createQuery } from '@hcengineering/presentation'
import { type DocumentTemplate } from '@hcengineering/controlled-documents'
import { ActionContext } from '@hcengineering/presentation'
import { Button, IconAdd, Loading, showPopup } from '@hcengineering/ui'
import view, { ViewOptions, Viewlet, ViewletPreference } from '@hcengineering/view'
import { TableBrowser, ViewletPanelHeader } from '@hcengineering/view-resources'
Expand All @@ -34,22 +34,7 @@
let loading = true
const _class: Ref<Mixin<DocumentTemplate>> = documents.mixin.DocumentTemplate

let spaces: Ref<DocumentSpace>[] = []
const spacesQuery = createQuery()
$: spacesQuery.query(
documents.class.DocumentSpace,
{},
(res) => {
spaces = res.map((s) => s._id)
},
{
projection: {
_id: 1
}
}
)

$: srcQuery = { ...query, space: { $in: spaces } }
$: srcQuery = { ...query }
$: canAddTemplate = checkMyPermission(
documents.permission.CreateDocument,
documents.space.QualityDocuments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
import { Class, DocumentQuery, Ref, Space } from '@hcengineering/core'
import type { IntlString, Asset } from '@hcengineering/platform'
import { IModeSelector, resolvedLocationStore } from '@hcengineering/ui'
import documents, { type Document, type DocumentSpace, DocumentState } from '@hcengineering/controlled-documents'
import { type Document, DocumentState } from '@hcengineering/controlled-documents'

import Documents from './Documents.svelte'
import document from '../plugin'
import { createQuery } from '@hcengineering/presentation'

export let _class: Ref<Class<Document>> = document.class.Document
export let query: DocumentQuery<Document> = {}
Expand All @@ -36,29 +35,13 @@
let mode: string | undefined = undefined
let modeSelectorProps: IModeSelector | undefined = undefined

let spaces: Ref<DocumentSpace>[] = []
const spacesQuery = createQuery()

$: spacesQuery.query(
documents.class.DocumentSpace,
{},
(res) => {
spaces = res.map((s) => s._id)
},
{
projection: {
_id: 1
}
}
)

// NOTE: we have to use "{ type: { $in:" queries below. Otherwise, it breaks when combined
// with custom Filters added by State.
$: inProgress = { state: { $in: [DocumentState.Draft] }, space: { $in: spaces } }
$: effective = { state: { $in: [DocumentState.Effective] }, space: { $in: spaces } }
$: archived = { state: { $in: [DocumentState.Archived, DocumentState.Deleted] }, space: { $in: spaces } }
$: obsolete = { state: { $in: [DocumentState.Obsolete] }, space: { $in: spaces } }
$: all = { space: { $in: spaces } }
$: inProgress = { state: { $in: [DocumentState.Draft] } }
$: effective = { state: { $in: [DocumentState.Effective] } }
$: archived = { state: { $in: [DocumentState.Archived, DocumentState.Deleted] } }
$: obsolete = { state: { $in: [DocumentState.Obsolete] } }
$: all = {}

$: queries = { inProgress, effective, archived, obsolete, all }

Expand Down
Loading
Loading