Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-02-25 21:32:23 +06:00 committed by GitHub
parent 5d5d1a9acf
commit 6a5caa86ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 25 deletions

View File

@ -249,6 +249,10 @@ export function createModel (builder: Builder): void {
presenter: contact.component.ContactPresenter
})
builder.mixin(contact.class.Employee, core.class.Class, view.mixin.IgnoreActions, {
actions: [view.action.Delete]
})
builder.createDoc(presentation.class.ObjectSearchCategory, core.space.Model, {
icon: contact.icon.Person,
label: contact.string.SearchEmployee,

View File

@ -24,6 +24,7 @@ import type {
ActionTarget,
AttributeEditor,
AttributePresenter,
IgnoreActions,
ObjectDDParticipant,
ObjectEditor,
ObjectEditorHeader,
@ -100,6 +101,11 @@ export class TActionTarget extends TDoc implements ActionTarget {
action!: Ref<Action>
}
@Mixin(view.mixin.IgnoreActions, core.class.Class)
export class TIgnoreActions extends TClass implements IgnoreActions {
actions!: Ref<Action>[]
}
@Mixin(view.mixin.HTMLPresenter, core.class.Class)
export class THTMLPresenter extends TClass implements HTMLPresenter {
presenter!: Resource<(doc: Doc) => string>
@ -124,7 +130,8 @@ export function createModel (builder: Builder): void {
TObjectEditorHeader,
TObjectDDParticipant,
THTMLPresenter,
TTextPresenter
TTextPresenter,
TIgnoreActions
)
builder.mixin(core.class.TypeString, core.class.Class, view.mixin.AttributeEditor, {

View File

@ -28,6 +28,7 @@
export let object: any
export let maxWidth: string
export let focus: boolean = false
export let editable = true
const client = getClient()
const hierarchy = client.getHierarchy()
@ -45,6 +46,7 @@
}
function onChange (value: any) {
if (!editable) return
const doc = object as Doc
updateAttribute(client, doc, _class, { key: attributeKey, attr: attribute }, value)
}

View File

@ -20,10 +20,12 @@
import { ChannelProvider, Channel } from '@anticrm/contact'
import contact from '../plugin'
import Channels from './Channels.svelte'
import ChannelsView from './ChannelsView.svelte'
export let attachedTo: Ref<Doc>
export let attachedClass: Ref<Class<Doc>>
export let integrations: Set<Ref<Doc>> | undefined = undefined
export let editable = true
let channels: Channel[] = []
@ -96,11 +98,15 @@
}
</script>
<Channels
{channels}
{integrations}
on:change={(e) => {
save(e.detail)
}}
on:click
/>
{#if editable}
<Channels
{channels}
{integrations}
on:change={(e) => {
save(e.detail)
}}
on:click
/>
{:else}
<ChannelsView value={channels} size={'small'} {integrations} on:click />
{/if}

View File

@ -14,20 +14,23 @@
// limitations under the License.
-->
<script lang="ts">
import { createEventDispatcher, onMount, afterUpdate } from 'svelte'
import { getCurrentAccount, Ref, Space } from '@anticrm/core'
import { CircleButton, EditBox, IconActivity, Label } from '@anticrm/ui'
import { getClient, createQuery, EditableAvatar, AttributeEditor } from '@anticrm/presentation'
import { getResource } from '@anticrm/platform'
import attachment from '@anticrm/attachment'
import setting from '@anticrm/setting'
import { IntegrationType } from '@anticrm/setting'
import { combineName,getFirstName,getLastName,Person } from '@anticrm/contact'
import { getCurrentAccount,Ref,Space } from '@anticrm/core'
import { getResource } from '@anticrm/platform'
import { AttributeEditor,Avatar,createQuery,EditableAvatar,getClient } from '@anticrm/presentation'
import setting,{ IntegrationType } from '@anticrm/setting'
import { CircleButton,EditBox,IconActivity,Label } from '@anticrm/ui'
import { afterUpdate,createEventDispatcher,onMount } from 'svelte'
import contact from '../plugin'
import { combineName, getFirstName, getLastName, Person } from '@anticrm/contact'
import ChannelsEditor from './ChannelsEditor.svelte'
export let object: Person
const client = getClient()
const hierarchy = client.getHierarchy()
$: editable = !hierarchy.isDerived(object._class, contact.class.Employee)
let firstName = getFirstName(object.name)
let lastName = getLastName(object.name)
@ -38,8 +41,6 @@
lastName = getLastName(object.name)
}
const client = getClient()
const dispatch = createEventDispatcher()
function firstNameChange () {
@ -83,18 +84,30 @@
{#if object !== undefined}
<div class="flex-row-streach flex-grow">
<div class="mr-8">
<EditableAvatar avatar={object.avatar} size={'x-large'} on:done={onAvatarDone} />
{#if editable}
<EditableAvatar avatar={object.avatar} size={'x-large'} on:done={onAvatarDone} />
{:else}
<Avatar avatar={object.avatar} size={'x-large'} />
{/if}
</div>
<div class="flex-grow flex-col">
<div class="flex-grow flex-col">
<div class="name">
<EditBox placeholder={contact.string.PersonFirstNamePlaceholder} maxWidth="20rem" bind:value={firstName} on:change={firstNameChange} />
{#if editable}
<EditBox placeholder={contact.string.PersonFirstNamePlaceholder} maxWidth="20rem" bind:value={firstName} on:change={firstNameChange} />
{:else}
{firstName}
{/if}
</div>
<div class="name">
<EditBox placeholder={contact.string.PersonLastNamePlaceholder} maxWidth="20rem" bind:value={lastName} on:change={lastNameChange} />
{#if editable}
<EditBox placeholder={contact.string.PersonLastNamePlaceholder} maxWidth="20rem" bind:value={lastName} on:change={lastNameChange} />
{:else}
{lastName}
{/if}
</div>
<div class="location">
<AttributeEditor maxWidth="20rem" _class={contact.class.Person} {object} key="city" />
<AttributeEditor maxWidth="20rem" _class={contact.class.Person} {editable} {object} key="city" />
</div>
</div>
@ -102,7 +115,7 @@
<div class="flex-between channels">
<div class="flex-row-center">
<ChannelsEditor attachedTo={object._id} attachedClass={object._class} {integrations} on:click />
<ChannelsEditor attachedTo={object._id} attachedClass={object._class} {editable} {integrations} on:click />
</div>
<div class="flex-row-center">

View File

@ -174,7 +174,13 @@ function filterActions (
): Array<Ref<Action>> {
const result: Array<Ref<Action>> = []
const hierarchy = client.getHierarchy()
const clazz = hierarchy.getClass(doc._class)
const ignoreActions = hierarchy.as(clazz, view.mixin.IgnoreActions)
const ignore = ignoreActions?.actions ?? []
for (const target of targets) {
if (ignore.includes(target.action)) {
continue
}
if (target.query !== undefined) {
const r = matchQuery([doc], target.query)
if (r.length === 0) {

View File

@ -84,10 +84,16 @@ export interface Action extends Doc, UXObject {
export interface ActionTarget<T extends Doc = Doc> extends Doc {
target: Ref<Class<T>>
action: Ref<Action>
query?: DocumentQuery<T>
}
/**
* @public
*/
export interface IgnoreActions extends Class<Doc> {
actions: Ref<Action>[]
}
/**
* @public
*/
@ -179,6 +185,7 @@ const view = plugin(viewId, {
ObjectValidator: '' as Ref<Mixin<ObjectValidator>>,
ObjectFactory: '' as Ref<Mixin<ObjectFactory>>,
ObjectDDParticipant: '' as Ref<ObjectDDParticipant>,
IgnoreActions: '' as Ref<Mixin<IgnoreActions>>,
HTMLPresenter: '' as Ref<Mixin<HTMLPresenter>>,
TextPresenter: '' as Ref<Mixin<TextPresenter>>
},

View File

@ -64,6 +64,7 @@
_class={spaceSample._class}
config={['name', 'company', 'location', 'modifiedOn']}
options={{}}
showNotification
baseMenuClass={core.class.Space}
query={{
_class: { $in: model?.spaces.map(x => x.spaceClass) ?? [] },