diff --git a/models/lead/src/index.ts b/models/lead/src/index.ts index 63015a8001..9067842452 100644 --- a/models/lead/src/index.ts +++ b/models/lead/src/index.ts @@ -149,7 +149,7 @@ export function createModel (builder: Builder): void { attachTo: lead.class.Funnel, descriptor: view.viewlet.Table, configOptions: { - hiddenKeys: ['identifier', 'name', 'description'], + hiddenKeys: ['identifier', 'name', 'customerDescription'], sortable: true }, config: ['', 'members', 'private', 'archived'] diff --git a/models/lead/src/migration.ts b/models/lead/src/migration.ts index fc06bd5766..59155e68b0 100644 --- a/models/lead/src/migration.ts +++ b/models/lead/src/migration.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import { AccountRole, DOMAIN_TX, TxOperations, type Ref, type Status } from '@hcengineering/core' +import { AccountRole, DOMAIN_TX, makeCollaborativeDoc, TxOperations, type Ref, type Status } from '@hcengineering/core' import { leadId, type Lead } from '@hcengineering/lead' import { tryMigrate, @@ -25,7 +25,7 @@ import { } from '@hcengineering/model' import core, { DOMAIN_SPACE } from '@hcengineering/model-core' -import contact from '@hcengineering/model-contact' +import contact, { DOMAIN_CONTACT } from '@hcengineering/model-contact' import task, { DOMAIN_TASK, createSequence, migrateDefaultStatusesBase } from '@hcengineering/model-task' import lead from './plugin' @@ -191,6 +191,60 @@ export const leadOperation: MigrateOperation = { { state: 'migrateDefaultProjectOwners', func: migrateDefaultProjectOwners + }, + { + state: 'migrate-customer-description', + func: async (client) => { + await client.update( + DOMAIN_CONTACT, + { + [lead.mixin.Customer + '.description']: { $exists: true } + }, + { + $rename: { + [lead.mixin.Customer + '.description']: lead.mixin.Customer + '.customerDescription' + } + } + ) + const it = await client.traverse(DOMAIN_CONTACT, { + _class: contact.class.Organization, + description: { $exists: false } + }) + while (true) { + const docs = await it.next(50) + if (docs == null || docs.length === 0) { + break + } + await client.bulk( + DOMAIN_CONTACT, + docs.map((doc) => ({ + filter: { _id: doc._id }, + update: { $set: { description: makeCollaborativeDoc(doc._id, 'description') } } + })) + ) + } + const it2 = await client.traverse(DOMAIN_CONTACT, { [lead.mixin.Customer + '.customerDescription']: null }) + while (true) { + const docs = await it2.next(50) + if (docs == null || docs.length === 0) { + break + } + await client.bulk( + DOMAIN_CONTACT, + docs.map((doc) => ({ + filter: { _id: doc._id }, + update: { + $set: { + [lead.mixin.Customer + '.customerDescription']: makeCollaborativeDoc( + docs[0]._id, + 'customerDescription' + ) + } + } + })) + ) + } + } } ]) }, diff --git a/models/lead/src/types.ts b/models/lead/src/types.ts index 9869970326..7a32aeebbf 100644 --- a/models/lead/src/types.ts +++ b/models/lead/src/types.ts @@ -95,9 +95,9 @@ export class TCustomer extends TContact implements Customer { @Prop(Collection(lead.class.Lead), lead.string.Leads) leads?: number - @Prop(TypeCollaborativeDoc(), core.string.Description) + @Prop(TypeCollaborativeDoc(), lead.string.Description) @Index(IndexKind.FullText) - description!: CollaborativeDoc + customerDescription!: CollaborativeDoc } @Mixin(lead.mixin.DefaultFunnelTypeData, lead.class.Funnel) diff --git a/plugins/lead-assets/lang/en.json b/plugins/lead-assets/lang/en.json index 0db48b3c0b..7fa0cd0249 100644 --- a/plugins/lead-assets/lang/en.json +++ b/plugins/lead-assets/lang/en.json @@ -25,7 +25,7 @@ "CreateCustomer": "Create Customer", "CreateCustomerLabel": "New Customer", "NoLeadsForDocument": "No leads for document", - "Description": "Description", + "Description": "Customer Description", "FullDescription": "Full description", "FunnelPlaceholder": "The simple funnel", "Members": "Members", diff --git a/plugins/lead-assets/lang/es.json b/plugins/lead-assets/lang/es.json index 1e0d8b2cf1..f21a3e765f 100644 --- a/plugins/lead-assets/lang/es.json +++ b/plugins/lead-assets/lang/es.json @@ -22,10 +22,10 @@ "ManageFunnelStatuses": "Gestionar estados del Embudo", "GotoLeadApplication": "Cambiar a la aplicación de Clientes Potenciales", "IssueDescriptionPlaceholder": "Añadir descripción...", - "CreateCustomer": "Crear Cliente", + "CreateCustomer": "Cliente Cliente", "CreateCustomerLabel": "Nuevo Cliente", "NoLeadsForDocument": "No hay Clientes Potenciales para el documento", - "Description": "Descripción", + "Description": "Customer Descripción", "FullDescription": "Descripción completa", "FunnelPlaceholder": "El Embudo simple", "Members": "Miembros", diff --git a/plugins/lead-assets/lang/fr.json b/plugins/lead-assets/lang/fr.json index 37b99f02e0..f22b854a6c 100644 --- a/plugins/lead-assets/lang/fr.json +++ b/plugins/lead-assets/lang/fr.json @@ -25,7 +25,7 @@ "CreateCustomer": "Créer un client", "CreateCustomerLabel": "Nouveau client", "NoLeadsForDocument": "Aucun prospect pour le document", - "Description": "Description", + "Description": "Client Description", "FullDescription": "Description complète", "FunnelPlaceholder": "Le pipeline simple", "Members": "Membres", diff --git a/plugins/lead-assets/lang/pt.json b/plugins/lead-assets/lang/pt.json index 7ba652552c..0b5e871c90 100644 --- a/plugins/lead-assets/lang/pt.json +++ b/plugins/lead-assets/lang/pt.json @@ -25,7 +25,7 @@ "CreateCustomer": "Criar Cliente", "CreateCustomerLabel": "Novo Cliente", "NoLeadsForDocument": "Sem leads para o documento", - "Description": "Descrição", + "Description": "Cliente Descrição", "FullDescription": "Descrição completa", "FunnelPlaceholder": "O Funil simples", "Members": "Membros", diff --git a/plugins/lead-assets/lang/ru.json b/plugins/lead-assets/lang/ru.json index 350c27e1a2..0478aba685 100644 --- a/plugins/lead-assets/lang/ru.json +++ b/plugins/lead-assets/lang/ru.json @@ -25,7 +25,7 @@ "CreateCustomer": "Добавить Клиента", "CreateCustomerLabel": "Новый Клиент", "NoLeadsForDocument": "Нет потенциальных клиентов для документа", - "Description": "Описание", + "Description": "Описание Клиента", "FullDescription": "Детальное описание", "FunnelPlaceholder": "Простая воронка", "Members": "Пользователи", diff --git a/plugins/lead-assets/lang/zh.json b/plugins/lead-assets/lang/zh.json index 1b1d1adaff..8139b3d9a1 100644 --- a/plugins/lead-assets/lang/zh.json +++ b/plugins/lead-assets/lang/zh.json @@ -25,7 +25,7 @@ "CreateCustomer": "创建客户", "CreateCustomerLabel": "新客户", "NoLeadsForDocument": "此文档没有潜在客户", - "Description": "描述", + "Description": "客户描述", "FullDescription": "完整描述", "FunnelPlaceholder": "简单漏斗", "Members": "成员", diff --git a/plugins/lead-resources/package.json b/plugins/lead-resources/package.json index 052ea94859..d39f2e39ac 100644 --- a/plugins/lead-resources/package.json +++ b/plugins/lead-resources/package.json @@ -55,6 +55,7 @@ "@hcengineering/task-resources": "^0.6.0", "@hcengineering/tracker": "^0.6.24", "@hcengineering/text-editor-resources": "^0.6.0", + "@hcengineering/text": "^0.6.5", "@hcengineering/ui": "^0.6.15", "@hcengineering/view": "^0.6.13", "@hcengineering/view-resources": "^0.6.0", diff --git a/plugins/lead-resources/src/components/CreateCustomer.svelte b/plugins/lead-resources/src/components/CreateCustomer.svelte index 8f678be3dc..b218fc30be 100644 --- a/plugins/lead-resources/src/components/CreateCustomer.svelte +++ b/plugins/lead-resources/src/components/CreateCustomer.svelte @@ -13,7 +13,7 @@ // limitations under the License. --> - +{#if collaborativeDoc != null} + +{/if}