Change channel domain (#1007)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-02-15 15:05:44 +06:00 committed by GitHub
parent 4c60b40eb3
commit f5fcc5fa3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 12 deletions

View File

@ -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<ChannelProvider>
@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)

View File

@ -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<Contact>, channel: any): Channel {
const doc: Channel = {
@ -203,10 +203,15 @@ export async function migrateContactChannels (client: MigrationClient, classes:
}
}
async function migrateChannelsDomain (client: MigrationClient): Promise<void> {
await client.move(DOMAIN_CONTACT, { _class: contact.class.Channel }, DOMAIN_CHANNEL)
}
export const contactOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {
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<void> {
}

View File

@ -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<ObjectSearchFactory>,

View File

@ -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"
}
}