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 @@ -86,6 +86,7 @@ async function createDocument (
seqNumber: 0,
major: 1,
minor: 0,
patch: 0,
commentSequence: 0,
template: templateId,
state: DocumentState.Draft,
Expand Down Expand Up @@ -170,6 +171,7 @@ async function createTemplateIfNotExist (
category,
major: 0,
minor: 1,
patch: 0,
commentSequence: 0,
state: DocumentState.Draft,
author: owner,
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 @@ -151,6 +151,7 @@ async function createProductChangeControlTemplate (tx: TxOperations): Promise<vo
seqNumber: 0,
major: 1,
minor: 0,
patch: 0,
state: DocumentState.Effective,
commentSequence: 0,
content: null
Expand Down Expand Up @@ -527,6 +528,19 @@ async function migrateExternalApprovers (client: MigrationClient): Promise<void>
)
}

async function migratePatchVersion (client: MigrationClient): Promise<void> {
await client.update(
DOMAIN_DOCUMENTS,
{
_class: documents.class.ControlledDocument,
patch: { $exists: false }
},
{
patch: 0
}
)
}

export const documentsOperation: MigrateOperation = {
async migrate (client: MigrationClient, mode): Promise<void> {
await tryMigrate(mode, client, documentsId, [
Expand Down Expand Up @@ -568,6 +582,10 @@ export const documentsOperation: MigrateOperation = {
{
state: 'migrateExternalApprovers',
func: migrateExternalApprovers
},
{
state: 'migratePatchVersion',
func: migratePatchVersion
}
])
},
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 @@ -250,6 +250,9 @@ export class TDocument extends TDoc implements Document {
@Prop(TypeNumber(), documents.string.Minor)
minor!: number

@Prop(TypeNumber(), documents.string.Patch)
patch!: number

@Prop(TypeRef(documents.class.DocumentCategory), documents.string.Category)
category?: Ref<DocumentCategory>

Expand Down
4 changes: 4 additions & 0 deletions models/products/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export class TProductVersion extends TProject implements ProductVersion {
@ReadOnly()
minor!: number

@Prop(TypeNumber(), products.string.Patch)
@ReadOnly()
patch!: number

@Prop(TypeString(), products.string.Codename)
codename?: string

Expand Down
31 changes: 29 additions & 2 deletions models/products/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,36 @@
// limitations under the License.
//

import { type MigrateOperation, type MigrationClient, type MigrationUpgradeClient } from '@hcengineering/model'
import {
type MigrateOperation,
type MigrationClient,
type MigrationUpgradeClient,
tryMigrate
} from '@hcengineering/model'
import { DOMAIN_DOCUMENTS } from '@hcengineering/model-controlled-documents'
import products, { productsId } from '@hcengineering/products'

async function migratePatchVersion (client: MigrationClient): Promise<void> {
await client.update(
DOMAIN_DOCUMENTS,
{
_class: products.class.ProductVersion,
patch: { $exists: false }
},
{
patch: 0
}
)
}

export const productsOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {},
async migrate (client: MigrationClient, mode): Promise<void> {
await tryMigrate(mode, client, productsId, [
{
state: 'migratePatchVersion',
func: migratePatchVersion
}
])
},
async upgrade (state: Map<string, Set<string>>, client: () => Promise<MigrationUpgradeClient>): Promise<void> {}
}
2 changes: 2 additions & 0 deletions packages/importer/src/huly/huly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ export class HulyFormatImporter {
code: codeMatch?.[1],
major: 0,
minor: 1,
patch: 0,
state: DocumentState.Draft,
category,
author,
Expand Down Expand Up @@ -735,6 +736,7 @@ export class HulyFormatImporter {
code: codeMatch?.[1],
major: 0,
minor: 1,
patch: 0,
state: DocumentState.Draft,
category,
author,
Expand Down
2 changes: 2 additions & 0 deletions packages/importer/src/importer/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ export class ImportWorkspaceBuilder {
// Validate numbers are positive
if (!this.validatePossitiveNumber(doc.major)) errors.push('invalid value for field "major"')
if (!this.validatePossitiveNumber(doc.minor)) errors.push('invalid value for field "minor"')
if (!this.validatePossitiveNumber(doc.patch)) errors.push('invalid value for field "patch"')

// Validate arrays
errors.push(...this.validateArray(doc.reviewers, 'string', 'reviewers'))
Expand Down Expand Up @@ -822,6 +823,7 @@ export class ImportWorkspaceBuilder {
// Validate numbers are positive
if (!this.validatePossitiveNumber(template.major)) errors.push('invalid value for field "major"')
if (!this.validatePossitiveNumber(template.minor)) errors.push('invalid value for field "minor"')
if (!this.validatePossitiveNumber(template.patch)) errors.push('invalid value for field "patch"')

// Validate arrays
errors.push(...this.validateArray(template.reviewers, 'string', 'reviewers'))
Expand Down
4 changes: 4 additions & 0 deletions packages/importer/src/importer/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export interface ImportControlledDocumentTemplate extends ImportDoc {
code?: string
major: number
minor: number
patch: number
state: DocumentState
category: Ref<DocumentCategory>
author?: Ref<Employee>
Expand All @@ -220,6 +221,7 @@ export interface ImportControlledDocument extends ImportDoc {
code?: string
major: number
minor: number
patch: number
state: DocumentState
category?: Ref<DocumentCategory>
reviewers?: Ref<Employee>[]
Expand Down Expand Up @@ -994,6 +996,7 @@ export class WorkspaceImporter {
title: template.title,
major: template.major,
minor: template.minor,
patch: template.patch,
state: template.state,
author: template.author,
owner: template.owner,
Expand Down Expand Up @@ -1115,6 +1118,7 @@ export class WorkspaceImporter {
title: document.title,
major: document.major,
minor: document.minor,
patch: document.patch,
state: document.state,
author: document.author,
owner: document.owner,
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"EditorPlaceholder": "Začněte psát...",
"Version": "Verze",
"TemplateVersion": "Verze šablony",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "Vyhledat dokument...",
"CreateEnVersion": "Vytvořit verzi pro revizi",
"Approvers": "Schvalovatelé",
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"EditorPlaceholder": "Tippen Sie, um mit der Bearbeitung zu beginnen...",
"Version": "Version",
"TemplateVersion": "Vorlagenversion",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "Dokument suchen...",
"CreateEnVersion": "Version zur Überprüfung erstellen",
"Approvers": "Genehmiger",
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"EditorPlaceholder": "type to start editing...",
"Version": "Version",
"TemplateVersion": "Template version",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "Search document...",
"CreateEnVersion": "Create version for review",
"Approvers": "Approvers",
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"EditorPlaceholder": "tapez pour commencer à éditer...",
"Version": "Version",
"TemplateVersion": "Version du modèle",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "Rechercher un document...",
"CreateEnVersion": "Créer une version pour révision",
"Approvers": "Approuveurs",
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"EditorPlaceholder": "digita per iniziare a modificare...",
"Version": "Versione",
"TemplateVersion": "Versione del modello",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "Cerca documento...",
"CreateEnVersion": "Crea versione per revisione",
"Approvers": "Approvatori",
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"EditorPlaceholder": "入力して編集を開始...",
"Version": "バージョン",
"TemplateVersion": "テンプレートバージョン",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "ドキュメントを検索...",
"CreateEnVersion": "レビュー用バージョンを作成",
"Approvers": "承認者",
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"EditorPlaceholder": "Digite para começar a editar...",
"Version": "Versão",
"TemplateVersion": "Versão do modelo",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "Buscar documento...",
"CreateEnVersion": "Criar versão para revisão",
"Approvers": "Aprovadores",
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"EditorPlaceholder": "введите для начала...",
"Version": "Версия",
"TemplateVersion": "Версия шаблона",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "Найти документ...",
"CreateEnVersion": "Создать версию для оценки",
"Approvers": "Утверждающие",
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"EditorPlaceholder": "düzenlemeye başlamak için yazın...",
"Version": "Sürüm",
"TemplateVersion": "Şablon sürümü",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "Doküman ara...",
"CreateEnVersion": "İnceleme için sürüm oluştur",
"Approvers": "Onaylayanlar",
Expand Down
2 changes: 1 addition & 1 deletion plugins/controlled-documents-assets/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"EditorPlaceholder": "开始编辑...",
"Version": "版本",
"TemplateVersion": "模板版本",
"VersionValue": "v{major}.{minor}",
"VersionValue": "v{major}.{minor}.{patch}",
"SearchDocument": "搜索文档...",
"CreateEnVersion": "创建审核版本",
"Approvers": "批准人",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
labels: 0,
major: 1,
minor: 0,
patch: 0,
commentSequence: 0,
author: currentUser,
owner: currentUser,
Expand All @@ -79,7 +80,7 @@
const client = getClient()

async function handleOkAction (): Promise<void> {
if (isTemplateMandatory && !templateId) {

Check warning on line 83 in plugins/controlled-documents-resources/src/components/CreateDocument.svelte

View workflow job for this annotation

GitHub Actions / formatting

Unexpected nullable object value in conditional. An explicit null check is required
return
}

Expand Down Expand Up @@ -111,7 +112,7 @@
templateMixin,
{ _class: documentClass, _id: templateId },
(res) => {
if (res) {

Check warning on line 115 in plugins/controlled-documents-resources/src/components/CreateDocument.svelte

View workflow job for this annotation

GitHub Actions / formatting

Unexpected object value in conditional. The condition is always true
;[template] = res
object.template = template._id
object.prefix = template.prefix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
void notificationClient.then((client) => client.readDoc(_id))
})

$: if (_id && _class && project) {

Check warning on line 121 in plugins/controlled-documents-resources/src/components/EditDocPanel.svelte

View workflow job for this annotation

GitHub Actions / formatting

Unexpected object value in conditional. The condition is always true

Check warning on line 121 in plugins/controlled-documents-resources/src/components/EditDocPanel.svelte

View workflow job for this annotation

GitHub Actions / formatting

Unexpected object value in conditional. The condition is always true

Check warning on line 121 in plugins/controlled-documents-resources/src/components/EditDocPanel.svelte

View workflow job for this annotation

GitHub Actions / formatting

Unexpected object value in conditional. The condition is always true
controlledDocumentOpened({ _id, _class, project })
}

Expand Down Expand Up @@ -196,9 +196,9 @@
{ confirmationTitle: documentRes.string.ConfirmReviewCompletion },
eventToHTMLElement(ev),
async (res) => {
if (!res) return

Check warning on line 199 in plugins/controlled-documents-resources/src/components/EditDocPanel.svelte

View workflow job for this annotation

GitHub Actions / formatting

Unexpected any value in conditional. An explicit comparison or type cast is required

if (!$controlledDocument || $documentState !== ControlledDocumentState.InReview) {

Check warning on line 201 in plugins/controlled-documents-resources/src/components/EditDocPanel.svelte

View workflow job for this annotation

GitHub Actions / formatting

Unexpected nullable object value in conditional. An explicit null check is required
return
}

Expand All @@ -209,7 +209,7 @@

async function changeApprovalRequestState (ev: MouseEvent, isRejection: boolean): Promise<void> {
showPopup(SignatureDialog, { isRejection }, eventToHTMLElement(ev), async (res) => {
if (!res) return

Check warning on line 212 in plugins/controlled-documents-resources/src/components/EditDocPanel.svelte

View workflow job for this annotation

GitHub Actions / formatting

Unexpected any value in conditional. An explicit comparison or type cast is required

if (!$controlledDocument || $documentState !== ControlledDocumentState.InApproval) {
return
Expand Down Expand Up @@ -242,7 +242,7 @@
}

const latest = $documentLatestVersion
const version = { major: latest.major, minor: latest.minor + 1 }
const version = { major: latest.major, minor: latest.minor + 1, patch: 0 }
const project = await getLatestProjectId($controlledDocument.space)

if (project === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
labels: 0,
major: 1,
minor: 0,
patch: 0,
seqNumber: 0,
commentSequence: 0,
category: '' as Ref<DocumentCategory>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
labels: 0,
major: 1,
minor: 0,
patch: 0,
commentSequence: 0,
seqNumber: 0,
category: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
}

if (isDocument(document)) {
return `v${document.major}.${document.minor} | ${translatedStates ? translatedStates[state] : ''}`
return `v${document.major}.${document.minor}.${document.patch} | ${translatedStates ? translatedStates[state] : ''}`
} else {
return `${document.name} | ${translatedStates ? translatedStates[state] : ''}`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@

return (
doc.major < $controlledDocument.major ||
(doc.major === $controlledDocument.major && doc.minor <= $controlledDocument.minor)
(doc.major === $controlledDocument.major && doc.minor < $controlledDocument.minor) ||
(doc.major === $controlledDocument.major &&
doc.minor === $controlledDocument.minor &&
doc.patch <= $controlledDocument.patch)
)
})
.sort(documentCompareFn)
Expand Down
Loading
Loading