introduce ChannelsPresenter

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-08-31 12:42:40 +02:00
parent 9fd29de26d
commit c728103e68
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
9 changed files with 635 additions and 466 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,20 +13,39 @@
// limitations under the License.
//
import type { Domain } from '@anticrm/core'
import type { Domain, Type } from '@anticrm/core'
import { DOMAIN_MODEL } from '@anticrm/core'
import { Builder, Model, Prop, TypeString, UX } from '@anticrm/model'
import type { IntlString } from '@anticrm/platform'
import type { IntlString, Asset } from '@anticrm/platform'
import core, { TDoc } from '@anticrm/model-core'
import type { Contact, Person, Organization, Employee } from '@anticrm/contact'
import core, { TDoc, TType } from '@anticrm/model-core'
import type { Contact, Person, Organization, Employee, Channel, ChannelProvider } from '@anticrm/contact'
import view from '@anticrm/model-view'
import { ids as contact } from './plugin'
export const DOMAIN_CONTACT = 'contact' as Domain
@Model(contact.class.ChannelProvider, core.class.Doc, DOMAIN_MODEL)
export class TChannelProvider extends TDoc implements ChannelProvider {
label!: IntlString
icon?: Asset
}
@Model(contact.class.TypeChannels, core.class.Type)
export class TTypeChannels extends TType {}
/**
* @public
*/
export function TypeChannels (): Type<Channel[]> {
return { _class: contact.class.TypeChannels }
}
@Model(contact.class.Contact, core.class.Doc, DOMAIN_CONTACT)
export class TContact extends TDoc implements Contact {
@Prop(TypeChannels(), 'Contact Info' as IntlString)
channels!: Channel[]
}
@Model(contact.class.Person, contact.class.Contact)
@ -38,11 +57,11 @@ export class TPerson extends TContact implements Person {
@Prop(TypeString(), 'Last name' as IntlString)
lastName!: string
@Prop(TypeString(), 'Email' as IntlString)
email!: string
// @Prop(TypeString(), 'Email' as IntlString)
// email!: string
@Prop(TypeString(), 'Phone' as IntlString)
phone!: string
// @Prop(TypeString(), 'Phone' as IntlString)
// phone!: string
@Prop(TypeString(), 'City' as IntlString)
city!: string
@ -58,7 +77,15 @@ export class TEmployee extends TPerson implements Employee {
}
export function createModel (builder: Builder): void {
builder.createModel(TContact, TPerson, TOrganization, TEmployee)
builder.createModel(TChannelProvider, TTypeChannels, TContact, TPerson, TOrganization, TEmployee)
builder.mixin(contact.class.TypeChannels, core.class.Class, view.mixin.AttributePresenter, {
presenter: contact.component.ChannelsPresenter
})
builder.createDoc(contact.class.ChannelProvider, core.space.Model, {
label: 'Email' as IntlString
}, contact.channelProvider.Email)
builder.createDoc(core.class.Space, core.space.Model, {
name: 'Employees',

View File

@ -14,16 +14,22 @@
//
import { mergeIds } from '@anticrm/platform'
import type { Ref, Space } from '@anticrm/core'
import type { Ref, Space, Class, Type } from '@anticrm/core'
import contact, { contactId } from '@anticrm/contact'
import type { ChannelProvider, Channel } from '@anticrm/contact'
import type { AnyComponent } from '@anticrm/ui'
import {} from '@anticrm/core'
export const ids = mergeIds(contactId, contact, {
channelProvider: {
Email: '' as Ref<ChannelProvider>
},
component: {
PersonPresenter: '' as AnyComponent
PersonPresenter: '' as AnyComponent,
ChannelsPresenter: '' as AnyComponent
},
class: {
TypeChannels: '' as Ref<Class<Type<Channel[]>>>
},
space: {
Employee: '' as Ref<Space>

View File

@ -24,9 +24,8 @@ export function createDemo (builder: Builder): void {
builder.createDoc(contact.class.Employee, contact.space.Employee, {
firstName: 'Rosamund',
lastName: 'Chen',
email: 'rosamund@hc.engineering',
phone: '+1 655 912 3424',
city: 'Mountain View'
city: 'Mountain View',
channels: []
})
builder.createDoc(core.class.Account, core.space.Model, {
@ -36,9 +35,8 @@ export function createDemo (builder: Builder): void {
builder.createDoc(contact.class.Employee, contact.space.Employee, {
firstName: 'Elon',
lastName: 'Musk',
email: 'elon@hc.engineering',
phone: '+1 655 843 3453',
city: 'Bel Air'
city: 'Bel Air',
channels: []
})
builder.createDoc(core.class.Account, core.space.Model, {
@ -48,16 +46,24 @@ export function createDemo (builder: Builder): void {
builder.createDoc(recruit.class.Candidate, recruit.space.CandidatesPublic, {
firstName: 'Andrey',
lastName: 'P.',
email: 'andrey@hc.engineering',
phone: '+1 646 667 6832',
city: 'Monte Carlo'
city: 'Monte Carlo',
channels: [
{
provider: contact.channelProvider.Email,
value: 'andrey@hc.engineering'
}
]
})
builder.createDoc(recruit.class.Candidate, recruit.space.CandidatesPublic, {
firstName: 'Marina',
lastName: 'M.',
email: 'marina@hc.engineering',
phone: '+1 646 777 3333',
city: 'Los Angeles'
city: 'Los Angeles',
channels: [
{
provider: contact.channelProvider.Email,
value: 'marina@hc.engineering'
}
]
})
}

View File

@ -94,7 +94,7 @@ export function createModel (builder: Builder): void {
attachTo: recruit.class.Candidate,
descriptor: view.viewlet.Table,
open: recruit.component.EditCandidate,
config: ['', 'email', 'phone', 'city']
config: ['', 'channels', 'city']
})
builder.createDoc(view.class.Viewlet, core.space.Model, {

View File

@ -0,0 +1,26 @@
<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import type { Channel } from '@anticrm/contact'
export let value: Channel[]
</script>
Channels: {value.length}

View File

@ -15,9 +15,11 @@
//
import PersonPresenter from './components/PersonPresenter.svelte'
import ChannelsPresenter from './components/ChannelsPresenter.svelte'
export default async () => ({
component: {
PersonPresenter
PersonPresenter,
ChannelsPresenter
},
})

View File

@ -15,12 +15,27 @@
import { plugin } from '@anticrm/platform'
import type { Plugin } from '@anticrm/platform'
import type { Doc, Ref, Class } from '@anticrm/core'
import type { Doc, Ref, Class, UXObject } from '@anticrm/core'
/**
* @public
*/
export interface ChannelProvider extends Doc, UXObject {
}
/**
* @public
*/
export interface Channel {
provider: Ref<ChannelProvider>
value: string
}
/**
* @public
*/
export interface Contact extends Doc {
channels: Channel[]
}
/**
@ -29,8 +44,8 @@ export interface Contact extends Doc {
export interface Person extends Contact {
firstName: string
lastName: string
email: string
phone: string
// email: string
// phone: string
city: string
}
@ -55,6 +70,7 @@ export const contactId = 'contact' as Plugin
export default plugin(contactId, {
class: {
ChannelProvider: '' as Ref<Class<ChannelProvider>>,
Contact: '' as Ref<Class<Contact>>,
Person: '' as Ref<Class<Person>>,
Organization: '' as Ref<Class<Organization>>,

File diff suppressed because it is too large Load Diff