From f5fcc5fa3dc24c42c48cc3610bbdf146cce85f8f Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Tue, 15 Feb 2022 15:05:44 +0600 Subject: [PATCH] Change channel domain (#1007) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- models/contact/src/index.ts | 19 ++++++++++--------- models/contact/src/migration.ts | 7 ++++++- models/contact/src/plugin.ts | 10 +++++++++- plugins/contact-assets/lang/en.json | 10 +++++++++- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 064c5ebf5e..670c81d3a1 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -32,6 +32,7 @@ import type { Asset, IntlString } from '@anticrm/platform' import { ids as contact } from './plugin' export const DOMAIN_CONTACT = 'contact' as Domain +export const DOMAIN_CHANNEL = 'channel' as Domain @Model(contact.class.ChannelProvider, core.class.Doc, DOMAIN_MODEL) export class TChannelProvider extends TDoc implements ChannelProvider { @@ -41,7 +42,7 @@ export class TChannelProvider extends TDoc implements ChannelProvider { } @Model(contact.class.Contact, core.class.Doc, DOMAIN_CONTACT) -@UX('Contact' as IntlString, contact.icon.Person, undefined, 'name') +@UX(contact.string.Contact, contact.icon.Person, undefined, 'name') export class TContact extends TDoc implements Contact { @Prop(TypeString(), 'Name' as IntlString) @Index(IndexKind.FullText) @@ -58,18 +59,18 @@ export class TContact extends TDoc implements Contact { @Prop(Collection(chunter.class.Comment), chunter.string.Comments) comments?: number - @Prop(TypeString(), 'Location' as IntlString) + @Prop(TypeString(), contact.string.Location) @Index(IndexKind.FullText) city!: string } -@Model(contact.class.Channel, core.class.AttachedDoc, DOMAIN_CONTACT) -@UX('Channel' as IntlString, contact.icon.Person, undefined, 'modifiedOn') +@Model(contact.class.Channel, core.class.AttachedDoc, DOMAIN_CHANNEL) +@UX(contact.string.Channel, contact.icon.Person, undefined, 'modifiedOn') export class TChannel extends TAttachedDoc implements Channel { - @Prop(TypeRef(contact.class.ChannelProvider), 'Channel provider' as IntlString) + @Prop(TypeRef(contact.class.ChannelProvider), contact.string.ChannelProvider) provider!: Ref - @Prop(TypeString(), 'Value' as IntlString) + @Prop(TypeString(), contact.string.Value) @Index(IndexKind.FullText) value!: string @@ -77,15 +78,15 @@ export class TChannel extends TAttachedDoc implements Channel { } @Model(contact.class.Person, contact.class.Contact) -@UX('Person' as IntlString, contact.icon.Person, undefined, 'name') +@UX(contact.string.Person, contact.icon.Person, undefined, 'name') export class TPerson extends TContact implements Person {} @Model(contact.class.Organization, contact.class.Contact) -@UX('Organization' as IntlString, contact.icon.Company, undefined, 'name') +@UX(contact.string.Organization, contact.icon.Company, undefined, 'name') export class TOrganization extends TContact implements Organization {} @Model(contact.class.Employee, contact.class.Person) -@UX('Employee' as IntlString, contact.icon.Person) +@UX(contact.string.Employee, contact.icon.Person) export class TEmployee extends TPerson implements Employee {} @Model(contact.class.EmployeeAccount, core.class.Account) diff --git a/models/contact/src/migration.ts b/models/contact/src/migration.ts index 15b0e8aef3..324363df29 100644 --- a/models/contact/src/migration.ts +++ b/models/contact/src/migration.ts @@ -18,7 +18,7 @@ import { Channel, ChannelProvider, Contact } from '@anticrm/contact' import { Class, DOMAIN_TX, generateId, Ref, SortingOrder, TxCreateDoc, TxCUD, TxRemoveDoc, TxUpdateDoc } from '@anticrm/core' import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@anticrm/model' import core from '@anticrm/model-core' -import contact, { DOMAIN_CONTACT } from './index' +import contact, { DOMAIN_CHANNEL, DOMAIN_CONTACT } from './index' function createChannel (tx: TxCUD, channel: any): Channel { const doc: Channel = { @@ -203,10 +203,15 @@ export async function migrateContactChannels (client: MigrationClient, classes: } } +async function migrateChannelsDomain (client: MigrationClient): Promise { + await client.move(DOMAIN_CONTACT, { _class: contact.class.Channel }, DOMAIN_CHANNEL) +} + export const contactOperation: MigrateOperation = { async migrate (client: MigrationClient): Promise { const classes = [contact.class.Contact, contact.class.Person, contact.class.Employee, contact.class.Organization] await migrateContactChannels(client, classes) + await migrateChannelsDomain(client) }, async upgrade (client: MigrationUpgradeClient): Promise { } diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index 6c9c4914c4..0ce2023dd7 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -49,7 +49,15 @@ export const ids = mergeIds(contactId, contact, { SearchEmployee: '' as IntlString, SearchPerson: '' as IntlString, SearchOrganization: '' as IntlString, - ContactInfo: '' as IntlString + ContactInfo: '' as IntlString, + Contact: '' as IntlString, + Location: '' as IntlString, + Channel: '' as IntlString, + ChannelProvider: '' as IntlString, + Person: '' as IntlString, + Organization: '' as IntlString, + Employee: '' as IntlString, + Value: '' as IntlString }, completion: { PersonQuery: '' as Resource, diff --git a/plugins/contact-assets/lang/en.json b/plugins/contact-assets/lang/en.json index da26584d21..32ce06d1a5 100644 --- a/plugins/contact-assets/lang/en.json +++ b/plugins/contact-assets/lang/en.json @@ -24,6 +24,14 @@ "SearchEmployee": "Search for employee...", "SearchPerson": "Search for person...", "SearchOrganization": "Search for organization...", - "ContactInfo": "Contact Info" + "ContactInfo": "Contact Info", + "Contact": "Contact", + "Location": "Location", + "Channel": "Channel", + "ChannelProvider": "Channel provider", + "Person": "Person", + "Organization": "Organization", + "Employee": "Employee", + "Value": "Value" } } \ No newline at end of file