mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-05 15:24:22 +00:00
introduce ChannelsPresenter
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
9fd29de26d
commit
c728103e68
File diff suppressed because it is too large
Load Diff
@ -13,20 +13,39 @@
|
|||||||
// limitations under the License.
|
// 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 { 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 core, { TDoc, TType } from '@anticrm/model-core'
|
||||||
import type { Contact, Person, Organization, Employee } from '@anticrm/contact'
|
import type { Contact, Person, Organization, Employee, Channel, ChannelProvider } from '@anticrm/contact'
|
||||||
|
|
||||||
import view from '@anticrm/model-view'
|
import view from '@anticrm/model-view'
|
||||||
import { ids as contact } from './plugin'
|
import { ids as contact } from './plugin'
|
||||||
|
|
||||||
export const DOMAIN_CONTACT = 'contact' as Domain
|
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)
|
@Model(contact.class.Contact, core.class.Doc, DOMAIN_CONTACT)
|
||||||
export class TContact extends TDoc implements Contact {
|
export class TContact extends TDoc implements Contact {
|
||||||
|
@Prop(TypeChannels(), 'Contact Info' as IntlString)
|
||||||
|
channels!: Channel[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@Model(contact.class.Person, contact.class.Contact)
|
@Model(contact.class.Person, contact.class.Contact)
|
||||||
@ -38,11 +57,11 @@ export class TPerson extends TContact implements Person {
|
|||||||
@Prop(TypeString(), 'Last name' as IntlString)
|
@Prop(TypeString(), 'Last name' as IntlString)
|
||||||
lastName!: string
|
lastName!: string
|
||||||
|
|
||||||
@Prop(TypeString(), 'Email' as IntlString)
|
// @Prop(TypeString(), 'Email' as IntlString)
|
||||||
email!: string
|
// email!: string
|
||||||
|
|
||||||
@Prop(TypeString(), 'Phone' as IntlString)
|
// @Prop(TypeString(), 'Phone' as IntlString)
|
||||||
phone!: string
|
// phone!: string
|
||||||
|
|
||||||
@Prop(TypeString(), 'City' as IntlString)
|
@Prop(TypeString(), 'City' as IntlString)
|
||||||
city!: string
|
city!: string
|
||||||
@ -58,7 +77,15 @@ export class TEmployee extends TPerson implements Employee {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createModel (builder: Builder): void {
|
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, {
|
builder.createDoc(core.class.Space, core.space.Model, {
|
||||||
name: 'Employees',
|
name: 'Employees',
|
||||||
|
@ -14,16 +14,22 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { mergeIds } from '@anticrm/platform'
|
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 contact, { contactId } from '@anticrm/contact'
|
||||||
|
import type { ChannelProvider, Channel } from '@anticrm/contact'
|
||||||
import type { AnyComponent } from '@anticrm/ui'
|
import type { AnyComponent } from '@anticrm/ui'
|
||||||
import {} from '@anticrm/core'
|
import {} from '@anticrm/core'
|
||||||
|
|
||||||
export const ids = mergeIds(contactId, contact, {
|
export const ids = mergeIds(contactId, contact, {
|
||||||
|
channelProvider: {
|
||||||
|
Email: '' as Ref<ChannelProvider>
|
||||||
|
},
|
||||||
component: {
|
component: {
|
||||||
PersonPresenter: '' as AnyComponent
|
PersonPresenter: '' as AnyComponent,
|
||||||
|
ChannelsPresenter: '' as AnyComponent
|
||||||
},
|
},
|
||||||
class: {
|
class: {
|
||||||
|
TypeChannels: '' as Ref<Class<Type<Channel[]>>>
|
||||||
},
|
},
|
||||||
space: {
|
space: {
|
||||||
Employee: '' as Ref<Space>
|
Employee: '' as Ref<Space>
|
||||||
|
@ -24,9 +24,8 @@ export function createDemo (builder: Builder): void {
|
|||||||
builder.createDoc(contact.class.Employee, contact.space.Employee, {
|
builder.createDoc(contact.class.Employee, contact.space.Employee, {
|
||||||
firstName: 'Rosamund',
|
firstName: 'Rosamund',
|
||||||
lastName: 'Chen',
|
lastName: 'Chen',
|
||||||
email: 'rosamund@hc.engineering',
|
city: 'Mountain View',
|
||||||
phone: '+1 655 912 3424',
|
channels: []
|
||||||
city: 'Mountain View'
|
|
||||||
})
|
})
|
||||||
|
|
||||||
builder.createDoc(core.class.Account, core.space.Model, {
|
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, {
|
builder.createDoc(contact.class.Employee, contact.space.Employee, {
|
||||||
firstName: 'Elon',
|
firstName: 'Elon',
|
||||||
lastName: 'Musk',
|
lastName: 'Musk',
|
||||||
email: 'elon@hc.engineering',
|
city: 'Bel Air',
|
||||||
phone: '+1 655 843 3453',
|
channels: []
|
||||||
city: 'Bel Air'
|
|
||||||
})
|
})
|
||||||
|
|
||||||
builder.createDoc(core.class.Account, core.space.Model, {
|
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, {
|
builder.createDoc(recruit.class.Candidate, recruit.space.CandidatesPublic, {
|
||||||
firstName: 'Andrey',
|
firstName: 'Andrey',
|
||||||
lastName: 'P.',
|
lastName: 'P.',
|
||||||
email: 'andrey@hc.engineering',
|
city: 'Monte Carlo',
|
||||||
phone: '+1 646 667 6832',
|
channels: [
|
||||||
city: 'Monte Carlo'
|
{
|
||||||
|
provider: contact.channelProvider.Email,
|
||||||
|
value: 'andrey@hc.engineering'
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
builder.createDoc(recruit.class.Candidate, recruit.space.CandidatesPublic, {
|
builder.createDoc(recruit.class.Candidate, recruit.space.CandidatesPublic, {
|
||||||
firstName: 'Marina',
|
firstName: 'Marina',
|
||||||
lastName: 'M.',
|
lastName: 'M.',
|
||||||
email: 'marina@hc.engineering',
|
city: 'Los Angeles',
|
||||||
phone: '+1 646 777 3333',
|
channels: [
|
||||||
city: 'Los Angeles'
|
{
|
||||||
|
provider: contact.channelProvider.Email,
|
||||||
|
value: 'marina@hc.engineering'
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ export function createModel (builder: Builder): void {
|
|||||||
attachTo: recruit.class.Candidate,
|
attachTo: recruit.class.Candidate,
|
||||||
descriptor: view.viewlet.Table,
|
descriptor: view.viewlet.Table,
|
||||||
open: recruit.component.EditCandidate,
|
open: recruit.component.EditCandidate,
|
||||||
config: ['', 'email', 'phone', 'city']
|
config: ['', 'channels', 'city']
|
||||||
})
|
})
|
||||||
|
|
||||||
builder.createDoc(view.class.Viewlet, core.space.Model, {
|
builder.createDoc(view.class.Viewlet, core.space.Model, {
|
||||||
|
@ -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}
|
||||||
|
|
@ -15,9 +15,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import PersonPresenter from './components/PersonPresenter.svelte'
|
import PersonPresenter from './components/PersonPresenter.svelte'
|
||||||
|
import ChannelsPresenter from './components/ChannelsPresenter.svelte'
|
||||||
|
|
||||||
export default async () => ({
|
export default async () => ({
|
||||||
component: {
|
component: {
|
||||||
PersonPresenter
|
PersonPresenter,
|
||||||
|
ChannelsPresenter
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -15,12 +15,27 @@
|
|||||||
|
|
||||||
import { plugin } from '@anticrm/platform'
|
import { plugin } from '@anticrm/platform'
|
||||||
import type { 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
|
* @public
|
||||||
*/
|
*/
|
||||||
export interface Contact extends Doc {
|
export interface Contact extends Doc {
|
||||||
|
channels: Channel[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,8 +44,8 @@ export interface Contact extends Doc {
|
|||||||
export interface Person extends Contact {
|
export interface Person extends Contact {
|
||||||
firstName: string
|
firstName: string
|
||||||
lastName: string
|
lastName: string
|
||||||
email: string
|
// email: string
|
||||||
phone: string
|
// phone: string
|
||||||
city: string
|
city: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +70,7 @@ export const contactId = 'contact' as Plugin
|
|||||||
|
|
||||||
export default plugin(contactId, {
|
export default plugin(contactId, {
|
||||||
class: {
|
class: {
|
||||||
|
ChannelProvider: '' as Ref<Class<ChannelProvider>>,
|
||||||
Contact: '' as Ref<Class<Contact>>,
|
Contact: '' as Ref<Class<Contact>>,
|
||||||
Person: '' as Ref<Class<Person>>,
|
Person: '' as Ref<Class<Person>>,
|
||||||
Organization: '' as Ref<Class<Organization>>,
|
Organization: '' as Ref<Class<Organization>>,
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user